evolution r34878 - in trunk: mail plugins/groupwise-features



Author: mcrha
Date: Thu Jan 24 11:06:21 2008
New Revision: 34878
URL: http://svn.gnome.org/viewvc/evolution?rev=34878&view=rev

Log:
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.



Modified:
   trunk/mail/ChangeLog
   trunk/mail/em-folder-browser.c
   trunk/mail/em-folder-utils.c
   trunk/mail/em-folder-view.c
   trunk/mail/mail-vfolder.c
   trunk/mail/mail-vfolder.h
   trunk/plugins/groupwise-features/ChangeLog
   trunk/plugins/groupwise-features/share-folder-common.c

Modified: trunk/mail/em-folder-browser.c
==============================================================================
--- trunk/mail/em-folder-browser.c	(original)
+++ trunk/mail/em-folder-browser.c	Thu Jan 24 11:06:21 2008
@@ -761,8 +761,7 @@
 			char *name, *text;
 
 			/* ensures vfolder is running */
-			if (!vfolder_loaded ())
-				vfolder_load_storage ();
+			vfolder_load_storage ();
 
 			rule = vfolder_clone_rule (efb->current_query);
 			text = e_search_bar_get_text(esb);

Modified: trunk/mail/em-folder-utils.c
==============================================================================
--- trunk/mail/em-folder-utils.c	(original)
+++ trunk/mail/em-folder-utils.c	Thu Jan 24 11:06:21 2008
@@ -711,8 +711,7 @@
 		EMVFolderRule *rule;
 
 		/* ensures vfolder is running */
-		if (!vfolder_loaded ())
-			vfolder_load_storage ();
+		vfolder_load_storage ();
 
 		rule = em_vfolder_rule_new();
 		filter_rule_set_name((FilterRule *)rule, path);

Modified: trunk/mail/em-folder-view.c
==============================================================================
--- trunk/mail/em-folder-view.c	(original)
+++ trunk/mail/em-folder-view.c	Thu Jan 24 11:06:21 2008
@@ -1958,8 +1958,7 @@
 
 	if (url->path && url->path[0]) {
 		/* ensures vfolder is running */
-		if (!vfolder_loaded ())
-			vfolder_load_storage ();
+		vfolder_load_storage ();
 
 		addr = camel_internet_address_new ();
 		camel_address_decode (CAMEL_ADDRESS (addr), url->path);
@@ -1988,8 +1987,7 @@
 
 	if (url->path && url->path[0]) {
 		/* ensures vfolder is running */
-		if (!vfolder_loaded ())
-			vfolder_load_storage ();
+		vfolder_load_storage ();
 
 		addr = camel_internet_address_new ();
 		camel_address_decode (CAMEL_ADDRESS (addr), url->path);
@@ -2021,8 +2019,7 @@
 
 	if (uids->len == 1) {
 		/* ensures vfolder is running */
-		if (!vfolder_loaded ())
-			vfolder_load_storage ();
+		vfolder_load_storage ();
 
 		vfolder_type_uid (emfv->folder, (char *) uids->pdata[0], emfv->folder_uri, type);
 	}

Modified: trunk/mail/mail-vfolder.c
==============================================================================
--- trunk/mail/mail-vfolder.c	(original)
+++ trunk/mail/mail-vfolder.c	Thu Jan 24 11:06:21 2008
@@ -896,12 +896,25 @@
 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 @@
 	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 @@
 	}
 
 	/* 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 @@
 	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 @@
 	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 @@
 	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);

Modified: trunk/mail/mail-vfolder.h
==============================================================================
--- trunk/mail/mail-vfolder.h	(original)
+++ trunk/mail/mail-vfolder.h	Thu Jan 24 11:06:21 2008
@@ -10,7 +10,6 @@
 struct _CamelInternetAddress;
 
 void vfolder_load_storage(void);
-gboolean vfolder_loaded (void);
 void vfolder_revert(void);
 
 void vfolder_edit (void);

Modified: trunk/plugins/groupwise-features/share-folder-common.c
==============================================================================
--- trunk/plugins/groupwise-features/share-folder-common.c	(original)
+++ trunk/plugins/groupwise-features/share-folder-common.c	Thu Jan 24 11:06:21 2008
@@ -274,8 +274,7 @@
 		EMVFolderRule *rule;
 
 		/* ensures vfolder is running */
-		if (!vfolder_loaded ())
-			vfolder_load_storage ();
+		vfolder_load_storage ();
 
 		rule = em_vfolder_rule_new();
 		filter_rule_set_name((FilterRule *)rule, path);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]