diff options
author | Peter Williams <peterw@ximian.com> | 2001-07-03 02:42:18 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-07-03 02:42:18 +0800 |
commit | 26b8fe817e4eebb373dfcdbf49b55d971084bf6e (patch) | |
tree | 209432ab48a505354ff104be7fc421a12737b593 /mail/mail-local.c | |
parent | a881f16f9338fd78ef80bbbdb38b2e65675f2d4d (diff) | |
download | gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.tar gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.tar.gz gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.tar.bz2 gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.tar.lz gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.tar.xz gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.tar.zst gsoc2013-evolution-26b8fe817e4eebb373dfcdbf49b55d971084bf6e.zip |
New file. Protoypes for the Mail Folder Cache, which provides a place for
2001-07-02 Peter Williams <peterw@ximian.com>
* mail-folder-cache.h: New file. Protoypes for the Mail Folder Cache, which
provides a place for all the disparate pieces of the mailer to save bits of
information about a folder. Centralizes the information display code.
* mail-folder-cache.c: New file. Implements the Mail Folder Cache.
* Makefile.am (evolution_mail_SOURCES): Add the mail-folder-cache.{c,h}
* folder-browser-factory.c (fb_get_svi): Copy of that absurdly long-named
function in mail-display.c that gets the GNOME_Evolution_ShellView.
(control_activate): Set the ShellView for the folder cache.
* folder-browser.c (got_folder): Tell the folder browser about this folder.
* mail-callbacks.c (create_folders): Tell the folder cache about the new
folders.
* mail-local.c (reconfigure_folder_reconfigure): Don't unhook our
events as we no longer hook them up.
(register_folder_registered): Tell the folder cache about this
folder's place in the local storage.
(register_folder_register): No longer hook events; the Folder Cache
will do this.
(local_folder_changed, local_folder_changed_proxy): Move to mail-folder-cache.c
(free_local_folder): No longer unhook events.
* mail-ops.c (do_update_subfolders_rec): Instead of setting the
folder status ourselves, inform the Folder Cache about the changes.
* mail-tools.c (mail_tool_uri_to_folder): Replace danw's cache
with the new Mail Folder Cache.
(cache_folder, etc): removed.
svn path=/trunk/; revision=10694
Diffstat (limited to 'mail/mail-local.c')
-rw-r--r-- | mail/mail-local.c | 95 |
1 files changed, 20 insertions, 75 deletions
diff --git a/mail/mail-local.c b/mail/mail-local.c index 017125f8b2..56b68344e0 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -65,7 +65,7 @@ #include "mail-tools.h" #include "folder-browser.h" #include "mail-mt.h" - +#include "mail-folder-cache.h" #include "mail-vfolder.h" #define d(x) @@ -183,7 +183,6 @@ typedef struct { char *local_path; int local_pathlen; GHashTable *folders; /* points to MailLocalFolder */ - GHashTable *unread; } MailLocalStore; typedef struct { @@ -194,15 +193,12 @@ typedef struct { CamelFolder *folder; MailLocalStore *local_store; char *path, *name, *uri; - int last_unread; } MailLocalFolder; static MailLocalStore *local_store; CamelType mail_local_store_get_type (void); -static void local_folder_changed_proxy (CamelObject *folder, gpointer event_data, gpointer user_data); - static char *get_name (CamelService *service, gboolean brief); static CamelFolder *get_folder (CamelStore *store, const char *folder_name, @@ -254,15 +250,9 @@ mail_local_store_init (gpointer object, gpointer klass) static void free_local_folder (MailLocalFolder *lf) { - if (lf->folder) { - camel_object_unhook_event((CamelObject *)lf->folder, - "folder_changed", local_folder_changed_proxy, - lf); - camel_object_unhook_event((CamelObject *)lf->folder, - "message_changed", local_folder_changed_proxy, - lf); + if (lf->folder) camel_object_unref((CamelObject *)lf->folder); - } + g_free(lf->path); g_free(lf->name); g_free(lf->uri); @@ -447,47 +437,6 @@ local_storage_destroyed_cb (EvolutionStorageListener *storage_listener, g_warning ("%s -- The LocalStorage has gone?!", __FILE__); } - -static void -local_folder_changed (CamelObject *object, gpointer event_data, - gpointer user_data) -{ - MailLocalFolder *local_folder = user_data; - int unread = GPOINTER_TO_INT (event_data); - char *display; - - if (unread != local_folder->last_unread) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - if (unread > 0) { - display = g_strdup_printf ("%s (%d)", local_folder->name, unread); - GNOME_Evolution_LocalStorage_updateFolder ( - local_folder->local_store->corba_local_storage, - local_folder->path, display, TRUE, &ev); - g_free (display); - } else { - GNOME_Evolution_LocalStorage_updateFolder ( - local_folder->local_store->corba_local_storage, - local_folder->path, local_folder->name, - FALSE, &ev); - } - CORBA_exception_free (&ev); - - local_folder->last_unread = unread; - } -} - -static void -local_folder_changed_proxy (CamelObject *folder, gpointer event_data, gpointer user_data) -{ - int unread; - - unread = camel_folder_get_unread_message_count (CAMEL_FOLDER (folder)); - mail_proxy_event (local_folder_changed, folder, - GINT_TO_POINTER (unread), user_data); -} - /* ********************************************************************** */ /* Register folder */ @@ -536,15 +485,6 @@ register_folder_register(struct _mail_msg *mm) if (meta->indexed) flags |= CAMEL_STORE_FOLDER_BODY_INDEX; local_folder->folder = camel_store_get_folder (store, meta->name, flags, &mm->ex); - if (local_folder->folder) { - camel_object_hook_event (CAMEL_OBJECT (local_folder->folder), - "folder_changed", local_folder_changed_proxy, - local_folder); - camel_object_hook_event (CAMEL_OBJECT (local_folder->folder), - "message_changed", local_folder_changed_proxy, - local_folder); - local_folder->last_unread = camel_folder_get_unread_message_count(local_folder->folder); - } camel_object_unref (CAMEL_OBJECT (store)); free_metainfo (meta); @@ -557,9 +497,10 @@ register_folder_registered(struct _mail_msg *mm) { struct _register_msg *m = (struct _register_msg *)mm; MailLocalFolder *local_folder = m->local_folder; - int unread; if (local_folder->folder) { + gchar *name; + g_hash_table_insert (local_folder->local_store->folders, local_folder->uri + 8, local_folder); /* Remove the circular ref once the local store knows aboutthe folder */ @@ -567,11 +508,20 @@ register_folder_registered(struct _mail_msg *mm) /* add the folder to the vfolder lists FIXME: merge stuff above with this */ vfolder_register_source(local_folder->folder); - - unread = local_folder->last_unread; - local_folder->last_unread = 0; - local_folder_changed (CAMEL_OBJECT (local_folder->folder), GINT_TO_POINTER (unread), - local_folder); + + mail_folder_cache_set_update_lstorage (local_folder->uri, + local_folder->local_store->corba_local_storage, + local_folder->path); + + name = strrchr (local_folder->path, '/'); + if (name) /* should always be true... */ { + name += 1; /* skip the slash */ + mail_folder_cache_note_name (local_folder->uri, name); + } + + /* Do this after specifying the name so it isn't 'mbox' */ + mail_folder_cache_note_folder (local_folder->uri, local_folder->folder); + m->local_folder = NULL; } } @@ -860,12 +810,7 @@ reconfigure_folder_reconfigure(struct _mail_msg *mm) /* first, 'close' the old folder */ update_progress(_("Closing current folder"), 0.0); camel_folder_sync(local_folder->folder, FALSE, &mm->ex); - camel_object_unhook_event(CAMEL_OBJECT (local_folder->folder), - "folder_changed", local_folder_changed_proxy, - local_folder); - camel_object_unhook_event(CAMEL_OBJECT (local_folder->folder), - "message_changed", local_folder_changed_proxy, - local_folder); + /* Once for the FolderBrowser, once for the local store */ camel_object_unref(CAMEL_OBJECT(local_folder->folder)); camel_object_unref(CAMEL_OBJECT(local_folder->folder)); |