aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-folder-cache.c
diff options
context:
space:
mode:
authorMichael Zucci <zucchi@src.gnome.org>2001-10-17 03:13:31 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-17 03:13:31 +0800
commit8c85ed61ba64bd548460543dd87445b9a21dbf6a (patch)
tree76d2bc77eb83263b4d5b4122bf47127a1666214b /mail/mail-folder-cache.c
parente1d0f3dc45692a04dbd93c7ef82c24af74e05f25 (diff)
downloadgsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.gz
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.tar.zst
gsoc2013-evolution-8c85ed61ba64bd548460543dd87445b9a21dbf6a.zip
Added an async_event handler to store_info. (mail_note_store): Setup async
* mail-folder-cache.c: Added an async_event handler to store_info. (mail_note_store): Setup async event handler here. (store_finalised): Flush out async events here. (folder_changed): Use async event handler to emit event. (mail_note_folder): Chagned, do most of the work in the calling context, only do the corba stuff in main. (store_folder_subscribed): Use async event, and do more work locally. (store_folder_unsubscribed): Same. (store_folder_deleted): Call store_folder_unsubscribed if we have to do any work. (store_folder_created): Call store_folder_subscribed if we have to do any work. (store_folder_unsubscribed): Ref store while busy. (real_folder_deleted): And unref here. (store_folder_subscribed): Reg store while busy. (real_folder_created): Unref here. (mail_note_folder): Ref folder while busy. (real_note_folder): And unref here. (mail_note_folder): Hook onto folder_deleted event. (folder_deleted): Just mark this folder as no longer available. * mail-session.c (register_timeout): Use mail_call_main instead of proxy_event. (remove_timeout): Same here. * folder-browser.c (folder_changed): use the new mail_async_event stuff. (folder_changed_main): Remove old async event handling stuff. (FOLDER_BROWSER_LOCK/UNLOCK): Removed. (FolderBrowserPrivate): Removed too, sigh. * mail-mt.c (mail_async_event_new, mail_async_event_emit, mail_async_event_destroy): New functions to handle async events. (mail_proxy_event, mail_proxy_event_id): Removed old functions for async events. (do_call): Add suport for MAIL_CALL_p_pp. (mail_msg_free): Use mail_async_event instead of proxy_event. * message-list.c (message_changed): Promote the message_changed to a folder_changed and use main_folder_changed to process it. (main_message_changed): Remove.d (message_list_init): Setup async event handler. (message_list_destroy): Remove async handler. (folder_changed): Use async hanler to emit event in main loop. (message_changed): Same. svn path=/trunk/; revision=13698
Diffstat (limited to 'mail/mail-folder-cache.c')
-rw-r--r--mail/mail-folder-cache.c108
1 files changed, 68 insertions, 40 deletions
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index b1bf92bee0..ccff8f7555 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -70,6 +70,7 @@ struct _store_info {
/* only 1 should be set */
EvolutionStorage *storage;
GNOME_Evolution_Storage corba_storage;
+ MailAsyncEvent *async_event;
};
static GHashTable *stores;
@@ -195,9 +196,8 @@ folder_changed(CamelObject *o, gpointer event_data, gpointer user_data)
return;
d(printf("Fodler changed!\n"));
- /* hopefully our mfi isn't lost while this is executing ... */
camel_object_ref((CamelObject *)o);
- mail_proxy_event((CamelObjectEventHookFunc)real_folder_changed, o, NULL, mfi);
+ mail_async_event_emit(mfi->store_info->async_event, (CamelObjectEventHookFunc)real_folder_changed, o, NULL, mfi);
}
static void
@@ -210,74 +210,90 @@ folder_finalised(CamelObject *o, gpointer event_data, gpointer user_data)
}
static void
+folder_deleted(CamelObject *o, gpointer event_data, gpointer user_data)
+{
+ struct _folder_info *mfi = user_data;
+
+ (printf("Folder deleted '%s'!\n", ((CamelFolder *)o)->full_name));
+ mfi->folder = NULL;
+}
+
+static void
real_note_folder(CamelFolder *folder, void *event_data, void *data)
{
+ struct _folder_info *mfi = event_data;
+
+ update_1folder(mfi, NULL);
+ camel_object_unref((CamelObject *)folder);
+}
+
+void mail_note_folder(CamelFolder *folder)
+{
CamelStore *store = folder->parent_store;
struct _store_info *si;
struct _folder_info *mfi;
+ if (stores == NULL) {
+ g_warning("Adding a folder `%s' to a store which hasn't been added yet?\n", folder->full_name);
+ return;
+ }
+
LOCK(info_lock);
si = g_hash_table_lookup(stores, store);
- UNLOCK(info_lock);
if (si == NULL) {
g_warning("Adding a folder `%s' to a store %p which hasn't been added yet?\n", folder->full_name, store);
- camel_object_unref((CamelObject *)folder);
+ UNLOCK(info_lock);
return;
}
- LOCK(info_lock);
mfi = g_hash_table_lookup(si->folders, folder->full_name);
- UNLOCK(info_lock);
-
if (mfi == NULL) {
g_warning("Adding a folder `%s' that I dont know about yet?", folder->full_name);
- camel_object_unref((CamelObject *)folder);
+ UNLOCK(info_lock);
return;
}
/* dont do anything if we already have this */
if (mfi->folder == folder) {
- camel_object_unref (CAMEL_OBJECT (folder));
+ UNLOCK(info_lock);
return;
}
mfi->folder = folder;
- update_1folder(mfi, NULL);
camel_object_hook_event((CamelObject *)folder, "folder_changed", folder_changed, mfi);
camel_object_hook_event((CamelObject *)folder, "message_changed", folder_changed, mfi);
+ camel_object_hook_event((CamelObject *)folder, "deleted", folder_deleted, mfi);
camel_object_hook_event((CamelObject *)folder, "finalize", folder_finalised, mfi);
- camel_object_unref((CamelObject *)folder);
+ camel_object_ref((CamelObject *)folder);
+
+ UNLOCK(info_lock);
+
+ mail_async_event_emit(si->async_event, (CamelObjectEventHookFunc)real_note_folder, (CamelObject *)folder, (void *)mfi, NULL);
}
-void mail_note_folder(CamelFolder *folder)
+static void
+real_folder_created(CamelStore *store, struct _store_info *si, CamelFolderInfo *fi)
{
- if (stores == NULL) {
- g_warning("Adding a folder `%s' to a store which hasn't been added yet?\n", folder->full_name);
- return;
- }
-
- camel_object_ref((CamelObject *)folder);
- mail_proxy_event((CamelObjectEventHookFunc)real_note_folder, (CamelObject *)folder, NULL, NULL);
+ setup_folder(fi, si);
+ camel_object_unref((CamelObject *)store);
}
static void
-real_folder_created(CamelStore *store, void *event_data, CamelFolderInfo *fi)
+store_folder_subscribed(CamelObject *o, void *event_data, void *data)
{
struct _store_info *si;
- d(printf("real_folder_created: %s (%s)\n", fi->full_name, fi->url));
-
LOCK(info_lock);
- si = g_hash_table_lookup(stores, store);
+ si = g_hash_table_lookup(stores, o);
+ if (si)
+ camel_object_ref(o);
UNLOCK(info_lock);
+
if (si)
- setup_folder(fi, si);
- else
- /* leaks, so what */
- g_warning("real_folder_created: can't find store: %s\n",
- camel_url_to_string(((CamelService *)store)->url, 0));
+ mail_async_event_emit(si->async_event,
+ (CamelObjectEventHookFunc)real_folder_created, o, si, event_data);
}
static void
@@ -285,14 +301,9 @@ store_folder_created(CamelObject *o, void *event_data, void *data)
{
/* we only want created events to do more work if we dont support subscriptions */
if (!camel_store_supports_subscriptions(CAMEL_STORE(o)))
- mail_msg_wait(mail_proxy_event((CamelObjectEventHookFunc)real_folder_created, o, NULL, event_data));
+ store_folder_subscribed(o, event_data, data);
}
-static void
-store_folder_subscribed(CamelObject *o, void *event_data, void *data)
-{
- mail_msg_wait(mail_proxy_event((CamelObjectEventHookFunc)real_folder_created, o, NULL, event_data));
-}
static void
real_folder_deleted(CamelStore *store, void *event_data, CamelFolderInfo *fi)
@@ -301,22 +312,35 @@ real_folder_deleted(CamelStore *store, void *event_data, CamelFolderInfo *fi)
if (strstr(fi->url, ";noselect") == NULL)
mail_vfolder_remove_uri(store, fi->url);
+
+ camel_object_unref((CamelObject *)store);
}
static void
-store_folder_deleted(CamelObject *o, void *event_data, void *data)
+store_folder_unsubscribed(CamelObject *o, void *event_data, void *data)
{
- /* we only want deleted events to do more work if we dont support subscriptions */
- if (!camel_store_supports_subscriptions(CAMEL_STORE(o)))
- mail_msg_wait(mail_proxy_event((CamelObjectEventHookFunc)real_folder_deleted, o, NULL, event_data));
+ struct _store_info *si;
+
+ LOCK(info_lock);
+ si = g_hash_table_lookup(stores, o);
+ if (si)
+ camel_object_ref(o);
+ UNLOCK(info_lock);
+
+ if (si)
+ mail_async_event_emit(si->async_event,
+ (CamelObjectEventHookFunc)real_folder_deleted, o, si, event_data);
}
static void
-store_folder_unsubscribed(CamelObject *o, void *event_data, void *data)
+store_folder_deleted(CamelObject *o, void *event_data, void *data)
{
- mail_msg_wait(mail_proxy_event((CamelObjectEventHookFunc)real_folder_deleted, o, NULL, event_data));
+ /* we only want deleted events to do more work if we dont support subscriptions */
+ if (!camel_store_supports_subscriptions(CAMEL_STORE(o)))
+ store_folder_unsubscribed(o, event_data, data);
}
+
static void
free_folder_info(char *path, struct _folder_info *info, void *data)
{
@@ -336,6 +360,9 @@ store_finalised(CamelObject *o, void *event_data, void *data)
si = g_hash_table_lookup(stores, store);
if (si) {
g_hash_table_remove(stores, store);
+ UNLOCK(info_lock);
+ mail_async_event_destroy(si->async_event);
+ LOCK(info_lock);
g_hash_table_foreach(si->folders, (GHFunc)free_folder_info, NULL);
g_hash_table_destroy(si->folders);
g_free(si);
@@ -408,6 +435,7 @@ mail_note_store(CamelStore *store, EvolutionStorage *storage, GNOME_Evolution_St
si->corba_storage = corba_storage;
si->store = store;
g_hash_table_insert(stores, store, si);
+ si->async_event = mail_async_event_new();
camel_object_hook_event((CamelObject *)store, "folder_created", store_folder_created, NULL);
camel_object_hook_event((CamelObject *)store, "folder_deleted", store_folder_deleted, NULL);