[evolution/account-mgmt: 21/50] Adapt evolution-settings capplet to the new ESource API.



commit a3adfa9582500e46dae8ba53c600fd54d37d19a4
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Mar 28 08:28:51 2011 -0400

    Adapt evolution-settings capplet to the new ESource API.

 capplet/settings/mail-account-view.c  |   40 ++++++--------
 capplet/settings/mail-account-view.h  |    3 +-
 capplet/settings/mail-capplet-shell.c |   98 ---------------------------------
 capplet/settings/mail-settings-view.c |   18 +++++-
 capplet/settings/mail-view.c          |    8 +++
 5 files changed, 41 insertions(+), 126 deletions(-)
---
diff --git a/capplet/settings/mail-account-view.c b/capplet/settings/mail-account-view.c
index 5947440..7a78595 100644
--- a/capplet/settings/mail-account-view.c
+++ b/capplet/settings/mail-account-view.c
@@ -27,9 +27,6 @@
 #include <glib/gi18n.h>
 #include "mail-account-view.h"
 #include <libedataserverui/e-passwords.h>
-#include <libedataserver/e-source-group.h>
-#include <libedataserver/e-source-list.h>
-#include <libedataserver/e-account-list.h>
 #include "mail-view.h"
 #include "e-util/e-config.h"
 #include "mail/e-mail-backend.h"
@@ -159,6 +156,7 @@ save_identity (MailAccountView *view)
 static gint
 validate_identity (MailAccountView *view)
 {
+#if 0  /* ACCOUNT_MGMT */
 	gchar *user = (gchar *) e_account_get_string (em_account_editor_get_modified_account (view->edit), E_ACCOUNT_ID_NAME);
 	gchar *email = (gchar *) e_account_get_string (em_account_editor_get_modified_account (view->edit), E_ACCOUNT_ID_ADDRESS);
 	gchar *tmp;
@@ -176,20 +174,10 @@ validate_identity (MailAccountView *view)
 	tmp = strchr (email, '@');
 	if (!tmp || tmp[1] == 0)
 		return ERROR_INVALID_EMAIL;
+#endif /* ACCOUNT_MGMT */
 
 	return 0;
 }
-#ifdef NOT_USED
-static void
-save_send (MailAccountView *view)
-{
-}
-
-static void
-save_account (MailAccountView *view)
-{
-}
-#endif
 
 #define PACK_BOX(w) box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start((GtkBox *)box, w, FALSE, FALSE, 12); gtk_widget_show(box);
 #define PACK_BOXF(w) box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start((GtkBox *)box, w, FALSE, FALSE, 0); gtk_widget_show(box);
@@ -262,11 +250,10 @@ add_selected_calendar (const gchar *uid)
 static void
 setup_yahoo_account (MailAccountView *mav)
 {
-	GConfClient *gconf = gconf_client_get_default ();
-
 	mav->priv->do_gcontacts = gtk_toggle_button_get_active ((GtkToggleButton *) mav->priv->gcontacts);
 	mav->priv->do_calendar = gtk_toggle_button_get_active ((GtkToggleButton *) mav->priv->calendar);
 
+#if 0  /* ACCOUNT_MGMT */
 	if (mav->priv->do_calendar) {
 		ESourceList *slist;
 		ESourceGroup *sgrp;
@@ -352,18 +339,16 @@ setup_yahoo_account (MailAccountView *mav)
 		g_object_unref (abook);
 
 	}
-
-	g_object_unref (gconf);
+#endif /* ACCOUNT_MGMT */
 }
 
 static void
 setup_google_accounts (MailAccountView *mav)
 {
-	GConfClient *gconf = gconf_client_get_default ();
-
 	mav->priv->do_gcontacts = gtk_toggle_button_get_active ((GtkToggleButton *) mav->priv->gcontacts);
 	mav->priv->do_calendar = gtk_toggle_button_get_active ((GtkToggleButton *) mav->priv->calendar);
 
+#if 0  /* ACCOUNT_MGMT */
 	if (mav->priv->do_calendar) {
 		ESourceList *slist;
 		ESourceGroup *sgrp;
@@ -460,8 +445,7 @@ setup_google_accounts (MailAccountView *mav)
 		g_object_unref (slist);
 		g_object_unref (sgrp);
 	}
-
-	g_object_unref (gconf);
+#endif /* ACCOUNT_MGMT */
 }
 
 #define INDENTATION 10
