aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-02-19 15:27:49 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-02-19 15:27:49 +0800
commit05e0ef6fea2f2feec010109142c8305c69e64c57 (patch)
treef01a116128a1e73d5971bf1ba1bfc711e292aaf4 /camel
parent8b86c88624f926a7122ab4dd39ebd26d0e839ab2 (diff)
downloadgsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.tar
gsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.tar.gz
gsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.tar.bz2
gsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.tar.lz
gsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.tar.xz
gsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.tar.zst
gsoc2013-evolution-05e0ef6fea2f2feec010109142c8305c69e64c57.zip
Fixes for api changes.
2004-02-19 Not Zed <NotZed@Ximian.com> * providers/*/camel-*-provider.c (camel_provider_module_init): Fixes for api changes. * camel-provider.c (camel_provider_load): no longer take session argument. the providers are global resources. (camel_provider_init): dont return anything anymore. (error?) call from camel_init now. Use a recursive lock too. * camel-session.c (camel_session_register_provider) (camel_session_list_providers, camel_session_get_provider): Moved to camel-provider, camel_provider_register/list/get. (vee_provider): moved to camel-provider.c svn path=/trunk/; revision=24794
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog15
-rw-r--r--camel/camel-filter-search.c2
-rw-r--r--camel/camel-provider.c232
-rw-r--r--camel/camel-provider.h10
-rw-r--r--camel/camel-session.c244
-rw-r--r--camel/camel-session.h18
-rw-r--r--camel/camel.c6
-rw-r--r--camel/providers/groupwise/camel-groupwise-provider.c22
-rw-r--r--camel/providers/imap/camel-imap-provider.c10
-rw-r--r--camel/providers/imapp/camel-imapp-provider.c8
-rw-r--r--camel/providers/local/camel-local-provider.c12
-rw-r--r--camel/providers/nntp/camel-nntp-provider.c7
-rw-r--r--camel/providers/pop3/camel-pop3-provider.c4
-rw-r--r--camel/providers/sendmail/camel-sendmail-provider.c7
-rw-r--r--camel/providers/smtp/camel-smtp-provider.c7
15 files changed, 274 insertions, 330 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 766aa70734..58ef4d3209 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,18 @@
+2004-02-19 Not Zed <NotZed@Ximian.com>
+
+ * providers/*/camel-*-provider.c
+ (camel_provider_module_init): Fixes for api changes.
+
+ * camel-provider.c (camel_provider_load): no longer take session
+ argument. the providers are global resources.
+ (camel_provider_init): dont return anything anymore. (error?)
+ call from camel_init now. Use a recursive lock too.
+
+ * camel-session.c (camel_session_register_provider)
+ (camel_session_list_providers, camel_session_get_provider): Moved
+ to camel-provider, camel_provider_register/list/get.
+ (vee_provider): moved to camel-provider.c
+
2004-02-18 Jeffrey Stedfast <fejj@ximian.com>
* camel-gpg-context.c (gpg_verify): Use the trust to decide the
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 53fe074b10..fa3273d895 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -463,7 +463,7 @@ header_source (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMes
}
if (src
- && (provider = camel_session_get_provider(fms->session, src, NULL))
+ && (provider = camel_provider_get(src, NULL))
&& provider->url_equal) {
uria = camel_url_new(src, NULL);
if (uria) {
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 1b8ef2cab5..be15aed046 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -1,7 +1,5 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-provider.c: provider framework */
-
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * camel-provider.c: provider framework
*
* Authors:
* Bertrand Guiheneuf <bertrand@helixcode.com>
@@ -25,7 +23,6 @@
* USA
*/
-
/* FIXME: Shouldn't we add a version number to providers ? */
#ifdef HAVE_CONFIG_H
@@ -43,7 +40,33 @@
#include "camel-provider.h"
#include "camel-exception.h"
#include "camel-string-utils.h"
+#include "camel-vee-store.h"
+
+#include "e-util/e-msgport.h"
+/* table of CamelProviderModule's */
+static GHashTable *module_table;
+/* table of CamelProvider's */
+static GHashTable *provider_table;
+static EMutex *provider_lock;
+
+#define LOCK() e_mutex_lock(provider_lock);
+#define UNLOCK() e_mutex_unlock(provider_lock);
+
+/* The vfolder provider is always available */
+static CamelProvider vee_provider = {
+ "vfolder",
+ N_("Virtual folder email provider"),
+
+ N_("For reading mail as a query of another set of folders"),
+
+ "vfolder",
+
+ CAMEL_PROVIDER_IS_STORAGE,
+ CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE | CAMEL_URL_FRAGMENT_IS_PATH,
+
+ /* ... */
+};
/**
* camel_provider_init:
@@ -55,25 +78,35 @@
* A .urls file has the same initial prefix as the shared library it
* correspond to, and consists of a series of lines containing the URL
* protocols that that library handles.
- *
- * Return value: a hash table mapping URLs to module names
**/
-GHashTable *
+void
camel_provider_init (void)
{
- GHashTable *providers;
DIR *dir;
struct dirent *d;
char *p, *name, buf[80];
CamelProviderModule *m;
+ static int init = 0;
+
+ if (init)
+ return;
+
+ init = 1;
+
+ provider_lock = e_mutex_new(E_MUTEX_REC);
+ module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+ provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+
+ vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
+ vee_provider.url_hash = camel_url_hash;
+ vee_provider.url_equal = camel_url_equal;
+ camel_provider_register(&vee_provider);
- providers = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
-
dir = opendir (CAMEL_PROVIDERDIR);
if (!dir) {
g_error ("Could not open camel provider directory (%s): %s",
CAMEL_PROVIDERDIR, g_strerror (errno));
- return NULL;
+ return;
}
while ((d = readdir (dir))) {
@@ -108,7 +141,7 @@ camel_provider_init (void)
char *protocol = g_strdup(buf);
m->types = g_slist_prepend(m->types, protocol);
- g_hash_table_insert(providers, protocol, m);
+ g_hash_table_insert(module_table, protocol, m);
}
}
@@ -116,7 +149,6 @@ camel_provider_init (void)
}
closedir (dir);
- return providers;
}
/**
@@ -130,10 +162,10 @@ camel_provider_init (void)
* itself with @session.
**/
void
-camel_provider_load (CamelSession *session, const char *path, CamelException *ex)
+camel_provider_load(const char *path, CamelException *ex)
{
GModule *module;
- CamelProvider *(*camel_provider_module_init) ();
+ CamelProvider *(*camel_provider_module_init) (void);
if (!g_module_supported ()) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -160,7 +192,173 @@ camel_provider_load (CamelSession *session, const char *path, CamelException *ex
return;
}
- camel_provider_module_init (session);
+ camel_provider_module_init ();
+}
+
+/**
+ * camel_provider_register:
+ * @provider: provider object
+ *
+ * Registers a provider.
+ **/
+void
+camel_provider_register(CamelProvider *provider)
+{
+ int i;
+ CamelProviderConfEntry *conf;
+ GList *l;
+
+ g_return_if_fail (provider != NULL);
+
+ LOCK();
+
+ if (g_hash_table_lookup(provider_table, provider->protocol) != NULL) {
+ g_warning("Trying to re-register camel provider for protocol '%s'", provider->protocol);
+ UNLOCK();
+ return;
+ }
+
+ for (i = 0; i < CAMEL_NUM_PROVIDER_TYPES; i++) {
+ if (provider->object_types[i])
+ provider->service_cache[i] = camel_object_bag_new (provider->url_hash, provider->url_equal,
+ (CamelCopyFunc)camel_url_copy, (GFreeFunc)camel_url_free);
+ }
+
+ /* Translate all strings here */
+#define P_(string) dgettext (provider->translation_domain, string)
+
+ provider->name = P_(provider->name);
+ provider->description = P_(provider->description);
+ conf = provider->extra_conf;
+ if (conf) {
+ for (i=0;conf[i].type != CAMEL_PROVIDER_CONF_END;i++) {
+ if (conf[i].text)
+ conf[i].text = P_(conf[i].text);
+ }
+ }
+
+ l = provider->authtypes;
+ while (l) {
+ CamelServiceAuthType *auth = l->data;
+
+ auth->name = P_(auth->name);
+ auth->description = P_(auth->description);
+ l = l->next;
+ }
+
+ g_hash_table_insert(provider_table, provider->protocol, provider);
+
+ UNLOCK();
+}
+
+static gint
+provider_compare (gconstpointer a, gconstpointer b)
+{
+ const CamelProvider *cpa = (const CamelProvider *)a;
+ const CamelProvider *cpb = (const CamelProvider *)b;
+
+ return strcmp (cpa->name, cpb->name);
+}
+
+static void
+add_to_list (gpointer key, gpointer value, gpointer user_data)
+{
+ GList **list = user_data;
+
+ *list = g_list_prepend(*list, value);
+}
+
+/**
+ * camel_session_list_providers:
+ * @session: the session
+ * @load: whether or not to load in providers that are not already loaded
+ *
+ * This returns a list of available providers in this session. If @load
+ * is %TRUE, it will first load in all available providers that haven't
+ * yet been loaded.
+ *
+ * Return value: a GList of providers, which the caller must free.
+ **/
+GList *
+camel_provider_list(gboolean load)
+{
+ GList *list;
+
+ LOCK();
+
+ if (load) {
+ GList *w;
+
+ g_hash_table_foreach(module_table, add_to_list, &list);
+ for (w = list;w;w = w->next) {
+ CamelProviderModule *m = w->data;
+
+ if (!m->loaded) {
+ camel_provider_load(m->path, NULL);
+ m->loaded = 1;
+ }
+ }
+ g_list_free(list);
+ list = NULL;
+ }
+
+ g_hash_table_foreach(provider_table, add_to_list, &list);
+
+ UNLOCK();
+
+ list = g_list_sort(list, provider_compare);
+
+ return list;
+}
+
+/**
+ * camel_provider_get:
+ * @url_string: the URL for the service whose provider you want
+ * @ex: a CamelException
+ *
+ * This returns the CamelProvider that would be used to handle
+ * @url_string, loading it in from disk if necessary.
+ *
+ * Return value: the provider, or %NULL, in which case @ex will be set.
+ **/
+CamelProvider *
+camel_provider_get(const char *url_string, CamelException *ex)
+{
+ CamelProvider *provider = NULL;
+ char *protocol;
+ size_t len;
+
+ g_return_val_if_fail(url_string != NULL, NULL);
+
+ len = strcspn(url_string, ":");
+ protocol = g_alloca(len+1);
+ memcpy(protocol, url_string, len);
+ protocol[len] = 0;
+
+ LOCK();
+
+ provider = g_hash_table_lookup(provider_table, protocol);
+ if (!provider) {
+ CamelProviderModule *m;
+
+ m = g_hash_table_lookup(module_table, protocol);
+ if (m && !m->loaded) {
+ m->loaded = 1;
+ camel_provider_load(m->path, ex);
+ if (camel_exception_is_set (ex))
+ goto fail;
+ }
+ provider = g_hash_table_lookup(provider_table, protocol);
+ }
+
+ if (provider == NULL)
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ _("No provider available for protocol `%s'"),
+ protocol);
+fail:
+ UNLOCK();
+
+ return provider;
}
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index fb64143f28..273c7554d2 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -192,11 +192,15 @@ struct _CamelProviderModule {
int loaded:1;
};
-GHashTable *camel_provider_init (void);
-void camel_provider_load (CamelSession *session, const char *path, CamelException *ex);
+void camel_provider_init(void);
+
+void camel_provider_load(const char *path, CamelException *ex);
+void camel_provider_register(CamelProvider *provider);
+GList *camel_provider_list(gboolean load);
+CamelProvider *camel_provider_get(const char *url_string, CamelException *ex);
/* This is defined by each module, not by camel-provider.c. */
-void camel_provider_module_init (CamelSession *session);
+void camel_provider_module_init(void);
int camel_provider_auto_detect (CamelProvider *provider, CamelURL *url,
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 2672c0a685..69569aef2d 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -41,7 +41,6 @@
#include "camel-file-utils.h"
#include "camel-string-utils.h"
#include "camel-url.h"
-#include "camel-vee-store.h"
#include "camel-private.h"
@@ -49,12 +48,6 @@
#define CS_CLASS(so) ((CamelSessionClass *)((CamelObject *)so)->klass)
-static void register_provider (CamelSession *session, CamelProvider *provider);
-static GList *list_providers (CamelSession *session, gboolean load);
-static CamelProvider *get_provider (CamelSession *session,
- const char *url_string,
- CamelException *ex);
-
static CamelService *get_service (CamelSession *session,
const char *url_string,
CamelProviderType type,
@@ -69,27 +62,10 @@ static int session_thread_queue(CamelSession *session, CamelSessionThreadMsg *ms
static void session_thread_wait(CamelSession *session, int id);
static void session_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const char *text, int pc);
-/* The vfolder provider is always available */
-static CamelProvider vee_provider = {
- "vfolder",
- N_("Virtual folder email provider"),
-
- N_("For reading mail as a query of another set of folders"),
-
- "vfolder",
-
- CAMEL_PROVIDER_IS_STORAGE,
- CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE | CAMEL_URL_FRAGMENT_IS_PATH,
-
- /* ... */
-};
-
static void
camel_session_init (CamelSession *session)
{
session->online = TRUE;
- session->modules = camel_provider_init ();
- session->providers = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
session->priv = g_malloc0(sizeof(*session->priv));
session->priv->lock = g_mutex_new();
@@ -99,22 +75,6 @@ camel_session_init (CamelSession *session)
session->priv->thread_queue = NULL;
}
-#if 0
-/* NOTE: this code ruins all chance of ever having more than 1 session object */
-static gboolean
-camel_session_destroy_provider (gpointer key, gpointer value, gpointer user_data)
-{
- CamelProvider *prov = (CamelProvider *)value;
- int i;
-
- for (i = 0; i < CAMEL_NUM_PROVIDER_TYPES; i++) {
- if (prov->service_cache[i])
- camel_object_bag_destroy (prov->service_cache[i]);
- }
- return TRUE;
-}
-#endif
-
static void
camel_session_finalise (CamelObject *o)
{
@@ -125,8 +85,6 @@ camel_session_finalise (CamelObject *o)
e_thread_destroy(session->priv->thread_queue);
g_free(session->storage_path);
- /*g_hash_table_foreach_remove (session->providers, camel_session_destroy_provider, NULL);*/
- g_hash_table_destroy (session->providers);
g_mutex_free(session->priv->lock);
g_mutex_free(session->priv->thread_lock);
@@ -138,9 +96,6 @@ static void
camel_session_class_init (CamelSessionClass *camel_session_class)
{
/* virtual method definition */
- camel_session_class->register_provider = register_provider;
- camel_session_class->list_providers = list_providers;
- camel_session_class->get_provider = get_provider;
camel_session_class->get_service = get_service;
camel_session_class->get_storage_path = get_storage_path;
@@ -149,10 +104,6 @@ camel_session_class_init (CamelSessionClass *camel_session_class)
camel_session_class->thread_queue = session_thread_queue;
camel_session_class->thread_wait = session_thread_wait;
camel_session_class->thread_status = session_thread_status;
-
- vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
- vee_provider.url_hash = camel_url_hash;
- vee_provider.url_equal = camel_url_equal;
}
CamelType
@@ -186,199 +137,6 @@ void
camel_session_construct (CamelSession *session, const char *storage_path)
{
session->storage_path = g_strdup (storage_path);
- camel_session_register_provider(session, &vee_provider);
-}
-
-
-static void
-register_provider (CamelSession *session, CamelProvider *provider)
-{
- int i;
- CamelProviderConfEntry *conf;
- GList *l;
-
- for (i = 0; i < CAMEL_NUM_PROVIDER_TYPES; i++) {
- if (provider->object_types[i])
- provider->service_cache[i] = camel_object_bag_new (provider->url_hash, provider->url_equal,
- (CamelCopyFunc)camel_url_copy, (GFreeFunc)camel_url_free);
- }
-
- /* Translate all strings here */
-
-#define P_(string) dgettext (provider->translation_domain, string)
-
- provider->name = P_(provider->name);
- provider->description = P_(provider->description);
- conf = provider->extra_conf;
- if (conf) {
- for (i=0;conf[i].type != CAMEL_PROVIDER_CONF_END;i++) {
- if (conf[i].text)
- conf[i].text = P_(conf[i].text);
- }
- }
- l = provider->authtypes;
- while (l) {
- CamelServiceAuthType *auth = l->data;
-
- auth->name = P_(auth->name);
- auth->description = P_(auth->description);
- l = l->next;
- }
-
- g_hash_table_insert (session->providers, provider->protocol, provider);
-}
-
-/**
- * camel_session_register_provider:
- * @session: a session object
- * @protocol: the protocol the provider provides for
- * @provider: provider object
- *
- * Registers a protocol to provider mapping for the session.
- *
- * Assumes the session lock has already been obtained,
- * which is the case for automatically loaded provider modules.
- **/
-void
-camel_session_register_provider (CamelSession *session,
- CamelProvider *provider)
-{
- g_return_if_fail (CAMEL_IS_SESSION (session));
- g_return_if_fail (provider != NULL);
-
- CS_CLASS (session)->register_provider (session, provider);
-}
-
-
-static void
-ensure_loaded (gpointer key, gpointer value, gpointer user_data)
-{
- CamelSession *session = user_data;
- CamelProviderModule *m = value;
- CamelException ex;
-
- if (m->loaded)
- return;
-
- m->loaded = 1;
- camel_exception_init(&ex);
- camel_provider_load(session, m->path, &ex);
- camel_exception_clear(&ex);
-}
-
-static gint
-provider_compare (gconstpointer a, gconstpointer b)
-{
- const CamelProvider *cpa = (const CamelProvider *)a;
- const CamelProvider *cpb = (const CamelProvider *)b;
-
- return strcmp (cpa->name, cpb->name);
-}
-
-static void
-add_to_list (gpointer key, gpointer value, gpointer user_data)
-{
- GList **list = user_data;
- CamelProvider *prov = value;
-
- *list = g_list_insert_sorted (*list, prov, provider_compare);
-}
-
-static GList *
-list_providers (CamelSession *session, gboolean load)
-{
- GList *list = NULL;
-
- if (load)
- g_hash_table_foreach (session->modules, ensure_loaded, session);
-
- g_hash_table_foreach (session->providers, add_to_list, &list);
- return list;
-}
-
-/**
- * camel_session_list_providers:
- * @session: the session
- * @load: whether or not to load in providers that are not already loaded
- *
- * This returns a list of available providers in this session. If @load
- * is %TRUE, it will first load in all available providers that haven't
- * yet been loaded.
- *
- * Return value: a GList of providers, which the caller must free.
- **/
-GList *
-camel_session_list_providers (CamelSession *session, gboolean load)
-{
- GList *list;
-
- g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
-
- CAMEL_SESSION_LOCK (session, lock);
- list = CS_CLASS (session)->list_providers (session, load);
- CAMEL_SESSION_UNLOCK (session, lock);
-
- return list;
-}
-
-
-static CamelProvider *
-get_provider (CamelSession *session, const char *url_string, CamelException *ex)
-{
- CamelProvider *provider;
- char *protocol;
-
- protocol = g_strndup (url_string, strcspn (url_string, ":"));
-
- provider = g_hash_table_lookup (session->providers, protocol);
- if (!provider) {
- /* See if there's one we can load. */
- CamelProviderModule *m;
-
- m = g_hash_table_lookup (session->modules, protocol);
- if (m && !m->loaded) {
- m->loaded = 1;
- camel_provider_load (session, m->path, ex);
- if (camel_exception_is_set (ex)) {
- g_free (protocol);
- return NULL;
- }
- }
- provider = g_hash_table_lookup (session->providers, protocol);
- }
-
- if (!provider) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- _("No provider available for protocol `%s'"),
- protocol);
- }
- g_free (protocol);
-
- return provider;
-}
-
-/**
- * camel_session_get_provider:
- * @session: the session
- * @url_string: the URL for the service whose provider you want
- * @ex: a CamelException
- *
- * This returns the CamelProvider that would be used to handle
- * @url_string, loading it in from disk if necessary.
- *
- * Return value: the provider, or %NULL, in which case @ex will be set.
- **/
-CamelProvider *
-camel_session_get_provider (CamelSession *session, const char *url_string,
- CamelException *ex)
-{
- CamelProvider *provider;
-
- CAMEL_SESSION_LOCK (session, lock);
- provider = CS_CLASS (session)->get_provider (session, url_string, ex);
- CAMEL_SESSION_UNLOCK (session, lock);
-
- return provider;
}
static CamelService *
@@ -396,7 +154,7 @@ get_service (CamelSession *session, const char *url_string,
/* We need to look up the provider so we can then lookup
the service in the provider's cache */
- provider = CS_CLASS (session)->get_provider (session, url->protocol, ex);
+ provider = camel_provider_get(url->protocol, ex);
if (provider && !provider->object_types[type]) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
_("No provider available for protocol `%s'"),
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 27beb0a45f..9548a7a5b8 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -64,7 +64,6 @@ struct _CamelSession
struct _CamelSessionPrivate *priv;
char *storage_path;
- GHashTable *providers, *modules;
gboolean online;
CamelJunkPlugin *junk_plugin;
@@ -80,14 +79,6 @@ typedef struct _CamelSessionThreadMsg CamelSessionThreadMsg;
typedef struct {
CamelObjectClass parent_class;
- void (*register_provider) (CamelSession *session,
- CamelProvider *provider);
- GList * (*list_providers) (CamelSession *session,
- gboolean load);
- CamelProvider * (*get_provider) (CamelSession *session,
- const char *url_string,
- CamelException *ex);
-
CamelService * (*get_service) (CamelSession *session,
const char *url_string,
CamelProviderType type,
@@ -135,15 +126,6 @@ CamelType camel_session_get_type (void);
void camel_session_construct (CamelSession *session,
const char *storage_path);
-void camel_session_register_provider (CamelSession *session,
- CamelProvider *provider);
-GList * camel_session_list_providers (CamelSession *session,
- gboolean load);
-
-CamelProvider * camel_session_get_provider (CamelSession *session,
- const char *url_string,
- CamelException *ex);
-
CamelService * camel_session_get_service (CamelSession *session,
const char *url_string,
CamelProviderType type,
diff --git a/camel/camel.c b/camel/camel.c
index 44a894cfc0..e926203732 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -38,6 +38,7 @@
#include "camel.h"
#include "camel-certdb.h"
#include "camel-mime-utils.h"
+#include "camel-provider.h"
gboolean camel_verbose_debug = FALSE;
@@ -80,10 +81,11 @@ camel_init (const char *configdir, gboolean nss_init)
camel_verbose_debug = TRUE;
/* initialise global camel_object_type */
- camel_object_get_type ();
+ camel_object_get_type();
- camel_mime_utils_init ();
+ camel_mime_utils_init();
camel_operation_init();
+ camel_provider_init();
#ifdef HAVE_NSS
if (nss_init) {
diff --git a/camel/providers/groupwise/camel-groupwise-provider.c b/camel/providers/groupwise/camel-groupwise-provider.c
index c9fc7946fa..50e3346710 100644
--- a/camel/providers/groupwise/camel-groupwise-provider.c
+++ b/camel/providers/groupwise/camel-groupwise-provider.c
@@ -107,38 +107,28 @@ CamelServiceAuthType camel_groupwise_password_authtype = {
};
void
-camel_provider_module_init (CamelSession *session)
+camel_provider_module_init(void)
{
-
-
CamelProvider *imap_provider;
CamelProvider *smtp_provider;
- CamelSession *temp_session;
- temp_session = CAMEL_SESSION ( camel_object_new ( CAMEL_SESSION_TYPE));
- imap_provider = camel_session_get_provider (temp_session, "imap://", NULL);
- smtp_provider = camel_session_get_provider (temp_session, "smtp://", NULL);
+ imap_provider = camel_provider_get("imap://", NULL);
+ smtp_provider = camel_provider_get("smtp://", NULL);
groupwise_provider.url_hash = groupwise_url_hash;
groupwise_provider.url_equal = groupwise_url_equal;
- groupwise_provider.authtypes = g_list_prepend (groupwise_provider.authtypes, &camel_groupwise_password_authtype);
+ groupwise_provider.authtypes = g_list_prepend (groupwise_provider.authtypes, &camel_groupwise_password_authtype);
if (imap_provider != NULL && smtp_provider != NULL) {
-
groupwise_provider.object_types[CAMEL_PROVIDER_STORE] = imap_provider->object_types [CAMEL_PROVIDER_STORE];
groupwise_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = smtp_provider->object_types [CAMEL_PROVIDER_TRANSPORT];
- camel_session_register_provider (session, &groupwise_provider);
+ camel_provider_register(&groupwise_provider);
}
-
- if (!config_listener) {
-
+ if (!config_listener) {
config_listener = camel_gw_listener_new ();
g_atexit ( free_groupwise_listener );
}
-
- camel_object_unref (temp_session);
-
}
void free_groupwise_listener ( void )
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index abda8f89a0..fb7c69766c 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -96,17 +96,15 @@ CamelServiceAuthType camel_imap_password_authtype = {
};
void
-camel_provider_module_init (CamelSession *session)
+camel_provider_module_init(void)
{
- imap_provider.object_types[CAMEL_PROVIDER_STORE] =
- camel_imap_store_get_type ();
+ imap_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imap_store_get_type ();
imap_provider.url_hash = imap_url_hash;
imap_provider.url_equal = imap_url_equal;
imap_provider.authtypes = camel_sasl_authtype_list (FALSE);
- imap_provider.authtypes = g_list_prepend (imap_provider.authtypes,
- &camel_imap_password_authtype);
+ imap_provider.authtypes = g_list_prepend (imap_provider.authtypes, &camel_imap_password_authtype);
- camel_session_register_provider (session, &imap_provider);
+ camel_provider_register(&imap_provider);
}
static void
diff --git a/camel/providers/imapp/camel-imapp-provider.c b/camel/providers/imapp/camel-imapp-provider.c
index 6b0cdd2d43..bdf33ec1da 100644
--- a/camel/providers/imapp/camel-imapp-provider.c
+++ b/camel/providers/imapp/camel-imapp-provider.c
@@ -72,7 +72,7 @@ CamelServiceAuthType camel_imapp_password_authtype = {
};
void
-camel_imapp_module_init(CamelSession *session)
+camel_imapp_module_init(void)
{
extern void camel_exception_setup(void);
@@ -87,11 +87,11 @@ camel_imapp_module_init(CamelSession *session)
/* TEMPORARY */
camel_exception_setup();
- camel_session_register_provider(session, &imapp_provider);
+ camel_provider_register(&imapp_provider);
}
void
-camel_provider_module_init(CamelSession *session)
+camel_provider_module_init(void)
{
- camel_imapp_module_init(session);
+ camel_imapp_module_init();
}
diff --git a/camel/providers/local/camel-local-provider.c b/camel/providers/local/camel-local-provider.c
index fc33f34f58..27fae76695 100644
--- a/camel/providers/local/camel-local-provider.c
+++ b/camel/providers/local/camel-local-provider.c
@@ -189,7 +189,7 @@ local_url_equal(const void *v, const void *v2)
&& u1->port == u2->port;
}
-void camel_provider_module_init(CamelSession * session)
+void camel_provider_module_init(void)
{
char *path;
static int init = 0;
@@ -202,7 +202,7 @@ void camel_provider_module_init(CamelSession * session)
mh_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mh_store_get_type ();
mh_provider.url_hash = local_url_hash;
mh_provider.url_equal = local_url_equal;
- camel_session_register_provider(session, &mh_provider);
+ camel_provider_register(&mh_provider);
if (!(path = getenv ("MAIL")))
path = g_strdup_printf (SYSTEM_MAIL_DIR "/%s", g_get_user_name ());
@@ -210,18 +210,18 @@ void camel_provider_module_init(CamelSession * session)
mbox_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mbox_store_get_type ();
mbox_provider.url_hash = local_url_hash;
mbox_provider.url_equal = local_url_equal;
- camel_session_register_provider(session, &mbox_provider);
+ camel_provider_register(&mbox_provider);
spool_conf_entries[0].value = path; /* default path - same as mbox */
spool_provider.object_types[CAMEL_PROVIDER_STORE] = camel_spool_store_get_type ();
spool_provider.url_hash = local_url_hash;
spool_provider.url_equal = local_url_equal;
- camel_session_register_provider(session, &spool_provider);
+ camel_provider_register(&spool_provider);
- path = getenv ("MAILDIR");
+ path = getenv("MAILDIR");
maildir_conf_entries[0].value = path ? path : ""; /* default path */
maildir_provider.object_types[CAMEL_PROVIDER_STORE] = camel_maildir_store_get_type ();
maildir_provider.url_hash = local_url_hash;
maildir_provider.url_equal = local_url_equal;
- camel_session_register_provider(session, &maildir_provider);
+ camel_provider_register(&maildir_provider);
}
diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c
index 886c09983e..f2b4c1a24d 100644
--- a/camel/providers/nntp/camel-nntp-provider.c
+++ b/camel/providers/nntp/camel-nntp-provider.c
@@ -78,16 +78,15 @@ CamelServiceAuthType camel_nntp_password_authtype = {
};
void
-camel_provider_module_init (CamelSession *session)
+camel_provider_module_init(void)
{
- news_provider.object_types[CAMEL_PROVIDER_STORE] =
- camel_nntp_store_get_type();
+ news_provider.object_types[CAMEL_PROVIDER_STORE] = camel_nntp_store_get_type();
news_provider.url_hash = nntp_url_hash;
news_provider.url_equal = nntp_url_equal;
news_provider.authtypes = g_list_append (NULL, &camel_nntp_password_authtype);
- camel_session_register_provider (session, &news_provider);
+ camel_provider_register(&news_provider);
}
static void
diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c
index 1354470e69..7c3db155a7 100644
--- a/camel/providers/pop3/camel-pop3-provider.c
+++ b/camel/providers/pop3/camel-pop3-provider.c
@@ -89,7 +89,7 @@ CamelServiceAuthType camel_pop3_apop_authtype = {
};
void
-camel_provider_module_init (CamelSession *session)
+camel_provider_module_init(void)
{
CamelServiceAuthType *auth;
@@ -104,5 +104,5 @@ camel_provider_module_init (CamelSession *session)
pop3_provider.authtypes = g_list_prepend(pop3_provider.authtypes, &camel_pop3_apop_authtype);
pop3_provider.authtypes = g_list_prepend(pop3_provider.authtypes, &camel_pop3_password_authtype);
- camel_session_register_provider(session, &pop3_provider);
+ camel_provider_register(&pop3_provider);
}
diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c
index 9615dff1b4..36cbf88a77 100644
--- a/camel/providers/sendmail/camel-sendmail-provider.c
+++ b/camel/providers/sendmail/camel-sendmail-provider.c
@@ -48,15 +48,14 @@ static CamelProvider sendmail_provider = {
};
void
-camel_provider_module_init (CamelSession *session)
+camel_provider_module_init(void)
{
- sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
- camel_sendmail_transport_get_type();
+ sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_sendmail_transport_get_type();
sendmail_provider.url_hash = camel_url_hash;
sendmail_provider.url_equal = camel_url_equal;
- camel_session_register_provider (session, &sendmail_provider);
+ camel_provider_register(&sendmail_provider);
}
diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c
index 07991eb695..8658fb4e62 100644
--- a/camel/providers/smtp/camel-smtp-provider.c
+++ b/camel/providers/smtp/camel-smtp-provider.c
@@ -49,16 +49,15 @@ static CamelProvider smtp_provider = {
};
void
-camel_provider_module_init (CamelSession *session)
+camel_provider_module_init(void)
{
- smtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
- camel_smtp_transport_get_type ();
+ smtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_smtp_transport_get_type ();
smtp_provider.authtypes = g_list_append (camel_sasl_authtype_list (TRUE), camel_sasl_authtype ("LOGIN"));
smtp_provider.authtypes = g_list_append (smtp_provider.authtypes, camel_sasl_authtype ("POPB4SMTP"));
smtp_provider.url_hash = camel_url_hash;
smtp_provider.url_equal = camel_url_equal;
- camel_session_register_provider (session, &smtp_provider);
+ camel_provider_register(&smtp_provider);
}