diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-06-24 12:40:49 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-06-24 12:40:49 +0800 |
commit | 174c942e0945a2017f0c479883dce2950e42e786 (patch) | |
tree | 0011078b4121d5c6c200825b0ab1bb1c4cefd519 /mail/mail-folder-cache.c | |
parent | ce7537b495a3788d9bda4b6a783a5c3d95309926 (diff) | |
download | gsoc2013-evolution-174c942e0945a2017f0c479883dce2950e42e786.tar.gz gsoc2013-evolution-174c942e0945a2017f0c479883dce2950e42e786.tar.zst gsoc2013-evolution-174c942e0945a2017f0c479883dce2950e42e786.zip |
Split store and local folder management out from shell backend.
Diffstat (limited to 'mail/mail-folder-cache.c')
-rw-r--r-- | mail/mail-folder-cache.c | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 9125e94a14..faa80b2629 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -65,6 +65,9 @@ #include "em-event.h" +#include "e-mail-local.h" +#include "e-mail-store.h" + #define w(x) #define d(x) @@ -109,8 +112,6 @@ struct _folder_update { }; struct _store_info { - EMailShellBackend *mail_shell_backend; - GHashTable *folders; /* by full_name */ GHashTable *folders_uri; /* by uri */ @@ -151,14 +152,14 @@ free_update(struct _folder_update *up) } static void -real_flush_updates (EMailShellBackend *mail_shell_backend) +real_flush_updates (void) { EShell *shell; - struct _EMFolderTreeModel *model; + EMFolderTreeModel *default_model; struct _folder_update *up; - shell = e_shell_backend_get_shell (E_SHELL_BACKEND (mail_shell_backend)); - model = e_mail_shell_backend_get_folder_tree_model (mail_shell_backend); + shell = e_shell_get_default (); + default_model = em_folder_tree_model_get_default (); LOCK(info_lock); while ((up = (struct _folder_update *)e_dlist_remhead(&updates))) { @@ -187,14 +188,17 @@ real_flush_updates (EMailShellBackend *mail_shell_backend) } /* update unread counts */ - em_folder_tree_model_set_unread_count (model, up->store, up->full_name, up->unread); + em_folder_tree_model_set_unread_count ( + default_model, up->store, up->full_name, up->unread); if (up->uri) { EMEvent *e = em_event_peek(); EMEventTargetFolder *t = em_event_target_new_folder(e, up->uri, up->new); - t->is_inbox = em_folder_tree_model_is_type_inbox (model, up->store, up->full_name); - t->name = em_folder_tree_model_get_folder_name (model, up->store, up->full_name); + t->is_inbox = em_folder_tree_model_is_type_inbox ( + default_model, up->store, up->full_name); + t->name = em_folder_tree_model_get_folder_name ( + default_model, up->store, up->full_name); if (t->new > 0) e_shell_event ( @@ -233,13 +237,13 @@ real_flush_updates (EMailShellBackend *mail_shell_backend) } static void -flush_updates (EMailShellBackend *shell_backend) +flush_updates (void) { if (update_id == -1 && !e_dlist_empty(&updates)) update_id = mail_async_event_emit ( mail_async_event, MAIL_ASYNC_GUI, (MailAsyncFunc) real_flush_updates, - shell_backend, NULL, NULL); + NULL, NULL, NULL); } static void @@ -252,7 +256,7 @@ unset_folder_info(struct _folder_info *mfi, gint delete, gint unsub) if (mfi->folder) { CamelFolder *folder = mfi->folder; - camel_object_unhook_event(folder, "folder_changed", folder_changed, mfi->store_info->mail_shell_backend); + camel_object_unhook_event(folder, "folder_changed", folder_changed, NULL); camel_object_unhook_event(folder, "renamed", folder_renamed, NULL); camel_object_unhook_event(folder, "finalize", folder_finalised, NULL); } @@ -269,7 +273,7 @@ unset_folder_info(struct _folder_info *mfi, gint delete, gint unsub) up->uri = g_strdup(mfi->uri); e_dlist_addtail(&updates, (EDListNode *)up); - flush_updates(mfi->store_info->mail_shell_backend); + flush_updates(); } } @@ -307,7 +311,6 @@ static void update_1folder(struct _folder_info *mfi, gint new, CamelFolderInfo *info) { struct _folder_update *up; - EMailShellBackend *mail_shell_backend; CamelFolder *folder; CamelFolder *local_drafts; CamelFolder *local_outbox; @@ -315,13 +318,9 @@ update_1folder(struct _folder_info *mfi, gint new, CamelFolderInfo *info) gint unread = -1; gint deleted; - mail_shell_backend = mfi->store_info->mail_shell_backend; - local_drafts = e_mail_shell_backend_get_folder ( - mail_shell_backend, E_MAIL_FOLDER_DRAFTS); - local_outbox = e_mail_shell_backend_get_folder ( - mail_shell_backend, E_MAIL_FOLDER_OUTBOX); - local_sent = e_mail_shell_backend_get_folder ( - mail_shell_backend, E_MAIL_FOLDER_SENT); + local_drafts = e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS); + local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); + local_sent = e_mail_local_get_folder (E_MAIL_FOLDER_SENT); folder = mfi->folder; if (folder) { @@ -366,7 +365,7 @@ update_1folder(struct _folder_info *mfi, gint new, CamelFolderInfo *info) up->uri = g_strdup(mfi->uri); camel_object_ref(up->store); e_dlist_addtail(&updates, (EDListNode *)up); - flush_updates(mail_shell_backend); + flush_updates(); } static void @@ -400,7 +399,7 @@ setup_folder(CamelFolderInfo *fi, struct _store_info *si) up->add = TRUE; e_dlist_addtail(&updates, (EDListNode *)up); - flush_updates(si->mail_shell_backend); + flush_updates(); } } @@ -423,7 +422,6 @@ static void folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) { static time_t last_newmail = 0; - EMailShellBackend *mail_shell_backend = user_data; CamelFolderChangeInfo *changes = event_data; CamelFolder *folder = (CamelFolder *)o; CamelFolder *local_drafts; @@ -439,12 +437,9 @@ folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) d(printf("folder '%s' changed\n", folder->full_name)); - local_drafts = e_mail_shell_backend_get_folder ( - mail_shell_backend, E_MAIL_FOLDER_DRAFTS); - local_outbox = e_mail_shell_backend_get_folder ( - mail_shell_backend, E_MAIL_FOLDER_OUTBOX); - local_sent = e_mail_shell_backend_get_folder ( - mail_shell_backend, E_MAIL_FOLDER_SENT); + local_drafts = e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS); + local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); + local_sent = e_mail_local_get_folder (E_MAIL_FOLDER_SENT); if (!CAMEL_IS_VEE_FOLDER(folder) && folder != local_drafts @@ -541,7 +536,7 @@ void mail_note_folder(CamelFolder *folder) UNLOCK(info_lock); - camel_object_hook_event(folder, "folder_changed", folder_changed, si->mail_shell_backend); + camel_object_hook_event(folder, "folder_changed", folder_changed, NULL); camel_object_hook_event(folder, "renamed", folder_renamed, NULL); camel_object_hook_event(folder, "finalize", folder_finalised, NULL); } @@ -685,7 +680,7 @@ rename_folders(struct _store_info *si, const gchar *oldbase, const gchar *newbas up->add = TRUE; e_dlist_addtail(&updates, (EDListNode *)up); - flush_updates(si->mail_shell_backend); + flush_updates(); #if 0 if (fi->sibling) rename_folders(si, oldbase, newbase, fi->sibling, folders); @@ -694,7 +689,7 @@ rename_folders(struct _store_info *si, const gchar *oldbase, const gchar *newbas #endif /* rename the meta-data we maintain ourselves */ - shell_backend = E_SHELL_BACKEND (si->mail_shell_backend); + shell_backend = E_SHELL_BACKEND (global_mail_shell_backend); config_dir = e_shell_backend_get_config_dir (shell_backend); olduri = folder_to_url(si->store, old); e_filename_make_safe(olduri); @@ -810,8 +805,6 @@ mail_note_store_remove(CamelStore *store) if (si) { g_hash_table_remove(stores, store); - g_object_unref(si->mail_shell_backend); - camel_object_unhook_event(store, "folder_opened", store_folder_opened, NULL); camel_object_unhook_event(store, "folder_created", store_folder_created, NULL); camel_object_unhook_event(store, "folder_deleted", store_folder_deleted, NULL); @@ -964,7 +957,7 @@ store_online_cb (CamelStore *store, gpointer data) } void -mail_note_store(EMailShellBackend *mail_shell_backend, CamelStore *store, CamelOperation *op, +mail_note_store(CamelStore *store, CamelOperation *op, gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data), gpointer data) { struct _store_info *si; @@ -973,7 +966,6 @@ mail_note_store(EMailShellBackend *mail_shell_backend, CamelStore *store, CamelO guint timeout; gint hook = 0; - g_return_if_fail (E_IS_MAIL_SHELL_BACKEND (mail_shell_backend)); g_return_if_fail (CAMEL_IS_STORE(store)); g_return_if_fail (mail_in_main_thread()); @@ -993,7 +985,6 @@ mail_note_store(EMailShellBackend *mail_shell_backend, CamelStore *store, CamelO d(printf("Noting a new store: %p: %s\n", store, camel_url_to_string(((CamelService *)store)->url, 0))); si = g_malloc0(sizeof(*si)); - si->mail_shell_backend = g_object_ref (mail_shell_backend); si->folders = g_hash_table_new(g_str_hash, g_str_equal); si->folders_uri = g_hash_table_new(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->hash_folder_name, CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name); |