diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 25 | ||||
-rw-r--r-- | camel/camel-provider.c | 250 | ||||
-rw-r--r-- | camel/camel-provider.h | 44 | ||||
-rw-r--r-- | camel/camel-session.c | 274 | ||||
-rw-r--r-- | camel/camel-session.h | 59 | ||||
-rw-r--r-- | camel/providers/mbox/Makefile.am | 3 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-provider.c | 29 | ||||
-rw-r--r-- | camel/providers/mbox/libcamelmbox.urls | 1 | ||||
-rw-r--r-- | camel/providers/nntp/Makefile.am | 3 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-provider.c | 46 | ||||
-rw-r--r-- | camel/providers/nntp/libcamelnntp.urls | 2 | ||||
-rw-r--r-- | camel/providers/pop3/Makefile.am | 3 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-provider.c | 29 | ||||
-rw-r--r-- | camel/providers/pop3/libcamelpop3.urls | 1 | ||||
-rw-r--r-- | camel/providers/sendmail/Makefile.am | 3 | ||||
-rw-r--r-- | camel/providers/sendmail/camel-sendmail-provider.c | 25 | ||||
-rw-r--r-- | camel/providers/sendmail/libcamelsendmail.urls | 1 | ||||
-rw-r--r-- | camel/providers/smtp/Makefile.am | 3 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-provider.c | 26 | ||||
-rw-r--r-- | camel/providers/smtp/libcamelsmtp.urls | 1 |
20 files changed, 329 insertions, 499 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 9a2deae312..6c28e6371c 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,28 @@ +2000-04-30 Dan Winship <danw@helixcode.com> + + * camel-provider.h: Tweak the definition of CamelProvider. Among + other things, a provider may now be both a store and a transport. + + * camel-provider.c: Remove a lot of code we had no intention of + using. This now only contains two functions: camel_provider_init + to read the installed .urls files, and camel_provider_load to + load and register a new provider. + + * camel-session.c: Remove more unused code and simplify some of + the remaining code. The list of available provider modules is now + stored in the session, and it handles calling camel_provider_load + to load them as needed. Provider registration is now done by + calling back from the module init routine, which allows a single + module to register providers for multiple URL types. + + * providers/*: Update provider structures and init routines for + the new stuff. Add a .urls file to each provider specifying what + urls it handles, and install that with the library. + + * providers/nntp/camel-nntp-provider.c: Add hints towards + supporting both news: and nntp: URLs, and using nntp as both a + store and a transport. + 2000-04-29 Dan Winship <danw@helixcode.com> * camel-internet-address.c (camel_internet_address_get): const diff --git a/camel/camel-provider.c b/camel/camel-provider.c index 52cfea60a1..83a51c3579 100644 --- a/camel/camel-provider.c +++ b/camel/camel-provider.c @@ -1,15 +1,16 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-provider.c : provider framework */ +/* camel-provider.c: provider framework */ -/* +/* * - * Author : + * Authors: * Bertrand Guiheneuf <bertrand@helixcode.com> + * Dan Winship <danw@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * @@ -25,177 +26,128 @@ */ -/* - 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-exception.h" +#include "hash-table-utils.h" #include <dirent.h> +#include <errno.h> +#include <stdio.h> #include <string.h> -static GList *_provider_list = NULL; +#include <gmodule.h> -static gint -_provider_name_cmp (gconstpointer a, gconstpointer b) -{ - CamelProvider *provider_a = CAMEL_PROVIDER (a); - CamelProvider *provider_b = CAMEL_PROVIDER (b); +char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES] = { + "store", + "transport" +}; - return strcmp ( provider_a->name, provider_b->name); -} - -void -camel_provider_register (CamelProvider *provider) +/** + * camel_provider_init: + * + * Initialize the Camel provider system by reading in the .urls + * files in the provider directory and creating a hash table mapping + * URLs to module names. + * + * 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 * +camel_provider_init (void) { - GList *old_provider_node = NULL; - - g_assert (provider); + GHashTable *providers; + DIR *dir; + struct dirent *d; + char *p, *name, buf[80]; + FILE *f; - if (_provider_list) - old_provider_node = g_list_find_custom (_provider_list, provider, _provider_name_cmp); + providers = g_hash_table_new (g_strcase_hash, g_strcase_equal); - if (old_provider_node != NULL) { - /* camel_provider_unref (CAMEL_PROVIDER (old_provider_node->data)); */ - old_provider_node->data = provider; - } else { - /* be careful, we use prepend here, so that last registered - providers come first */ - _provider_list = g_list_prepend (_provider_list, provider); + dir = opendir (CAMEL_PROVIDERDIR); + if (!dir) { + g_error ("Could not open camel provider directory: %s", + g_strerror (errno)); + return NULL; } - /* camel_provider_ref (provider); */ -} + while ((d = readdir (dir))) { + p = strchr (d->d_name, '.'); + if (!p || strcmp (p, ".urls") != 0) + continue; -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; - - g_return_val_if_fail (module_path, NULL); + name = g_strdup_printf ("%s/%s", CAMEL_PROVIDERDIR, d->d_name); + f = fopen (name, "r"); + if (!f) { + g_warning ("Could not read provider info file %s: %s", + name, g_strerror (errno)); + g_free (name); + continue; + } - if (!g_module_supported ()) { - g_warning ("CamelProvider::register_as_module: module " - "loading not supported on this system\n"); - return NULL; - } - + p = strrchr (name, '.'); + strcpy (p, ".so"); + while ((fgets (buf, sizeof (buf), f))) { + buf[sizeof (buf) - 1] = '\0'; + p = strchr (buf, '\n'); + if (p) + *p = '\0'; - new_module = g_module_open (module_path, 0); - if (!new_module) { - printf ("g_module_open reports: %s\n", g_module_error ()); - g_warning ("CamelProvider::register_as_module: Unable to " - "load module %s\n", module_path); - return NULL; - } - - has_module_init = g_module_symbol (new_module, "camel_provider_module_init", (gpointer *)&camel_provider_module_init); - if (!has_module_init){ - g_warning ("CamelProvider::register_as_module loading " - "of module %s failed,\n\tSymbol " - "camel_provider_module_init not defined in it\n", - module_path); - return NULL; + g_hash_table_insert (providers, g_strdup (buf), name); + } + fclose (f); } - new_provider = camel_provider_module_init(); - new_provider->gmodule = new_module; - camel_provider_register (new_provider); - - return new_provider; -} + closedir (dir); + return providers; +} /** - * camel_provider_scan: Scan for available providers and return a list. - * - * Note that this function will cause all providers in the providerdir - * to be loaded into memory. + * camel_provider_load: + * @session: the current session + * @path: the path to a shared library + * @ex: a CamelException * - * Return value: the list of CamelProviders. The caller must free this - * list when it is done with it. - **/ -GList * -camel_provider_scan (void) + * Loads the provider at @path, and calls its initialization function, + * passing @session as an argument. The provider should then register + * itself with @session. + **/ +void +camel_provider_load (CamelSession *session, const char *path, + CamelException *ex) { - DIR *dir; - struct dirent *dent; - char *p, *name; + GModule *module; + CamelProvider *(*camel_provider_module_init) (); - dir = opendir (CAMEL_PROVIDERDIR); - if (!dir) - return NULL; - while ((dent = readdir (dir))) { - p = strstr (dent->d_name, ".so"); - if (!p || strcmp (p, ".so") != 0) - continue; - - name = g_module_build_path (CAMEL_PROVIDERDIR, dent->d_name); - camel_provider_register_as_module (name); - g_free (name); + if (!g_module_supported ()) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not load %s: Module loading " + "not supported on this system.", + path); + return; } - closedir (dir); - return g_list_copy (_provider_list); -} - + module = g_module_open (path, 0); + if (!module) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not load %s: %s", + path, g_module_error ()); + return; + } -/** - * camel_provider_get_for_protocol: get a registered provider for a protocol - * @protocol: protocol name (case insensitive) - * @type: provider type (transport, store, ...) - * - * Look into the list of registered provider if - * one correspond both to the protocol name - * and to the protocol type. When several providers - * exist for a same protocol, the last registered - * is returned. - * - * Return value: Matching provider or NULL if none exists. - **/ -const CamelProvider * -camel_provider_get_for_protocol (const gchar *protocol, ProviderType type) -{ - CamelProvider *current_provider = NULL; - GList *current_provider_node; - gboolean protocol_is_found; - gboolean provider_is_found; - - g_assert (protocol); - g_return_val_if_fail (_provider_list, NULL); - - current_provider_node = _provider_list; - provider_is_found = FALSE; - - while ((!provider_is_found) && current_provider_node) { - current_provider = (CamelProvider *)current_provider_node->data; - - protocol_is_found = (g_strcasecmp (protocol, current_provider->protocol) == 0); - if (protocol_is_found) - provider_is_found = (current_provider->provider_type == type); - - current_provider_node = current_provider_node->next; - } + if (!g_module_symbol (module, "camel_provider_module_init", + (gpointer *)&camel_provider_module_init)) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Could not load %s: No initialization " + "routine in module.", path); + g_module_close (module); + return; + } - if (provider_is_found) return current_provider; - else return NULL; + camel_provider_module_init (session); } diff --git a/camel/camel-provider.h b/camel/camel-provider.h index d359ca90c8..cac6e9d6cc 100644 --- a/camel/camel-provider.h +++ b/camel/camel-provider.h @@ -1,15 +1,15 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* camel-provider.h : provider definition */ -/* +/* * - * Author : + * Author : * Bertrand Guiheneuf <bertrand@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * @@ -35,27 +35,26 @@ extern "C" { #endif /* __cplusplus }*/ #include <gtk/gtk.h> -#include <gmodule.h> +#include "camel-types.h" #define CAMEL_PROVIDER(obj) ((CamelProvider *)(obj)) typedef enum { - PROVIDER_STORE, - PROVIDER_TRANSPORT -} ProviderType; + CAMEL_PROVIDER_STORE, + CAMEL_PROVIDER_TRANSPORT, + CAMEL_NUM_PROVIDER_TYPES +} CamelProviderType; -#define PROVIDER_REMOTE 0x01 +extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES]; -typedef struct { - GtkType object_type; /* used to create instance of the provider */ - ProviderType provider_type; /* is a store or a transport */ - int flags; /* information about the provider */ +#define CAMEL_PROVIDER_IS_REMOTE (1 << 0) +typedef struct { /* Provider name used in CamelURLs. */ - gchar *protocol; + char *protocol; /* Provider name as used by people. (May be the same as protocol) */ - gchar *name; + char *name; /* Description of the provider. A novice user should be able * to read this description, and the information provided by @@ -63,16 +62,19 @@ typedef struct { * this provider is relevant to him, and if so, which * information goes with it. */ - gchar *description; + char *description; + + int flags; - GModule *gmodule; + GtkType object_types [CAMEL_NUM_PROVIDER_TYPES]; } CamelProvider; -void camel_provider_register (CamelProvider *provider); -const CamelProvider *camel_provider_register_as_module (const gchar *module_path); -const CamelProvider *camel_provider_get_for_protocol (const gchar *protocol, ProviderType type); -GList *camel_provider_scan (void); +GHashTable *camel_provider_init (void); +void camel_provider_load (CamelSession *session, const char *path, + CamelException *ex); +/* This is defined by each module, not by camel-provider.c. */ +void camel_provider_module_init (CamelSession *session); #ifdef __cplusplus } diff --git a/camel/camel-session.c b/camel/camel-session.c index 7b672c5c60..06a708b752 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -1,15 +1,16 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* camel-session.c : Abstract class for an email session */ -/* +/* * - * Author : + * Author: * Bertrand Guiheneuf <bertrand@helixcode.com> + * Dan Winship <danw@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * @@ -24,9 +25,6 @@ * USA */ - - - #include <config.h> #include "camel-session.h" #include "camel-store.h" @@ -36,59 +34,36 @@ #include "camel-url.h" #include "hash-table-utils.h" - - -static GtkObjectClass *parent_class=NULL; - - - -/* Returns the class for a CamelSession */ -#define CSS_CLASS(so) CAMEL_SESSION_CLASS (GTK_OBJECT(so)->klass) - - -static void -camel_session_class_init (CamelSessionClass *camel_session_class) -{ - parent_class = gtk_type_class (gtk_object_get_type ()); - - /* virtual method definition */ - /* virtual method overload */ -} - - - - - static void camel_session_init (CamelSession *session) { - session->store_provider_list = g_hash_table_new (g_strcase_hash, g_strcase_equal); - session->transport_provider_list = g_hash_table_new (g_strcase_hash, g_strcase_equal); + session->modules = camel_provider_init (); + session->providers = g_hash_table_new (g_strcase_hash, + g_strcase_equal); } - - GtkType camel_session_get_type (void) { static GtkType camel_session_type = 0; - - if (!camel_session_type) { - GtkTypeInfo camel_session_info = + + if (!camel_session_type) { + GtkTypeInfo camel_session_info = { "CamelSession", sizeof (CamelSession), sizeof (CamelSessionClass), - (GtkClassInitFunc) camel_session_class_init, + (GtkClassInitFunc) NULL, (GtkObjectInitFunc) camel_session_init, /* reserved_1 */ NULL, /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; - - camel_session_type = gtk_type_unique (gtk_object_get_type (), &camel_session_info); + + camel_session_type = gtk_type_unique (gtk_object_get_type (), + &camel_session_info); } - + return camel_session_type; } @@ -103,158 +78,67 @@ camel_session_new (CamelAuthCallback authenticator) } /** - * camel_session_set_provider: set the default provider for a protocol - * @session: session object for wich the provider will the default + * camel_session_register_provider: + * @session: a session object + * @protocol: the protocol the provider provides for * @provider: provider object - * - * Set the default implementation for a protocol. The protocol - * is determined by provider->protocol field (See CamelProvider). - * It overrides the default provider for this protocol. - * + * + * Registers a protocol to provider mapping for the session. **/ -void -camel_session_set_provider (CamelSession *session, CamelProvider *provider) +void +camel_session_register_provider (CamelSession *session, + CamelProvider *provider) { - GHashTable *table; + g_return_if_fail (CAMEL_IS_SESSION (session)); + g_return_if_fail (provider != NULL); - g_assert(session); - g_assert(provider); - - if (provider->provider_type == PROVIDER_STORE) - table = session->store_provider_list; - else - table = session->transport_provider_list; - - g_hash_table_insert (table, (gpointer)(provider->protocol), (gpointer)(provider)); - + g_hash_table_insert (session->providers, provider->protocol, provider); } - - - -/** - * camel_session_get_store_from_provider: create a folder instance for a given provider - * @session: session object the folder will be initialized with - * @provider: provider folder to instantiate - * @ex: a CamelException - * - * - * Return value: the newly instantiated store - **/ -CamelStore * -camel_session_get_store_from_provider (CamelSession *session, - CamelProvider *provider, - CamelException *ex) +CamelService * +camel_session_get_service (CamelSession *session, const char *url_string, + CamelProviderType type, CamelException *ex) { - g_assert(session); - g_assert(provider); - - return CAMEL_STORE (camel_service_new (provider->object_type, - session, NULL, ex)); -} - - + CamelURL *url; + const CamelProvider *provider; -/** - * get_store_for_protocol_with_url: private helper routine - * @session: CamelSession object - * @protocol: protocol name - * @url: a URL, or NULL - * @ex: a CamelException - * - * Used by camel_session_get_store_for_protocol and - * camel_session_get_store. - * - * Return value: initialized store associated with this protocol, or NULL if no provider was found. - **/ -static CamelStore * -get_store_for_protocol_with_url (CamelSession *session, const char *protocol, - CamelURL *url, CamelException *ex) -{ - const CamelProvider *provider = NULL; + url = camel_url_new (url_string, ex); + if (!url) + return NULL; - /* See if there is a provider assiciated with this - * protocol in this session. - */ - provider = CAMEL_PROVIDER (g_hash_table_lookup (session->store_provider_list, protocol)); + provider = g_hash_table_lookup (session->providers, url->protocol); if (!provider) { - /* No provider was found in this session. See - * if there is a registered provider for this - * protocol. - */ - provider = camel_provider_get_for_protocol (protocol, PROVIDER_STORE); + /* See if there's one we can load. */ + char *path; + + path = g_hash_table_lookup (session->modules, url->protocol); + if (path) { + camel_provider_load (session, path, ex); + if (camel_exception_get_id (ex) != + CAMEL_EXCEPTION_NONE) { + camel_url_free (url); + return NULL; + } + } + provider = g_hash_table_lookup (session->providers, + url->protocol); } - if (!provider) { + + if (!provider || !provider->object_types[type]) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, - "No provider available for protocol " - "`%s'", protocol); + "No %s available for protocol `%s'", + camel_provider_type_name[type], + url->protocol); + camel_url_free (url); return NULL; } - return CAMEL_STORE (camel_service_new (provider->object_type, - session, url, ex)); -} - - -/** - * camel_session_get_store_for_protocol: get the store associated to a protocol - * @session: CamelSession object - * @protocol: protocol name - * @ex: a CamelException - * - * Return a CamelStore object associated with a given - * store protocol. If a provider has been set for this - * protocol in the session @session using - * camel_session_set_provider (), then a store - * obtained from this provider is returned. - * Otherwise, if one or more providers corresponding - * to this protocol have been registered (See - * camel_provider_register_as_module), the last registered - * one is used. - * - * Return value: store associated with this protocol, or NULL if no provider was found. - **/ -CamelStore * -camel_session_get_store_for_protocol (CamelSession *session, - const char *protocol, - CamelException *ex) -{ - return get_store_for_protocol_with_url (session, protocol, NULL, ex); -} - - - -/** - * camel_session_get_store: get a store object for an URL - * @session: session object - * @url_string: url - * @ex: a CamelException - * - * return a store corresponding to an URL. - * - * Return value: the store, or NULL if no provider correponds to the protocol - **/ -CamelStore * -camel_session_get_store (CamelSession *session, const char *url_string, - CamelException *ex) -{ - CamelURL *url; - CamelStore *store; - - url = camel_url_new (url_string, ex); - if (!url) - return NULL; - - store = get_store_for_protocol_with_url (session, url->protocol, - url, ex); - if (store == NULL) - camel_url_free (url); - return store; + return camel_service_new (provider->object_types[type], session, + url, ex); } - /** * camel_session_query_authenticator: query the session authenticator * @session: session object @@ -286,45 +170,3 @@ camel_session_query_authenticator (CamelSession *session, char *prompt, { return session->authenticator (prompt, secret, service, item, ex); } - - - -/** - * camel_session_get_transport_for_protocol: get the transport for a protocol - * @session: the session - * @protocol: protocol name - * @ex: a CamelException - * - * Return a CamelTransport object associated with a given transport - * protocol. If a provider has been set for this protocol in the - * session @session using camel_session_set_provider (), then a transport - * obtained from this provider is returned. Otherwise, if one or more - * providers corresponding to this protocol have been registered (See - * camel_provider_register_as_module), the last registered one is - * used. - * - * Return value: transport associated with this protocol, or NULL if no provider was found. - **/ -CamelTransport * -camel_session_get_transport_for_protocol (CamelSession *session, - const char *protocol, - CamelException *ex) -{ - const CamelProvider *provider = NULL; - - /* See if there is a provider assiciated with this - * protocol in this session. - */ - provider = CAMEL_PROVIDER (g_hash_table_lookup (session->transport_provider_list, protocol)); - if (!provider) { - /* No provider was found in this session. See - * if there is a registered provider for this - * protocol. - */ - provider = camel_provider_get_for_protocol (protocol, PROVIDER_TRANSPORT); - } - if (!provider) - return NULL; - - return CAMEL_TRANSPORT (gtk_object_new (provider->object_type, NULL)); -} diff --git a/camel/camel-session.h b/camel/camel-session.h index 4bb51804ac..4eff6c94a3 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -1,15 +1,15 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* camel-session.h : Abstract class for an email session */ -/* +/* * - * Author : + * Author : * Bertrand Guiheneuf <bertrand@helixcode.com> * * Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com) * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * @@ -48,23 +48,17 @@ typedef char *(*CamelAuthCallback) (char *prompt, gboolean secret, CamelService *service, char *item, CamelException *ex); - struct _CamelSession { GtkObject parent_object; CamelAuthCallback authenticator; - GHashTable *store_provider_list; /* providers are identified by their protocol */ - GHashTable *transport_provider_list; + GHashTable *providers, *modules; }; - - typedef struct { GtkObjectClass parent_class; - - /* Virtual methods */ } CamelSessionClass; @@ -72,24 +66,31 @@ typedef struct { /* public methods */ /* Standard Gtk function */ -GtkType camel_session_get_type (void); - - -CamelSession * camel_session_new (CamelAuthCallback authenticator); -void camel_session_set_provider (CamelSession *session, CamelProvider *provider); -CamelStore * camel_session_get_store_for_protocol (CamelSession *session, - const gchar *protocol, - CamelException *ex); -CamelStore * camel_session_get_store (CamelSession *session, - const char *url_string, - CamelException *ex); -CamelTransport * camel_session_get_transport_for_protocol (CamelSession *session, - const char *protocol, - CamelException *ex); -char * camel_session_query_authenticator (CamelSession *session, char *prompt, - gboolean secret, - CamelService *service, char *item, - CamelException *ex); +GtkType camel_session_get_type (void); + + +CamelSession * camel_session_new (CamelAuthCallback + authenticator); + +void camel_session_register_provider (CamelSession *session, + CamelProvider *provider); + +CamelService * camel_session_get_service (CamelSession *session, + const char *url_string, + CamelProviderType type, + CamelException *ex); +#define camel_session_get_store(session, url_string, ex) \ + ((CamelStore *) camel_session_get_service (session, url_string, CAMEL_PROVIDER_STORE, ex)) +#define camel_session_get_transport(session, url_string, ex) \ + ((CamelTransport *) camel_session_get_service (session, url_string, CAMEL_PROVIDER_TRANSPORT, ex)) + + +char * camel_session_query_authenticator (CamelSession *session, + char *prompt, + gboolean secret, + CamelService *service, + char *item, + CamelException *ex); #ifdef __cplusplus } diff --git a/camel/providers/mbox/Makefile.am b/camel/providers/mbox/Makefile.am index 258c01a94e..25a26e25db 100644 --- a/camel/providers/mbox/Makefile.am +++ b/camel/providers/mbox/Makefile.am @@ -8,6 +8,7 @@ libcamelmboxincludedir = $(includedir)/camel providerdir = $(pkglibdir)/camel-providers/$(VERSION) provider_LTLIBRARIES = libcamelmbox.la +provider_DATA = libcamelmbox.urls INCLUDES = -I.. \ -I$(srcdir)/.. \ @@ -37,5 +38,5 @@ libcamelmbox_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) libcamelmbox_la_LIBADD = $(top_builddir)/e-util/libeutil.la $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS) #libcamelmbox_la_LIBADD = $(top_builddir)/libibex/libibex.la $(UNICODE_LIBS) -EXTRA_DIST = +EXTRA_DIST = libcamelmbox.urls diff --git a/camel/providers/mbox/camel-mbox-provider.c b/camel/providers/mbox/camel-mbox-provider.c index 74c4345306..04ce88de12 100644 --- a/camel/providers/mbox/camel-mbox-provider.c +++ b/camel/providers/mbox/camel-mbox-provider.c @@ -26,32 +26,25 @@ #include "config.h" #include "camel-mbox-store.h" #include "camel-provider.h" +#include "camel-session.h" - -static CamelProvider _mbox_provider = { - (GtkType) 0, - PROVIDER_STORE, - 0, - +static CamelProvider mbox_provider = { "mbox", "UNIX mbox-format mail files", "For reading mail delivered by the local system, and for " "storing mail on local disk.", - (GModule *) NULL -}; - -CamelProvider * -camel_provider_module_init (void); + 0, + { 0, 0 } +}; -CamelProvider * -camel_provider_module_init (void) +void +camel_provider_module_init (CamelSession *session) { - _mbox_provider.object_type = camel_mbox_store_get_type(); - return &_mbox_provider; -} - - + mbox_provider.object_types[CAMEL_PROVIDER_STORE] = + camel_mbox_store_get_type(); + camel_session_register_provider (session, &mbox_provider); +} diff --git a/camel/providers/mbox/libcamelmbox.urls b/camel/providers/mbox/libcamelmbox.urls new file mode 100644 index 0000000000..e021190356 --- /dev/null +++ b/camel/providers/mbox/libcamelmbox.urls @@ -0,0 +1 @@ +mbox diff --git a/camel/providers/nntp/Makefile.am b/camel/providers/nntp/Makefile.am index 2aabff29ef..ec393ea907 100644 --- a/camel/providers/nntp/Makefile.am +++ b/camel/providers/nntp/Makefile.am @@ -7,6 +7,7 @@ libcamelnntpincludedir = $(includedir)/camel providerdir = $(pkglibdir)/camel-providers/$(VERSION) provider_LTLIBRARIES = libcamelnntp.la +provider_DATA = libcamelnntp.urls INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ -I$(top_srcdir)/intl \ @@ -28,4 +29,4 @@ libcamelnntpinclude_HEADERS = \ libcamelnntp_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) -EXTRA_DIST = +EXTRA_DIST = libcamelnntp.urls diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c index 5ddda3f39d..449de945e6 100644 --- a/camel/providers/nntp/camel-nntp-provider.c +++ b/camel/providers/nntp/camel-nntp-provider.c @@ -26,27 +26,45 @@ #include "config.h" #include "camel-nntp-store.h" #include "camel-provider.h" +#include "camel-session.h" - -static CamelProvider _nntp_provider = { - (GtkType) 0, - PROVIDER_STORE, - PROVIDER_REMOTE, +static CamelProvider news_provider = { "news", - "Camel default NNTP provider", - "This is a provider that reads from a NNTP server.", - (GModule *) NULL + "USENET news", + + "This is a read-only provider for USENET newsgroups.", + + CAMEL_PROVIDER_IS_REMOTE, + + { 0, 0 } }; -CamelProvider * -camel_provider_module_init (void); +static CamelProvider nntp_provider = { + "nntp", + "USENET news via NNTP", + "This is a provider for reading from and posting to" + "USENET newsgroups.", -CamelProvider * -camel_provider_module_init (void) + CAMEL_PROVIDER_IS_REMOTE, + + { 0, 0 } +}; + +void +camel_provider_module_init (CamelSession *session) { - _nntp_provider.object_type = camel_nntp_store_get_type(); - return &_nntp_provider; + news_provider.object_types[CAMEL_PROVIDER_STORE] = + camel_nntp_store_get_type(); + nntp_provider.object_types[CAMEL_PROVIDER_STORE] = + camel_nntp_store_get_type(); +#ifdef NOTYET + nntp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = + camel_nntp_transport_get_type(); +#endif + + camel_session_register_provider (session", &news_provider); + camel_session_register_provider (session", &nntp_provider); } diff --git a/camel/providers/nntp/libcamelnntp.urls b/camel/providers/nntp/libcamelnntp.urls new file mode 100644 index 0000000000..dee2e70f14 --- /dev/null +++ b/camel/providers/nntp/libcamelnntp.urls @@ -0,0 +1,2 @@ +news +nntp diff --git a/camel/providers/pop3/Makefile.am b/camel/providers/pop3/Makefile.am index 202320b3f0..4775c866d1 100644 --- a/camel/providers/pop3/Makefile.am +++ b/camel/providers/pop3/Makefile.am @@ -7,6 +7,7 @@ libcamelpop3includedir = $(includedir)/camel providerdir = $(pkglibdir)/camel-providers/$(VERSION) provider_LTLIBRARIES = libcamelpop3.la +provider_DATA = libcamelpop3.urls INCLUDES = \ -I.. \ @@ -30,4 +31,4 @@ libcamelpop3include_HEADERS = \ libcamelpop3_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) -EXTRA_DIST = +EXTRA_DIST = libcamelpop3.urls diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c index 8d9d4ac94d..dc6e2b9442 100644 --- a/camel/providers/pop3/camel-pop3-provider.c +++ b/camel/providers/pop3/camel-pop3-provider.c @@ -26,13 +26,9 @@ #include "config.h" #include "camel-pop3-store.h" #include "camel-provider.h" +#include "camel-session.h" - -static CamelProvider _pop3_provider = { - (GtkType) 0, - PROVIDER_STORE, - PROVIDER_REMOTE, - +static CamelProvider pop3_provider = { "pop", "POP", @@ -40,19 +36,16 @@ static CamelProvider _pop3_provider = { "to retrieve mail from certain web mail providers and proprietary " "email systems.", - (GModule *) NULL -}; - -CamelProvider * -camel_provider_module_init (void); + CAMEL_PROVIDER_IS_REMOTE, + { 0, 0 } +}; -CamelProvider * -camel_provider_module_init (void) +void +camel_provider_module_init (CamelSession *session) { - _pop3_provider.object_type = camel_pop3_store_get_type(); - return &_pop3_provider; -} - - + pop3_provider.object_types[CAMEL_PROVIDER_STORE] = + camel_pop3_store_get_type(); + camel_session_register_provider (session, &pop3_provider); +} diff --git a/camel/providers/pop3/libcamelpop3.urls b/camel/providers/pop3/libcamelpop3.urls new file mode 100644 index 0000000000..7fffa4d861 --- /dev/null +++ b/camel/providers/pop3/libcamelpop3.urls @@ -0,0 +1 @@ +pop diff --git a/camel/providers/sendmail/Makefile.am b/camel/providers/sendmail/Makefile.am index 9c9c3f356b..0c12a6e23d 100644 --- a/camel/providers/sendmail/Makefile.am +++ b/camel/providers/sendmail/Makefile.am @@ -8,6 +8,7 @@ libcamelsendmailincludedir = $(includedir)/camel providerdir = $(pkglibdir)/camel-providers/$(VERSION) provider_LTLIBRARIES = libcamelsendmail.la +provider_DATA = libcamelsendmail.urls INCLUDES = \ -I.. \ @@ -26,4 +27,4 @@ libcamelsendmailinclude_HEADERS = \ libcamelsendmail_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) -EXTRA_DIST = +EXTRA_DIST = libcamelsendmail.urls diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c index 5d3809b6f0..16ebce8b12 100644 --- a/camel/providers/sendmail/camel-sendmail-provider.c +++ b/camel/providers/sendmail/camel-sendmail-provider.c @@ -26,30 +26,27 @@ #include "config.h" #include "camel-provider.h" #include "camel-sendmail-transport.h" +#include "camel-session.h" -static CamelProvider _sendmail_provider = { - (GtkType) 0, - PROVIDER_TRANSPORT, - 0, - +static CamelProvider sendmail_provider = { "sendmail", "Sendmail", "For delivering mail by passing it to the \"sendmail\" program " "on the local system.", - (GModule *) NULL -}; - -CamelProvider * -camel_provider_module_init (void); + 0, + { 0, 0 } +}; -CamelProvider * -camel_provider_module_init (void) +void +camel_provider_module_init (CamelSession *session) { - _sendmail_provider.object_type = camel_sendmail_transport_get_type(); - return &_sendmail_provider; + sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = + camel_sendmail_transport_get_type(); + + camel_session_register_provider (session, &sendmail_provider); } diff --git a/camel/providers/sendmail/libcamelsendmail.urls b/camel/providers/sendmail/libcamelsendmail.urls new file mode 100644 index 0000000000..ccad52828e --- /dev/null +++ b/camel/providers/sendmail/libcamelsendmail.urls @@ -0,0 +1 @@ +sendmail diff --git a/camel/providers/smtp/Makefile.am b/camel/providers/smtp/Makefile.am index dee3a50abb..8c49e8778b 100644 --- a/camel/providers/smtp/Makefile.am +++ b/camel/providers/smtp/Makefile.am @@ -7,6 +7,7 @@ libcamelsmtpincludedir = $(includedir)/camel providerdir = $(pkglibdir)/camel-providers/$(VERSION) provider_LTLIBRARIES = libcamelsmtp.la +provider_DATA = libcamelsmtp.urls INCLUDES = \ -I.. \ @@ -27,4 +28,4 @@ libcamelsmtpinclude_HEADERS = \ libcamelsmtp_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) -EXTRA_DIST = +EXTRA_DIST = libcamelsmtp.urls diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c index 03ef1a9eb3..44560ce34c 100644 --- a/camel/providers/smtp/camel-smtp-provider.c +++ b/camel/providers/smtp/camel-smtp-provider.c @@ -26,30 +26,26 @@ #include "config.h" #include "camel-smtp-transport.h" #include "camel-provider.h" +#include "camel-session.h" - -static CamelProvider _smtp_provider = { - (GtkType) 0, - PROVIDER_TRANSPORT, - 0, - +static CamelProvider smtp_provider = { "smtp", "SMTP", "For delivering mail by connecting to a remote mailhub using SMTP.", - (GModule *) NULL -}; - -CamelProvider * -camel_provider_module_init (void); + 0, + { 0, 0 } +}; -CamelProvider * -camel_provider_module_init (void) +void +camel_provider_module_init (CamelSession *session) { - _smtp_provider.object_type = camel_smtp_transport_get_type(); - return &_smtp_provider; + smtp_provider.object_types[CAMEL_TRANSPORT_TYPE] = + camel_smtp_transport_get_type(); + + camel_session_register_provider (session, &smtp_provider); } diff --git a/camel/providers/smtp/libcamelsmtp.urls b/camel/providers/smtp/libcamelsmtp.urls new file mode 100644 index 0000000000..ec2fc0fc16 --- /dev/null +++ b/camel/providers/smtp/libcamelsmtp.urls @@ -0,0 +1 @@ +smtp |