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



commit 93dae2678ba40ab2386d80ff65f01f9dfcbb4760
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 d4054b5..a30cf59 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -45,13 +45,17 @@
 
 #include <libebook/e-contact.h>
 #include <libebook/e-book-client.h>
+#include <libebook/e-source-address-book.h>
 
 #include <libecal/e-cal-client.h>
 #include <libecal/e-cal-component.h>
+#include <libecal/e-source-calendar.h>
 
 #include <libedataserver/e-data-server-util.h>
-#include <libedataserverui/e-source-combo-box.h>
+#include <libedataserver/e-source-registry.h>
 #include <libedataserverui/e-client-utils.h>
+#include <libedataserverui/e-source-combo-box.h>
+#include <libedataserverui/e-source-selector-dialog.h>
 
 #include <mail/e-mail-backend.h>
 #include <mail/e-mail-local.h>
@@ -382,19 +386,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);
@@ -402,22 +429,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 (registry, extension_name);
+	e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (combo), 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);
+	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);
 
@@ -523,6 +543,7 @@ org_credativ_evolution_readpst_getwidget (EImport *ei,
                                           EImportImporter *im)
 {
 	EShell *shell;
+	ESourceRegistry *registry;
 	EShellBackend *shell_backend;
 	GtkWidget *hbox, *framebox, *w, *check;
 	gchar *foldername;
@@ -539,6 +560,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");
 
 	w = em_folder_selection_button_new (
@@ -562,22 +584,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")));
 
@@ -656,7 +678,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]