aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-vfolder.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-01-24 19:06:21 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-01-24 19:06:21 +0800
commit8e8d332b85b56b98e1f7d8d977170403fe1a42d5 (patch)
tree3e5587629b352246ca0bd459e2d2568e57e84d49 /mail/mail-vfolder.c
parentd5ec942afbcd814dbe6f9adaa0bf4d31b7b1b26a (diff)
downloadgsoc2013-evolution-8e8d332b85b56b98e1f7d8d977170403fe1a42d5.tar.gz
gsoc2013-evolution-8e8d332b85b56b98e1f7d8d977170403fe1a42d5.tar.zst
gsoc2013-evolution-8e8d332b85b56b98e1f7d8d977170403fe1a42d5.zip
** Part of bug #511488
2008-01-24 Milan Crha <mcrha@redhat.com> ** 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
Diffstat (limited to 'mail/mail-vfolder.c')
-rw-r--r--mail/mail-vfolder.c36
1 files changed, 17 insertions, 19 deletions
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);