diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-05-31 06:35:40 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-05-31 06:35:40 +0800 |
commit | 631dda8ae0829b1fb7b503348de541e3fe2027c5 (patch) | |
tree | b809428b7c6e01cf6bce0513b7ab20f436b0352a /camel/camel-session.c | |
parent | a9ddc24118d91139784cb0ce99789a739fdc5978 (diff) | |
download | gsoc2013-evolution-631dda8ae0829b1fb7b503348de541e3fe2027c5.tar.gz gsoc2013-evolution-631dda8ae0829b1fb7b503348de541e3fe2027c5.tar.zst gsoc2013-evolution-631dda8ae0829b1fb7b503348de541e3fe2027c5.zip |
Init filter_from to NULL, for exception case. (mbox_get_message_by_uid):
2000-05-30 Not Zed <NotZed@HelixCode.com>
* providers/mbox/camel-mbox-folder.c (mbox_append_message): Init
filter_from to NULL, for exception case.
(mbox_get_message_by_uid): Cast off_t to long int for diagnostics.
* camel-url.c (camel_url_hash): Hash funciton for using camel
url's as hash keys.
(camel_url_equal): equal function for same.
* camel-session.c (camel_session_finalise): Free cached services.
(camel_session_init): Init service cache.
(service_cache_remove): destroy callback to remove a service from
the cache.
* camel-store.c (get_folder_internal): Remove the extra ref of the
folder. That seems the right behaviour ...?
(camel_store_get_type): Doh, actually call store init, so the
cache works.
(cache_folder): strdup the folder name! no wonder it never found
it again.
svn path=/trunk/; revision=3298
Diffstat (limited to 'camel/camel-session.c')
-rw-r--r-- | camel/camel-session.c | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/camel/camel-session.c b/camel/camel-session.c index 55a466e404..17d7e60ee0 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -34,12 +34,43 @@ #include "camel-url.h" #include "hash-table-utils.h" +static CamelObjectClass *parent_class; + static void camel_session_init (CamelSession *session) { session->modules = camel_provider_init (); - session->providers = g_hash_table_new (g_strcase_hash, - g_strcase_equal); + session->providers = + g_hash_table_new (g_strcase_hash, g_strcase_equal); + session->service_cache = + g_hash_table_new (camel_url_hash, camel_url_equal); +} + +static void +hash_unref_service(void *key, void *value, void *data) +{ + gtk_object_unref((GtkObject *)value); +} + +static void +camel_session_finalise(GtkObject *o) +{ + CamelSession *session = (CamelSession *)o; + + g_hash_table_foreach(session->service_cache, hash_unref_service, 0); + g_hash_table_destroy(session->service_cache); + g_hash_table_destroy(session->providers); + + GTK_OBJECT_CLASS (parent_class)->finalize (o); +} + +static void +camel_session_class_init (CamelServiceClass *camel_service_class) +{ + GtkObjectClass *object_class = (GtkObjectClass *)camel_service_class; + + parent_class = gtk_type_class (camel_object_get_type ()); + object_class->finalize = camel_session_finalise; } GtkType @@ -53,7 +84,7 @@ camel_session_get_type (void) "CamelSession", sizeof (CamelSession), sizeof (CamelSessionClass), - (GtkClassInitFunc) NULL, + (GtkClassInitFunc) camel_session_class_init, (GtkObjectInitFunc) camel_session_init, /* reserved_1 */ NULL, /* reserved_2 */ NULL, @@ -157,6 +188,11 @@ camel_session_list_providers (CamelSession *session, gboolean load) return list; } +static void +service_cache_remove(CamelService *service, CamelSession *session) +{ + g_hash_table_remove(session->service_cache, service->url); +} CamelService * camel_session_get_service (CamelSession *session, const char *url_string, @@ -164,11 +200,23 @@ camel_session_get_service (CamelSession *session, const char *url_string, { CamelURL *url; const CamelProvider *provider; + CamelService *service; url = camel_url_new (url_string, ex); if (!url) return NULL; + /* lookup in cache first */ + printf("looking up service in cache: %s\n", url_string); + service = g_hash_table_lookup(session->service_cache, url); + if (service != NULL) { + printf("found!!\n"); + camel_url_free(url); + gtk_object_ref((GtkObject *)service); + return service; + } + printf("not found, creating service\n"); + provider = g_hash_table_lookup (session->providers, url->protocol); if (!provider) { /* See if there's one we can load. */ @@ -196,8 +244,12 @@ camel_session_get_service (CamelSession *session, const char *url_string, return NULL; } - return camel_service_new (provider->object_types[type], session, - url, ex); + service = camel_service_new (provider->object_types[type], session, url, ex); + if (service) { + g_hash_table_insert(session->service_cache, url, service); + gtk_signal_connect((GtkObject *)service, "destroy", service_cache_remove, session); + } + return service; } |