aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-10-07 17:37:33 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-10-07 17:37:33 +0800
commit714fcc165ac9d611625f80015fc8eb7912de8eaa (patch)
treea01d54be78129a4c7905710745f5f07ebe349afa
parentb0e927b258bc1a05fc5df822dbfb55b3f5679d31 (diff)
downloadgsoc2013-evolution-714fcc165ac9d611625f80015fc8eb7912de8eaa.tar.gz
gsoc2013-evolution-714fcc165ac9d611625f80015fc8eb7912de8eaa.tar.zst
gsoc2013-evolution-714fcc165ac9d611625f80015fc8eb7912de8eaa.zip
noop if we're disabled, and do some lifecycle stuff now, call
2004-10-07 Not Zed <NotZed@Ximian.com> * e-plugin.c (epl_invoke): noop if we're disabled, and do some lifecycle stuff now, call e_plugin_lib_enable on the module if it exists. svn path=/trunk/; revision=27494
-rw-r--r--e-util/ChangeLog6
-rw-r--r--e-util/e-plugin.c28
-rw-r--r--e-util/e-plugin.h10
3 files changed, 39 insertions, 5 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index f96e121ffe..eeeb8e00ea 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,5 +1,11 @@
2004-10-07 Not Zed <NotZed@Ximian.com>
+ * e-plugin.c (epl_invoke): noop if we're disabled, and do some
+ lifecycle stuff now, call e_plugin_lib_enable on the module if it
+ exists.
+
+2004-10-07 Not Zed <NotZed@Ximian.com>
+
* e-config.c (ec_rebuild): show the toplevel notebook if we
had to create one, always.
diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c
index d64360c382..08fc304699 100644
--- a/e-util/e-plugin.c
+++ b/e-util/e-plugin.c
@@ -624,6 +624,7 @@ e_plugin_xml_content_domain(xmlNodePtr node, const char *domain)
/* ********************************************************************** */
static void *epl_parent_class;
+/* this looks weird, but it saves a lot of typing */
#define epl ((EPluginLib *)ep)
/* TODO:
@@ -640,20 +641,37 @@ static void *epl_parent_class;
static void *
epl_invoke(EPlugin *ep, const char *name, void *data)
{
- void *(*cb)(EPlugin *ep, void *data);
+ EPluginLibFunc cb;
- if (epl->module == NULL
- && (epl->module = g_module_open(epl->location, 0)) == NULL) {
- g_warning("can't load plugin '%s'", g_module_error());
+ if (!ep->enabled) {
+ g_warning("trying to invoke '%s' on disabled plugin '%s'", name, ep->id);
return NULL;
}
+ if (epl->module == NULL) {
+ EPluginLibEnableFunc enable;
+
+ if ((epl->module = g_module_open(epl->location, 0)) == NULL) {
+ g_warning("can't load plugin '%s'", g_module_error());
+ return NULL;
+ }
+
+ if (g_module_symbol(epl->module, "e_plugin_lib_enable", (void *)&enable)) {
+ if (enable(epl, TRUE) != 0) {
+ ep->enabled = FALSE;
+ g_module_close(epl->module);
+ epl->module = NULL;
+ return NULL;
+ }
+ }
+ }
+
if (!g_module_symbol(epl->module, name, (void *)&cb)) {
g_warning("Cannot resolve symbol '%s' in plugin '%s' (not exported?)", name, epl->location);
return NULL;
}
- return cb(ep, data);
+ return cb(epl, data);
}
static int
diff --git a/e-util/e-plugin.h b/e-util/e-plugin.h
index 802469acb4..1ecc75b308 100644
--- a/e-util/e-plugin.h
+++ b/e-util/e-plugin.h
@@ -102,6 +102,13 @@ char *e_plugin_xml_content_domain(xmlNodePtr node, const char *domain);
typedef struct _EPluginLib EPluginLib;
typedef struct _EPluginLibClass EPluginLibClass;
+/* The callback signature used for epluginlib methods */
+typedef void *(EPluginLibFunc)(EPluginLib *ep, void *data);
+/* The setup method, this will be called when the plugin is
+ * initialised. In the future it may also be called when the plugin
+ * is disabled. */
+typedef int (EPluginLibEnableFunc)(EPluginLib *ep, int enable);
+
/**
* struct _EPluginLib -
*
@@ -112,6 +119,9 @@ typedef struct _EPluginLibClass EPluginLibClass;
* This is a concrete EPlugin class. It loads and invokes dynamically
* loaded libraries using GModule. The shared object isn't loaded
* until the first callback is invoked.
+ *
+ * When the plugin is loaded, and if it exists, "e_plugin_lib_enable"
+ * will be invoked to initialise the
**/
struct _EPluginLib {
EPlugin plugin;