コード例 #1
0
ファイル: dlg_setup.c プロジェクト: cstim/aqbanking
static void AB_SetupDialog_ActivateProviders(GWEN_DIALOG *dlg)
{
  AB_SETUP_DIALOG *xdlg;
  GWEN_PLUGIN_DESCRIPTION_LIST2 *pdl;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg);
  assert(xdlg);

  if (xdlg->providersInUse)
    AB_Provider_List2_free(xdlg->providersInUse);
  xdlg->providersInUse=AB_Provider_List2_new();

  pdl=AB_Banking_GetProviderDescrs(xdlg->banking);
  if (pdl) {
    GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *it;

    it=GWEN_PluginDescription_List2_First(pdl);
    if (it) {
      GWEN_PLUGIN_DESCRIPTION *pd;

      pd=GWEN_PluginDescription_List2Iterator_Data(it);
      while (pd) {
        const char *pName;

        pName=GWEN_PluginDescription_GetName(pd);
        if (pName && *pName) {
          AB_PROVIDER *pro;

          pro=AB_Banking_BeginUseProvider(xdlg->banking, pName);
          if (pro) {
            DBG_INFO(AQBANKING_LOGDOMAIN, "Adding provider %s", pName);
            AB_Provider_List2_PushBack(xdlg->providersInUse, pro);
          }
          else {
            DBG_INFO(AQBANKING_LOGDOMAIN, "Provider %s not available", pName);
          }
        }
        pd=GWEN_PluginDescription_List2Iterator_Next(it);
      }
      GWEN_PluginDescription_List2Iterator_free(it);
    }
    GWEN_PluginDescription_List2_free(pdl);
  }
}
コード例 #2
0
ファイル: banking_init.c プロジェクト: aqbanking/aqbanking
void AB_Banking_ActivateAllProviders(AB_BANKING *ab) {
    GWEN_PLUGIN_DESCRIPTION_LIST2 *descrs;
    GWEN_PLUGIN_MANAGER *pm;

    pm=GWEN_PluginManager_FindPluginManager("provider");
    if (!pm) {
        DBG_ERROR(AQBANKING_LOGDOMAIN,
                  "Could not find plugin manager for \"%s\"",
                  "provider");
        return;
    }

    descrs=GWEN_PluginManager_GetPluginDescrs(pm);
    if (descrs) {
        GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *it;
        GWEN_PLUGIN_DESCRIPTION *pd;

        it=GWEN_PluginDescription_List2_First(descrs);
        assert(it);
        pd=GWEN_PluginDescription_List2Iterator_Data(it);
        assert(pd);
        while(pd) {
            const char *pname=GWEN_PluginDescription_GetName(pd);
            AB_PROVIDER *pro;

            pro=AB_Banking_GetProvider(ab, pname);
            if (!pro) {
                DBG_WARN(AQBANKING_LOGDOMAIN,
                         "Could not load backend \"%s\", ignoring", pname);
            }
            else {
                GWEN_StringList_AppendString(ab->activeProviders, pname, 0, 1);
            }

            pd=GWEN_PluginDescription_List2Iterator_Next(it);
        } /* while */
        GWEN_PluginDescription_List2Iterator_free(it);
        GWEN_PluginDescription_List2_freeAll(descrs);
    }
}
コード例 #3
0
ファイル: ctplugin.c プロジェクト: cstim/gwenhywfar
int GWEN_Crypt_Token_PluginManager_CheckToken(GWEN_PLUGIN_MANAGER *pm,
                                              GWEN_CRYPT_TOKEN_DEVICE devt,
                                              GWEN_BUFFER *typeName,
                                              GWEN_BUFFER *tokenName,
                                              uint32_t guiid)
{
  GWEN_PLUGIN_DESCRIPTION_LIST2 *pdl;

  assert(pm);

  pdl=GWEN_Crypt_Token_PluginManager_GetPluginDescrs(pm, devt);
  if (pdl==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "No plugin descriptions found for this device type");
    GWEN_Gui_ProgressLog(guiid,
                         GWEN_LoggerLevel_Error,
                         I18N("No plugin found for this device type"));
    GWEN_Gui_ProgressLog(guiid,
                         GWEN_LoggerLevel_Error,
                         I18N("If you're using a Debian/Ubuntu based system "
                              "please consider to install package "
                              LIBCHIPCARD_GWENHYWFAR_PLUGIN_PACKAGE));
    return GWEN_ERROR_NOT_FOUND;
  }
  else {
    GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *pit;

    pit=GWEN_PluginDescription_List2_First(pdl);
    if (pit) {
      GWEN_PLUGIN_DESCRIPTION *pd;
      uint32_t progressId;
      unsigned int pdcount;
      unsigned int cnt=0;

      pdcount=GWEN_PluginDescription_List2_GetSize(pdl);
      progressId=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_DELAY |
                                        GWEN_GUI_PROGRESS_ALLOW_EMBED |
                                        GWEN_GUI_PROGRESS_SHOW_PROGRESS |
                                        GWEN_GUI_PROGRESS_SHOW_LOG |
                                        GWEN_GUI_PROGRESS_ALWAYS_SHOW_LOG |
                                        GWEN_GUI_PROGRESS_SHOW_ABORT,
                                        I18N("Determining plugin module..."),
                                        NULL,
                                        pdcount,
                                        guiid);

      pd=GWEN_PluginDescription_List2Iterator_Data(pit);
      assert(pd);
      while (pd) {
        GWEN_XMLNODE *n;
        int err;
        GWEN_PLUGIN *pl;
        char logbuffer[256];

        n=GWEN_PluginDescription_GetXmlNode(pd);
        assert(n);

        snprintf(logbuffer, sizeof(logbuffer)-1,
                 I18N("Loading plugin \"%s\""),
                 GWEN_PluginDescription_GetName(pd));
        logbuffer[sizeof(logbuffer)-1]=0;
        GWEN_Gui_ProgressLog(progressId,
                             GWEN_LoggerLevel_Notice,
                             logbuffer);

        /* device type matches, check this plugin */
        pl=GWEN_PluginManager_GetPlugin(pm, GWEN_PluginDescription_GetName(pd));
        if (pl) {
          GWEN_BUFFER *lTokenName;
          int rv;

          lTokenName=GWEN_Buffer_dup(tokenName);

          snprintf(logbuffer, sizeof(logbuffer)-1,
                   I18N("Checking plugin \"%s\""),
                   GWEN_Plugin_GetName(pl));
          logbuffer[sizeof(logbuffer)-1]=0;
          GWEN_Gui_ProgressLog(progressId,
                               GWEN_LoggerLevel_Notice,
                               logbuffer);

          DBG_INFO(GWEN_LOGDOMAIN,
                   "Checking plugin \"%s\" for [%s]",
                   GWEN_Plugin_GetName(pl),
                   GWEN_Buffer_GetStart(lTokenName));

          rv=GWEN_Crypt_Token_Plugin_CheckToken(pl, lTokenName);
          switch (rv) {
          case 0:
            /* responsive plugin found */
            snprintf(logbuffer, sizeof(logbuffer)-1,
                     I18N("Plugin \"%s\" supports this token"),
                     GWEN_Plugin_GetName(pl));
            logbuffer[sizeof(logbuffer)-1]=0;
            err=GWEN_Gui_ProgressLog(progressId,
                                     GWEN_LoggerLevel_Notice,
                                     logbuffer);
            if (err==GWEN_ERROR_USER_ABORTED) {
              GWEN_Gui_ProgressEnd(progressId);
              GWEN_Buffer_free(lTokenName);
              GWEN_PluginDescription_List2Iterator_free(pit);
              GWEN_PluginDescription_List2_freeAll(pdl);
              return err;
            }

            GWEN_Buffer_Reset(typeName);
            GWEN_Buffer_AppendString(typeName, GWEN_Plugin_GetName(pl));
            GWEN_Buffer_Reset(tokenName);
            GWEN_Buffer_AppendBuffer(tokenName, lTokenName);
            GWEN_Buffer_free(lTokenName);
            GWEN_PluginDescription_List2Iterator_free(pit);
            GWEN_PluginDescription_List2_freeAll(pdl);
            GWEN_Gui_ProgressEnd(progressId);
            return 0;

          case GWEN_ERROR_NOT_IMPLEMENTED:
            snprintf(logbuffer, sizeof(logbuffer)-1,
                     I18N("Plugin \"%s\": Function not implemented"),
                     GWEN_Plugin_GetName(pl));
            logbuffer[sizeof(logbuffer)-1]=0;
            GWEN_Gui_ProgressLog(progressId,
                                 GWEN_LoggerLevel_Notice,
                                 logbuffer);
            break;

          case GWEN_ERROR_NOT_SUPPORTED:
            snprintf(logbuffer, sizeof(logbuffer)-1,
                     I18N("Plugin \"%s\" does not support this token"),
                     GWEN_Plugin_GetName(pl));
            logbuffer[sizeof(logbuffer)-1]=0;
            GWEN_Gui_ProgressLog(progressId,
                                 GWEN_LoggerLevel_Info,
                                 logbuffer);
            break;

          case GWEN_ERROR_BAD_NAME:
            snprintf(logbuffer, sizeof(logbuffer)-1,
                     I18N("Plugin \"%s\" supports this token, but the name "
                          "did not match"),
                     GWEN_Plugin_GetName(pl));
            logbuffer[sizeof(logbuffer)-1]=0;
            GWEN_Gui_ProgressLog(progressId,
                                 GWEN_LoggerLevel_Info,
                                 logbuffer);
            break;

          default:
            snprintf(logbuffer, sizeof(logbuffer)-1,
                     I18N("Plugin \"%s\": Unexpected error (%d)"),
                     GWEN_Plugin_GetName(pl), rv);
            logbuffer[sizeof(logbuffer)-1]=0;
            GWEN_Gui_ProgressLog(progressId,
                                 GWEN_LoggerLevel_Info,
                                 logbuffer);
            break;
          } /* switch */
        } /* if plugin loaded */
        else {
          snprintf(logbuffer, sizeof(logbuffer)-1,
                   I18N("Could not load plugin \"%s\""),
                   GWEN_PluginDescription_GetName(pd));
          logbuffer[sizeof(logbuffer)-1]=0;
          GWEN_Gui_ProgressLog(progressId,
                               GWEN_LoggerLevel_Warning,
                               logbuffer);
        }

        cnt++;
        err=GWEN_Gui_ProgressAdvance(progressId, cnt);
        if (err) {
          DBG_INFO(GWEN_LOGDOMAIN, "User aborted");
          GWEN_Gui_ProgressEnd(progressId);
          GWEN_PluginDescription_List2Iterator_free(pit);
          GWEN_PluginDescription_List2_freeAll(pdl);
          GWEN_Gui_ProgressEnd(progressId);
          return err;
        }

        pd=GWEN_PluginDescription_List2Iterator_Next(pit);
      }

      GWEN_Gui_ProgressEnd(progressId);
      GWEN_PluginDescription_List2Iterator_free(pit);
    }
    GWEN_PluginDescription_List2_freeAll(pdl);
  }

  return GWEN_ERROR_NOT_SUPPORTED;
}
コード例 #4
0
ファイル: ctplugin.c プロジェクト: cstim/gwenhywfar
GWEN_PLUGIN_DESCRIPTION_LIST2 *GWEN_Crypt_Token_PluginManager_GetPluginDescrs(GWEN_PLUGIN_MANAGER *pm,
                                                                              GWEN_CRYPT_TOKEN_DEVICE devt)
{
  GWEN_PLUGIN_DESCRIPTION_LIST2 *pl1;

  pl1=GWEN_PluginManager_GetPluginDescrs(pm);
  if (pl1) {
    GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *pit;
    GWEN_PLUGIN_DESCRIPTION_LIST2 *pl2;

    pl2=GWEN_PluginDescription_List2_new();
    pit=GWEN_PluginDescription_List2_First(pl1);
    if (pit) {
      GWEN_PLUGIN_DESCRIPTION *pd;
      const char *ts;

      if (devt==GWEN_Crypt_Token_Device_Any)
        ts=NULL;
      else
        ts=GWEN_Crypt_Token_Device_toString(devt);
      pd=GWEN_PluginDescription_List2Iterator_Data(pit);
      while (pd) {
        GWEN_XMLNODE *node;
        const char *nts;
        int match=0;

        node=GWEN_PluginDescription_GetXmlNode(pd);
        assert(node);
        nts=GWEN_XMLNode_GetProperty(node, "device", 0);
        if (nts) {
          if (!ts || (ts && strcasecmp(ts, nts)==0))
            match=1;
        }
        else if (!ts)
          match=1;

        if (match) {
          GWEN_PLUGIN_DESCRIPTION *pd2;

          pd2=GWEN_PluginDescription_dup(pd);
          GWEN_PluginDescription_List2_PushBack(pl2, pd2);
        }

        pd=GWEN_PluginDescription_List2Iterator_Next(pit);
      }
      GWEN_PluginDescription_List2Iterator_free(pit);
    }
    GWEN_PluginDescription_List2_freeAll(pl1);

    if (GWEN_PluginDescription_List2_GetSize(pl2)==0) {
      GWEN_PluginDescription_List2_freeAll(pl2);
      DBG_ERROR(GWEN_LOGDOMAIN,
                "No matching plugin descriptions for the given device type");
      return NULL;
    }
    return pl2;
  }
  else {
    DBG_ERROR(GWEN_LOGDOMAIN, "No plugin descriptions at all");
  }
  return NULL;
}
コード例 #5
0
GWEN_DIALOG *AB_SetupNewUserDialog_new(AB_BANKING *ab) {
  GWEN_DIALOG *dlg;
  AB_SETUP_NEWUSER_DIALOG *xdlg;
  GWEN_BUFFER *fbuf;
  int rv;
  GWEN_XMLNODE *n;
  GWEN_XMLNODE *nDialog;
  GWEN_PLUGIN_DESCRIPTION_LIST2 *providers;
  GWEN_DIALOG_LIST *subDialogs=NULL;

  dlg=GWEN_Dialog_new("ab_setup_newuser");
  GWEN_NEW_OBJECT(AB_SETUP_NEWUSER_DIALOG, xdlg);
  GWEN_INHERIT_SETDATA(GWEN_DIALOG, AB_SETUP_NEWUSER_DIALOG, dlg, xdlg,
		       AB_SetupNewUserDialog_FreeData);
  GWEN_Dialog_SetSignalHandler(dlg, AB_SetupNewUserDialog_SignalHandler);

  xdlg->backendDialogs=GWEN_Dialog_List2_new();
  xdlg->backendRadioNames=GWEN_StringList_new();
  xdlg->backendNames=GWEN_StringList_new();

  /* get path of dialog description file */
  fbuf=GWEN_Buffer_new(0, 256, 0, 1);
  rv=GWEN_PathManager_FindFile(AB_PM_LIBNAME, AB_PM_DATADIR,
			       "aqbanking/dialogs/dlg_setup_newuser.dlg",
			       fbuf);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "Dialog description file not found (%d).", rv);
    GWEN_Buffer_free(fbuf);
    GWEN_Dialog_free(dlg);
    return NULL;
  }

  /* read XML file, extend it */
  n=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "root");
  rv=GWEN_XML_ReadFile(n, GWEN_Buffer_GetStart(fbuf),
		       GWEN_XML_FLAGS_DEFAULT |
		       GWEN_XML_FLAGS_HANDLE_HEADERS);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
    GWEN_XMLNode_free(n);
    GWEN_Buffer_free(fbuf);
    GWEN_Dialog_free(dlg);
    return NULL;
  }

  nDialog=GWEN_XMLNode_FindFirstTag(n, "dialog", NULL, NULL);
  if (nDialog==NULL) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "Dialog element not found in XML file [%s]", GWEN_Buffer_GetStart(fbuf));
    GWEN_XMLNode_free(n);
    GWEN_Buffer_free(fbuf);
    GWEN_Dialog_free(dlg);
    return NULL;
  }

  providers=AB_Banking_GetProviderDescrs(ab);
  if (providers) {
    GWEN_XMLNODE *nBackendRadioWidget;

    nBackendRadioWidget=GWEN_XMLNode_FindFirstTag(nDialog, "widget", "name", "dialogVLayout");
    if (nBackendRadioWidget)
      nBackendRadioWidget=GWEN_XMLNode_FindFirstTag(nBackendRadioWidget, "widget", "name", "wiz_stack");
    if (nBackendRadioWidget)
      nBackendRadioWidget=GWEN_XMLNode_FindFirstTag(nBackendRadioWidget, "widget", "name", "backendRadioWidget");
    subDialogs=GWEN_Dialog_List_new();
    if (nBackendRadioWidget) {
      GWEN_PLUGIN_DESCRIPTION_LIST2_ITERATOR *pit;
  
      pit=GWEN_PluginDescription_List2_First(providers);
      if (pit) {
	GWEN_PLUGIN_DESCRIPTION *pd;
  
	pd=GWEN_PluginDescription_List2Iterator_Data(pit);
	while(pd) {
	  const char *name;
  
	  name=GWEN_PluginDescription_GetName(pd);
	  if (name && *name) {
	    AB_PROVIDER *pro;

	    pro=AB_Banking_GetProvider(ab, name);
	    if (pro) {
	      GWEN_DIALOG *cdlg;
	      GWEN_BUFFER *tbuf;
	      GWEN_XMLNODE *wn;
	      const char *s;

	      if (AB_Provider_GetFlags(pro) & AB_PROVIDER_FLAGS_HAS_USERTYPE_DIALOG) {
		cdlg=AB_ProviderGetUserTypeDialog(pro);
		if (cdlg==NULL) {
		  DBG_WARN(AQBANKING_LOGDOMAIN, "Backend [%s] does not return a userType dialog, using default", name);
		  cdlg=AB_UserTypePageDefaultDialog_new(ab);
		}
	      }
	      else
		cdlg=AB_UserTypePageDefaultDialog_new(ab);

	      tbuf=GWEN_Buffer_new(0, 256, 0, 1);
	      GWEN_Buffer_AppendString(tbuf, "backend_");
	      GWEN_Buffer_AppendString(tbuf, name);
	      GWEN_Buffer_AppendString(tbuf, "_radio");
    
	      wn=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "widget");
	      GWEN_XMLNode_SetProperty(wn, "type", "radioButton");
	      GWEN_XMLNode_SetProperty(wn, "name", GWEN_Buffer_GetStart(tbuf));
	      GWEN_StringList_AppendString(xdlg->backendRadioNames, GWEN_Buffer_GetStart(tbuf), 0, 0);
	      GWEN_StringList_AppendString(xdlg->backendNames, name, 0, 0);
    
	      s=GWEN_PluginDescription_GetShortDescr(pd);
	      if (!(s && *s))
		s=name;
	      GWEN_XMLNode_SetProperty(wn, "text", I18N(s));
    
	      GWEN_XMLNode_SetProperty(wn, "groupId", "999999");
	      GWEN_XMLNode_SetProperty(wn, "flags", "fillX justifyLeft");
    
	      GWEN_XMLNode_AddChild(nBackendRadioWidget, wn);
	      GWEN_Dialog_List_Add(cdlg, subDialogs);
	    }
	    else {
	      DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not activate backend [%s]", name);
	    }
	  }
  
	  pd=GWEN_PluginDescription_List2Iterator_Next(pit);
	}
	GWEN_PluginDescription_List2Iterator_free(pit);
      }
    }
    else {
      DBG_ERROR(AQBANKING_LOGDOMAIN, "Dialog description does not contain path [dialogVLayout/wiz_stack/backendRadioWidget]");
      GWEN_XMLNode_Dump(nDialog, 2);
      GWEN_XMLNode_free(n);
      GWEN_Buffer_free(fbuf);
      GWEN_Dialog_free(dlg);
      return NULL;
    }
  }

  /* read dialog from dialog description file */
  rv=GWEN_Dialog_ReadXml(dlg, nDialog);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d).", rv);
    GWEN_Dialog_List_free(subDialogs);
    GWEN_XMLNode_free(n);
    GWEN_Buffer_free(fbuf);
    GWEN_Dialog_free(dlg);
    return NULL;
  }
  GWEN_XMLNode_free(n);
  GWEN_Buffer_free(fbuf);

  /* insert pages for each backend */
  if (GWEN_Dialog_List_GetCount(subDialogs)) {
    GWEN_DIALOG *cdlg;

    while ( (cdlg=GWEN_Dialog_List_First(subDialogs)) ) {
      GWEN_Dialog_List_Del(cdlg);
      DBG_NOTICE(AQBANKING_LOGDOMAIN, "Adding dialog %s", GWEN_Dialog_GetId(cdlg));
      rv=GWEN_Dialog_AddSubDialog(dlg, "wiz_stack", cdlg);
      if (rv<0) {
	DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
        GWEN_Dialog_List_free(subDialogs);
	GWEN_Dialog_free(cdlg);
	GWEN_Dialog_free(dlg);
	return NULL;
      }
      GWEN_Dialog_List2_PushBack(xdlg->backendDialogs, cdlg);
    }
  }
  GWEN_Dialog_List_free(subDialogs);

  xdlg->banking=ab;

  /* done */
  return dlg;
}