aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-session.c
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/camel-session.c
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/camel-session.c')
-rw-r--r--camel/camel-session.c244
1 files changed, 1 insertions, 243 deletions
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'"),