diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-03-09 04:01:42 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-03-09 04:01:42 +0800 |
commit | e74803511e0c3fcdb4b50a24b519fb46f5de97fd (patch) | |
tree | 039f8a8ef5c84bde71189cc4eb80552b7c07c922 /camel | |
parent | 9618cd2cb63840bd9138519bc52a3afad07590fa (diff) | |
download | gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.tar gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.tar.gz gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.tar.bz2 gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.tar.lz gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.tar.xz gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.tar.zst gsoc2013-evolution-e74803511e0c3fcdb4b50a24b519fb46f5de97fd.zip |
These fixes make it so that the CamelStore does not actually hold a ref on
2001-03-08 Jeffrey Stedfast <fejj@ximian.com>
These fixes make it so that the CamelStore does not actually hold
a ref on it's vTrash folder. The vTrash folder is now created ONLY
when it is requested. This solves the problem of not being able to
unref a Store and have it disconnect/finalize like we expect it to.
* camel-store.c (init_trash): When we create the vtrash, add all
previously opened folders to it and hook on to the finalize event
so that we can then set the store->vtrash to NULL.
(get_trash): If a vtrash folder for the store doesn't exist,
init_trash() and then try.
(construct): No longer need this.
(camel_store_class_init): Don't override the construct method.
(camel_store_finalize): We no longer hold a ref on the vtrash so
don't unref it.
svn path=/trunk/; revision=8595
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-store.c | 65 |
2 files changed, 54 insertions, 27 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index eb82e302af..bda570f9bc 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,19 @@ +2001-03-08 Jeffrey Stedfast <fejj@ximian.com> + These fixes make it so that the CamelStore does not actually hold + a ref on it's vTrash folder. The vTrash folder is now created ONLY + when it is requested. This solves the problem of not being able to + unref a Store and have it disconnect/finalize like we expect it to. + + * camel-store.c (init_trash): When we create the vtrash, add all + previously opened folders to it and hook on to the finalize event + so that we can then set the store->vtrash to NULL. + (get_trash): If a vtrash folder for the store doesn't exist, + init_trash() and then try. + (construct): No longer need this. + (camel_store_class_init): Don't override the construct method. + (camel_store_finalize): We no longer hold a ref on the vtrash so + don't unref it. + 2001-03-07 Jeffrey Stedfast <fejj@ximian.com> * providers/pop3/camel-pop3-store.c (init_trash): Implement. diff --git a/camel/camel-store.c b/camel/camel-store.c index 19d4a53d5e..78cd66de93 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -42,10 +42,6 @@ static CamelServiceClass *parent_class = NULL; /* Returns the class for a CamelStore */ #define CS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) -static void construct (CamelService *service, CamelSession *session, - CamelProvider *provider, CamelURL *url, - CamelException *ex); - static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex); static CamelFolder *get_inbox (CamelStore *store, CamelException *ex); @@ -78,14 +74,10 @@ camel_store_class_init (CamelStoreClass *camel_store_class) { CamelObjectClass *camel_object_class = CAMEL_OBJECT_CLASS (camel_store_class); - CamelServiceClass *camel_service_class = - CAMEL_SERVICE_CLASS (camel_store_class); parent_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ())); /* virtual method definition */ - camel_service_class->construct = construct; - camel_store_class->hash_folder_name = g_str_hash; camel_store_class->compare_folder_name = g_str_equal; camel_store_class->get_folder = get_folder; @@ -131,19 +123,6 @@ camel_store_init (void *o) } static void -construct (CamelService *service, CamelSession *session, CamelProvider *provider, - CamelURL *url, CamelException *ex) -{ - CamelStoreClass *store_class; - - parent_class->construct (service, session, provider, url, ex); - - /* initialize the vTrash folder */ - store_class = (CamelStoreClass *) CAMEL_OBJECT_GET_CLASS (service); - store_class->init_trash (CAMEL_STORE (service)); -} - -static void camel_store_finalize (CamelObject *object) { CamelStore *store = CAMEL_STORE (object); @@ -157,9 +136,6 @@ camel_store_finalize (CamelObject *object) g_hash_table_destroy (store->folders); } - if (store->vtrash) - camel_object_unref (CAMEL_OBJECT (store->vtrash)); - #ifdef ENABLE_THREADS g_mutex_free (store->priv->folder_lock); g_mutex_free (store->priv->cache_lock); @@ -246,7 +222,7 @@ camel_store_get_folder (CamelStore *store, const char *folder_name, guint32 flag folder = CS_CLASS (store)->get_folder (store, folder_name, flags, ex); if (folder && store->folders) { CAMEL_STORE_LOCK(store, cache_lock); - + g_hash_table_insert (store->folders, g_strdup (folder_name), folder); /* Add the folder to the vTrash folder if this store implements it */ @@ -380,6 +356,23 @@ camel_store_get_inbox (CamelStore *store, CamelException *ex) static void +trash_add_folder (gpointer key, gpointer value, gpointer data) +{ + CamelFolder *folder = CAMEL_FOLDER (value); + CamelStore *store = CAMEL_STORE (data); + + camel_vee_folder_add_folder (CAMEL_VEE_FOLDER (store->vtrash), folder); +} + +static void +trash_finalize (CamelObject *trash, gpointer event_data, gpointer user_data) +{ + CamelStore *store = CAMEL_STORE (user_data); + + store->vtrash = NULL; +} + +static void init_trash (CamelStore *store) { char *name; @@ -390,6 +383,16 @@ init_trash (CamelStore *store) CAMEL_STORE_VEE_FOLDER_AUTO, NULL); g_free (name); + + if (store->vtrash) { + /* attach to the finalise event of the vtrash */ + camel_object_hook_event (CAMEL_OBJECT (store->vtrash), "finalize", + trash_finalize, store); + + /* add all the pre-opened folders to the vtrash */ + if (store->folders) + g_hash_table_foreach (store->folders, trash_add_folder, store); + } } @@ -400,8 +403,16 @@ get_trash (CamelStore *store, CamelException *ex) camel_object_ref (CAMEL_OBJECT (store->vtrash)); return store->vtrash; } else { - g_warning ("This store does not support vTrash."); - return NULL; + CS_CLASS (store)->init_trash (store); + if (store->vtrash) { + /* We don't ref here because we don't want the + store to own a ref on the trash folder */ + /*camel_object_ref (CAMEL_OBJECT (store->vtrash));*/ + return store->vtrash; + } else { + g_warning ("This store does not support vTrash."); + return NULL; + } } } |