diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-08-12 18:24:01 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-12 18:24:01 +0800 |
commit | f888058fc6e6db2309336426662023502a461d5a (patch) | |
tree | d414fa4a003e9c3746980396061f4b54b4b49419 /camel/camel-provider.c | |
parent | a478ee7e9d44ea7947b2dc51fcf5d7f09735ee52 (diff) | |
download | gsoc2013-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-provider.c')
-rw-r--r-- | camel/camel-provider.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/camel/camel-provider.c b/camel/camel-provider.c index 0018e262e0..98c43bd7ce 100644 --- a/camel/camel-provider.c +++ b/camel/camel-provider.c @@ -72,7 +72,9 @@ camel_provider_register (CamelProvider *provider) // camel_provider_unref (CAMEL_PROVIDER (old_provider_node->data)); old_provider_node->data = provider; } else { - _provider_list = g_list_append (_provider_list, provider); + /* be careful, we use prepend here, so that last registered + providers come first */ + _provider_list = g_list_prepend (_provider_list, provider); } // camel_provider_ref (provider); @@ -122,3 +124,60 @@ camel_provider_register_as_module (const gchar *module_path) } + + + + +/* + be careful to this function, @a is expected to be + a provider, @b a protocol name (const gchar *) +*/ +static gint +_provider_protocol_find (gconstpointer a, gconstpointer b) +{ + CamelProvider *provider_a = CAMEL_PROVIDER (a); + const gchar *name_b = (const gchar *)b; + + return g_strcasecmp ( provider_a->name, name_b); +} + +/** + * 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 providerss + * 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) +{ + GList *found_provider_node; + CamelProvider *found_provider = NULL; + + g_assert (protocol); + g_return_val_if_fail (_provider_list, NULL); + + /* we've got a compilation warning here because of bad prototype of + g_list_find_custom (), don't worry about that */ + do { + found_provider_node = g_list_find_custom (_provider_list, (gconstpointer)protocol, _provider_name_cmp); + /* we will get the last registered provider + here because providers are registered + using g_list_prepend(). This is a bit + dangerous however because we rely on + the way g_list_find_custom() is implemented. + This should be changed one day */ + if (found_provider_node) + found_provider = (CamelProvider*)found_provider_node->data; + else found_provider = NULL; + } + while (found_provider && (found_provider->provider_type != type)); + + return found_provider; +} |