@@ -469,6 +453,7 @@ setup_google_accounts (MailAccountView *mav)
 static GtkWidget *
 create_review (MailAccountView *view)
 {
+#if 0  /* ACCOUNT_MGMT */
 	GtkWidget *table, *box, *label, *entry;
 	gchar *uri;
 	gchar *enc;
@@ -608,6 +593,9 @@ create_review (MailAccountView *view)
 	gtk_widget_show (table);
 
 	return table;
+#endif /* ACCOUNT_MGMT */
+
+	return NULL;
 }
 
 #define IDENTITY_DETAIL N_("To use the email application you'll need to setup an account. Put your email address and password in below and we'll try and work out all the settings. If we can't do it automatically you'll need your server details as well.")
@@ -647,6 +635,7 @@ static void
 mav_next_pressed (GtkButton *button,
                   MailAccountView *mav)
 {
+#if 0  /* ACCOUNT_MGMT */
 	if (mail_account_pages[mav->current_page].validate_page) {
 		gint ret = (*mail_account_pages[mav->current_page].validate_page) (mav);
 		MAVPage *page = mav->pages[mav->current_page];
@@ -691,8 +680,10 @@ mav_next_pressed (GtkButton *button,
 			/* Save the password ahead of time */
 			aurl = camel_url_new (account->source->url, NULL);
 			surl = camel_url_to_string (aurl, CAMEL_URL_HIDE_ALL);
+#if 0  /* ACCOUNT_MGMT */
 			e_passwords_add_password (surl, gtk_entry_get_text ((GtkEntry *) mav->password));
 			e_passwords_remember_password (NULL, surl);
+#endif /* ACCOUNT_MGMT */
 			camel_url_free (aurl);
 			g_free (surl);
 		}
@@ -853,6 +844,7 @@ mav_next_pressed (GtkButton *button,
 				mav_next_pressed (NULL, mav);
 		}
 	}
+#endif /* ACCOUNT_MGMT */
 }
 
 static void
@@ -975,6 +967,7 @@ next_page (GtkWidget *entry,
 	mav_next_pressed (NULL, mav);
 }
 
+#if 0  /* ACCOUNT_MGMT */
 static void
 mail_account_view_construct (MailAccountView *view,
                              EMailBackend *backend)
