[evolution/email-factory-3-4: 33/47] MailFolderCache: Don't respond to "service-added" signals.



commit 266ae3a1d7285681841c20e98da3ed175a20ef55
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Fri Dec 16 15:58:38 2011 +0530

        MailFolderCache: Don't respond to "service-added" signals.
    
        Causes folder info queries on disabled accounts.  Instead
        respond to "service-enabled" and "service-disabled" signals, one of
        which always immediately follows "service-added".

 libemail-engine/mail-folder-cache.c |   20 +++++++++++++++++++-
 libemail-engine/mail-folder-cache.h |    7 +++++++
 mail/e-mail-account-store.c         |   22 ++++++++++++++++------
 3 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c
index 05f151f..3cb77f2 100644
--- a/libemail-engine/mail-folder-cache.c
+++ b/libemail-engine/mail-folder-cache.c
@@ -1064,7 +1064,7 @@ mail_folder_cache_service_added (MailFolderCache *cache,
 }
 
 void
-mail_folder_cache_service_removed (MailFolderCache *cache
+mail_folder_cache_service_removed (MailFolderCache *cache,
                                    CamelService *service)
 {
 	StoreInfo *si;
@@ -1092,6 +1092,24 @@ mail_folder_cache_service_removed (MailFolderCache *cache
 	g_mutex_unlock (cache->priv->stores_mutex);
 }
 
+void
+mail_folder_cache_service_enabled (MailFolderCache *cache,
+                                   CamelService *service)
+{
+	mail_folder_cache_note_store (
+		cache, CAMEL_STORE (service), NULL, NULL, NULL);
+}
+
+void
+mail_folder_cache_service_disabled (MailFolderCache *cache,
+                                    CamelService *service)
+{
+	/* To the folder cache, disabling a service is the same as
+	 * removing it.  We keep a separate callback function only
+	 * to use as a breakpoint target in a debugger. */
+	mail_folder_cache_service_removed (account_store, service, cache);
+}
+
 static void
 mail_folder_cache_set_session (MailFolderCache *cache,
                                EMailSession *session)
diff --git a/libemail-engine/mail-folder-cache.h b/libemail-engine/mail-folder-cache.h
index ac56575..a34375c 100644
--- a/libemail-engine/mail-folder-cache.h
+++ b/libemail-engine/mail-folder-cache.h
@@ -142,6 +142,13 @@ void		mail_folder_cache_service_added (MailFolderCache *cache,
 void		mail_folder_cache_service_removed 
 						(MailFolderCache *cache
                                    		 CamelService *service);
+void		mail_folder_cache_service_enabled 
+						(MailFolderCache *cache,
+                                   		 CamelService *service);
+void		mail_folder_cache_service_disabled 
+						(MailFolderCache *cache,
+                                    		 CamelService *service);
+
 
 G_END_DECLS
 
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index 6ade039..b2f4018 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -1092,14 +1092,19 @@ e_mail_account_store_add_service (EMailAccountStore *store,
 	/* This populates the rest of the columns. */
 	mail_account_store_update_row (store, service, &iter);
 
-	mail_folder_cache_service_added (cache, service);
+	/* No need to connect to "service-added" emissions since it's
+	 * always immediately followed by either "service-enabled" or
+	 * "service-disabled" in MailFolderCache */
+
 	g_signal_emit (store, signals[SERVICE_ADDED], 0, service);
 
-	if (enabled)
+	if (enabled) {
+		mail_folder_cache_service_enabled (cache, service);
 		g_signal_emit (store, signals[SERVICE_ENABLED], 0, service);
-	else
+	} else {
+		mail_folder_cache_service_disabled (cache, service);		
 		g_signal_emit (store, signals[SERVICE_DISABLED], 0, service);
-
+	}
 	filename = store->priv->sort_order_filename;
 
 	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
@@ -1180,11 +1185,16 @@ e_mail_account_store_disable_service (EMailAccountStore *store,
                                       CamelService *service)
 {
 	GtkTreeIter iter;
-	gboolean proceed = TRUE;
+	gboolean proceed;
+	MailFolderCache *cache;
+	EMailSession *session;
 
 	g_return_if_fail (E_IS_MAIL_ACCOUNT_STORE (store));
 	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
+	session = e_mail_account_store_get_session (store);
+	cache = e_mail_session_get_folder_cache (session);
+
 	if (!mail_account_store_get_iter (store, service, &iter))
 		g_return_if_reached ();
 
@@ -1198,7 +1208,7 @@ e_mail_account_store_disable_service (EMailAccountStore *store,
 		gtk_list_store_set (
 			GTK_LIST_STORE (store), &iter,
 			E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED, FALSE, -1);
-
+		mail_folder_cache_service_disabled (cache, service);		
 		g_signal_emit (store, signals[SERVICE_DISABLED], 0, service);
 	}
 }



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