From 8e8d332b85b56b98e1f7d8d977170403fe1a42d5 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 24 Jan 2008 11:06:21 +0000 Subject: ** Part of bug #511488 2008-01-24 Milan Crha ** Part of bug #511488 * mail/mail-vfolder.h: * mail/mail-vfolder.c: (vfolder_loaded): Function dropped. * mail/mail-vfolder.c: (vfolder_load_storage): Allow to call this function more than once, but do load the storage only once. * mail/em-folder-utils.c: (emfu_popup_new_folder_response): * mail/mail-vfolder.c: (vfolder_edit), (vfolder_gui_add_rule), (vfolder_gui_add_from_message), (vfolder_gui_add_from_address): * mail/em-folder-browser.c: (emfb_search_menu_activated): * mail/em-folder-view.c: (emp_uri_popup_vfolder_sender), (emp_uri_popup_vfolder_recipient), (vfolder_type_current): Ensure vfolder is running. * plugins/groupwise-features/share-folder-common.c: (users_dialog_response): The logic to check if vfolder is running has been changed, so reflect it here too. svn path=/trunk/; revision=34878 --- mail/mail-vfolder.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'mail/mail-vfolder.c') diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 14655a769f..75e0dc11f8 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -896,12 +896,25 @@ store_folder_renamed(CamelObject *o, void *event_data, void *data) void vfolder_load_storage(void) { + /* lock for loading storage, it is safe to call it more than once */ + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + char *user, *storeuri; FilterRule *rule; char *xmlfile; + pthread_mutex_lock (&lock); + + if (vfolder_hash) { + /* we have already initialized */ + pthread_mutex_unlock (&lock); + return; + } + vfolder_hash = g_hash_table_new(g_str_hash, g_str_equal); + pthread_mutex_unlock (&lock); + /* first, create the vfolder store, and set it up */ storeuri = g_strdup_printf("vfolder:%s/mail/vfolder", mail_component_peek_base_directory (mail_component_peek ())); vfolder_store = camel_session_get_store(session, storeuri, NULL); @@ -947,17 +960,6 @@ vfolder_load_storage(void) g_free(storeuri); } -/** - * vfolder_loaded - * Test if we have vfolder already inited or not. - * @return Whether was vfolder inited or not (by call of @ref vfolder_load_storage). - **/ -gboolean -vfolder_loaded (void) -{ - return vfolder_hash != NULL; -} - void vfolder_revert(void) { @@ -1002,8 +1004,7 @@ vfolder_edit (void) } /* ensures vfolder is running */ - if (!vfolder_loaded ()) - vfolder_load_storage (); + vfolder_load_storage (); vfolder_editor = GTK_WIDGET (em_vfolder_editor_new (context)); gtk_window_set_title (GTK_WINDOW (vfolder_editor), _("Search Folders")); @@ -1130,8 +1131,7 @@ vfolder_gui_add_rule(EMVFolderRule *rule) GtkDialog *gd; /* this should be done before we call this function */ - if (!vfolder_loaded ()) - vfolder_load_storage (); + vfolder_load_storage (); w = filter_rule_get_widget((FilterRule *)rule, (RuleContext *)context); @@ -1163,8 +1163,7 @@ vfolder_gui_add_from_message(CamelMimeMessage *msg, int flags, const char *sourc g_return_if_fail (msg != NULL); /* ensures vfolder is running */ - if (!vfolder_loaded ()) - vfolder_load_storage (); + vfolder_load_storage (); rule = (EMVFolderRule*)em_vfolder_rule_from_message(context, msg, flags, source); vfolder_gui_add_rule(rule); @@ -1178,8 +1177,7 @@ vfolder_gui_add_from_address(CamelInternetAddress *addr, int flags, const char * g_return_if_fail (addr != NULL); /* ensures vfolder is running */ - if (!vfolder_loaded ()) - vfolder_load_storage (); + vfolder_load_storage (); rule = (EMVFolderRule*)em_vfolder_rule_from_address(context, addr, flags, source); vfolder_gui_add_rule(rule); -- cgit