diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/plugin-def.h | 2 | ||||
-rw-r--r-- | src/plugins/plugin-int.h | 3 | ||||
-rw-r--r-- | src/plugins/plugin.c | 57 |
3 files changed, 47 insertions, 15 deletions
diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index 68f9942..b73ee97 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -103,7 +103,7 @@ typedef enum _PluginAction PGA_BASIC_NONE = DPC_BASIC | DPS_NONE | DEFINE_PLUGIN_ACTION(0), /** - * DPC_BASIC | DPS_NONE + * DPC_BASIC | DPS_PG_MANAGEMENT */ /* Chargement */ diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 1f4e17e..f136d3f 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -120,6 +120,9 @@ struct _GPluginModuleClass +/* Termine le chargement du greffon préparé. */ +bool g_plugin_module_load(GPluginModule *, GObject *); + /* Présente dans le journal un message simple. */ void g_plugin_module_log_simple_message(const GPluginModule *, LogMessageType, const char *); 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; - } |