summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-08-27 00:26:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-08-27 00:26:20 (GMT)
commite07a541d1dea13a19a587f2b97d12ed3443f235b (patch)
tree95ef0ba21345c34c7c246ff824ba70317b810717 /src
parent50a657889a32a6df365bf9880a6f56bf3a0e828c (diff)
Redefined and improved the load process for Python plugins.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@572 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/plugins/plugin-def.h2
-rw-r--r--src/plugins/plugin-int.h3
-rw-r--r--src/plugins/plugin.c57
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;
-
}