[evolution-groupwise] Adapt to Evolution's EMConfig API changes.



commit c4046447364487f0148a3ae9d59020b85b1c7438
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Nov 6 12:17:34 2011 -0500

    Adapt to Evolution's EMConfig API changes.

 src/plugins/org-gnome-groupwise-features.eplug.xml |   10 +-
 src/plugins/proxy.c                                |  228 +++++++++-----------
 src/plugins/proxy.h                                |   18 +-
 src/plugins/send-options.c                         |   77 ++++---
 4 files changed, 156 insertions(+), 177 deletions(-)
---
diff --git a/src/plugins/org-gnome-groupwise-features.eplug.xml b/src/plugins/org-gnome-groupwise-features.eplug.xml
index 08001f9..080ee4f 100644
--- a/src/plugins/org-gnome-groupwise-features.eplug.xml
+++ b/src/plugins/org-gnome-groupwise-features.eplug.xml
@@ -17,20 +17,20 @@
 			<group id="org.gnome.evolution.mail.folderConfig" target="folder" check= "shared_folder_check" commit="shared_folder_commit" abort ="shared_folder_abort">
 				<item type="page" path="10.shared" label="Shared" factory="org_gnome_shared_folder_factory"/>
 			</group>
-			<group id="org.gnome.evolution.mail.config.accountEditor" target="account" check  = "send_options_changed" commit = "send_options_commit" abort  = "send_options_abort">
+			<group id="org.gnome.evolution.mail.config.accountEditor" target="settings" check  = "send_options_changed" commit = "send_options_commit" abort  = "send_options_abort">
 				<item type="section" path="40.defaults/50.send_options" label="Send Options" factory="org_gnome_send_options" />
 			</group>
-			<group id="org.gnome.evolution.mail.config.accountEditor" target="account" commit = "proxy_commit" abort="proxy_abort">
+			<group id="org.gnome.evolution.mail.config.accountEditor" target="settings" commit = "proxy_commit" abort="proxy_abort">
 				<item type="page" path="60.proxy" factory="org_gnome_proxy"/>
 			</group>
 
-			<group target="account" id="org.gnome.evolution.mail.config.accountAssistant">
+			<group target="settings" id="org.gnome.evolution.mail.config.accountAssistant">
 				<item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
 			</group>
-			<group target="account" id="org.gnome.evolution.mail.config.accountEditor">
+			<group target="settings" id="org.gnome.evolution.mail.config.accountEditor">
 				<item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
 			</group>
-			<group target="account" id="org.gnome.evolution.mail.config.accountWizard">
+			<group target="settings" id="org.gnome.evolution.mail.config.accountWizard">
 				<item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
 			</group>
 		</hook>
diff --git a/src/plugins/proxy.c b/src/plugins/proxy.c
index d067891..43baa10 100644
--- a/src/plugins/proxy.c
+++ b/src/plugins/proxy.c
@@ -61,7 +61,7 @@
 
 static GObjectClass *parent_class = NULL;
 
-static gboolean proxy_page_changed_cb (GtkNotebook *notebook, GtkWidget *page, gint num, EAccount *account);
+static gboolean proxy_page_changed_cb (GtkNotebook *notebook, GtkWidget *page, gint num, CamelSettings *settings);
 
 struct _proxyDialogPrivate {
 	/* UI data for the Add/Edit Proxy dialog*/
@@ -251,13 +251,13 @@ proxy_dialog_new (void)
 }
 
 static gint
-proxy_get_permissions_from_dialog (EAccount *account)
+proxy_get_permissions_from_dialog (CamelSettings *settings)
 {
 	gint permissions;
 	proxyDialogPrivate *priv;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	permissions = 0;
 
@@ -301,7 +301,7 @@ proxy_get_permissions_from_dialog (EAccount *account)
 }
 
 static gint
