[evolution] Adapt to new CamelSubscribable interface.



commit f3648e1cb5f1a2537b557bce2ff9b0bc4f17c751
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Aug 15 17:36:43 2011 -0400

    Adapt to new CamelSubscribable interface.

 mail/e-mail-folder-utils.c       |    7 ++++---
 mail/e-mail-session-utils.c      |    5 +++--
 mail/e-mail-sidebar.c            |    4 ++--
 mail/e-mail-sidebar.h            |    2 +-
 mail/e-mail-store-utils.c        |    7 ++++---
 mail/em-folder-tree-model.c      |   25 +++++++++++++++----------
 mail/em-folder-utils.c           |   25 +++++++++++++++----------
 mail/em-subscription-editor.c    |   30 +++++++++++++++++++-----------
 mail/mail-folder-cache.c         |    7 +++++--
 modules/mail/e-mail-shell-view.c |   18 +++++++++---------
 10 files changed, 77 insertions(+), 53 deletions(-)
---
diff --git a/mail/e-mail-folder-utils.c b/mail/e-mail-folder-utils.c
index d7d4808..72afb08 100644
--- a/mail/e-mail-folder-utils.c
+++ b/mail/e-mail-folder-utils.c
@@ -746,9 +746,10 @@ mail_folder_remove_recursive (CamelStore *store,
 
 		/* If the store supports subscriptions,
 		 * then unsubscribe from this folder. */
-		if (camel_store_supports_subscriptions (store)) {
-			success = camel_store_unsubscribe_folder_sync (
-				store, folder_info->full_name,
+		if (CAMEL_IS_SUBSCRIBABLE (store)) {
+			success = camel_subscribable_unsubscribe_folder_sync (
+				CAMEL_SUBSCRIBABLE (store),
+				folder_info->full_name,
 				cancellable, error);
 			if (!success)
 				break;
diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c
index 2922e3c..5522124 100644
--- a/mail/e-mail-session-utils.c
+++ b/mail/e-mail-session-utils.c
@@ -877,8 +877,9 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session,
 	success =
 		em_utils_connect_service_sync (
 			CAMEL_SERVICE (store), cancellable, error) &&
-		camel_store_unsubscribe_folder_sync (
-			store, folder_name, cancellable, error);
+		camel_subscribable_unsubscribe_folder_sync (
+			CAMEL_SUBSCRIBABLE (store),
+			folder_name, cancellable, error);
 
 	camel_operation_pop_message (cancellable);
 
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index d217905..35048f8 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -404,8 +404,8 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
 		state |= E_MAIL_SIDEBAR_FOLDER_IS_STORE;
 	if (is_trash)
 		state |= E_MAIL_SIDEBAR_FOLDER_IS_TRASH;
-	if (camel_store_supports_subscriptions (store))
-		state |= E_MAIL_SIDEBAR_STORE_SUPPORTS_SUBSCRIPTIONS;
+	if (CAMEL_IS_SUBSCRIBABLE (store))
+		state |= E_MAIL_SIDEBAR_STORE_IS_SUBSCRIBABLE;
 
 	g_free (full_name);
 
diff --git a/mail/e-mail-sidebar.h b/mail/e-mail-sidebar.h
index 84d8183..af4c87e 100644
--- a/mail/e-mail-sidebar.h
+++ b/mail/e-mail-sidebar.h
@@ -57,7 +57,7 @@ enum {
 	E_MAIL_SIDEBAR_FOLDER_IS_OUTBOX			= 1 << 3,
 	E_MAIL_SIDEBAR_FOLDER_IS_STORE			= 1 << 4,
 	E_MAIL_SIDEBAR_FOLDER_IS_TRASH			= 1 << 5,
-	E_MAIL_SIDEBAR_STORE_SUPPORTS_SUBSCRIPTIONS	= 1 << 6
+	E_MAIL_SIDEBAR_STORE_IS_SUBSCRIBABLE		= 1 << 6
 };
 
 struct _EMailSidebar {
diff --git a/mail/e-mail-store-utils.c b/mail/e-mail-store-utils.c
index 1b9713b..0bf70ae 100644
--- a/mail/e-mail-store-utils.c
+++ b/mail/e-mail-store-utils.c
@@ -93,9 +93,10 @@ e_mail_store_create_folder_sync (CamelStore *store,
 	if (folder_info == NULL)
 		return FALSE;
 
-	if (camel_store_supports_subscriptions (store))
-		success = camel_store_subscribe_folder_sync (
-			store, full_name, cancellable, error);
+	if (CAMEL_IS_SUBSCRIBABLE (store))
+		success = camel_subscribable_subscribe_folder_sync (
+			CAMEL_SUBSCRIBABLE (store),
+			full_name, cancellable, error);
 
 	camel_store_free_folder_info (store, folder_info);
 
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index bbf9dd5..05113d0 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -102,8 +102,11 @@ store_info_free (EMFolderTreeModelStoreInfo *si)
 	g_signal_handler_disconnect (si->store, si->created_id);
 	g_signal_handler_disconnect (si->store, si->deleted_id);
 	g_signal_handler_disconnect (si->store, si->renamed_id);
-	g_signal_handler_disconnect (si->store, si->subscribed_id);
-	g_signal_handler_disconnect (si->store, si->unsubscribed_id);
+
+	if (si->subscribed_id > 0)
+		g_signal_handler_disconnect (si->store, si->subscribed_id);
+	if (si->unsubscribed_id > 0)
+		g_signal_handler_disconnect (si->store, si->unsubscribed_id);
 
 	g_object_unref (si->store);
 	gtk_tree_row_reference_free (si->row);
@@ -922,7 +925,7 @@ folder_created_cb (CamelStore *store,
 
 	/* We only want created events to do more
 	 * work if we don't support subscriptions. */
-	if (camel_store_supports_subscriptions (store))
+	if (CAMEL_IS_SUBSCRIBABLE (store))
 		return;
 
 	/* process "folder-created" event only when store already loaded */
@@ -940,7 +943,7 @@ folder_deleted_cb (CamelStore *store,
 {
 	/* We only want deleted events to do more
 	 * work if we don't support subscriptions. */
-	if (camel_store_supports_subscriptions (store))
+	if (CAMEL_IS_SUBSCRIBABLE (store))
 		return;
 
 	folder_unsubscribed_cb (store, fi, model);
@@ -1080,12 +1083,14 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model,
 	si->renamed_id = g_signal_connect (
 		store, "folder_renamed",
 		G_CALLBACK (folder_renamed_cb), model);
-	si->subscribed_id = g_signal_connect (
-		store, "folder_subscribed",
-		G_CALLBACK (folder_subscribed_cb), model);
-	si->unsubscribed_id = g_signal_connect (
-		store, "folder_unsubscribed",
-		G_CALLBACK (folder_unsubscribed_cb), model);
+	if (CAMEL_IS_SUBSCRIBABLE (store)) {
+		si->subscribed_id = g_signal_connect (
+			store, "folder_subscribed",
+			G_CALLBACK (folder_subscribed_cb), model);
+		si->unsubscribed_id = g_signal_connect (
+			store, "folder_unsubscribed",
+			G_CALLBACK (folder_unsubscribed_cb), model);
+	}
 
 	g_signal_emit (model, signals[LOADED_ROW], 0, path, &root);
 	gtk_tree_path_free (path);
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index f43a929..1ac8b33 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -194,9 +194,10 @@ emft_copy_folders__exec (struct _EMCopyFolders *m,
 						goto exception;
 
 					/* this folder no longer exists, unsubscribe it */
-					if (camel_store_supports_subscriptions (m->fromstore))
-						camel_store_unsubscribe_folder_sync (
-							m->fromstore, info->full_name, NULL, NULL);
+					if (CAMEL_IS_SUBSCRIBABLE (m->fromstore))
+						camel_subscribable_unsubscribe_folder_sync (
+							CAMEL_SUBSCRIBABLE (m->fromstore),
+							info->full_name, NULL, NULL);
 
 					deleted = 1;
 				} else {
@@ -238,10 +239,13 @@ emft_copy_folders__exec (struct _EMCopyFolders *m,
 				deleting = g_list_prepend (deleting, info);
 
 			/* subscribe to the new folder if appropriate */
-			if (camel_store_supports_subscriptions (m->tostore)
-			    && !camel_store_folder_is_subscribed (m->tostore, toname->str))
-				camel_store_subscribe_folder_sync (
-					m->tostore, toname->str, NULL, NULL);
+			if (CAMEL_IS_SUBSCRIBABLE (m->tostore)
+			    && !camel_subscribable_folder_is_subscribed (
+					CAMEL_SUBSCRIBABLE (m->tostore),
+					toname->str))
+				camel_subscribable_subscribe_folder_sync (
+					CAMEL_SUBSCRIBABLE (m->tostore),
+					toname->str, NULL, NULL);
 
 			info = info->next;
 		}
@@ -258,9 +262,10 @@ emft_copy_folders__exec (struct _EMCopyFolders *m,
 		/* FIXME: we need to do something with the exception
 		   since otherwise the users sees a failed operation
 		   with no error message or even any warnings */
-		if (camel_store_supports_subscriptions (m->fromstore))
-			camel_store_unsubscribe_folder_sync (
-				m->fromstore, info->full_name, NULL, NULL);
+		if (CAMEL_IS_SUBSCRIBABLE (m->fromstore))
+			camel_subscribable_unsubscribe_folder_sync (
+				CAMEL_SUBSCRIBABLE (m->fromstore),
+				info->full_name, NULL, NULL);
 
 		camel_store_delete_folder_sync (
 			m->fromstore, info->full_name, NULL, NULL);
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index 1c4d1ff..6c24e84 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -267,7 +267,7 @@ exit:
 }
 
 static void
-subscription_editor_subscribe_folder_done (CamelStore *store,
+subscription_editor_subscribe_folder_done (CamelSubscribable *subscribable,
                                            GAsyncResult *result,
                                            AsyncContext *context)
 {
@@ -279,7 +279,8 @@ subscription_editor_subscribe_folder_done (CamelStore *store,
 	GdkWindow *window;
 	GError *error = NULL;
 
-	camel_store_subscribe_folder_finish (store, result, &error);
+	camel_subscribable_subscribe_folder_finish (
+		subscribable, result, &error);
 
 	/* Just return quietly if we were cancelled. */
 	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
@@ -319,7 +320,7 @@ exit:
 }
 
 static void
-subscription_editor_unsubscribe_folder_done (CamelStore *store,
+subscription_editor_unsubscribe_folder_done (CamelSubscribable *subscribable,
                                              GAsyncResult *result,
                                              AsyncContext *context)
 {
@@ -331,7 +332,8 @@ subscription_editor_unsubscribe_folder_done (CamelStore *store,
 	GdkWindow *window;
 	GError *error = NULL;
 
-	camel_store_unsubscribe_folder_finish (store, result, &error);
+	camel_subscribable_unsubscribe_folder_finish (
+		subscribable, result, &error);
 
 	/* Just return quietly if we were cancelled. */
 	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
@@ -373,6 +375,7 @@ exit:
 static void
 subscription_editor_subscribe (EMSubscriptionEditor *editor)
 {
+	CamelStore *active_store;
 	CamelFolderInfo *folder_info;
 	GtkTreeRowReference *reference;
 	GtkTreeSelection *selection;
@@ -421,8 +424,10 @@ subscription_editor_subscribe (EMSubscriptionEditor *editor)
 	context->folder_info = folder_info;
 	context->reference = reference;
 
-	camel_store_subscribe_folder (
-		editor->priv->active->store,
+	active_store = editor->priv->active->store;
+
+	camel_subscribable_subscribe_folder (
+		CAMEL_SUBSCRIBABLE (active_store),
 		folder_info->full_name, G_PRIORITY_DEFAULT,
 		editor->priv->active->cancellable, (GAsyncReadyCallback)
 		subscription_editor_subscribe_folder_done, context);
@@ -431,6 +436,7 @@ subscription_editor_subscribe (EMSubscriptionEditor *editor)
 static void
 subscription_editor_unsubscribe (EMSubscriptionEditor *editor)
 {
+	CamelStore *active_store;
 	CamelFolderInfo *folder_info;
 	GtkTreeRowReference *reference;
 	GtkTreeSelection *selection;
@@ -479,8 +485,10 @@ subscription_editor_unsubscribe (EMSubscriptionEditor *editor)
 	context->folder_info = folder_info;
 	context->reference = reference;
 
-	camel_store_unsubscribe_folder (
-		editor->priv->active->store,
+	active_store = editor->priv->active->store;
+
+	camel_subscribable_unsubscribe_folder (
+		CAMEL_SUBSCRIBABLE (active_store),
 		folder_info->full_name, G_PRIORITY_DEFAULT,
 		editor->priv->active->cancellable, (GAsyncReadyCallback)
 		subscription_editor_unsubscribe_folder_done, context);
@@ -908,7 +916,7 @@ subscription_editor_set_store (EMSubscriptionEditor *editor,
 {
 	g_return_if_fail (editor->priv->initial_store == NULL);
 
-	if (CAMEL_IS_STORE (store))
+	if (CAMEL_IS_SUBSCRIBABLE (store))
 		editor->priv->initial_store = g_object_ref (store);
 }
 
@@ -1029,7 +1037,7 @@ subscription_editor_constructed (GObject *object)
 		session = em_subscription_editor_get_session (editor);
 		service = camel_session_get_service (session, account->uid);
 
-		if (CAMEL_IS_STORE (service))
+		if (CAMEL_IS_SUBSCRIBABLE (service))
 			editor->priv->initial_store = g_object_ref (service);
 	}
 
@@ -1059,7 +1067,7 @@ subscription_editor_realize (GtkWidget *widget)
 	for (link = list; link != NULL; link = g_list_next (link)) {
 		CamelStore *store = CAMEL_STORE (link->data);
 
-		if (!camel_store_supports_subscriptions (store))
+		if (!CAMEL_IS_SUBSCRIBABLE (store))
 			continue;
 
 		if (store == editor->priv->initial_store)
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 152d8fd..e8f183f 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -515,7 +515,7 @@ store_folder_created_cb (CamelStore *store,
 {
 	/* We only want created events to do more work
 	 * if we dont support subscriptions. */
-	if (!camel_store_supports_subscriptions (store))
+	if (!CAMEL_IS_SUBSCRIBABLE (store))
 		store_folder_subscribed_cb (store, info, cache);
 }
 
@@ -555,7 +555,7 @@ store_folder_deleted_cb (CamelStore *store,
 {
 	/* We only want deleted events to do more work
 	 * if we dont support subscriptions. */
-	if (!camel_store_supports_subscriptions (store))
+	if (!CAMEL_IS_SUBSCRIBABLE (store))
 		store_folder_unsubscribed_cb (store, info, self);
 }
 
@@ -1177,6 +1177,9 @@ mail_folder_cache_note_store (MailFolderCache *self,
 		g_signal_connect (
 			store, "folder-renamed",
 			G_CALLBACK (store_folder_renamed_cb), self);
+	}
+
+	if (hook && CAMEL_IS_SUBSCRIBABLE (store)) {
 		g_signal_connect (
 			store, "folder-subscribed",
 			G_CALLBACK (store_folder_subscribed_cb), self);
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 263a283..73041d7 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -845,8 +845,8 @@ mail_shell_view_update_actions (EShellView *shell_view)
 	gboolean folder_is_trash;
 	gboolean folder_has_unread_rec = FALSE;
 	gboolean folder_tree_and_message_list_agree = TRUE;
-	gboolean store_supports_subscriptions;
-	gboolean any_store_supports_subscriptions = FALSE;
+	gboolean store_is_subscribable;
+	gboolean any_store_is_subscribable = FALSE;
 
 	/* Chain up to parent's update_actions() method. */
 	E_SHELL_VIEW_CLASS (parent_class)->update_actions (shell_view);
@@ -879,8 +879,8 @@ mail_shell_view_update_actions (EShellView *shell_view)
 		(state & E_MAIL_SIDEBAR_FOLDER_IS_STORE);
 	folder_is_trash =
 		(state & E_MAIL_SIDEBAR_FOLDER_IS_TRASH);
-	store_supports_subscriptions =
-		(state & E_MAIL_SIDEBAR_STORE_SUPPORTS_SUBSCRIPTIONS);
+	store_is_subscribable =
+		(state & E_MAIL_SIDEBAR_STORE_IS_SUBSCRIBABLE);
 
 	uri = em_folder_tree_get_selected_uri (folder_tree);
 	account = em_folder_tree_get_selected_account (folder_tree);
@@ -934,8 +934,8 @@ mail_shell_view_update_actions (EShellView *shell_view)
 	for (link = list; link != NULL; link = g_list_next (link)) {
 		CamelStore *store = CAMEL_STORE (link->data);
 
-		if (camel_store_supports_subscriptions (store)) {
-			any_store_supports_subscriptions = TRUE;
+		if (CAMEL_IS_SUBSCRIBABLE (store)) {
+			any_store_is_subscribable = TRUE;
 			break;
 		}
 	}
@@ -1002,7 +1002,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
 
 	action = ACTION (MAIL_FOLDER_UNSUBSCRIBE);
 	sensitive =
-		store_supports_subscriptions &&
+		store_is_subscribable &&
 		!folder_is_store && folder_can_be_deleted;
 	gtk_action_set_sensitive (action, sensitive);
 
@@ -1011,11 +1011,11 @@ mail_shell_view_update_actions (EShellView *shell_view)
 	gtk_action_set_sensitive (action, sensitive);
 
 	action = ACTION (MAIL_MANAGE_SUBSCRIPTIONS);
-	sensitive = folder_is_store && store_supports_subscriptions;
+	sensitive = folder_is_store && store_is_subscribable;
 	gtk_action_set_sensitive (action, sensitive);
 
 	action = ACTION (MAIL_TOOLS_SUBSCRIPTIONS);
-	sensitive = any_store_supports_subscriptions;
+	sensitive = any_store_is_subscribable;
 	gtk_action_set_sensitive (action, sensitive);
 
 	e_mail_shell_view_update_popup_labels (mail_shell_view);



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