aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-09-30 20:09:02 +0800
committerMilan Crha <mcrha@redhat.com>2011-09-30 20:09:02 +0800
commit2def4a73864c87c4dee25b04180c882e72a0fee1 (patch)
tree7468765150228e1ceb782d087a9999c8f6030445
parent5c81e944e63fd1f0e653832c23a798a23e8c07eb (diff)
downloadgsoc2013-evolution-2def4a73864c87c4dee25b04180c882e72a0fee1.tar.gz
gsoc2013-evolution-2def4a73864c87c4dee25b04180c882e72a0fee1.tar.zst
gsoc2013-evolution-2def4a73864c87c4dee25b04180c882e72a0fee1.zip
Bug #601898 - SOCKS proxy does not work with mailer
-rw-r--r--mail/e-mail-session.c126
-rw-r--r--mail/mail-config.ui67
-rw-r--r--modules/mail/em-network-prefs.c35
-rw-r--r--modules/mail/em-network-prefs.h3
4 files changed, 128 insertions, 103 deletions
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c
index d716357288..45c8e0209c 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -45,6 +45,7 @@
#endif
#include <libedataserver/e-flag.h>
+#include <libedataserver/e-proxy.h>
#include <libebackend/e-extensible.h>
#include <libedataserverui/e-passwords.h>
@@ -73,7 +74,6 @@
((obj), E_TYPE_MAIL_SESSION, EMailSessionPrivate))
static guint session_check_junk_notify_id;
-static guint session_gconf_proxy_id;
typedef struct _AsyncContext AsyncContext;
@@ -82,6 +82,7 @@ struct _EMailSessionPrivate {
FILE *filter_logfile;
GHashTable *junk_filters;
+ EProxy *proxy;
};
struct _AsyncContext {
@@ -440,73 +441,6 @@ ms_forward_to_cb (CamelFolder *folder,
g_object_unref (client);
}
-/* Support for SOCKS proxy ***************************************************/
-
-static GSettings *proxy_settings = NULL, *proxy_socks_settings = NULL;
-
-static void
-set_socks_proxy_from_gsettings (CamelSession *session)
-{
- gchar *mode, *host;
- gint port;
-
- g_return_if_fail (proxy_settings != NULL);
- g_return_if_fail (proxy_socks_settings != NULL);
-
- mode = g_settings_get_string (proxy_settings, "mode");
- if (g_strcmp0 (mode, "manual") == 0) {
- host = g_settings_get_string (proxy_socks_settings, "host");
- port = g_settings_get_int (proxy_socks_settings, "port");
- camel_session_set_socks_proxy (session, host, port);
- g_free (host);
- }
- g_free (mode);
-}
-
-static void
-proxy_gsettings_changed_cb (GSettings *settings,
- const gchar *key,
- CamelSession *session)
-{
- set_socks_proxy_from_gsettings (session);
-}
-
-static void
-set_socks_proxy_gsettings_watch (CamelSession *session)
-{
- g_return_if_fail (proxy_settings != NULL);
- g_return_if_fail (proxy_socks_settings != NULL);
-
- g_signal_connect (
- proxy_settings, "changed::mode",
- G_CALLBACK (proxy_gsettings_changed_cb), session);
-
- g_signal_connect (
- proxy_socks_settings, "changed",
- G_CALLBACK (proxy_gsettings_changed_cb), session);
-}
-
-static void
-init_socks_proxy (CamelSession *session)
-{
- g_return_if_fail (CAMEL_IS_SESSION (session));
-
- if (!proxy_settings) {
- proxy_settings = g_settings_new ("org.gnome.system.proxy");
- proxy_socks_settings = g_settings_get_child (proxy_settings, "socks");
- g_object_weak_ref (G_OBJECT (proxy_settings), (GWeakNotify) g_nullify_pointer, &proxy_settings);
- g_object_weak_ref (G_OBJECT (proxy_socks_settings), (GWeakNotify) g_nullify_pointer, &proxy_socks_settings);
- } else {
- g_object_ref (proxy_settings);
- g_object_ref (proxy_socks_settings);
- }
-
- set_socks_proxy_gsettings_watch (session);
- set_socks_proxy_from_gsettings (session);
-}
-
-/*****************************************************************************/
-
static void
async_context_free (AsyncContext *context)
{
@@ -684,6 +618,7 @@ mail_session_finalize (GObject *object)
priv = E_MAIL_SESSION_GET_PRIVATE (object);
g_hash_table_destroy (priv->junk_filters);
+ g_object_unref (priv->proxy);
client = gconf_client_get_default ();
@@ -692,26 +627,11 @@ mail_session_finalize (GObject *object)
session_check_junk_notify_id = 0;
}
- if (session_gconf_proxy_id != 0) {
- gconf_client_notify_remove (client, session_gconf_proxy_id);
- session_gconf_proxy_id = 0;
- }
-
g_object_unref (client);
g_free (mail_data_dir);
g_free (mail_config_dir);
- if (proxy_settings) {
- g_signal_handlers_disconnect_by_func (proxy_settings, proxy_gsettings_changed_cb, CAMEL_SESSION (object));
- g_object_unref (proxy_settings);
- }
-
- if (proxy_socks_settings) {
- g_signal_handlers_disconnect_by_func (proxy_socks_settings, proxy_gsettings_changed_cb, CAMEL_SESSION (object));
- g_object_unref (proxy_socks_settings);
- }
-
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_mail_session_parent_class)->finalize (object);
}
@@ -1141,6 +1061,42 @@ mail_session_forward_to (CamelSession *session,
}
static void
+mail_session_get_socks_proxy (CamelSession *session,
+ const gchar *for_host,
+ gchar **host_ret,
+ gint *port_ret)
+{
+ EMailSession *mail_session;
+ gchar *uri;
+
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (for_host != NULL);
+ g_return_if_fail (host_ret != NULL);
+ g_return_if_fail (port_ret != NULL);
+
+ mail_session = E_MAIL_SESSION (session);
+ g_return_if_fail (mail_session != NULL);
+ g_return_if_fail (mail_session->priv != NULL);
+
+ *host_ret = NULL;
+ *port_ret = 0;
+
+ uri = g_strconcat ("socks://", for_host, NULL);
+
+ if (e_proxy_require_proxy_for_uri (mail_session->priv->proxy, uri)) {
+ SoupURI *suri;
+
+ suri = e_proxy_peek_uri_for (mail_session->priv->proxy, uri);
+ if (suri) {
+ *host_ret = g_strdup (suri->host);
+ *port_ret = suri->port;
+ }
+ }
+
+ g_free (uri);
+}
+
+static void
e_mail_session_class_init (EMailSessionClass *class)
{
GObjectClass *object_class;
@@ -1164,6 +1120,7 @@ e_mail_session_class_init (EMailSessionClass *class)
session_class->get_filter_driver = mail_session_get_filter_driver;
session_class->lookup_addressbook = mail_session_lookup_addressbook;
session_class->forward_to = mail_session_forward_to;
+ session_class->get_socks_proxy = mail_session_get_socks_proxy;
g_object_class_install_property (
object_class,
@@ -1200,6 +1157,7 @@ e_mail_session_init (EMailSession *session)
session->priv->folder_cache = mail_folder_cache_new ();
session->priv->junk_filters = g_hash_table_new (
(GHashFunc) g_str_hash, (GEqualFunc) g_str_equal);
+ session->priv->proxy = e_proxy_new ();
/* Initialize the EAccount setup. */
e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD);
@@ -1219,7 +1177,7 @@ e_mail_session_init (EMailSession *session)
mail_config_reload_junk_headers (session);
- init_socks_proxy (CAMEL_SESSION (session));
+ e_proxy_setup_proxy (session->priv->proxy);
g_object_unref (client);
}
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 5d934aafa2..7567d18603 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -409,6 +409,11 @@ for display purposes only. </property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment6">
+ <property name="upper">65535</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkNotebook" id="composer_toplevel">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -1505,6 +1510,22 @@ for display purposes only. </property>
</packing>
</child>
<child>
+ <object class="GtkLabel" id="lblSocksHost">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">SOC_KS Proxy:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">txtSocksHost</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="lblIgnoreHosts">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1547,6 +1568,20 @@ for display purposes only. </property>
</packing>
</child>
<child>
+ <object class="GtkEntry" id="txtSocksHost">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="lblHttpPort">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1577,6 +1612,22 @@ for display purposes only. </property>
</packing>
</child>
<child>
+ <object class="GtkLabel" id="lblSocksPort">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Port:</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
<object class="GtkSpinButton" id="spnHttpPort">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -1607,6 +1658,22 @@ for display purposes only. </property>
</packing>
</child>
<child>
+ <object class="GtkSpinButton" id="spnSocksPort">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="adjustment">adjustment6</property>
+ <property name="climb_rate">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
<object class="GtkEntry" id="txtIgnoreHosts">
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/modules/mail/em-network-prefs.c b/modules/mail/em-network-prefs.c
index 242c84993e..64fe23e7f9 100644
--- a/modules/mail/em-network-prefs.c
+++ b/modules/mail/em-network-prefs.c
@@ -148,12 +148,11 @@ emnp_set_sensitiveness (EMNetworkPrefs *prefs,
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_http_port, sensitivity);
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_https_host, sensitivity);
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_https_port, sensitivity);
-#if 0
gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_host, sensitivity);
gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_port, sensitivity);
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_socks_host, sensitivity);
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_socks_port, sensitivity);
-#endif
+
state = sensitivity && gtk_toggle_button_get_active (prefs->use_auth);
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_user, state);
gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_pwd, state);
@@ -389,13 +388,17 @@ em_network_prefs_construct (EMNetworkPrefs *prefs)
prefs->manual_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoManualProxy"));
prefs->http_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtHttpHost"));
prefs->https_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtHttpsHost"));
+ prefs->socks_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtSocksHost"));
prefs->ignore_hosts = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtIgnoreHosts"));
prefs->http_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnHttpPort"));
prefs->https_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnHttpsPort"));
+ prefs->socks_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnSocksPort"));
prefs->lbl_http_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpHost"));
prefs->lbl_http_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpPort"));
prefs->lbl_https_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpsHost"));
prefs->lbl_https_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpsPort"));
+ prefs->lbl_socks_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksHost"));
+ prefs->lbl_socks_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksPort"));
prefs->lbl_ignore_hosts = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblIgnoreHosts"));
prefs->use_auth = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "chkUseAuth"));
toggle_button_init (prefs, prefs->use_auth, GCONF_E_USE_AUTH_KEY);
@@ -404,17 +407,6 @@ em_network_prefs_construct (EMNetworkPrefs *prefs)
prefs->auth_user = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAuthUser"));
prefs->auth_pwd = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAuthPwd"));
-#if 0
- prefs->socks_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtSocksHost"));
- prefs->socks_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnSocksPort"));
- prefs->lbl_socks_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksHost"));
- prefs->lbl_socks_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksPort"));
- g_signal_connect (prefs->socks_host, "changed",
- G_CALLBACK (widget_entry_changed_cb), GCONF_E_SOCKS_HOST_KEY);
- g_signal_connect (prefs->socks_port, "value_changed",
- G_CALLBACK (widget_entry_changed_cb), GCONF_E_SOCKS_PORT_KEY);
-#endif
-
/* Manual proxy options */
g_signal_connect (prefs->http_host, "changed",
G_CALLBACK (widget_entry_changed_cb),
@@ -431,6 +423,12 @@ em_network_prefs_construct (EMNetworkPrefs *prefs)
g_signal_connect (prefs->https_port, "value_changed",
G_CALLBACK (widget_entry_changed_cb),
(gpointer) GCONF_E_HTTPS_PORT_KEY);
+ g_signal_connect (prefs->socks_host, "changed",
+ G_CALLBACK (widget_entry_changed_cb),
+ (gpointer) GCONF_E_SOCKS_HOST_KEY);
+ g_signal_connect (prefs->socks_port, "value_changed",
+ G_CALLBACK (widget_entry_changed_cb),
+ (gpointer) GCONF_E_SOCKS_PORT_KEY);
g_signal_connect (prefs->auth_user, "changed",
G_CALLBACK (widget_entry_changed_cb),
(gpointer) GCONF_E_AUTH_USER_KEY);
@@ -458,6 +456,10 @@ em_network_prefs_construct (EMNetworkPrefs *prefs)
gtk_entry_set_text (prefs->https_host, buf ? buf : "");
g_free (buf);
+ buf = gconf_client_get_string (prefs->gconf, GCONF_E_SOCKS_HOST_KEY, NULL);
+ gtk_entry_set_text (prefs->socks_host, buf ? buf : "");
+ g_free (buf);
+
buf = NULL;
ignore = gconf_client_get_list (prefs->gconf, GCONF_E_IGNORE_HOSTS_KEY, GCONF_VALUE_STRING, NULL);
if (ignore) {
@@ -502,14 +504,9 @@ em_network_prefs_construct (EMNetworkPrefs *prefs)
port = gconf_client_get_int (prefs->gconf, GCONF_E_HTTPS_PORT_KEY, NULL);
gtk_spin_button_set_value (prefs->https_port, (gdouble) port);
-#if 0
- buf = gconf_client_get_string (prefs->gconf, GCONF_E_SOCKS_HOST_KEY, NULL);
- gtk_entry_set_text (prefs->socks_host, buf ? buf : "");
- g_free (buf);
-
port = gconf_client_get_int (prefs->gconf, GCONF_E_SOCKS_PORT_KEY, NULL);
gtk_spin_button_set_value (prefs->socks_port, (gdouble) port);
-#endif
+
emnp_set_markups (prefs);
if (val == NETWORK_PROXY_DIRECT_CONNECTION ||
diff --git a/modules/mail/em-network-prefs.h b/modules/mail/em-network-prefs.h
index 4196686ffe..f13a239490 100644
--- a/modules/mail/em-network-prefs.h
+++ b/modules/mail/em-network-prefs.h
@@ -82,12 +82,15 @@ struct _EMNetworkPrefs {
GtkLabel *lbl_http_port;
GtkLabel *lbl_https_host;
GtkLabel *lbl_https_port;
+ GtkLabel *lbl_socks_host;
+ GtkLabel *lbl_socks_port;
GtkLabel *lbl_ignore_hosts;
GtkLabel *lbl_auth_user;
GtkLabel *lbl_auth_pwd;
GtkSpinButton *http_port;
GtkSpinButton *https_port;
+ GtkSpinButton *socks_port;
};
struct _EMNetworkPrefsClass {