[evolution-groupwise] Adapt to EMFolderTree / EMFolderSelector API changes.



commit 83c253656cf214c904fbc6507477356d8c163ec1
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue May 24 21:14:45 2011 -0400

    Adapt to EMFolderTree / EMFolderSelector API changes.

 src/plugins/install-shared.c      |   54 ++++++++++++++++------------------
 src/plugins/share-folder-common.c |   58 ++++++++++++++++--------------------
 2 files changed, 51 insertions(+), 61 deletions(-)
---
diff --git a/src/plugins/install-shared.c b/src/plugins/install-shared.c
index d00d210..ea6173f 100644
--- a/src/plugins/install-shared.c
+++ b/src/plugins/install-shared.c
@@ -33,6 +33,7 @@
 #include <e-util/e-account-utils.h>
 #include <shell/e-shell.h>
 #include <mail/e-mail-backend.h>
+#include <mail/e-mail-folder-utils.h>
 #include <mail/em-config.h>
 #include <mail/em-event.h>
 #include <mail/em-folder-tree.h>
@@ -52,14 +53,13 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 {
 	struct AcceptData *accept_data = (struct AcceptData *) data;
 	EMFolderTreeModel *model;
-	const gchar *uri, *path;
+	const gchar *uri;
 	gint parts = 0;
 	gchar **names;
 	gchar *folder_name;
 	gchar *parent_name;
 	gchar *container_id;
 	const gchar *item_id;
-	CamelService *service = NULL;
 	CamelFolder *folder;
 	EAccount *account;
 	CamelProvider *provider;
@@ -69,8 +69,9 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 		gtk_widget_destroy (GTK_WIDGET (emfs));
 	} else {
 		CamelSession *session;
-		CamelURL *url;
+		CamelStore *store;
 		EShell *shell;
+		gchar *path;
 
 		shell = e_shell_get_default ();
 		session = e_shell_settings_get_pointer (e_shell_get_shell_settings (shell), "mail-session");
@@ -78,7 +79,10 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 		model = accept_data->model;
 		item_id = camel_mime_message_get_message_id (accept_data->msg);
 		uri = em_folder_selector_get_selected_uri (emfs);
-		path = em_folder_selector_get_selected_path (emfs);
+
+		if (!e_mail_folder_uri_parse (session, uri, &store, &path, NULL))
+			g_return_if_reached ();
+
 		names = g_strsplit (path, "/", -1);
 		if (names == NULL) {
 			folder_name = (gchar *) path;
@@ -93,19 +97,7 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 				parent_name = NULL;
 		}
 
-		url = camel_url_new (uri, NULL);
-		if (url != NULL) {
-			service = camel_session_get_service_by_url (
-				session, url, CAMEL_PROVIDER_STORE);
-			camel_url_free (url);
-		}
-
-		if (!CAMEL_IS_STORE (service)) {
-			g_strfreev (names);
-			return;
-		}
-
-		cnc = get_cnc (CAMEL_STORE (service));
+		cnc = get_cnc (store);
 		if (E_IS_GW_CONNECTION (cnc)) {
 			container_id = get_container_id (cnc, parent_name);
 
@@ -114,8 +106,7 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 
 				/* FIXME Not passing a GCancellable or GError here. */
 				folder = camel_store_get_folder_sync (
-					CAMEL_STORE (service),
-					"Mailbox", 0, NULL, NULL);
+					store, "Mailbox", 0, NULL, NULL);
 				/*changes = camel_folder_change_info_new ();
 				camel_folder_change_info_remove_uid (changes, (gchar *) item_id);
 				camel_folder_summary_remove_uid (folder->summary, item_id);*/
@@ -126,11 +117,12 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 					CAMEL_MESSAGE_DELETED);
 				camel_folder_summary_touch (folder->summary);
 				/* camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes); */
-				uid = camel_service_get_uid (service);
+				uid = camel_service_get_uid (
+					CAMEL_SERVICE (store));
 				account = e_get_account_by_uid (uid);
 				uri = account->source->url;
 				em_folder_tree_model_remove_store (
-					model, CAMEL_STORE (service));
+					model, store);
 				provider = camel_provider_get (uri, NULL);
 				if (provider == NULL) {
 					g_strfreev (names);
@@ -144,11 +136,13 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data)
 				}
 
 				em_folder_tree_model_add_store (
-					model, CAMEL_STORE (service),
-					account->name);
+					model, store, account->name);
 			}
 		}
 
+		g_object_unref (store);
+		g_free (path);
+
 		g_strfreev (names);
 		gtk_widget_destroy ((GtkWidget *) emfs);
 	}
@@ -169,10 +163,10 @@ apply_clicked (GtkAssistant *assistant, CamelMimeMessage *msg)
 {
 	EShell *shell;
 	EShellBackend *shell_backend;
+	EMFolderSelector *selector;
 	EMFolderTree *folder_tree;
 	GtkWidget *dialog;
 	struct AcceptData *accept_data;
-	gchar *uri;
 	gpointer parent;
 
 	shell = e_shell_get_default ();
@@ -182,12 +176,14 @@ apply_clicked (GtkAssistant *assistant, CamelMimeMessage *msg)
 	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
 
 	accept_data = g_new0 (struct AcceptData, 1);
-	folder_tree = (EMFolderTree *) em_folder_tree_new (E_MAIL_BACKEND (shell_backend));
 
-	dialog = em_folder_selector_create_new (parent, folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
-	uri = em_folder_tree_get_selected_uri (folder_tree);
-	em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
-	g_free (uri);
+	dialog = em_folder_selector_create_new (
+		parent, E_MAIL_BACKEND (shell_backend), 0,
+		_("Create folder"), _("Specify where to create the folder:"));
+
+	selector = EM_FOLDER_SELECTOR (dialog);
+	folder_tree = em_folder_selector_get_folder_tree (selector);
+
 	accept_data->msg = msg;
 	g_object_ref (msg);
 	accept_data->model = EM_FOLDER_TREE_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (folder_tree)));
