aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-provider.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-12 06:34:09 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-12 06:34:09 +0800
commita478ee7e9d44ea7947b2dc51fcf5d7f09735ee52 (patch)
tree16013fe0bf49a83f311bd25c6c603d1a29e5277a /camel/camel-provider.c
parent33ffe9aadcef483a4900cc65fc9e840220951e3c (diff)
downloadgsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.tar
gsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.tar.gz
gsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.tar.bz2
gsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.tar.lz
gsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.tar.xz
gsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.tar.zst
gsoc2013-evolution-a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52.zip
new file. MH provider registration stuff.
1999-08-12 bertrand <Bertrand.Guiheneuf@aful.org> * camel/providers/MH/camel-mh-provider.c: new file. MH provider registration stuff. * camel/camel-provider.c (camel_provider_register_as_module): load a provider from a shared object (plugin). (camel_provider_register): register a provider "by hand". Used for statically defined providers. * tests/test7.c: new test. tests providers loading framework. Providers modules loading Works !!! :)))) svn path=/trunk/; revision=1105
Diffstat (limited to 'camel/camel-provider.c')
-rw-r--r--camel/camel-provider.c105
1 files changed, 100 insertions, 5 deletions
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 238b83ce29..0018e262e0 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -1,9 +1,9 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-provider.c : provider management */
+/* camel-provider.c : provider framework */
/*
*
- * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -22,8 +22,103 @@
*/
-
/*
+ A provider can be added "by hand" or by loading a module.
+
+
+ Adding providers with modules.
+ ------------------------------
+
+ The modules are shared libraries which must contain the
+ function
+
+ CamelProvider *camel_provider_module_init ();
+
+ returning the provider object defined in the module
+
+
+*/
+
+/* FIXME: Shouldn't we add a version number to providers ? */
+
+#include "config.h"
+#include "camel-provider.h"
+#include "camel-log.h"
+
+
+static GList *_provider_list = NULL;
+static gchar *_last_error;
+
+static gint
+_provider_name_cmp (gconstpointer a, gconstpointer b)
+{
+ CamelProvider *provider_a = CAMEL_PROVIDER (a);
+ CamelProvider *provider_b = CAMEL_PROVIDER (b);
+
+ return strcmp ( provider_a->name, provider_b->name);
+}
+
+void
+camel_provider_register (CamelProvider *provider)
+{
+ GList *old_provider_node = NULL;
+
+ g_assert (provider);
+
+ if (_provider_list)
+ old_provider_node = g_list_find_custom (_provider_list, provider, _provider_name_cmp);
+
+ if (old_provider_node != NULL) {
+ // camel_provider_unref (CAMEL_PROVIDER (old_provider_node->data));
+ old_provider_node->data = provider;
+ } else {
+ _provider_list = g_list_append (_provider_list, provider);
+ }
+ // camel_provider_ref (provider);
+
+}
+
+
+const CamelProvider *
+camel_provider_register_as_module (const gchar *module_path)
+{
+
+ CamelProvider *new_provider = NULL;
+ GModule *new_module = NULL;
+ CamelProvider * (*camel_provider_module_init) ();
+ gboolean has_module_init;
+
+ CAMEL_LOG_FULL_DEBUG ("Entering CamelProvider::register_as_module\n");
+
+ g_return_val_if_fail (module_path, NULL);
+
+ if (!g_module_supported ()) {
+ CAMEL_LOG_WARNING ("CamelProvider::register_as_module module loading not supported on this system\n");
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n");
+ return NULL;
+ }
+
+
+ new_module = g_module_open (module_path, 0);
+ if (!new_module) {
+ CAMEL_LOG_WARNING ("CamelProvider::register_as_module Unable to load module %s\n", module_path);
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n");
+ return NULL;
+ }
+
+ has_module_init = g_module_symbol (new_module, "camel_provider_module_init", (gpointer *)&camel_provider_module_init);
+ if (!has_module_init){
+ CAMEL_LOG_WARNING ("CamelProvider::register_as_module loading of module %s failed,\n"
+ "\t Symbol camel_provider_module_init not defined in it\n", module_path);
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n");
+ return NULL;
+ }
+
+ new_provider = camel_provider_module_init();
+ new_provider->gmodule = new_module;
+
+ CAMEL_LOG_FULL_DEBUG ("Leaving CamelProvider::register_as_module\n");
+ return new_provider;
- Here will be the routine to load providers (plugins)
- and register them */
+
+}