Ejemplo n.º 1
0
int GWEN_Crypt_Token_ModuleInit(void)
{
  GWEN_PLUGIN_MANAGER *pm;
  int err;
  GWEN_STRINGLIST *sl;

  pm=GWEN_PluginManager_new(GWEN_CRYPT_TOKEN_PLUGIN_TYPENAME, GWEN_PM_LIBNAME);
  err=GWEN_PluginManager_Register(pm);
  if (err) {
    DBG_ERROR(GWEN_LOGDOMAIN, "Could not register CryptToken plugin manager");
    return err;
  }

  /* create plugin paths */
  sl=GWEN_PathManager_GetPaths(GWEN_PM_LIBNAME, GWEN_PM_PLUGINDIR);
  if (sl) {
    GWEN_STRINGLISTENTRY *se;
    GWEN_BUFFER *pbuf;

    pbuf=GWEN_Buffer_new(0, 256, 0, 1);

    se=GWEN_StringList_FirstEntry(sl);
    while (se) {
      GWEN_Buffer_AppendString(pbuf, GWEN_StringListEntry_Data(se));
      GWEN_Buffer_AppendString(pbuf, DIRSEP GWEN_CRYPT_TOKEN_FOLDER);
      DBG_INFO(GWEN_LOGDOMAIN, "Adding plugin path [%s]",
               GWEN_Buffer_GetStart(pbuf));
      GWEN_PluginManager_AddPath(pm, GWEN_PM_LIBNAME,
                                 GWEN_Buffer_GetStart(pbuf));
      GWEN_Buffer_Reset(pbuf);
      se=GWEN_StringListEntry_Next(se);
    }
    GWEN_Buffer_free(pbuf);
    GWEN_StringList_free(sl);
  }

  return 0;
}
Ejemplo n.º 2
0
int AB_Banking_PluginSystemInit(void) {
    if (ab_plugin_init_count==0) {
        const char *s;
        GWEN_PLUGIN_MANAGER *pm;
        int rv;

        rv=GWEN_Init();
        if (rv) {
            DBG_ERROR_ERR(AQBANKING_LOGDOMAIN, rv);
            return rv;
        }
        if (!GWEN_Logger_IsOpen(AQBANKING_LOGDOMAIN)) {
            GWEN_Logger_Open(AQBANKING_LOGDOMAIN,
                             "aqbanking", 0,
                             GWEN_LoggerType_Console,
                             GWEN_LoggerFacility_User);
            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Notice);
        }

        s=getenv("AQBANKING_LOGLEVEL");
        if (s && *s) {
            GWEN_LOGGER_LEVEL ll;

            ll=GWEN_Logger_Name2Level(s);
            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, ll);
        }

        DBG_INFO(AQBANKING_LOGDOMAIN,
                 "AqBanking v"
                 AQBANKING_VERSION_FULL_STRING
                 " (compiled at "
                 COMPILE_DATETIME
                 "): initialising");

        /* define locale paths */
        GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_LOCALEDIR);
        GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME,
                                           AB_PM_LIBNAME,
                                           AB_PM_LOCALEDIR,
                                           AB_BANKING_REGKEY_PATHS,
                                           AB_BANKING_REGKEY_LOCALEDIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PathManager_AddRelPath(AB_PM_LIBNAME,
                                    AB_PM_LIBNAME,
                                    AB_PM_LOCALEDIR,
                                    LOCALEDIR,
                                    GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PathManager_AddPath(AB_PM_LIBNAME,
                                 AB_PM_LIBNAME,
                                 AB_PM_LOCALEDIR,
                                 LOCALEDIR);
#endif



        if (1) {
            GWEN_STRINGLIST *sl=GWEN_PathManager_GetPaths(AB_PM_LIBNAME,
                                AB_PM_LOCALEDIR);
            const char *localedir=GWEN_StringList_FirstString(sl);

            rv=GWEN_I18N_BindTextDomain_Dir(PACKAGE, localedir);
            if (rv) {
                DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not bind textdomain (%d)", rv);
            }
            else {
                rv=GWEN_I18N_BindTextDomain_Codeset(PACKAGE, "UTF-8");
                if (rv) {
                    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not set codeset (%d)", rv);
                }
            }

            GWEN_StringList_free(sl);
        }


        /* define sysconf paths */
        GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_SYSCONFDIR);
        GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME,
                                           AB_PM_LIBNAME,
                                           AB_PM_SYSCONFDIR,
                                           AB_BANKING_REGKEY_PATHS,
                                           AB_BANKING_REGKEY_SYSCONFDIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PathManager_AddRelPath(AB_PM_LIBNAME,
                                    AB_PM_LIBNAME,
                                    AB_PM_SYSCONFDIR,
                                    AQBANKING_SYSCONF_DIR,
                                    GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PathManager_AddPath(AB_PM_LIBNAME,
                                 AB_PM_LIBNAME,
                                 AB_PM_SYSCONFDIR,
                                 AQBANKING_SYSCONF_DIR);
#endif

        /* define data paths */
        GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_DATADIR);
        GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME,
                                           AB_PM_LIBNAME,
                                           AB_PM_DATADIR,
                                           AB_BANKING_REGKEY_PATHS,
                                           AB_BANKING_REGKEY_DATADIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PathManager_AddRelPath(AB_PM_LIBNAME,
                                    AB_PM_LIBNAME,
                                    AB_PM_DATADIR,
                                    AQBANKING_DATA_DIR,
                                    GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PathManager_AddPath(AB_PM_LIBNAME,
                                 AB_PM_LIBNAME,
                                 AB_PM_DATADIR,
                                 AQBANKING_DATA_DIR);
#endif

        /* define wizard paths */
        GWEN_PathManager_DefinePath(AB_PM_LIBNAME, AB_PM_WIZARDDIR);
        GWEN_PathManager_AddPathFromWinReg(AB_PM_LIBNAME,
                                           AB_PM_LIBNAME,
                                           AB_PM_WIZARDDIR,
                                           AB_BANKING_REGKEY_PATHS,
                                           AB_BANKING_REGKEY_WIZARDDIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PathManager_AddRelPath(AB_PM_LIBNAME,
                                    AB_PM_LIBNAME,
                                    AB_PM_WIZARDDIR,
                                    AQBANKING_PLUGINS
                                    DIRSEP
                                    AB_WIZARD_FOLDER,
                                    GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PathManager_AddPath(AB_PM_LIBNAME,
                                 AB_PM_LIBNAME,
                                 AB_PM_WIZARDDIR,
                                 AQBANKING_PLUGINS
                                 DIRSEP
                                 AB_WIZARD_FOLDER);
#endif

        /* create bankinfo plugin manager */
        DBG_INFO(AQBANKING_LOGDOMAIN, "Registering bankinfo plugin manager");
        pm=GWEN_PluginManager_new("bankinfo", AB_PM_LIBNAME);
        if (GWEN_PluginManager_Register(pm)) {
            DBG_ERROR(AQBANKING_LOGDOMAIN,
                      "Could not register bankinfo plugin manager");
            return GWEN_ERROR_GENERIC;
        }

        GWEN_PluginManager_AddPathFromWinReg(pm,
                                             AB_PM_LIBNAME,
                                             AB_BANKING_REGKEY_PATHS,
                                             AB_BANKING_REGKEY_BANKINFODIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PluginManager_AddRelPath(pm,
                                      AB_PM_LIBNAME,
                                      AQBANKING_PLUGINS
                                      DIRSEP
                                      AB_BANKINFO_PLUGIN_FOLDER,
                                      GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PluginManager_AddPath(pm,
                                   AB_PM_LIBNAME,
                                   AQBANKING_PLUGINS
                                   DIRSEP
                                   AB_BANKINFO_PLUGIN_FOLDER);
#endif
        ab_pluginManagerBankInfo=pm;


        /* create provider plugin manager */
        DBG_INFO(AQBANKING_LOGDOMAIN, "Registering provider plugin manager");
        pm=GWEN_PluginManager_new("provider", AB_PM_LIBNAME);
        if (GWEN_PluginManager_Register(pm)) {
            DBG_ERROR(AQBANKING_LOGDOMAIN,
                      "Could not register provider plugin manager");
            return GWEN_ERROR_GENERIC;
        }

        GWEN_PluginManager_AddPathFromWinReg(pm,
                                             AB_PM_LIBNAME,
                                             AB_BANKING_REGKEY_PATHS,
                                             AB_BANKING_REGKEY_PROVIDERDIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PluginManager_AddRelPath(pm,
                                      AB_PM_LIBNAME,
                                      AQBANKING_PLUGINS
                                      DIRSEP
                                      AB_PROVIDER_FOLDER,
                                      GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PluginManager_AddPath(pm,
                                   AB_PM_LIBNAME,
                                   AQBANKING_PLUGINS
                                   DIRSEP
                                   AB_PROVIDER_FOLDER);
#endif
        ab_pluginManagerProvider=pm;


        /* create imexporters plugin manager */
        DBG_INFO(AQBANKING_LOGDOMAIN, "Registering imexporters plugin manager");
        pm=GWEN_PluginManager_new("imexporter", AB_PM_LIBNAME);
        if (GWEN_PluginManager_Register(pm)) {
            DBG_ERROR(AQBANKING_LOGDOMAIN,
                      "Could not register imexporters plugin manager");
            return GWEN_ERROR_GENERIC;
        }

        GWEN_PluginManager_AddPathFromWinReg(pm,
                                             AB_PM_LIBNAME,
                                             AB_BANKING_REGKEY_PATHS,
                                             AB_BANKING_REGKEY_IMPORTERDIR);
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
        /* add folder relative to EXE */
        GWEN_PluginManager_AddRelPath(pm,
                                      AB_PM_LIBNAME,
                                      AQBANKING_PLUGINS
                                      DIRSEP
                                      AB_IMEXPORTER_FOLDER,
                                      GWEN_PathManager_RelModeExe);
#else
        /* add absolute folder */
        GWEN_PluginManager_AddPath(pm,
                                   AB_PM_LIBNAME,
                                   AQBANKING_PLUGINS
                                   DIRSEP
                                   AB_IMEXPORTER_FOLDER);
#endif
        ab_pluginManagerImExporter=pm;


        /* insert DBIO plugin folder */
        pm=GWEN_PluginManager_FindPluginManager("dbio");
        if (pm) {
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
            /* insert folder relative to EXE */
            GWEN_PluginManager_InsertRelPath(pm,
                                             AB_PM_LIBNAME,
                                             AQBANKING_PLUGINS
                                             DIRSEP
                                             AB_DBIO_FOLDER,
                                             GWEN_PathManager_RelModeExe);
#else
            /* add absolute folder */
            GWEN_PluginManager_InsertPath(pm,
                                          AB_PM_LIBNAME,
                                          AQBANKING_PLUGINS
                                          DIRSEP
                                          AB_DBIO_FOLDER);
#endif
        }
        else {
            DBG_ERROR(AQBANKING_LOGDOMAIN,
                      "Could not find DBIO plugin manager, maybe GWEN_Init() was not called?");
            return GWEN_ERROR_GENERIC;
        }


        ab_imexporters=AB_ImExporter_List_new();
        ab_bankInfoPlugins=AB_BankInfoPlugin_List_new();
    }
    ab_plugin_init_count++;
    return 0;
}