diff options
Diffstat (limited to 'src/plugins/plugin.c')
-rw-r--r-- | src/plugins/plugin.c | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 65f3cc6..9322bcb 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -164,7 +164,6 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) size_t i; /* Boucle de parcours */ uint32_t category; /* Catégorie principale */ uint32_t sub; /* Sous-catégorie visée */ - char *dir; /* Répertoire modifiable */ result = g_object_new(G_TYPE_PLUGIN_MODULE, NULL); @@ -300,32 +299,62 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref) /* Conclusion */ - dir = strdup(filename); + if (!g_plugin_module_load(result, ref)) + goto bad_plugin; + + return result; + + bad_plugin: + + g_object_unref(G_OBJECT(result)); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : plugin = greffon à valider. * +* ref = espace de référencement global. * +* * +* Description : Termine le chargement du greffon préparé. * +* * +* Retour : Bilan du chargement effectif. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_plugin_module_load(GPluginModule *plugin, GObject *ref) +{ + bool result; /* Bilan à faire remonter */ + char *dir; /* Répertoire modifiable */ + + result = true; + + dir = strdup(plugin->filename); dir = dirname(dir); - if (result->init != NULL) + if (plugin->init != NULL) { - if (!result->init(result, ref)) + if (!plugin->init(plugin, ref)) { log_variadic_message(LMT_ERROR, - _("Plugin '%s' failed to load itself..."), filename); - goto bad_plugin; + _("Plugin '%s' failed to load itself..."), plugin->filename); + result = false; } } - log_variadic_message(LMT_PROCESS, _("Loaded the '<b>%s</b>' from the '<b>%s</b>' directory"), - strrchr(filename, G_DIR_SEPARATOR) + 1, dir); + if (result) + log_variadic_message(LMT_PROCESS, + _("Loaded the '<b>%s</b>' file as plugin from the '<b>%s</b>' directory"), + strrchr(plugin->filename, G_DIR_SEPARATOR) + 1, dir); free(dir); return result; - bad_plugin: - - g_object_unref(G_OBJECT(result)); - - return NULL; - } |