aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2002-04-04 02:18:31 +0800
committerDan Winship <danw@src.gnome.org>2002-04-04 02:18:31 +0800
commitdf281e27199559d0166142ef78c01d7a38d60964 (patch)
treebcc2c33128259bc537e3611ac82aca2f28c513a4
parente9a1f5121d164292990f5cec0ef73efd4ddf0ed5 (diff)
downloadgsoc2013-evolution-df281e27199559d0166142ef78c01d7a38d60964.tar.gz
gsoc2013-evolution-df281e27199559d0166142ef78c01d7a38d60964.tar.zst
gsoc2013-evolution-df281e27199559d0166142ef78c01d7a38d60964.zip
make service_cache be an array of CAMEL_NUM_PROVIDER_TYPES elements so you
* camel-provider.h (CamelProvider): make service_cache be an array of CAMEL_NUM_PROVIDER_TYPES elements so you can have a single provider offer both stores and transports. (Eg, Exchange, NNTP) * providers/imap/camel-imap-provider.c: Don't initialize service_cache here. (The session code can do it itself since the url_hash and url_equal functions are stored as part of the provider.) * providers/nntp/camel-nntp-provider.c: Likewise. * providers/local/camel-local-provider.c: Likewise. * providers/pop3/camel-pop3-provider.c: Likewise. * providers/sendmail/camel-sendmail-provider.c: Likewise. * providers/smtp/camel-smtp-provider.c: Likewise. * camel-session.c (register_provider): Initialize the provider's service cache(s) here. (camel_session_class_init): Don't initialize. vee_provider.service_cache here. (camel_session_destroy_provider): Update to destroy multiple service_caches. (service_cache_remove, get_service): Tweak these a bit to deal with multiple service_caches. svn path=/trunk/; revision=16330
-rw-r--r--camel/ChangeLog30
-rw-r--r--camel/camel-provider.h11
-rw-r--r--camel/camel-session.c34
-rw-r--r--camel/providers/imap/camel-imap-provider.c1
-rw-r--r--camel/providers/local/camel-local-provider.c5
-rw-r--r--camel/providers/nntp/camel-nntp-provider.c1
-rw-r--r--camel/providers/pop3/camel-pop3-provider.c1
-rw-r--r--camel/providers/sendmail/camel-sendmail-provider.c1
-rw-r--r--camel/providers/smtp/camel-smtp-provider.c1
9 files changed, 58 insertions, 27 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index bb5ce59581..6dd0ee9b3b 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,33 @@
+2002-04-03 Dan Winship <danw@ximian.com>
+
+ * camel-provider.h (CamelProvider): make service_cache be an array
+ of CAMEL_NUM_PROVIDER_TYPES elements so you can have a single
+ provider offer both stores and transports. (Eg, Exchange, NNTP)
+
+ * providers/imap/camel-imap-provider.c: Don't initialize
+ service_cache here. (The session code can do it itself since the
+ url_hash and url_equal functions are stored as part of the
+ provider.)
+
+ * providers/nntp/camel-nntp-provider.c: Likewise.
+
+ * providers/local/camel-local-provider.c: Likewise.
+
+ * providers/pop3/camel-pop3-provider.c: Likewise.
+
+ * providers/sendmail/camel-sendmail-provider.c: Likewise.
+
+ * providers/smtp/camel-smtp-provider.c: Likewise.
+
+ * camel-session.c (register_provider): Initialize the provider's
+ service cache(s) here.
+ (camel_session_class_init): Don't initialize.
+ vee_provider.service_cache here.
+ (camel_session_destroy_provider): Update to destroy multiple
+ service_caches.
+ (service_cache_remove, get_service): Tweak these a bit to deal
+ with multiple service_caches.
+
2002-04-02 Jeffrey Stedfast <fejj@ximian.com>
* camel-tcp-stream-ssl.c (set_errno): Handle a ton more nspr i/o
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 9269745786..ae6016abcf 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -103,6 +103,8 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES];
#define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 12)
+#define CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT(prov) (prov->object_types[CAMEL_PROVIDER_STORE] && prov->object_types[CAMEL_PROVIDER_TRANSPORT])
+
/* Generic extra config stuff */
typedef enum {
CAMEL_PROVIDER_CONF_END,
@@ -148,12 +150,17 @@ typedef struct {
/* Extra configuration information */
CamelProviderConfEntry *extra_conf;
- CamelType object_types [CAMEL_NUM_PROVIDER_TYPES];
+ /* CamelType(s) of its store and/or transport. If both are
+ * set, then they are assumed to be linked together and the
+ * transport type can only be used in an account that also
+ * uses the store type (eg, Exchange or NNTP).
+ */
+ CamelType object_types[CAMEL_NUM_PROVIDER_TYPES];
/* GList of CamelServiceAuthTypes the provider supports */
GList *authtypes;
- GHashTable *service_cache;
+ GHashTable *service_cache[CAMEL_NUM_PROVIDER_TYPES];
GHashFunc url_hash;
GCompareFunc url_equal;
diff --git a/camel/camel-session.c b/camel/camel-session.c
index e8240db509..4e74c1bd9e 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -105,9 +105,12 @@ static gboolean
camel_session_destroy_provider (gpointer key, gpointer value, gpointer user_data)
{
CamelProvider *prov = (CamelProvider *)value;
+ int i;
- g_hash_table_destroy (prov->service_cache);
-
+ for (i = 0; i < CAMEL_NUM_PROVIDER_TYPES; i++) {
+ if (prov->service_cache[i])
+ g_hash_table_destroy (prov->service_cache[i]);
+ }
return TRUE;
}
@@ -151,12 +154,9 @@ camel_session_class_init (CamelSessionClass *camel_session_class)
camel_session_class->thread_wait = session_thread_wait;
#endif
- if (vee_provider.service_cache == NULL) {
- vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
- vee_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
- vee_provider.url_hash = camel_url_hash;
- vee_provider.url_equal = camel_url_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;
}
CamelType
@@ -201,6 +201,11 @@ register_provider (CamelSession *session, CamelProvider *provider)
CamelProviderConfEntry *conf;
GList *l;
+ for (i = 0; i < CAMEL_NUM_PROVIDER_TYPES; i++) {
+ if (provider->object_types[i])
+ provider->service_cache[i] = g_hash_table_new (provider->url_hash, provider->url_equal);
+ }
+
/* Translate all strings here */
provider->name = _(provider->name);
provider->description = _(provider->description);
@@ -379,8 +384,8 @@ camel_session_get_provider (CamelSession *session, const char *url_string,
static void
service_cache_remove (CamelService *service, gpointer event_data, gpointer user_data)
{
- CamelProvider *provider;
- CamelSession *session = CAMEL_SESSION (user_data);
+ CamelSession *session = service->session;
+ CamelProviderType type = GPOINTER_TO_INT (user_data);
g_return_if_fail (CAMEL_IS_SESSION (session));
g_return_if_fail (service != NULL);
@@ -388,8 +393,7 @@ service_cache_remove (CamelService *service, gpointer event_data, gpointer user_
CAMEL_SESSION_LOCK(session, lock);
- provider = g_hash_table_lookup (session->providers, service->url->protocol);
- g_hash_table_remove (provider->service_cache, service->url);
+ g_hash_table_remove (service->provider->service_cache[type], service->url);
CAMEL_SESSION_UNLOCK(session, lock);
}
@@ -422,7 +426,7 @@ get_service (CamelSession *session, const char *url_string,
}
/* Now look up the service in the provider's cache */
- service = g_hash_table_lookup (provider->service_cache, url);
+ service = g_hash_table_lookup (provider->service_cache[type], url);
if (service != NULL) {
camel_url_free (url);
camel_object_ref (CAMEL_OBJECT (service));
@@ -437,8 +441,8 @@ get_service (CamelSession *session, const char *url_string,
camel_object_unref (CAMEL_OBJECT (service));
service = NULL;
} else {
- g_hash_table_insert (provider->service_cache, url, service);
- camel_object_hook_event (CAMEL_OBJECT (service), "finalize", (CamelObjectEventHookFunc) service_cache_remove, session);
+ g_hash_table_insert (provider->service_cache[type], url, service);
+ camel_object_hook_event (CAMEL_OBJECT (service), "finalize", (CamelObjectEventHookFunc) service_cache_remove, GINT_TO_POINTER (type));
}
return service;
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index 35b27f20f4..305dbab443 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -91,7 +91,6 @@ camel_provider_module_init (CamelSession *session)
{
imap_provider.object_types[CAMEL_PROVIDER_STORE] =
camel_imap_store_get_type ();
- imap_provider.service_cache = g_hash_table_new (imap_url_hash, imap_url_equal);
imap_provider.url_hash = imap_url_hash;
imap_provider.url_equal = imap_url_equal;
imap_provider.authtypes = g_list_concat (camel_remote_store_authtype_list (),
diff --git a/camel/providers/local/camel-local-provider.c b/camel/providers/local/camel-local-provider.c
index 17c3576ae2..ba765ff20c 100644
--- a/camel/providers/local/camel-local-provider.c
+++ b/camel/providers/local/camel-local-provider.c
@@ -181,31 +181,26 @@ local_url_equal(const void *v, const void *v2)
void camel_provider_module_init(CamelSession * session)
{
mh_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mh_store_get_type();
- mh_provider.service_cache = g_hash_table_new(local_url_hash, local_url_equal);
mh_provider.url_hash = local_url_hash;
mh_provider.url_equal = local_url_equal;
camel_session_register_provider(session, &mh_provider);
mbox_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mbox_store_get_type();
- mbox_provider.service_cache = g_hash_table_new(local_url_hash, local_url_equal);
mbox_provider.url_hash = local_url_hash;
mbox_provider.url_equal = local_url_equal;
camel_session_register_provider(session, &mbox_provider);
maildir_provider.object_types[CAMEL_PROVIDER_STORE] = camel_maildir_store_get_type();
- maildir_provider.service_cache = g_hash_table_new(local_url_hash, local_url_equal);
maildir_provider.url_hash = local_url_hash;
maildir_provider.url_equal = local_url_equal;
camel_session_register_provider(session, &maildir_provider);
spool_provider.object_types[CAMEL_PROVIDER_STORE] = camel_spool_store_get_type();
- spool_provider.service_cache = g_hash_table_new(local_url_hash, local_url_equal);
spool_provider.url_hash = local_url_hash;
spool_provider.url_equal = local_url_equal;
camel_session_register_provider(session, &spool_provider);
spoold_provider.object_types[CAMEL_PROVIDER_STORE] = camel_spoold_store_get_type();
- spoold_provider.service_cache = g_hash_table_new(local_url_hash, local_url_equal);
spoold_provider.url_hash = local_url_hash;
spoold_provider.url_equal = local_url_equal;
camel_session_register_provider(session, &spoold_provider);
diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c
index 773e3d7e0e..c38b794504 100644
--- a/camel/providers/nntp/camel-nntp-provider.c
+++ b/camel/providers/nntp/camel-nntp-provider.c
@@ -59,7 +59,6 @@ camel_provider_module_init (CamelSession *session)
news_provider.object_types[CAMEL_PROVIDER_STORE] =
camel_nntp_store_get_type();
- news_provider.service_cache = g_hash_table_new (nntp_url_hash, nntp_url_equal);
news_provider.url_hash = nntp_url_hash;
news_provider.url_equal = nntp_url_equal;
diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c
index f68784fbd1..f01cf74253 100644
--- a/camel/providers/pop3/camel-pop3-provider.c
+++ b/camel/providers/pop3/camel-pop3-provider.c
@@ -92,7 +92,6 @@ camel_provider_module_init (CamelSession *session)
CamelServiceAuthType *auth;
pop3_provider.object_types[CAMEL_PROVIDER_STORE] = camel_pop3_store_get_type();
- pop3_provider.service_cache = g_hash_table_new(camel_url_hash, camel_url_equal);
pop3_provider.url_hash = camel_url_hash;
pop3_provider.url_equal = camel_url_equal;
diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c
index 4d546a081d..9615dff1b4 100644
--- a/camel/providers/sendmail/camel-sendmail-provider.c
+++ b/camel/providers/sendmail/camel-sendmail-provider.c
@@ -53,7 +53,6 @@ camel_provider_module_init (CamelSession *session)
sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
camel_sendmail_transport_get_type();
- sendmail_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
sendmail_provider.url_hash = camel_url_hash;
sendmail_provider.url_equal = camel_url_equal;
diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c
index 48e9bcc6d1..07991eb695 100644
--- a/camel/providers/smtp/camel-smtp-provider.c
+++ b/camel/providers/smtp/camel-smtp-provider.c
@@ -55,7 +55,6 @@ camel_provider_module_init (CamelSession *session)
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.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
smtp_provider.url_hash = camel_url_hash;
smtp_provider.url_equal = camel_url_equal;