@@ -1000,7 +993,7 @@ mail_account_view_construct (MailAccountView *view,
 	view->current_page = 0;
 	gtk_box_pack_start ((GtkBox *) view, view->scroll, TRUE, TRUE, 0);
 	view->edit = em_account_editor_new_for_pages (
-		view->original, EMAE_PAGES, backend,
+		view->original, EMAE_PAGES, session,
 		"org.gnome.evolution.mail.config.accountWizard", view->wpages);
 	gtk_widget_hide (e_config_create_widget (E_CONFIG (view->edit->config)));
 	if (!view->original) {
@@ -1047,6 +1040,7 @@ mail_account_view_new (EAccount *account,
 
 	return view;
 }
+#endif /* ACCOUNT_MGMT */
 
 static void
 mav_close (GtkButton *w,
diff --git a/capplet/settings/mail-account-view.h b/capplet/settings/mail-account-view.h
index 0a582c4..f50ef71 100644
--- a/capplet/settings/mail-account-view.h
+++ b/capplet/settings/mail-account-view.h
@@ -25,7 +25,6 @@
 
 #include <gtk/gtk.h>
 #include "mail/em-account-editor.h"
-#include <libedataserver/e-account-list.h>
 #include "mail-view.h"
 
 #define MAIL_ACCOUNT_VIEW_TYPE        (mail_account_view_get_type ())
@@ -87,7 +86,9 @@ typedef struct _MailAccountViewClass {
 } MailAccountViewClass;
 
 GType mail_account_view_get_type (void);
+#if 0  /* ACCOUNT_MGMT */
 MailAccountView *mail_account_view_new (EAccount *account, EMailBackend *backend);
+#endif /* ACCOUNT_MGMT */
 GtkWidget * mail_account_view_get_tab_widget (MailAccountView *mcv);
 void mail_account_view_activate (MailAccountView *mcv, GtkWidget *tree, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, gboolean act);
 #endif
diff --git a/capplet/settings/mail-capplet-shell.c b/capplet/settings/mail-capplet-shell.c
index 3d3e015..ef9dc8a 100644
--- a/capplet/settings/mail-capplet-shell.c
+++ b/capplet/settings/mail-capplet-shell.c
@@ -86,8 +86,6 @@ static void mail_capplet_shell_quit (MailCappletShell *shell);
 
 G_DEFINE_TYPE (MailCappletShell, mail_capplet_shell, GTK_TYPE_WINDOW)
 
-static void setup_abooks (void);
-
 static void
 mail_capplet_shell_init (MailCappletShell *shell)
 {
@@ -282,7 +280,6 @@ mail_capplet_shell_construct (MailCappletShell *shell,
 		gtk_notebook_set_show_tabs ((GtkNotebook *) shell->view, FALSE);
 		mc = mail_view_add_page ((MailView *) shell->view, MAIL_VIEW_ACCOUNT, NULL);
 		g_signal_connect (mc, "view-close", G_CALLBACK(ms_show_post_druid), shell);
-		setup_abooks ();
 	} else
 		shell->priv->settings_view = mail_view_add_page ((MailView *) shell->view, MAIL_VIEW_SETTINGS, NULL);
 
@@ -298,98 +295,3 @@ mail_capplet_shell_new (gint socket_id,
 
 	return GTK_WIDGET (shell);
 }
-
-#define LOCAL_BASE_URI "local:"
-#define PERSONAL_RELATIVE_URI "system"
-
-static void
-setup_abooks (void)
-{
-	GSList *groups;
-	ESourceGroup *group;
-	ESourceList *list = NULL;
-	ESourceGroup *on_this_computer = NULL;
-	ESource *personal_source = NULL;
-	GError *error = NULL;
-
-	e_book_client_get_sources (&list, &error);
-
-	if (error != NULL) {
-		g_warning (
-			"%s: Unable to get books: %s",
-			G_STRFUNC, error->message);
-		g_error_free (error);
-		return;
-	}
-
-	groups = e_source_list_peek_groups (list);
-	if (groups) {
-		/* groups are already there, we need to search for things... */
-		GSList *g;
-		gchar *base_dir, *base_uri;
-
-		base_dir = g_build_filename (
-			e_get_user_data_dir (), "addressbook", "local", NULL);
-		base_uri = g_filename_to_uri (base_dir, NULL, NULL);
-
-		for (g = groups; g; g = g->next) {
-			group = E_SOURCE_GROUP (g->data);
-
-			if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0)
-				e_source_group_set_base_uri (group, LOCAL_BASE_URI);
-
-			if (!on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) {
-				on_this_computer = g_object_ref (group);
-				break;
-			}
-		}
-
-		g_free (base_dir);
-		g_free (base_uri);
-	}
-
-	if (on_this_computer) {
-		/* make sure "Personal" shows up as a source under
-		 * this group */
-		GSList *sources = e_source_group_peek_sources (on_this_computer);
-		GSList *s;
-		for (s = sources; s; s = s->next) {
-			ESource *source = E_SOURCE (s->data);
-			const gchar *relative_uri;
-
-			relative_uri = e_source_peek_relative_uri (source);
-			if (relative_uri == NULL)
-				continue;
-			if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
-				personal_source = g_object_ref (source);
-				break;
-			}
-		}
-	}
-	else {
-		/* create the local source group */
-		group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI);
-		e_source_list_add_group (list, group, -1);
-
-		on_this_computer = group;
-	}
-
-	if (!personal_source) {
-		/* Create the default Person addressbook */
-		ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
-		e_source_group_add_source (on_this_computer, source, -1);
-
-		e_source_set_property (source, "completion", "true");
-
-		personal_source = source;
-	}
-
-	if (on_this_computer)
-		g_object_unref (on_this_computer);
-	if (personal_source)
-		g_object_unref (personal_source);
-
-	e_source_list_sync (list, NULL);
-	g_object_unref (list);
-}
-
diff --git a/capplet/settings/mail-settings-view.c b/capplet/settings/mail-settings-view.c
index 992f705..f1d16a9 100644
--- a/capplet/settings/mail-settings-view.c
+++ b/capplet/settings/mail-settings-view.c
@@ -25,9 +25,6 @@
 #endif
 
 #include <glib/gi18n.h>
-#include <libedataserver/e-account-list.h>
-
-#include <libemail-utils/e-account-utils.h>
 
 #include "mail-settings-view.h"
 #include "mail-view.h"
@@ -38,7 +35,9 @@ struct _MailSettingsViewPrivate {
 	GtkWidget *scroll;
 	GtkWidget *box;
 
+#if 0  /* ACCOUNT_MGMT */
 	EAccountList *accounts;
+#endif /* ACCOUNT_MGMT */
 };
 
 G_DEFINE_TYPE (MailSettingsView, mail_settings_view, GTK_TYPE_VBOX)
@@ -99,15 +98,18 @@ static void
 msv_edit_account (GtkButton *button,
                   MailSettingsView *msv)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EAccount *acc = g_object_get_data((GObject *)button, "account");
 
 	g_signal_emit (msv, signals[SHOW_ACCOUNT], 0, acc);
+#endif /* ACCOUNT_MGMT */
 }
 
 static void
 msv_delete_account (GtkButton *button,
                     MailSettingsView *msv)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EAccount *account = g_object_get_data((GObject *)button, "account");
 	EAccountList *account_list = e_get_account_list ();
 
