diff options
author | Peter Williams <peterw@ximian.com> | 2001-07-09 22:56:13 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-07-09 22:56:13 +0800 |
commit | b66a80f71be538d0eeeeca113d61859701b1d315 (patch) | |
tree | 2538690952ed55bee8647db65f69b5ee8638b809 /mail | |
parent | 913cd5d34e28dae1ab49f95d9c99645c225197a9 (diff) | |
download | gsoc2013-evolution-b66a80f71be538d0eeeeca113d61859701b1d315.tar.gz gsoc2013-evolution-b66a80f71be538d0eeeeca113d61859701b1d315.tar.zst gsoc2013-evolution-b66a80f71be538d0eeeeca113d61859701b1d315.zip |
Deleted (as opposed to #if 0) (get_folder_info): Changed to assume it has
2001-07-09 Peter Williams <peterw@ximian.com>
* mail-folder-cache.c (mail_folder_cache_set_update_shellview): Deleted
(as opposed to #if 0)
(get_folder_info): Changed to assume it has the folder lock.
(make_folder_name): Same.
(make_folder_status): Same.
(update_idle): Don't unlock around the make_folder_ functions.
(*): Changed behavior wrt. get_folder_info. Lock before calling, but
also move preconditions before -- get_folder_info can only return NULL
if uri is NULL. Also add preconditions for other arguments where
necessary.
svn path=/trunk/; revision=10910
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 13 | ||||
-rw-r--r-- | mail/mail-folder-cache.c | 82 |
2 files changed, 42 insertions, 53 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 3960d95909..4b722a0c90 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2001-07-09 Peter Williams <peterw@ximian.com> + + * mail-folder-cache.c (mail_folder_cache_set_update_shellview): Deleted + (as opposed to #if 0) + (get_folder_info): Changed to assume it has the folder lock. + (make_folder_name): Same. + (make_folder_status): Same. + (update_idle): Don't unlock around the make_folder_ functions. + (*): Changed behavior wrt. get_folder_info. Lock before calling, but + also move preconditions before -- get_folder_info can only return NULL + if uri is NULL. Also add preconditions for other arguments where + necessary. + 2001-07-07 Christopher James Lahey <clahey@ximian.com> * message-list.c (on_cursor_activated_cmd): Check for new_uid != diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index d00f3c02d9..d31f5efeef 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -90,6 +90,7 @@ static FolderBrowser *folder_browser = NULL; /* Private functions */ +/* call this with the folders locked */ static mail_folder_info * get_folder_info (const gchar *uri) { @@ -97,8 +98,6 @@ get_folder_info (const gchar *uri) g_return_val_if_fail (uri, NULL); - LOCK_FOLDERS (); - if (folders == NULL) { dm("Initializing"); folders = g_hash_table_new (g_str_hash, g_str_equal); @@ -123,31 +122,28 @@ get_folder_info (const gchar *uri) } else dm("Hit cache for uri %s", uri); - UNLOCK_FOLDERS (); - return mfi; } +/* call with the folders locked */ + static gchar * make_folder_name (mail_folder_info *mfi) { GString *work; gchar *ret; - LOCK_FOLDERS (); - work = g_string_new (mfi->name); if (mfi->flags & MAIL_FIF_UNREAD_VALID && mfi->unread) g_string_sprintfa (work, " (%d)", mfi->unread); - UNLOCK_FOLDERS (); - ret = work->str; g_string_free (work, FALSE); return ret; } +/* call with the folders locked */ static gchar * make_folder_status (mail_folder_info *mfi) @@ -156,8 +152,6 @@ make_folder_status (mail_folder_info *mfi) GString *work; gchar *ret; - LOCK_FOLDERS (); - /* Build the display string */ work = g_string_new (""); @@ -180,8 +174,6 @@ make_folder_status (mail_folder_info *mfi) g_string_sprintfa (work, _("%d total"), mfi->total); } - UNLOCK_FOLDERS (); - ret = work->str; g_string_free (work, FALSE); return ret; @@ -221,10 +213,8 @@ update_idle (gpointer user_data) /* Get the display string */ - UNLOCK_FOLDERS (); f_name = make_folder_name (mfi); f_status = make_folder_status (mfi); - LOCK_FOLDERS (); /* bold? */ @@ -554,11 +544,12 @@ mail_folder_cache_set_update_estorage (const gchar *uri, EvolutionStorage *estor { mail_folder_info *mfi; - mfi = get_folder_info (uri); - g_return_if_fail (mfi); + g_return_if_fail (uri); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + if (mfi->update_mode != MAIL_FIUM_UNKNOWN) { /* we could check to see that update_mode = ESTORAGE */ /*g_warning ("folder cache: update mode already set??");*/ @@ -578,11 +569,12 @@ mail_folder_cache_set_update_lstorage (const gchar *uri, GNOME_Evolution_LocalSt { mail_folder_info *mfi; - mfi = get_folder_info (uri); - g_return_if_fail (mfi); + g_return_if_fail (uri); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + if (mfi->update_mode != MAIL_FIUM_UNKNOWN) { /*we could check to see that update_mode = lstorage */ /*g_warning ("folder cache: update mode already set??");*/ @@ -601,41 +593,18 @@ mail_folder_cache_set_update_lstorage (const gchar *uri, GNOME_Evolution_LocalSt UNLOCK_FOLDERS (); } -#if 0 -void -mail_folder_cache_set_update_shellview (const gchar *uri) -{ - mail_folder_info *mfi; - - mfi = get_folder_info (uri); - g_return_if_fail (mfi); - - LOCK_FOLDERS (); - - if (mfi->update_mode != MAIL_FIUM_UNKNOWN) { - /*we could check to see that update_mode = shellview */ - /*g_warning ("folder cache: update mode already set??");*/ - UNLOCK_FOLDERS (); - return; - } - - dm ("Uri %s updates with SHELL VIEW", uri); - mfi->update_mode = MAIL_FIUM_SHELL_VIEW; - - UNLOCK_FOLDERS (); -} -#endif - void mail_folder_cache_note_folder (const gchar *uri, CamelFolder *folder) { mail_folder_info *mfi; - mfi = get_folder_info (uri); - g_return_if_fail (mfi); + g_return_if_fail (uri); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + if (mfi->flags & MAIL_FIF_FOLDER_VALID) { if (mfi->folder != folder) g_warning ("folder cache: CamelFolder being changed for %s??? I refuse.", uri); @@ -665,11 +634,13 @@ mail_folder_cache_note_fb (const gchar *uri, FolderBrowser *fb) { mail_folder_info *mfi; - mfi = get_folder_info (uri); - g_return_if_fail (mfi); + g_return_if_fail (uri); + g_return_if_fail (IS_FOLDER_BROWSER (fb)); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + if (!(mfi->flags & MAIL_FIF_FOLDER_VALID)) { dm ("No folder specified so ignoring NOTE_FB at %s", uri); UNLOCK_FOLDERS (); @@ -695,11 +666,13 @@ mail_folder_cache_note_folderinfo (const gchar *uri, CamelFolderInfo *fi) { mail_folder_info *mfi; - mfi = get_folder_info (uri); - g_return_if_fail (mfi); + g_return_if_fail (uri); + g_return_if_fail (fi); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + dm ("Noting folderinfo %p for %s", fi, uri); if (fi->unread_message_count != -1) { @@ -723,11 +696,13 @@ mail_folder_cache_note_name (const gchar *uri, const gchar *name) { mail_folder_info *mfi; - mfi = get_folder_info (uri); - g_return_if_fail (mfi); + g_return_if_fail (uri); + g_return_if_fail (name); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + dm ("Noting name %s for %s", name, uri); if (mfi->flags & MAIL_FIF_NAME_VALID) { @@ -751,11 +726,12 @@ mail_folder_cache_try_folder (const gchar *uri) mail_folder_info *mfi; CamelFolder *ret; - mfi = get_folder_info (uri); - g_return_val_if_fail (mfi, NULL); + g_return_val_if_fail (uri, NULL); LOCK_FOLDERS (); + mfi = get_folder_info (uri); + if (mfi->flags & MAIL_FIF_FOLDER_VALID) ret = mfi->folder; else |