diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin-def.h | 21 | ||||
-rw-r--r-- | src/plugins/plugin-int.h | 10 | ||||
-rw-r--r-- | src/plugins/plugin.c | 40 |
3 files changed, 49 insertions, 22 deletions
diff --git a/src/plugins/plugin-def.h b/src/plugins/plugin-def.h index d1a13b7..edab3a5 100644 --- a/src/plugins/plugin-def.h +++ b/src/plugins/plugin-def.h @@ -69,14 +69,15 @@ typedef uint32_t plugin_action_t; #define MASK_PLUGIN_SUB_CATEGORY(val) (val & (0xff << 16)) -#define DPC_NONE DEFINE_PLUGIN_CATEGORY(0) +#define DPC_BASIC DEFINE_PLUGIN_CATEGORY(0) #define DPC_BINARY_PROCESSING DEFINE_PLUGIN_CATEGORY(1) // GUI -/* DPC_NONE */ +/* DPC_BASIC */ #define DPS_NONE DEFINE_PLUGIN_SUB_CATEGORY(0) +#define DPS_PG_MANAGEMENT DEFINE_PLUGIN_SUB_CATEGORY(1) /* DPC_BINARY_PROCESSING */ @@ -94,8 +95,22 @@ typedef uint32_t plugin_action_t; /* Action(s) menée(s) par un greffon */ typedef enum _PluginAction { + /** + * DPC_BASIC | DPS_NONE + */ + /* Aucun intérêt */ - PGA_NONE = DPC_NONE | DPS_NONE | DEFINE_PLUGIN_ACTION(0), + PGA_BASIC_NONE = DPC_BASIC | DPS_NONE | DEFINE_PLUGIN_ACTION(0), + + /** + * DPC_BASIC | DPS_NONE + */ + + /* Chargement */ + PGA_PLUGIN_INIT = DPC_BASIC | DPS_PG_MANAGEMENT | DEFINE_PLUGIN_ACTION(0), + + /* Déchargement */ + PGA_PLUGIN_EXIT = DPC_BASIC | DPS_PG_MANAGEMENT | DEFINE_PLUGIN_ACTION(1), /** * DPC_BINARY_PROCESSING | DPS_FORMAT diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 7a3fb3e..1bf459c 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -26,14 +26,18 @@ #include <glib-object.h> +#include <stdbool.h> #include "plugin.h" #include "plugin-def.h" +#include "../glibext/gbincontent.h" #include "../gui/panels/log.h" +/* Prend acte du [dé]chargement du greffon. */ +typedef bool (* pg_management_fc) (GPluginModule *); /* Indique si le format peut être pris en charge ici. */ typedef bool (* pg_format_is_matching) (const GPluginModule *, GBinContent **); @@ -78,14 +82,16 @@ struct _GPluginModule const plugin_interface *interface; /* Déclaration d'interfaçage */ + pg_management_fc init; /* Procédure d'initialisation */ + pg_management_fc exit; /* Procédure d'extinction */ //char *name; /* Nom associé au greffon */ //PluginType type; /* Type(s) du greffon */ - init_plugin_fc init; /* Procédure d'initialisation */ - exit_plugin_fc exit; /* Procédure d'extinction */ + //init_plugin_fc init; /* Procédure d'initialisation */ + //exit_plugin_fc exit; /* Procédure d'extinction */ get_plugin_action_fc get_action; /* Opération(s) menée(s) */ //is_matching_fc is_matching; /* Recherche de correspondance */ diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index fd55f8c..0ca19e4 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -222,13 +222,25 @@ GPluginModule *g_plugin_module_new(const gchar *filename) switch (category) { - case DPC_NONE: + case DPC_BASIC: switch (sub) { case DPS_NONE: break; + case PGA_PLUGIN_INIT: + if (!load_plugin_symbol(result->module, + "chrysalide_plugin_init", &result->init)) + goto bad_plugin; + break; + + case PGA_PLUGIN_EXIT: + if (!load_plugin_symbol(result->module, + "chrysalide_plugin_exit", &result->exit)) + goto bad_plugin; + break; + default: log_variadic_message(LMT_WARNING, _("Unknown sub-category '0x%02x' in plugin '%s'..."), sub, filename); @@ -269,27 +281,21 @@ GPluginModule *g_plugin_module_new(const gchar *filename) } - - - - - /* - if (!g_module_symbol(result->module, "init_plugin", (gpointer *)&result->init)) - result->init = NULL; - - if (!g_module_symbol(result->module, "exit_plugin", (gpointer *)&result->exit)) - result->exit = NULL; - */ - - - - - /* Conclusion */ dir = strdup(filename); dir = dirname(dir); + if (result->init != NULL) + { + if (!result->init(result)) + { + log_variadic_message(LMT_ERROR, + _("Plugin '%s' failed to load itself..."), filename); + goto bad_plugin; + } + } + log_variadic_message(LMT_PROCESS, _("Loaded the '<b>%s</b>' from the '<b>%s</b>' directory"), strrchr(filename, G_DIR_SEPARATOR) + 1, dir); |