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
This commit is contained in:
@ -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>
|
2002-04-02 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
* camel-tcp-stream-ssl.c (set_errno): Handle a ton more nspr i/o
|
* camel-tcp-stream-ssl.c (set_errno): Handle a ton more nspr i/o
|
||||||
|
@ -103,6 +103,8 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES];
|
|||||||
#define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 12)
|
#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 */
|
/* Generic extra config stuff */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CAMEL_PROVIDER_CONF_END,
|
CAMEL_PROVIDER_CONF_END,
|
||||||
@ -148,12 +150,17 @@ typedef struct {
|
|||||||
/* Extra configuration information */
|
/* Extra configuration information */
|
||||||
CamelProviderConfEntry *extra_conf;
|
CamelProviderConfEntry *extra_conf;
|
||||||
|
|
||||||
|
/* 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];
|
CamelType object_types[CAMEL_NUM_PROVIDER_TYPES];
|
||||||
|
|
||||||
/* GList of CamelServiceAuthTypes the provider supports */
|
/* GList of CamelServiceAuthTypes the provider supports */
|
||||||
GList *authtypes;
|
GList *authtypes;
|
||||||
|
|
||||||
GHashTable *service_cache;
|
GHashTable *service_cache[CAMEL_NUM_PROVIDER_TYPES];
|
||||||
|
|
||||||
GHashFunc url_hash;
|
GHashFunc url_hash;
|
||||||
GCompareFunc url_equal;
|
GCompareFunc url_equal;
|
||||||
|
@ -105,9 +105,12 @@ static gboolean
|
|||||||
camel_session_destroy_provider (gpointer key, gpointer value, gpointer user_data)
|
camel_session_destroy_provider (gpointer key, gpointer value, gpointer user_data)
|
||||||
{
|
{
|
||||||
CamelProvider *prov = (CamelProvider *)value;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,13 +154,10 @@ camel_session_class_init (CamelSessionClass *camel_session_class)
|
|||||||
camel_session_class->thread_wait = session_thread_wait;
|
camel_session_class->thread_wait = session_thread_wait;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vee_provider.service_cache == NULL) {
|
|
||||||
vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
|
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_hash = camel_url_hash;
|
||||||
vee_provider.url_equal = camel_url_equal;
|
vee_provider.url_equal = camel_url_equal;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CamelType
|
CamelType
|
||||||
camel_session_get_type (void)
|
camel_session_get_type (void)
|
||||||
@ -201,6 +201,11 @@ register_provider (CamelSession *session, CamelProvider *provider)
|
|||||||
CamelProviderConfEntry *conf;
|
CamelProviderConfEntry *conf;
|
||||||
GList *l;
|
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 */
|
/* Translate all strings here */
|
||||||
provider->name = _(provider->name);
|
provider->name = _(provider->name);
|
||||||
provider->description = _(provider->description);
|
provider->description = _(provider->description);
|
||||||
@ -379,8 +384,8 @@ camel_session_get_provider (CamelSession *session, const char *url_string,
|
|||||||
static void
|
static void
|
||||||
service_cache_remove (CamelService *service, gpointer event_data, gpointer user_data)
|
service_cache_remove (CamelService *service, gpointer event_data, gpointer user_data)
|
||||||
{
|
{
|
||||||
CamelProvider *provider;
|
CamelSession *session = service->session;
|
||||||
CamelSession *session = CAMEL_SESSION (user_data);
|
CamelProviderType type = GPOINTER_TO_INT (user_data);
|
||||||
|
|
||||||
g_return_if_fail (CAMEL_IS_SESSION (session));
|
g_return_if_fail (CAMEL_IS_SESSION (session));
|
||||||
g_return_if_fail (service != NULL);
|
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);
|
CAMEL_SESSION_LOCK(session, lock);
|
||||||
|
|
||||||
provider = g_hash_table_lookup (session->providers, service->url->protocol);
|
g_hash_table_remove (service->provider->service_cache[type], service->url);
|
||||||
g_hash_table_remove (provider->service_cache, service->url);
|
|
||||||
|
|
||||||
CAMEL_SESSION_UNLOCK(session, lock);
|
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 */
|
/* 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) {
|
if (service != NULL) {
|
||||||
camel_url_free (url);
|
camel_url_free (url);
|
||||||
camel_object_ref (CAMEL_OBJECT (service));
|
camel_object_ref (CAMEL_OBJECT (service));
|
||||||
@ -437,8 +441,8 @@ get_service (CamelSession *session, const char *url_string,
|
|||||||
camel_object_unref (CAMEL_OBJECT (service));
|
camel_object_unref (CAMEL_OBJECT (service));
|
||||||
service = NULL;
|
service = NULL;
|
||||||
} else {
|
} else {
|
||||||
g_hash_table_insert (provider->service_cache, url, service);
|
g_hash_table_insert (provider->service_cache[type], url, service);
|
||||||
camel_object_hook_event (CAMEL_OBJECT (service), "finalize", (CamelObjectEventHookFunc) service_cache_remove, session);
|
camel_object_hook_event (CAMEL_OBJECT (service), "finalize", (CamelObjectEventHookFunc) service_cache_remove, GINT_TO_POINTER (type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
@ -91,7 +91,6 @@ camel_provider_module_init (CamelSession *session)
|
|||||||
{
|
{
|
||||||
imap_provider.object_types[CAMEL_PROVIDER_STORE] =
|
imap_provider.object_types[CAMEL_PROVIDER_STORE] =
|
||||||
camel_imap_store_get_type ();
|
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_hash = imap_url_hash;
|
||||||
imap_provider.url_equal = imap_url_equal;
|
imap_provider.url_equal = imap_url_equal;
|
||||||
imap_provider.authtypes = g_list_concat (camel_remote_store_authtype_list (),
|
imap_provider.authtypes = g_list_concat (camel_remote_store_authtype_list (),
|
||||||
|
@ -181,31 +181,26 @@ local_url_equal(const void *v, const void *v2)
|
|||||||
void camel_provider_module_init(CamelSession * session)
|
void camel_provider_module_init(CamelSession * session)
|
||||||
{
|
{
|
||||||
mh_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mh_store_get_type();
|
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_hash = local_url_hash;
|
||||||
mh_provider.url_equal = local_url_equal;
|
mh_provider.url_equal = local_url_equal;
|
||||||
camel_session_register_provider(session, &mh_provider);
|
camel_session_register_provider(session, &mh_provider);
|
||||||
|
|
||||||
mbox_provider.object_types[CAMEL_PROVIDER_STORE] = camel_mbox_store_get_type();
|
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_hash = local_url_hash;
|
||||||
mbox_provider.url_equal = local_url_equal;
|
mbox_provider.url_equal = local_url_equal;
|
||||||
camel_session_register_provider(session, &mbox_provider);
|
camel_session_register_provider(session, &mbox_provider);
|
||||||
|
|
||||||
maildir_provider.object_types[CAMEL_PROVIDER_STORE] = camel_maildir_store_get_type();
|
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_hash = local_url_hash;
|
||||||
maildir_provider.url_equal = local_url_equal;
|
maildir_provider.url_equal = local_url_equal;
|
||||||
camel_session_register_provider(session, &maildir_provider);
|
camel_session_register_provider(session, &maildir_provider);
|
||||||
|
|
||||||
spool_provider.object_types[CAMEL_PROVIDER_STORE] = camel_spool_store_get_type();
|
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_hash = local_url_hash;
|
||||||
spool_provider.url_equal = local_url_equal;
|
spool_provider.url_equal = local_url_equal;
|
||||||
camel_session_register_provider(session, &spool_provider);
|
camel_session_register_provider(session, &spool_provider);
|
||||||
|
|
||||||
spoold_provider.object_types[CAMEL_PROVIDER_STORE] = camel_spoold_store_get_type();
|
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_hash = local_url_hash;
|
||||||
spoold_provider.url_equal = local_url_equal;
|
spoold_provider.url_equal = local_url_equal;
|
||||||
camel_session_register_provider(session, &spoold_provider);
|
camel_session_register_provider(session, &spoold_provider);
|
||||||
|
@ -59,7 +59,6 @@ camel_provider_module_init (CamelSession *session)
|
|||||||
news_provider.object_types[CAMEL_PROVIDER_STORE] =
|
news_provider.object_types[CAMEL_PROVIDER_STORE] =
|
||||||
camel_nntp_store_get_type();
|
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_hash = nntp_url_hash;
|
||||||
news_provider.url_equal = nntp_url_equal;
|
news_provider.url_equal = nntp_url_equal;
|
||||||
|
|
||||||
|
@ -92,7 +92,6 @@ camel_provider_module_init (CamelSession *session)
|
|||||||
CamelServiceAuthType *auth;
|
CamelServiceAuthType *auth;
|
||||||
|
|
||||||
pop3_provider.object_types[CAMEL_PROVIDER_STORE] = camel_pop3_store_get_type();
|
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_hash = camel_url_hash;
|
||||||
pop3_provider.url_equal = camel_url_equal;
|
pop3_provider.url_equal = camel_url_equal;
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ camel_provider_module_init (CamelSession *session)
|
|||||||
sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
|
sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
|
||||||
camel_sendmail_transport_get_type();
|
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_hash = camel_url_hash;
|
||||||
sendmail_provider.url_equal = camel_url_equal;
|
sendmail_provider.url_equal = camel_url_equal;
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ camel_provider_module_init (CamelSession *session)
|
|||||||
camel_smtp_transport_get_type ();
|
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 (camel_sasl_authtype_list (TRUE), camel_sasl_authtype ("LOGIN"));
|
||||||
smtp_provider.authtypes = g_list_append (smtp_provider.authtypes, camel_sasl_authtype ("POPB4SMTP"));
|
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_hash = camel_url_hash;
|
||||||
smtp_provider.url_equal = camel_url_equal;
|
smtp_provider.url_equal = camel_url_equal;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user