-proxy_dialog_store_widgets_data (EAccount *account,
+proxy_dialog_store_widgets_data (CamelSettings *settings,
                                  gint32 dialog,
                                  GtkWindow *parent)
 {
@@ -313,7 +313,7 @@ proxy_dialog_store_widgets_data (EAccount *account,
 	gchar *account_mailid;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 
 	switch (dialog)
@@ -365,7 +365,7 @@ proxy_dialog_store_widgets_data (EAccount *account,
 						new_proxy = (proxyHandler *) existing_list->data;
 						if (!g_ascii_strcasecmp (new_proxy->proxy_email, email)) {
 							if (new_proxy->flags & E_GW_PROXY_DELETED) {
-								new_proxy->permissions = proxy_get_permissions_from_dialog (account);
+								new_proxy->permissions = proxy_get_permissions_from_dialog (settings);
 								if (new_proxy->flags & E_GW_PROXY_NEW)
 									new_proxy->flags = E_GW_PROXY_NEW;
 								else
@@ -400,7 +400,7 @@ proxy_dialog_store_widgets_data (EAccount *account,
 					new_proxy->proxy_email = g_strdup (email);
 					new_proxy->uniqueid = NULL;
 					new_proxy->flags =  E_GW_PROXY_NEW;
-					new_proxy->permissions = proxy_get_permissions_from_dialog (account);
+					new_proxy->permissions = proxy_get_permissions_from_dialog (settings);
 
 					priv->proxy_list = g_list_append (priv->proxy_list, new_proxy);
 				}
@@ -411,12 +411,12 @@ proxy_dialog_store_widgets_data (EAccount *account,
 			gtk_tree_selection_get_selected (account_select, &model, &iter);
 			gtk_tree_model_get (model, &iter, ACCOUNT_NAME, &account_mailid, -1);
 			account_mailid = g_strrstr (account_mailid, "\n") + 1;
-			new_proxy = proxy_get_item_from_list (account, account_mailid);
+			new_proxy = proxy_get_item_from_list (settings, account_mailid);
 
 			if (!new_proxy->flags & E_GW_PROXY_NEW)
 				new_proxy->flags = E_GW_PROXY_EDITED;
 
-			new_proxy->permissions = proxy_get_permissions_from_dialog (account);
+			new_proxy->permissions = proxy_get_permissions_from_dialog (settings);
 			break;
 		default:
 			return -1;
@@ -426,12 +426,12 @@ proxy_dialog_store_widgets_data (EAccount *account,
 }
 
 static gboolean
-proxy_dialog_initialize_widgets (EAccount *account)
+proxy_dialog_initialize_widgets (CamelSettings *settings)
 {
 	proxyDialogPrivate *priv;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	priv->account_name = GW ("proxy_account_name");
 	priv->mail_read = GW ("mailRead");
@@ -463,29 +463,28 @@ proxy_dialog_initialize_widgets (EAccount *account)
 }
 
 static EGwConnection *
-proxy_get_cnc (EAccount *account,
+proxy_get_cnc (CamelSettings *settings,
                GtkWindow *parent_window)
 {
-	CamelSettings *settings;
-	EGwConnection *cnc;
+	CamelNetworkSettings *network_settings;
 	const gchar *failed_auth;
 	gchar *uri, *key, *prompt, *password = NULL;
-	CamelURL *url;
 	CamelNetworkSecurityMethod security_method;
-	const gchar *poa_address;
 	const gchar *scheme;
+	const gchar *host;
+	const gchar *user;
 	gboolean remember;
 	gchar *soap_port;
 
-	url = camel_url_new (account->source->url, NULL);
-	if (url == NULL)
-		return NULL;
-	poa_address = url->host;
-	if (!poa_address || strlen (poa_address) ==0)
+	if (!CAMEL_IS_GROUPWISE_SETTINGS (settings))
 		return NULL;
 
-	settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
-	camel_settings_load_from_url (settings, url);
+	network_settings = CAMEL_NETWORK_SETTINGS (settings);
+	host = camel_network_settings_get_host (network_settings);
+	user = camel_network_settings_get_user (network_settings);
+
+	if (host == NULL || *host == '\0')
+		return NULL;
 
 	g_object_get (
 		settings,
@@ -493,22 +492,19 @@ proxy_get_cnc (EAccount *account,
 		"security-method", &security_method,
 		NULL);
 
-	g_object_unref (settings);
-
 	if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
 		scheme = "http";
 	else
 		scheme = "https";
 
-	key =  g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+	key =  g_strdup_printf ("groupwise://%s %s/", user, host);
 
-	uri = g_strdup_printf ("%s://%s:%s/soap", scheme, poa_address, soap_port);
+	uri = g_strdup_printf ("%s://%s:%s/soap", scheme, host, soap_port);
 
 	failed_auth = "";
-	cnc = NULL;
 
 	prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"),
-			failed_auth, poa_address, url->user);
+			failed_auth, host, user);
 
 	password = e_passwords_get_password (NULL, key);
 	if (!password)
@@ -516,24 +512,20 @@ proxy_get_cnc (EAccount *account,
 				E_PASSWORDS_REMEMBER_FOREVER | E_PASSWORDS_SECRET, &remember, parent_window);
 	g_free (prompt);
 
-	cnc = e_gw_connection_new (uri, url->user, password);
-
-	camel_url_free (url);
-
-	return cnc;
+	return e_gw_connection_new (uri, user, password);
 }
 
 void
 proxy_abort (GtkWidget *button,
              EConfigHookItemFactoryData *data)
 {
-	EMConfigTargetAccount *target_account;
-	EAccount *account;
+	EMConfigTargetSettings *target_account;
+	GObject *object;
 	proxyDialog *prd = NULL;
 
-	target_account = (EMConfigTargetAccount *) data->config->target;
-	account = target_account->modified_account;
-	prd = g_object_get_data ((GObject *)account, "prd");
+	target_account = (EMConfigTargetSettings *) data->config->target;
+	object = G_OBJECT (target_account->storage_settings);
+	prd = g_object_get_data (object, "prd");
 
 	if (!prd || !prd->priv || !prd->priv->proxy_list)
 		return;
@@ -546,16 +538,16 @@ void
 proxy_commit (GtkWidget *button,
               EConfigHookItemFactoryData *data)
 {
-	EAccount *account;
-	EMConfigTargetAccount *target_account;
+	EMConfigTargetSettings *target_account;
 	proxyDialogPrivate *priv;
 	GList *list_iter;
+	GObject *object;
 	proxyHandler *aclInstance;
 	proxyDialog *prd = NULL;
 
-	target_account = (EMConfigTargetAccount *) data->config->target;
-	account = target_account->modified_account;
-	prd = g_object_get_data ((GObject *)account, "prd");
+	target_account = (EMConfigTargetSettings *) data->config->target;
+	object = G_OBJECT (target_account->storage_settings);
+	prd = g_object_get_data (object, "prd");
 
 	/* In case of non-GroupWise preferences edit, "prd" will be NULL. */
 	if (!prd || !prd->priv || !prd->priv->proxy_list)
@@ -570,7 +562,7 @@ proxy_commit (GtkWidget *button,
 		if ( !((aclInstance->flags & E_GW_PROXY_NEW) && (aclInstance->flags & E_GW_PROXY_DELETED))) {
 
 			if ( !E_IS_GW_CONNECTION (prd->cnc))	/* Add check in case the connection request fails */
-				prd->cnc = proxy_get_cnc (account, GTK_WINDOW (gtk_widget_get_toplevel (button)));
+				prd->cnc = proxy_get_cnc (target_account->storage_settings, GTK_WINDOW (gtk_widget_get_toplevel (button)));
 
 			if (aclInstance->flags & E_GW_PROXY_NEW )
 				e_gw_connection_add_proxy (prd->cnc, aclInstance);
@@ -588,7 +580,7 @@ proxy_commit (GtkWidget *button,
 }
 
 static void
-proxy_setup_meta_tree_view (EAccount *account)
+proxy_setup_meta_tree_view (CamelSettings *settings)
 {
 	proxyDialog *prd = NULL;
 	proxyDialogPrivate *priv;
@@ -596,7 +588,7 @@ proxy_setup_meta_tree_view (EAccount *account)
 	GtkCellRenderer *renderer;
 	GtkTreeViewColumn *column;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF,
 				 "xpad", 4,
@@ -614,7 +606,7 @@ proxy_setup_meta_tree_view (EAccount *account)
 }
 
 static void
-proxy_update_tree_view (EAccount *account)
+proxy_update_tree_view (CamelSettings *settings)
 {
 	proxyDialog *prd = NULL;
 	GtkTreeIter iter;
@@ -624,7 +616,7 @@ proxy_update_tree_view (EAccount *account)
 	gchar *file_name = e_icon_factory_get_icon_filename ("avatar-default", GTK_ICON_SIZE_DIALOG);
 	proxyDialogPrivate *priv;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	broken_image = gdk_pixbuf_new_from_file (file_name, NULL);
 
@@ -652,80 +644,60 @@ GtkWidget *
 org_gnome_proxy (EPlugin *epl,
                  EConfigHookItemFactoryData *data)
 {
-	EMConfigTargetAccount *target_account;
-	EShell *shell;
-	EShellBackend *shell_backend;
-	EMailSession *session;
-	EAccount *account;
+	EMConfigTargetSettings *target_account;
+	CamelSettings *settings;
 	GtkButton *addProxy, *removeProxy, *editProxy;
 	proxyDialog *prd;
 	proxyDialogPrivate *priv;
-	CamelOfflineStore *store;
 	gint pag_num;
 
-	shell = e_shell_get_default ();
-	shell_backend = e_shell_get_backend_by_name (shell, "mail");
-	session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
-
-	target_account = (EMConfigTargetAccount *) data->config->target;
-	account = target_account->modified_account;
-	/* We are using some g_object_set on this. We shuold also avoid double-free later. So reffing */
-	g_object_ref (account);
+	target_account = (EMConfigTargetSettings *) data->config->target;
+	settings = target_account->storage_settings;
 
-	store = (CamelOfflineStore *) camel_session_get_service (
-		CAMEL_SESSION (session), account->uid);
-	if (store == NULL)
-		return NULL;
-
-	if (g_strrstr (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), "groupwise://"))
-	{
+	if (CAMEL_IS_GROUPWISE_SETTINGS (settings)) {
 		prd = proxy_dialog_new ();
-		g_object_set_data_full ((GObject *) account, "prd", prd, (GDestroyNotify) g_object_unref);
+		g_object_set_data_full (
+			G_OBJECT (settings), "prd", prd,
+			(GDestroyNotify) g_object_unref);
 		priv = prd->priv;
 
 		priv->builder_tab = gtk_builder_new ();
 		e_load_ui_builder_definition (priv->builder_tab, "proxy-listing.ui");
 
-		if (account->enabled && camel_offline_store_get_online (store)) {
+		if (e_shell_get_network_available (e_shell_get_default ())) {
 			priv->tab_dialog = GTK_WIDGET (e_builder_get_widget (priv->builder_tab, "proxy_vbox"));
 			priv->tree = GTK_TREE_VIEW (e_builder_get_widget (priv->builder_tab, "proxy_access_list"));
 			priv->store =  gtk_tree_store_new (2,
 							   GDK_TYPE_PIXBUF,
 							   G_TYPE_STRING
 				);
-			proxy_setup_meta_tree_view (account);
+			proxy_setup_meta_tree_view (settings);
 
 			addProxy = (GtkButton *) e_builder_get_widget (priv->builder_tab, "add_proxy");
 			removeProxy = (GtkButton *) e_builder_get_widget (priv->builder_tab, "remove_proxy");
 			editProxy = (GtkButton *) e_builder_get_widget (priv->builder_tab, "edit_proxy");
 
-			g_signal_connect (addProxy, "clicked", G_CALLBACK(proxy_add_account), account);
-			g_signal_connect (removeProxy, "clicked", G_CALLBACK(proxy_remove_account), account);
-			g_signal_connect (editProxy, "clicked", G_CALLBACK(proxy_edit_account), account);
+			g_signal_connect (addProxy, "clicked", G_CALLBACK(proxy_add_account), settings);
+			g_signal_connect (removeProxy, "clicked", G_CALLBACK(proxy_remove_account), settings);
+			g_signal_connect (editProxy, "clicked", G_CALLBACK(proxy_edit_account), settings);
 
 			priv->proxy_list = NULL;
-		} else if (account->enabled) {
-			GtkWidget *label;
-			priv->tab_dialog = gtk_vbox_new (TRUE, 10);
-			/*To Translators: In this case, Proxy does not mean something like 'HTTP Proxy', but a GroupWise feature by which one person can send/read mails/appointments using another person's identity without knowing his password, for example if that other person is on vacation*/
-			label = gtk_label_new (_("The Proxy tab will be available only when the account is online."));
-			gtk_box_pack_start ((GtkBox *) priv->tab_dialog, label, TRUE, TRUE, 10);
 		} else {
 			GtkWidget *label;
 			priv->tab_dialog = gtk_vbox_new (TRUE, 10);
 			/*To Translators: In this case, Proxy does not mean something like 'HTTP Proxy', but a GroupWise feature by which one person can send/read mails/appointments using another person's identity without knowing his password, for example if that other person is on vacation*/
-			label = gtk_label_new (_("The Proxy tab will be available only when the account is enabled."));
+			label = gtk_label_new (_("The Proxy tab will be available only when the account is online."));
 			gtk_box_pack_start ((GtkBox *) priv->tab_dialog, label, TRUE, TRUE, 10);
 		}
 
 		/*To Translators: In this case, Proxy does not mean something like 'HTTP Proxy', but a GroupWise feature by which one person can send/read mails/appointments using another person's identity without knowing his password, for example if that other person is on vacation*/
 		gtk_notebook_append_page ((GtkNotebook *)(data->parent), (GtkWidget *)priv->tab_dialog, gtk_label_new (C_("GW", "Proxy")));
-		g_signal_connect ((GtkNotebook *)(data->parent), "switch-page", G_CALLBACK (proxy_page_changed_cb), account);
+		g_signal_connect ((GtkNotebook *)(data->parent), "switch-page", G_CALLBACK (proxy_page_changed_cb), settings);
 		pag_num = gtk_notebook_page_num ((GtkNotebook *)(data->parent), (GtkWidget *) priv->tab_dialog);
-		g_object_set_data ((GObject *) account, "proxy_tab_num", GINT_TO_POINTER (pag_num));
+		g_object_set_data ((GObject *) settings, "proxy_tab_num", GINT_TO_POINTER (pag_num));
 		gtk_widget_show_all (priv->tab_dialog);
-	}  else if (!g_strrstr (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), "groupwise://")) {
-		prd = g_object_get_data ((GObject *) account, "prd");
+	} else {
+		prd = g_object_get_data ((GObject *) settings, "prd");
 
 		if (prd) {
 			priv = prd->priv;
@@ -744,7 +716,7 @@ static gboolean
 proxy_page_changed_cb (GtkNotebook *notebook,
                        GtkWidget *page,
                        gint num,
-                       EAccount *account)
+                       CamelSettings *settings)
 {
 	proxyDialog *prd;
 	proxyDialogPrivate *priv;
@@ -753,23 +725,23 @@ proxy_page_changed_cb (GtkNotebook *notebook,
 	GList *list_iter;
 	proxyHandler *aclInstance;
 
-	if (g_strrstr (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), "groupwise://")) {
+	if (CAMEL_IS_GROUPWISE_SETTINGS (settings)) {
 
-		prd = g_object_get_data ((GObject *) account, "prd");
+		prd = g_object_get_data ((GObject *) settings, "prd");
 
 		if (!prd || !prd->priv)
 			return TRUE;
 
-		val = g_object_get_data ((GObject *) account, "proxy_tab_num");
+		val = g_object_get_data ((GObject *) settings, "proxy_tab_num");
 
 		if (!val)
 			return FALSE;
 
 		pg_num = GPOINTER_TO_INT (val);
 
-		if ((pg_num == num) && account->enabled) {
+		if (pg_num == num) {
 			if (!prd->cnc)
-				prd->cnc = proxy_get_cnc (account, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (notebook))));
+				prd->cnc = proxy_get_cnc (settings, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (notebook))));
 			priv = prd->priv;
 
 			if (e_gw_connection_get_proxy_access_list (prd->cnc, &priv->proxy_list)!= E_GW_CONNECTION_STATUS_OK)
@@ -787,7 +759,7 @@ proxy_page_changed_cb (GtkNotebook *notebook,
 				}
 			}
 
-			proxy_update_tree_view (account);
+			proxy_update_tree_view (settings);
 			return TRUE;
 		}
 	}
@@ -797,12 +769,12 @@ proxy_page_changed_cb (GtkNotebook *notebook,
 
 static void
 proxy_cancel (GtkWidget *button,
-              EAccount *account)
+              CamelSettings *settings)
 {
 	proxyDialog *prd = NULL;
 	proxyDialogPrivate *priv;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	gtk_widget_destroy (priv->main);
 	g_object_unref (priv->builder);
@@ -810,42 +782,42 @@ proxy_cancel (GtkWidget *button,
 
 static void
 proxy_add_ok (GtkWidget *button,
-              EAccount *account)
+              CamelSettings *settings)
 {
 	proxyDialog *prd = NULL;
 	proxyDialogPrivate *priv;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 
-	if (proxy_dialog_store_widgets_data (account, PROXY_ADD_DIALOG, GTK_WINDOW (gtk_widget_get_toplevel (button))) < 0)
+	if (proxy_dialog_store_widgets_data (settings, PROXY_ADD_DIALOG, GTK_WINDOW (gtk_widget_get_toplevel (button))) < 0)
 		return;
 
-	proxy_update_tree_view (account);
+	proxy_update_tree_view (settings);
 	gtk_widget_destroy (priv->main);
 	g_object_unref (priv->builder);
 }
 
 static void
 proxy_edit_ok (GtkWidget *button,
-               EAccount *account)
+               CamelSettings *settings)
 {
 	proxyDialog *prd = NULL;
 	proxyDialogPrivate *priv;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 
-	if ( proxy_dialog_store_widgets_data (account, PROXY_EDIT_DIALOG, GTK_WINDOW (gtk_widget_get_toplevel (button))) < 0)
+	if ( proxy_dialog_store_widgets_data (settings, PROXY_EDIT_DIALOG, GTK_WINDOW (gtk_widget_get_toplevel (button))) < 0)
 		return;
 
-	proxy_update_tree_view (account);
+	proxy_update_tree_view (settings);
 	gtk_widget_destroy (priv->main);
 	g_object_unref (priv->builder);
 }
 
 static proxyHandler *
-proxy_get_item_from_list (EAccount *account,
+proxy_get_item_from_list (CamelSettings *settings,
                           gchar *account_name)
 {
 	proxyDialogPrivate *priv;
@@ -853,7 +825,7 @@ proxy_get_item_from_list (EAccount *account,
 	GList *list_iter;
 	proxyHandler *iter;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	list_iter = priv->proxy_list;
 
@@ -869,7 +841,7 @@ proxy_get_item_from_list (EAccount *account,
 
 static void
 proxy_remove_account (GtkWidget *button,
-                      EAccount *account)
+                      CamelSettings *settings)
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model;
@@ -879,19 +851,19 @@ proxy_remove_account (GtkWidget *button,
 	gchar *account_mailid;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	account_select = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree));
 
 	if (gtk_tree_selection_get_selected (account_select, &model, &iter)) {
 		gtk_tree_model_get (model, &iter, ACCOUNT_NAME, &account_mailid, -1);
 		account_mailid = g_strrstr (account_mailid, "\n") + 1;
-		deleted = proxy_get_item_from_list (account, account_mailid);
+		deleted = proxy_get_item_from_list (settings, account_mailid);
 
 		if (deleted != NULL)
 			deleted->flags |= E_GW_PROXY_DELETED;
 
-		proxy_update_tree_view (account);
+		proxy_update_tree_view (settings);
 	}
 }
 
@@ -911,19 +883,19 @@ addressbook_entry_changed (GtkWidget *entry,
 
 static void
 address_button_clicked (GtkButton *button,
-                        EAccount *account)
+                        CamelSettings *settings)
 {
 	proxyDialog *prd;
 	proxyDialogPrivate *priv;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	e_name_selector_show_dialog (priv->proxy_name_selector, priv->main);
 }
 
 static void
 proxy_add_account (GtkWidget *button,
-                   EAccount *account)
+                   CamelSettings *settings)
 {
 	GtkButton *contacts, *cancel;
 	proxyDialogPrivate *priv;
@@ -934,13 +906,13 @@ proxy_add_account (GtkWidget *button,
 	GtkWidget *proxy_name, *name_box;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 
 	priv->builder = gtk_builder_new ();
 	e_load_ui_builder_definition (priv->builder, "proxy-add-dialog.ui");
 
-	proxy_dialog_initialize_widgets (account);
+	proxy_dialog_initialize_widgets (settings);
 	priv->main = e_builder_get_widget (priv->builder, "ProxyAccessRights");
 	okButton = (GtkButton *) e_builder_get_widget (priv->builder,"proxy_button_ok");
 	contacts = (GtkButton *) e_builder_get_widget (priv->builder,"contacts");
@@ -949,10 +921,10 @@ proxy_add_account (GtkWidget *button,
 	priv->proxy_name_selector = e_name_selector_new ();
 	name_selector_dialog = e_name_selector_peek_dialog (priv->proxy_name_selector);
 
-	g_signal_connect ((GtkWidget *)okButton, "clicked", G_CALLBACK (proxy_add_ok), account);
-	g_signal_connect ((GtkWidget *)cancel, "clicked", G_CALLBACK (proxy_cancel), account);
-	g_signal_connect ((GtkWidget *)contacts, "clicked", G_CALLBACK (address_button_clicked), account);
-	g_signal_connect (name_selector_dialog, "response", G_CALLBACK (addressbook_dialog_response), account);
+	g_signal_connect ((GtkWidget *)okButton, "clicked", G_CALLBACK (proxy_add_ok), settings);
+	g_signal_connect ((GtkWidget *)cancel, "clicked", G_CALLBACK (proxy_cancel), settings);
+	g_signal_connect ((GtkWidget *)contacts, "clicked", G_CALLBACK (address_button_clicked), settings);
+	g_signal_connect (name_selector_dialog, "response", G_CALLBACK (addressbook_dialog_response), settings);
 	gtk_widget_show (GTK_WIDGET (priv->main));
 
 	name_selector_model = e_name_selector_peek_model (priv->proxy_name_selector);
@@ -971,13 +943,13 @@ proxy_add_account (GtkWidget *button,
 }
 
 static void
-proxy_load_edit_dialog (EAccount *account,
+proxy_load_edit_dialog (CamelSettings *settings,
                         proxyHandler *edited)
 {
 	proxyDialogPrivate *priv;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 	gtk_entry_set_text ((GtkEntry *) priv->account_name, edited->proxy_email);
 	gtk_widget_set_sensitive (priv->account_name, FALSE);
@@ -1021,7 +993,7 @@ proxy_load_edit_dialog (EAccount *account,
 
 static void
 proxy_edit_account (GtkWidget *button,
-                    EAccount *account)
+                    CamelSettings *settings)
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model;
@@ -1033,7 +1005,7 @@ proxy_edit_account (GtkWidget *button,
 	GtkWidget *contacts;
 	proxyDialog *prd = NULL;
 
-	prd = g_object_get_data ((GObject *)account, "prd");
+	prd = g_object_get_data ((GObject *)settings, "prd");
 	priv = prd->priv;
 
 	/*FIXME: If multiple properties dialogs are launched then the widgets lose data*/
@@ -1043,20 +1015,20 @@ proxy_edit_account (GtkWidget *button,
 	if (gtk_tree_selection_get_selected (account_select, &model, &iter)) {
 		gtk_tree_model_get (model, &iter, ACCOUNT_NAME, &account_mailid, -1);
 		account_mailid = g_strrstr (account_mailid, "\n") + 1;
-		edited = proxy_get_item_from_list (account, account_mailid);
+		edited = proxy_get_item_from_list (settings, account_mailid);
 		if (edited) {
 			priv->builder = gtk_builder_new ();
 			e_load_ui_builder_definition (priv->builder, "proxy-add-dialog.ui");
 
 			priv->main = e_builder_get_widget (priv->builder, "ProxyAccessRights");
-			proxy_dialog_initialize_widgets (account);
+			proxy_dialog_initialize_widgets (settings);
 			okButton = (GtkButton *) e_builder_get_widget (priv->builder,"proxy_button_ok");
 			proxyCancel = (GtkButton *) e_builder_get_widget (priv->builder,"proxy_cancel");
 			contacts = e_builder_get_widget (priv->builder, "contacts");
 
-			g_signal_connect ((GtkWidget *)okButton, "clicked", G_CALLBACK (proxy_edit_ok), account);
-			g_signal_connect ((GtkWidget *)proxyCancel, "clicked", G_CALLBACK (proxy_cancel), account);
-			proxy_load_edit_dialog (account, edited);
+			g_signal_connect ((GtkWidget *)okButton, "clicked", G_CALLBACK (proxy_edit_ok), settings);
+			g_signal_connect ((GtkWidget *)proxyCancel, "clicked", G_CALLBACK (proxy_cancel), settings);
+			proxy_load_edit_dialog (settings, edited);
 			gtk_widget_hide (contacts);
 			gtk_widget_show (GTK_WIDGET (priv->main));
 		}
diff --git a/src/plugins/proxy.h b/src/plugins/proxy.h
index 5dc1bb4..4151cb4 100644
--- a/src/plugins/proxy.h
+++ b/src/plugins/proxy.h
@@ -22,8 +22,8 @@
  *
  */
 
-#include <libedataserver/e-account.h>
 #include <gtk/gtk.h>
+#include <camel/camel.h>
 
 #define TYPE_PROXY_DIALOG       (proxy_dialog_get_type ())
 #define PROXY_DIALOG(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROXY_DIALOG, proxyDialog))
@@ -52,14 +52,14 @@ struct _proxyDialogClass {
 GType proxy_dialog_get_type (void);
 proxyDialog *proxy_dialog_new (void);
 GtkWidget * org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data);
-static void proxy_add_account (GtkWidget *button, EAccount *account);
-static void proxy_remove_account (GtkWidget *button, EAccount *account);
-static void proxy_update_tree_view (EAccount *account);
-static void proxy_cancel (GtkWidget *button, EAccount *account);
-static void proxy_edit_account (GtkWidget *button, EAccount *account);
+static void proxy_add_account (GtkWidget *button, CamelSettings *settings);
+static void proxy_remove_account (GtkWidget *button, CamelSettings *settings);
+static void proxy_update_tree_view (CamelSettings *settings);
+static void proxy_cancel (GtkWidget *button, CamelSettings *settings);
+static void proxy_edit_account (GtkWidget *button, CamelSettings *settings);
 void proxy_abort (GtkWidget *button, EConfigHookItemFactoryData *data);
 void proxy_commit (GtkWidget *button, EConfigHookItemFactoryData *data);
-static void proxy_setup_meta_tree_view (EAccount *account);
-static proxyHandler *proxy_get_item_from_list (EAccount *account, gchar *account_name);
-static void proxy_load_edit_dialog (EAccount *account, proxyHandler *edited);
+static void proxy_setup_meta_tree_view (CamelSettings *settings);
+static proxyHandler *proxy_get_item_from_list (CamelSettings *settings, gchar *account_name);
+static void proxy_load_edit_dialog (CamelSettings *settings, proxyHandler *edited);
 void free_proxy_list (GList *proxy_list);
diff --git a/src/plugins/send-options.c b/src/plugins/send-options.c
index 719b50d..74ceecf 100644
--- a/src/plugins/send-options.c
+++ b/src/plugins/send-options.c
@@ -43,7 +43,7 @@ GtkWidget *parent;
 EGwConnection *n_cnc;
 EGwSendOptions *opts = NULL;
 gboolean changed = FALSE;
-EAccount *account;
+CamelSettings *settings = NULL;
 
 GtkWidget * org_gnome_send_options (EPlugin *epl, EConfigHookItemFactoryData *data);
 void send_options_commit (EPlugin *epl, EConfigHookItemFactoryData *data);
@@ -53,49 +53,48 @@ void send_options_abort (EPlugin *epl, EConfigHookItemFactoryData *data);
 static EGwConnection *
 get_cnc (GtkWindow *parent_window)
 {
-	CamelSettings *settings;
-	EGwConnection *cnc;
+	CamelNetworkSettings *network_settings;
 	const gchar *failed_auth;
 	gchar *uri, *key, *prompt, *password = NULL;
-	CamelURL *url;
 	CamelNetworkSecurityMethod security_method;
-	const gchar *poa_address;
 	const gchar *scheme;
+	const gchar *host;
+	const gchar *user;
 	gboolean remember;
 	gchar *soap_port;
 
-	url = camel_url_new (account->source->url, NULL);
-	if (url == NULL)
+	if (!CAMEL_IS_NETWORK_SETTINGS (settings))
 		return NULL;
-	poa_address = url->host;
-	if (!poa_address || strlen (poa_address) ==0)
+
+	network_settings = CAMEL_NETWORK_SETTINGS (settings);
+	host = camel_network_settings_get_host (network_settings);
+	user = camel_network_settings_get_user (network_settings);
+
+	if (host == NULL || *host == '\0')
 		return NULL;
 
-	settings = g_object_new (CAMEL_TYPE_GROUPWISE_SETTINGS, NULL);
-	camel_settings_load_from_url (settings, url);
+	if (user == NULL || *user == '\0')
+		return NULL;
 
-	g_object_set (
+	g_object_get (
 		settings,
 		"soap-port", &soap_port,
 		"security-method", &security_method,
 		NULL);
 
-	g_object_unref (settings);
-
 	if (security_method == CAMEL_NETWORK_SECURITY_METHOD_NONE)
 		scheme = "http";
 	else
 		scheme = "https";
 
-	key =  g_strdup_printf ("groupwise://%s %s/", url->user, poa_address);
+	key =  g_strdup_printf ("groupwise://%s %s/", user, host);
 
-	uri = g_strdup_printf ("%s://%s:%s/soap", scheme, poa_address, soap_port);
+	uri = g_strdup_printf ("%s://%s:%s/soap", scheme, host, soap_port);
 
 	failed_auth = "";
-	cnc = NULL;
 
 	prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"),
-			failed_auth, poa_address, url->user);
+			failed_auth, host, user);
 
 	password = e_passwords_get_password (NULL, key);
 	if (!password)
@@ -103,11 +102,7 @@ get_cnc (GtkWindow *parent_window)
 				E_PASSWORDS_REMEMBER_FOREVER | E_PASSWORDS_SECRET, &remember, parent_window);
 	g_free (prompt);
 
-	cnc = e_gw_connection_new (uri, url->user, password);
-
-	camel_url_free (url);
-
-	return cnc;
+	return e_gw_connection_new (uri, user, password);
 }
 
 static void
@@ -176,7 +171,8 @@ e_send_options_clicked_cb (GtkWidget *button,
                            gpointer data)
 {
 	EGwConnectionStatus status;
-	account = (EAccount *) data;
+	settings = CAMEL_SETTINGS (data);
+
 	if (!sod) {
 		sod = e_send_options_dialog_new ();
 		e_send_options_set_global (sod, TRUE);
@@ -208,16 +204,17 @@ GtkWidget *
 org_gnome_send_options (EPlugin *epl,
                         EConfigHookItemFactoryData *data)
 {
-	EMConfigTargetAccount *target_account;
+	EMConfigTargetSettings *target_account;
 	GtkWidget *frame, *button, *label, *vbox;
 	gchar *markup;
 
-	target_account = (EMConfigTargetAccount *) data->config->target;
-	account = target_account->modified_account;
+	target_account = (EMConfigTargetSettings *) data->config->target;
 
-	if (!g_strrstr (account->source->url, "groupwise://"))
+	if (!CAMEL_IS_GROUPWISE_SETTINGS (target_account->storage_settings))
 		return NULL;
 
+	settings = target_account->storage_settings;
+
 	vbox = gtk_vbox_new (FALSE, 0);
 	frame = gtk_frame_new ("");
 	label = gtk_frame_get_label_widget (GTK_FRAME (frame));
@@ -228,7 +225,7 @@ org_gnome_send_options (EPlugin *epl,
 	g_free (markup);
 
 	g_signal_connect(button, "clicked",
-			    G_CALLBACK (e_send_options_clicked_cb), account);
+			    G_CALLBACK (e_send_options_clicked_cb), settings);
 
 	parent = gtk_widget_get_toplevel (GTK_WIDGET (data->parent));
 	if (!gtk_widget_is_toplevel (parent))
@@ -375,9 +372,23 @@ send_options_copy_check_changed (EGwSendOptions *n_opts)
 static ESource *
 get_source (ESourceList *list)
 {
+	CamelURL *url;
+	gchar *url_string;
 	GSList *p, *l;
-	gchar **temp = g_strsplit (account->source->url, ";", -1);
-	gchar *uri = temp[0];
+	gchar **temp;
+	gchar *uri;
+
+	/* FIXME Wow... just... wow.  If ever one needed proof that
+	 *       URL-based accounts were a bad idea, here ya go. */
+
+	url = g_malloc0 (sizeof (CamelURL));
+	camel_settings_save_to_url (settings, url);
+	url_string = camel_url_to_string (url, 0);
+	temp = g_strsplit (url_string, ";", -1);
+	g_free (url_string);
+	camel_url_free (url);
+
+	uri = temp[0];
 
 	l = e_source_list_peek_groups (list);
 
@@ -434,9 +445,6 @@ put_options_in_source (ESource *source,
 	gchar *value;
 	const gchar *val;
 	icaltimetype tt;
-	CamelURL  *url;
-
-       url = camel_url_new (account->source->url, NULL);
 
 	if (gopts) {
 			/* priority */
@@ -454,7 +462,6 @@ put_options_in_source (ESource *source,
 				value = g_strdup ("undefined");
 		}
 		e_source_set_property (source, "priority", value);
-		camel_url_set_param (url, "priority", value);
 		g_free (value), value = NULL;
 
 			/* Reply Requested */



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