diff --git a/src/plugins/share-folder-common.c b/src/plugins/share-folder-common.c
index 69b585c..49bce0f 100644
--- a/src/plugins/share-folder-common.c
+++ b/src/plugins/share-folder-common.c
@@ -245,10 +245,10 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi)
 {
 	struct _EMFolderTreeModelStoreInfo *si;
 	EMFolderSelector *emfs = ssi->emfs;
-	const gchar *uri, *path;
+	EMFolderTree *folder_tree;
 	EMailBackend *mail_backend;
-	CamelService *service = NULL;
-	CamelURL *url;
+	CamelStore *store;
+	gchar *folder_name;
 
 	if (response != GTK_RESPONSE_OK) {
 		gtk_widget_destroy ((GtkWidget *) emfs);
@@ -256,42 +256,34 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi)
 		return;
 	}
 
-	uri = em_folder_selector_get_selected_uri (emfs);
-	path = em_folder_selector_get_selected_path (emfs);
-	mail_backend = em_folder_tree_get_backend (emfs->emft);
-
-	d(printf ("Creating new folder: %s (%s)\n", path, uri));
-
-	url = camel_url_new (uri, NULL);
-	if (url != NULL) {
-		service = camel_session_get_service_by_url (
-			CAMEL_SESSION (e_mail_backend_get_session (mail_backend)), url, CAMEL_PROVIDER_STORE);
-		camel_url_free (url);
-	}
+	folder_tree = em_folder_selector_get_folder_tree (emfs);
+	mail_backend = em_folder_tree_get_backend (folder_tree);
 
-	if (!CAMEL_IS_STORE (service))
-		return;
+	if (!em_folder_tree_get_selected (folder_tree, &store, &folder_name))
+		g_return_if_reached ();
 
-	si = em_folder_tree_model_lookup_store_info (
-		ssi->model, CAMEL_STORE (service));
+	si = em_folder_tree_model_lookup_store_info (ssi->model, store);
 	if (si == NULL) {
 		g_assert_not_reached ();
 		return;
 	}
 
-	if (CAMEL_IS_VEE_STORE (service)) {
+	if (CAMEL_IS_VEE_STORE (store)) {
 		EFilterRule *rule;
 
 		rule = em_vfolder_rule_new (mail_backend);
-		e_filter_rule_set_name (rule, path);
+		e_filter_rule_set_name (rule, folder_name);
 		vfolder_gui_add_rule (EM_VFOLDER_RULE (rule));
 		gtk_widget_destroy ((GtkWidget *) emfs);
 	} else {
 		g_object_ref (emfs);
 		ssi->d = dialog;
-		create_folder (si->store, path, new_folder_created_cb, ssi);
-
+		create_folder (
+			si->store, folder_name, new_folder_created_cb, ssi);
 	}
+
+	g_object_unref (store);
+	g_free (folder_name);
 }
 
 static void
@@ -346,25 +338,27 @@ new_folder_response (EMFolderSelector *emfs, gint response, EMFolderTreeModel *m
 void
 gw_new_shared_folder_cb (GtkAction *action, EShellView *shell_view)
 {
+	EMFolderSelector *selector;
 	EMFolderTree *folder_tree;
 	EShellBackend *shell_backend;
 	GtkWidget *dialog;
-	gchar *uri;
 	gpointer parent;
 
 	parent = e_shell_view_get_shell_window (shell_view);
 	shell_backend = e_shell_view_get_shell_backend (shell_view);
 
-	folder_tree = (EMFolderTree *) em_folder_tree_new (E_MAIL_BACKEND (shell_backend));
-	emu_restore_folder_tree_state (folder_tree);
+	dialog = em_folder_selector_create_new (
+		parent, E_MAIL_BACKEND (shell_backend), 0,
+		_("Create folder"), _("Specify where to create the folder:"));
+
+	selector = EM_FOLDER_SELECTOR (dialog);
+	folder_tree = em_folder_selector_get_folder_tree (selector);
 
-	dialog = em_folder_selector_create_new (parent, folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
-	uri = em_folder_tree_get_selected_uri (folder_tree);
-	if (uri != NULL)
-		em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
-	g_free (uri);
+	g_signal_connect (
+		dialog, "response",
+		G_CALLBACK (new_folder_response),
+		gtk_tree_view_get_model (GTK_TREE_VIEW (folder_tree)));
 
-	g_signal_connect (dialog, "response", G_CALLBACK (new_folder_response), gtk_tree_view_get_model (GTK_TREE_VIEW (folder_tree)));
 	gtk_window_set_title (GTK_WINDOW (dialog), "New Shared Folder" );
 	gtk_widget_show (dialog);
 }



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