aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-session.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-12 18:24:01 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-12 18:24:01 +0800
commitf888058fc6e6db2309336426662023502a461d5a (patch)
treed414fa4a003e9c3746980396061f4b54b4b49419 /camel/camel-session.c
parenta478ee7e9d44ea7947b2dc51fcf5d7f09735ee52 (diff)
downloadgsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.tar
gsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.tar.gz
gsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.tar.bz2
gsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.tar.lz
gsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.tar.xz
gsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.tar.zst
gsoc2013-evolution-f888058fc6e6db2309336426662023502a461d5a.zip
new function: returns a store for an URL.
1999-08-12 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-session.c (camel_session_get_store): new function: returns a store for an URL. (camel_session_get_store_for_protocol): new functionc: returns a store for a given store protocol (as IMAP/POP/MH ...) * camel/string-utils.c (g_strcase_equal): (g_strcase_hash): case insensitive hash table funcs. * camel/camel-session.c (camel_session_init): hash table keys are case insensitive. * camel/camel-provider.c (camel_provider_get_for_protocol): new function, returns the last registered provider for a protocol. svn path=/trunk/; revision=1106
Diffstat (limited to 'camel/camel-session.c')
-rw-r--r--camel/camel-session.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/camel/camel-session.c b/camel/camel-session.c
index fef670ece6..2c2d64ade6 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -22,6 +22,7 @@
*/
#include <config.h>
#include "camel-session.h"
+#include "string-utils.h"
static GtkObjectClass *parent_class=NULL;
@@ -45,8 +46,8 @@ camel_session_class_init (CamelSessionClass *camel_session_class)
static void
camel_session_init (CamelSession *session)
{
- session->store_provider_list = g_hash_table_new (g_str_hash, g_str_equal);
- session->transport_provider_list = g_hash_table_new (g_str_hash, g_str_equal);
+ 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);
}
@@ -129,3 +130,76 @@ camel_session_get_store_from_provider (CamelSession *session, CamelProvider *pro
camel_store_init(store, session, NULL);
return store;
}
+
+
+
+
+/**
+ * camel_session_get_store_for_protocol: get the store associated to a protocol
+ * @session: CamelSession object
+ * @protocol: protocol name
+ *
+ * Return a CamelStore object associated to 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 return.
+ * Otherwise, if one or more provider corresponding
+ * to this protocol has been registered (See
+ * camel_provider_register_as_module), the last registered
+ * one is used.
+ *
+ * Return value: store associated to this protocol or NULL if no provider was found.
+ **/
+CamelStore *
+camel_session_get_store_for_protocol (CamelSession *session, const gchar *protocol)
+{
+ CamelProvider *provider = NULL;
+ CamelStore *new_store;
+
+ /* look if there is a provider assiciated to this
+ protocol in this session */
+ provider = CAMEL_PROVIDER (g_hash_table_lookup (session->store_provider_list, protocol));
+ if (!provider)
+ /* no provider was found in this session, look
+ if there is a registered provider for this
+ protocol */
+ provider = camel_provider_get_for_protocol (protocol, PROVIDER_STORE);
+
+ if (!provider) return NULL;
+
+ new_store = (CamelStore *)gtk_type_new (provider->object_type);
+ return new_store;
+}
+
+
+
+
+/**
+ * camel_session_get_store: get a store object for an URL
+ * @session: session object
+ * @url_string: url
+ *
+ * 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 gchar *url_string)
+{
+ Gurl *url = NULL;
+ CamelStore *new_store = NULL;
+
+ url = g_url_new (url_string);
+ g_return_val_if_fail (url, NULL);
+
+ if (url->protocol) {
+ new_store = camel_session_get_store_for_protocol (session, url->protocol);
+ if (new_store)
+ camel_store_init (new_store, session, url_string);
+ }
+ g_url_free (url);
+
+ return new_store;
+
+}