@@ -116,9 +118,10 @@ msv_delete_account (GtkButton *button,
 	e_account_list_save (account_list);
 
 	msv_regen_view (msv);
-
+#endif /* ACCOUNT_MGMT */
 }
 
+#if 0  /* ACCOUNT_MGMT */
 static void
 msv_account_added (EAccountList *al,
                    EAccount *account,
@@ -126,9 +129,11 @@ msv_account_added (EAccountList *al,
 {
 	msv_regen_view (msv);
 }
+#endif /* ACCOUNT_MGMT */
 
 #define PACK_BOX(w,s) box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start((GtkBox *)box, w, FALSE, FALSE, s); gtk_widget_show(box); gtk_widget_show(w); gtk_box_pack_start((GtkBox *)acview->priv->box, box, FALSE, FALSE, 3);
 
+#if 0  /* ACCOUNT_MGMT */
 static void
 build_account_button (MailSettingsView *acview,
                       EAccount *account)
@@ -174,10 +179,12 @@ build_account_button (MailSettingsView *acview,
 
 	PACK_BOX (box1,24);
 }
+#endif /* ACCOUNT_MGMT */
 
 static void
 msv_regen_view (MailSettingsView *acview)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EAccount *account;
 	EAccountList *accounts = acview->priv->accounts;
 	EIterator *node;
@@ -200,6 +207,7 @@ msv_regen_view (MailSettingsView *acview)
 	}
 	g_object_unref (node);
 	build_account_button (acview, NULL);
+#endif /* ACCOUNT_MGMT */
 }
 
 static void
@@ -213,8 +221,10 @@ mail_settings_view_construct (MailSettingsView *acview)
 	gtk_widget_show (acview->priv->box);
 	gtk_scrolled_window_add_with_viewport ((GtkScrolledWindow *) acview->priv->scroll, acview->priv->box);
 
+#if 0  /* ACCOUNT_MGMT */
 	acview->priv->accounts = e_get_account_list ();
 	g_signal_connect (acview->priv->accounts, "account-added", G_CALLBACK(msv_account_added), acview);
+#endif /* ACCOUNT_MGMT */
 	msv_regen_view (acview);
 	gtk_widget_show ((GtkWidget *) acview);
 
diff --git a/capplet/settings/mail-view.c b/capplet/settings/mail-view.c
index 4477be5..80c10d1 100644
--- a/capplet/settings/mail-view.c
+++ b/capplet/settings/mail-view.c
@@ -414,6 +414,7 @@ mail_view_add_message (MailView *mv,
 
 #endif
 
+#if 0  /* ACCOUNT_MGMT */
 static void
 mv_show_acc_mcv (MailViewChild *mfv,
                  EAccount *account,
@@ -421,6 +422,7 @@ mv_show_acc_mcv (MailViewChild *mfv,
 {
 	mail_view_add_page (mv, MAIL_VIEW_ACCOUNT, account);
 }
+#endif /* ACCOUNT_MGMT */
 
 static MailViewChild *
 mail_view_add_settings (MailView *mv,
@@ -437,7 +439,9 @@ mail_view_add_settings (MailView *mv,
 
 	position = gtk_notebook_append_page ((GtkNotebook *) mv, (GtkWidget *) msv, mail_settings_view_get_tab_widget (msv));
 	g_signal_connect (msv, "view-close", G_CALLBACK(mv_close_mcv), mv);
+#if 0  /* ACCOUNT_MGMT */
 	g_signal_connect (msv, "show-account", G_CALLBACK(mv_show_acc_mcv), mv);
+#endif /* ACCOUNT_MGMT */
 	gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (mv), (GtkWidget *) msv, TRUE);
 	gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (mv), (GtkWidget *) msv, FALSE);
 	if (!block)
@@ -453,6 +457,7 @@ mail_view_add_account (MailView *mv,
                        gpointer data,
                        gboolean block)
 {
+#if 0  /* ACCOUNT_MGMT */
 	MailAccountView *msv;
 	gint position = 0;
 
@@ -471,6 +476,9 @@ mail_view_add_account (MailView *mv,
 		 mail_account_view_activate (msv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
 
 	return (MailViewChild *) msv;
+#endif /* ACCOUNT_MGMT */
+
+	return NULL;
 }
 
 MailViewChild *



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