[evolution/account-mgmt: 49/55] Adapt pst-importer plugin to the new ESource API.



commit 37e5e9e1aa7f74b2170cb553c04f2ab96ba4ac1f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Mar 28 11:39:16 2011 -0400

    Adapt pst-importer plugin to the new ESource API.

 plugins/pst-import/pst-importer.c |   63 ++++++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 21 deletions(-)
---
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index e86fa2a..6323387 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -50,8 +50,12 @@
 #include <libecal/e-cal-component.h>
 
 #include <libedataserver/e-data-server-util.h>
-#include <libedataserverui/e-source-combo-box.h>
+#include <libedataserver/e-source-registry.h>
+#include <libedataserver/e-source-calendar.h>
+#include <libedataserver/e-source-address-book.h>
 #include <libedataserverui/e-client-utils.h>
+#include <libedataserverui/e-source-combo-box.h>
+#include <libedataserverui/e-source-selector-dialog.h>
 
 #include <libemail-utils/mail-mt.h>
 #include <libemail-engine/mail-tools.h>
@@ -387,19 +391,42 @@ get_source_combo_key (EClientSourceType source_type)
 static void
 add_source_list_with_check (GtkWidget *frame,
                             const gchar *caption,
+                            ESourceRegistry *registry,
                             EClientSourceType source_type,
                             GCallback toggle_callback,
                             EImportTarget *target,
                             gboolean active)
 {
+	ESource *source;
 	GtkWidget *check, *hbox;
-	ESourceList *source_list = NULL;
 	GtkWidget *combo = NULL;
+	const gchar *extension_name;
 
 	g_return_if_fail (frame != NULL);
 	g_return_if_fail (caption != NULL);
 	g_return_if_fail (toggle_callback != NULL);
 
+	switch (source_type) {
+		case E_CLIENT_SOURCE_TYPE_CONTACTS:
+			extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+			source = e_source_registry_get_default_address_book (registry);
+			break;
+		case E_CLIENT_SOURCE_TYPE_EVENTS:
+			extension_name = E_SOURCE_EXTENSION_CALENDAR;
+			source = e_source_registry_get_default_calendar (registry);
+			break;
+		case E_CLIENT_SOURCE_TYPE_TASKS:
+			extension_name = E_SOURCE_EXTENSION_TASK_LIST;
+			source = e_source_registry_get_default_task_list (registry);
+			break;
+		case E_CLIENT_SOURCE_TYPE_MEMOS:
+			extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
+			source = e_source_registry_get_default_memo_list (registry);
+			break;
+		default:
+			g_return_if_reached ();
+	}
+
 	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
 	check = gtk_check_button_new_with_mnemonic (caption);
@@ -407,22 +434,15 @@ add_source_list_with_check (GtkWidget *frame,
 	g_signal_connect (check, "toggled", toggle_callback, target);
 	gtk_box_pack_start ((GtkBox *) hbox, check, FALSE, FALSE, 0);
 
-	if (e_client_utils_get_sources (&source_list, source_type, NULL)) {
-		ESource *source;
-
-		combo = e_source_combo_box_new (source_list);
-		source = e_source_list_peek_default_source (source_list);
-		if (!source)
-			source = e_source_list_peek_source_any (source_list);
-		e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (combo), source);
+	combo = e_source_combo_box_new (registry, extension_name);
+	e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (combo), source);
 
-		gtk_box_pack_end ((GtkBox *) hbox, combo, FALSE, FALSE, 0);
+	gtk_box_pack_end ((GtkBox *) hbox, combo, FALSE, FALSE, 0);
 
-		g_signal_connect (
-			check, "toggled",
-			G_CALLBACK (widget_sanitizer_cb), combo);
-		widget_sanitizer_cb (GTK_TOGGLE_BUTTON (check), combo);
-	}
+	g_signal_connect (
+		check, "toggled",
+		G_CALLBACK (widget_sanitizer_cb), combo);
+	widget_sanitizer_cb (GTK_TOGGLE_BUTTON (check), combo);
 
 	gtk_box_pack_start ((GtkBox *) frame, hbox, FALSE, FALSE, 0);
 
@@ -528,6 +548,7 @@ org_credativ_evolution_readpst_getwidget (EImport *ei,
                                           EImportImporter *im)
 {
 	EShell *shell;
+	ESourceRegistry *registry;
 	EShellBackend *shell_backend;
 	EMailBackend *backend;
 	EMailSession *session;
@@ -548,6 +569,7 @@ org_credativ_evolution_readpst_getwidget (EImport *ei,
 	gtk_box_pack_start ((GtkBox *) hbox, check, FALSE, FALSE, 0);
 
 	shell = e_shell_get_default ();
+	registry = e_shell_get_registry (shell);
 	shell_backend = e_shell_get_backend_by_name (shell, "mail");
 
 	backend = E_MAIL_BACKEND (shell_backend);
@@ -579,22 +601,22 @@ org_credativ_evolution_readpst_getwidget (EImport *ei,
 
 	add_source_list_with_check (
 		framebox, _("_Address Book"),
-		E_CLIENT_SOURCE_TYPE_CONTACTS,
+		registry, E_CLIENT_SOURCE_TYPE_CONTACTS,
 		G_CALLBACK (checkbox_addr_toggle_cb), target,
 		GPOINTER_TO_INT (g_datalist_get_data (&target->data, "pst-do-addr")));
 	add_source_list_with_check (
 		framebox, _("A_ppointments"),
-		E_CLIENT_SOURCE_TYPE_EVENTS,
+		registry, E_CLIENT_SOURCE_TYPE_EVENTS,
 		G_CALLBACK (checkbox_appt_toggle_cb), target,
 		GPOINTER_TO_INT (g_datalist_get_data (&target->data, "pst-do-appt")));
 	add_source_list_with_check (
 		framebox, _("_Tasks"),
-		E_CLIENT_SOURCE_TYPE_TASKS,
+		registry, E_CLIENT_SOURCE_TYPE_TASKS,
 		G_CALLBACK (checkbox_task_toggle_cb), target,
 		GPOINTER_TO_INT (g_datalist_get_data (&target->data, "pst-do-task")));
 	add_source_list_with_check (
 		framebox, _("_Journal entries"),
-		E_CLIENT_SOURCE_TYPE_MEMOS,
+		registry, E_CLIENT_SOURCE_TYPE_MEMOS,
 		G_CALLBACK (checkbox_journal_toggle_cb), target,
 		GPOINTER_TO_INT (g_datalist_get_data (&target->data, "pst-do-journal")));
 
@@ -673,7 +695,6 @@ open_client (PstImporter *m,
 
 	e_client_utils_open_new (
 		source, source_type, FALSE, m->cancellable,
-		e_client_utils_authenticate_handler, NULL,
 		client_opened_cb, m);
 }
 



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