diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-10-04 18:36:48 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-10-04 18:36:48 (GMT) |
commit | 105394bcc19b3565c6b77d38625d8813596d0c1b (patch) | |
tree | a4ee17a5ecfa3dfa9327f5ec78da78cd2bd65a59 /src/plugins | |
parent | 208abfe4182c0dafc230e0377b3efcc6c24be0f9 (diff) |
Updated and improved the plugin system.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/pglist.c | 16 | ||||
-rw-r--r-- | src/plugins/plugin-def.h | 2 | ||||
-rw-r--r-- | src/plugins/plugin.c | 40 | ||||
-rw-r--r-- | src/plugins/plugin.h | 5 |
4 files changed, 54 insertions, 9 deletions
diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index 54c8784..2010cda 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -306,6 +306,22 @@ void load_remaning_plugins(void) } while (changed); + for (i = 0; i < _pg_count; i++) + { + flags = g_plugin_module_get_flags(_pg_list[i]); + + if (flags & PSF_UNKNOW_DEP) + log_variadic_message(LMT_ERROR, + _("There is (at least) one unknown dependency in the plugin '%s'"), + g_plugin_module_get_filename(_pg_list[i])); + + else if (flags & PSF_DEP_LOOP) + log_variadic_message(LMT_ERROR, + _("There is a dependency loop in the plugin '%s'"), + g_plugin_module_get_filename(_pg_list[i])); + + } + /* Effectue les chargements possibles */ for (i = 0; i < _pg_count; i++) diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index e5d06c3..ed09e91 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -302,7 +302,7 @@ typedef struct _plugin_interface #define AL(...) BUILD_PG_LIST(.actions, ((plugin_action_t []){ __VA_ARGS__ })) -#define RL(...) BUILD_PG_LIST(.required, ((char *[]){ __VA_ARGS__ })) +#define RL(...) BUILD_PG_LIST(.required, ((const char *[]){ __VA_ARGS__ })) #define DEFINE_CHRYSALIDE_PLUGIN(n, d, v, r, a) \ diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index f12c1f6..a57cb6f 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -336,6 +336,25 @@ GPluginModule *g_plugin_module_new(const gchar *filename) * * * Paramètres : plugin = greffon à consulter. * * * +* Description : Indique le fichier contenant le greffon manipulé. * +* * +* Retour : Chemin d'accès au greffon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +const char *g_plugin_module_get_filename(const GPluginModule *plugin) +{ + return plugin->filename; + +} + + +/****************************************************************************** +* * +* Paramètres : plugin = greffon à consulter. * +* * * Description : Fournit la description du greffon dans son intégralité. * * * * Retour : Interfaçage renseigné. * @@ -403,7 +422,7 @@ bool g_plugin_module_resolve_dependencies(GPluginModule *plugin, GPluginModule * assert(count == get_bit_field_size(plugin->dependencies)); #endif - if ((plugin->flags & (PSF_UNKNOW_DEP | PSF_DEP_LOOP)) != 0) + if ((plugin->flags & (PSF_UNKNOW_DEP | PSF_DEP_LOOP)) == 0) { pg_iface = g_plugin_module_get_interface(plugin); @@ -420,9 +439,10 @@ bool g_plugin_module_resolve_dependencies(GPluginModule *plugin, GPluginModule * else { + set_in_bit_field(new, index, 1); or_bit_field(new, dependency->dependencies); - g_object_ref(G_OBJECT(dependency)); + g_object_unref(G_OBJECT(dependency)); } @@ -446,7 +466,7 @@ bool g_plugin_module_resolve_dependencies(GPluginModule *plugin, GPluginModule * if (test_in_bit_field(plugin->dependencies, index)) plugin->flags |= PSF_DEP_LOOP; - g_object_ref(G_OBJECT(dependency)); + g_object_unref(G_OBJECT(dependency)); } @@ -483,9 +503,7 @@ bool g_plugin_module_load(GPluginModule *plugin, GPluginModule **list, size_t co flags = g_plugin_module_get_flags(plugin); - assert((flags & BROKEN_PLUGIN_STATUS) == 0); - - if (flags & PSF_FAILURE) return false; + if (flags & BROKEN_PLUGIN_STATUS) return false; if (flags & PSF_LOADED) return true; @@ -498,14 +516,17 @@ bool g_plugin_module_load(GPluginModule *plugin, GPluginModule **list, size_t co for (i = 0; i < pg_iface->required_count && result; i++) { dependency = get_plugin_by_name(pg_iface->required[i], NULL); + assert(dependency != NULL); result = g_plugin_module_load(dependency, list, count); + g_object_unref(G_OBJECT(dependency)); + } if (!result) log_variadic_message(LMT_ERROR, - _("Some dependencies failed to load for Plugin '%s'"), plugin->filename); + _("Some dependencies failed to load for plugin '%s'"), plugin->filename); /* Chargement du greffon courant */ @@ -516,9 +537,14 @@ bool g_plugin_module_load(GPluginModule *plugin, GPluginModule **list, size_t co result = plugin->init(plugin); if (!result) + { log_variadic_message(LMT_ERROR, _("Plugin '%s' failed to load itself..."), plugin->filename); + plugin->flags |= PSF_FAILURE; + + } + } if (result) diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 6d783b7..78dcaa6 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -51,7 +51,7 @@ typedef enum _PluginStatusFlags PSF_UNKNOW_DEP = (1 << 0), /* Dépendance non trouvée */ PSF_DEP_LOOP = (1 << 1), /* Dépendances circulaires */ PSF_FAILURE = (1 << 2), /* Erreur au chargement */ - PSF_LOADED = (1 << 2) /* Greffon intégré au système */ + PSF_LOADED = (1 << 3) /* Greffon intégré au système */ } PluginStatusFlags; @@ -73,6 +73,9 @@ GType g_plugin_module_get_type(void); /* Crée un module pour un greffon donné. */ GPluginModule *g_plugin_module_new(const gchar *); +/* Indique le fichier contenant le greffon manipulé. */ +const char *g_plugin_module_get_filename(const GPluginModule *); + /* Fournit la description du greffon dans son intégralité. */ const plugin_interface *g_plugin_module_get_interface(const GPluginModule *); |