evolution-3.6.4/modules/mail/em-network-prefs.c

No issues found

  1 /*
  2  * This program is free software; you can redistribute it and/or
  3  * modify it under the terms of the GNU Lesser General Public
  4  * License as published by the Free Software Foundation; either
  5  * version 2 of the License, or (at your option) version 3.
  6  *
  7  * This program is distributed in the hope that it will be useful,
  8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 10  * Lesser General Public License for more details.
 11  *
 12  * You should have received a copy of the GNU Lesser General Public
 13  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 14  *
 15  *
 16  * Authors:
 17  *		Veerapuram Varadhan  <vvaradhan@novell.com>
 18  *
 19  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 20  *
 21  */
 22 
 23 #ifdef HAVE_CONFIG_H
 24 #include <config.h>
 25 #endif
 26 
 27 #include "em-network-prefs.h"
 28 
 29 #include <string.h>
 30 #include <sys/types.h>
 31 #include <sys/stat.h>
 32 #include <unistd.h>
 33 #include <fcntl.h>
 34 
 35 #include <glib/gstdio.h>
 36 #include <gdk/gdkkeysyms.h>
 37 
 38 #include <e-util/e-util.h>
 39 #include <e-util/e-util-private.h>
 40 
 41 #include <mail/em-config.h>
 42 #include <mail/em-folder-selection-button.h>
 43 #include <mail/e-mail-junk-options.h>
 44 
 45 #define d(x)
 46 
 47 #define SETTINGS_KEY_NAME "evo-proxy-settings-key-name"
 48 #define SET_KEY_NAME(_widget, _key) g_object_set_data_full (G_OBJECT (_widget), SETTINGS_KEY_NAME, g_strdup (_key), g_free)
 49 
 50 G_DEFINE_TYPE (
 51 	EMNetworkPrefs,
 52 	em_network_prefs,
 53 	GTK_TYPE_VBOX)
 54 
 55 static void
 56 em_network_prefs_class_init (EMNetworkPrefsClass *class)
 57 {
 58 }
 59 
 60 static void
 61 em_network_prefs_init (EMNetworkPrefs *prefs)
 62 {
 63 }
 64 
 65 static void
 66 toggle_button_toggled (GtkToggleButton *toggle,
 67                        EMNetworkPrefs *prefs)
 68 {
 69 	const gchar *key;
 70 
 71 	key = g_object_get_data ((GObject *) toggle, SETTINGS_KEY_NAME);
 72 	g_settings_set_boolean (prefs->proxy_settings, key, gtk_toggle_button_get_active (toggle));
 73 	if (toggle == prefs->use_auth) {
 74 		gboolean sensitivity = gtk_toggle_button_get_active (prefs->use_auth);
 75 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_user, sensitivity);
 76 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_pwd, sensitivity);
 77 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auth_user, sensitivity);
 78 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auth_pwd, sensitivity);
 79 	}
 80 }
 81 
 82 static void
 83 toggle_button_init (EMNetworkPrefs *prefs,
 84                     GtkToggleButton *toggle,
 85                     const gchar *key)
 86 {
 87 	gboolean bval;
 88 
 89 	bval = g_settings_get_boolean (prefs->proxy_settings, key);
 90 	gtk_toggle_button_set_active (toggle, bval);
 91 
 92 	SET_KEY_NAME (toggle, key);
 93 	g_signal_connect (
 94 		toggle, "toggled",
 95 		G_CALLBACK (toggle_button_toggled), prefs);
 96 
 97 	if (!g_settings_is_writable (prefs->proxy_settings, key))
 98 		gtk_widget_set_sensitive ((GtkWidget *) toggle, FALSE);
 99 }
100 
101 static GtkWidget *
102 emnp_widget_glade (EConfig *ec,
103                    EConfigItem *item,
104                    GtkWidget *parent,
105                    GtkWidget *old,
106                    gint position,
107                    gpointer data)
108 {
109 	EMNetworkPrefs *prefs = data;
110 
111 	return e_builder_get_widget (prefs->builder, item->label);
112 }
113 
114 static void
115 emnp_set_sensitiveness (EMNetworkPrefs *prefs,
116                         NetworkConfigProxyType type,
117                         gboolean sensitivity)
118 {
119 #if 0
120 	if (type == NETWORK_PROXY_AUTOCONFIG) {
121 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auto_proxy_url, sensitivity);
122 		d (g_print ("Setting sensitivity of autoconfig to: %d\n", sensitivity));
123 	} else
124 #endif
125 	if (type == NETWORK_PROXY_MANUAL) {
126 		gboolean state;
127 
128 		gtk_widget_set_sensitive ((GtkWidget *) prefs->http_host, sensitivity);
129 		gtk_widget_set_sensitive ((GtkWidget *) prefs->https_host, sensitivity);
130 		gtk_widget_set_sensitive ((GtkWidget *) prefs->ignore_hosts, sensitivity);
131 		gtk_widget_set_sensitive ((GtkWidget *) prefs->use_auth, sensitivity);
132 		gtk_widget_set_sensitive ((GtkWidget *) prefs->http_port, sensitivity);
133 		gtk_widget_set_sensitive ((GtkWidget *) prefs->https_port, sensitivity);
134 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_ignore_hosts, sensitivity);
135 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_http_host, sensitivity);
136 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_http_port, sensitivity);
137 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_https_host, sensitivity);
138 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_https_port, sensitivity);
139 		gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_host, sensitivity);
140 		gtk_widget_set_sensitive ((GtkWidget *) prefs->socks_port, sensitivity);
141 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_socks_host, sensitivity);
142 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_socks_port, sensitivity);
143 
144 		state = sensitivity && gtk_toggle_button_get_active (prefs->use_auth);
145 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_user, state);
146 		gtk_widget_set_sensitive ((GtkWidget *) prefs->lbl_auth_pwd, state);
147 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auth_user, state);
148 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auth_pwd, state);
149 
150 		d (g_print ("Setting sensitivity of manual proxy to: %d\n", sensitivity));
151 	}
152 }
153 
154 static void
155 notify_proxy_type_changed (GtkWidget *widget,
156                            EMNetworkPrefs *prefs)
157 {
158 	gint type;
159 
160 	if (gtk_toggle_button_get_active (prefs->sys_proxy))
161 		type = NETWORK_PROXY_SYS_SETTINGS;
162 	else if (gtk_toggle_button_get_active (prefs->no_proxy))
163 		type = NETWORK_PROXY_DIRECT_CONNECTION;
164 	else if (gtk_toggle_button_get_active (prefs->manual_proxy))
165 		type = NETWORK_PROXY_MANUAL;
166 	else
167 #if 0
168 		type = NETWORK_PROXY_AUTOCONFIG;
169 #else
170 		type = NETWORK_PROXY_SYS_SETTINGS;
171 #endif
172 
173 	g_settings_set_int (prefs->proxy_settings, "proxy-type", type);
174 
175 	if (type == NETWORK_PROXY_DIRECT_CONNECTION ||
176 	    type == NETWORK_PROXY_SYS_SETTINGS) {
177 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
178 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE);
179 	} else if (type == NETWORK_PROXY_AUTOCONFIG) {
180 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
181 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, TRUE);
182 	} else if (type == NETWORK_PROXY_MANUAL) {
183 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE);
184 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, TRUE);
185 	}
186 
187 	if (type != NETWORK_PROXY_DIRECT_CONNECTION)
188 		g_settings_set_boolean (prefs->proxy_settings, "use-http-proxy", TRUE);
189 	else if (type != NETWORK_PROXY_SYS_SETTINGS)
190 		g_settings_set_boolean (prefs->proxy_settings, "use-http-proxy", FALSE);
191 }
192 
193 static void
194 widget_entry_changed_cb (GtkWidget *widget,
195                          gpointer user_data)
196 {
197 	const gchar *key;
198 	const gchar *value;
199 	gint port = -1;
200 	GSettings *proxy_settings = user_data;
201 
202 	g_return_if_fail (proxy_settings != NULL);
203 
204 	key = g_object_get_data (G_OBJECT (widget), SETTINGS_KEY_NAME);
205 	g_return_if_fail (key != NULL);
206 
207 	/*
208 	 * Do not change the order of comparison -
209 	 * GtkSpinButton is an extended form of GtkEntry
210 	*/
211 	if (GTK_IS_SPIN_BUTTON (widget)) {
212 		port = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
213 		g_settings_set_int (proxy_settings, key, port);
214 		d (g_print ("%s:%s: %s is SpinButton: value = [%d]\n", G_STRLOC, G_STRFUNC, key, port));
215 	} else if (GTK_IS_ENTRY (widget)) {
216 		value = gtk_entry_get_text (GTK_ENTRY (widget));
217 		g_settings_set_string (proxy_settings, key, value);
218 		d (g_print ("%s:%s: %s is Entry: value = [%s]\n", G_STRLOC, G_STRFUNC, key, value));
219 	}
220 }
221 
222 static void
223 ignore_hosts_entry_changed_cb (GtkWidget *widget,
224                                gpointer user_data)
225 {
226 	const gchar *key;
227 	const gchar *value;
228 	gchar **split;
229 	GPtrArray *ptrs;
230 	GSettings *proxy_settings = user_data;
231 
232 	g_return_if_fail (widget != NULL);
233 	g_return_if_fail (GTK_IS_ENTRY (widget));
234 	g_return_if_fail (proxy_settings != NULL);
235 
236 	key = g_object_get_data (G_OBJECT (widget), SETTINGS_KEY_NAME);
237 	g_return_if_fail (key != NULL);
238 
239 	ptrs = g_ptr_array_new_with_free_func (g_free);
240 
241 	/* transform comma-separated list of ignore_hosts to a string-list */
242 	value = gtk_entry_get_text (GTK_ENTRY (widget));
243 	split = g_strsplit (value ? value : "", ",", -1);
244 	if (split) {
245 		gint ii;
246 
247 		for (ii = 0; split[ii]; ii++) {
248 			const gchar *tmp = split[ii];
249 
250 			if (tmp && *tmp) {
251 				gchar *val = g_strstrip (g_strdup (tmp));
252 
253 				if (val && *val)
254 					g_ptr_array_add (ptrs, val);
255 				else
256 					g_free (val);
257 			}
258 		}
259 
260 		g_strfreev (split);
261 	}
262 
263 	/* NULL-terminated array of strings */
264 	g_ptr_array_add (ptrs, NULL);
265 
266 	g_settings_set_strv (proxy_settings, key, (const gchar * const *) ptrs->pdata);
267 
268 	g_ptr_array_free (ptrs, TRUE);
269 }
270 
271 /* plugin meta-data */
272 static EMConfigItem emnp_items[] = {
273 	{ E_CONFIG_BOOK, (gchar *) "", (gchar *) "network_preferences_toplevel", emnp_widget_glade },
274 	{ E_CONFIG_PAGE, (gchar *) "00.general", (gchar *) "vboxNetworkGeneral", emnp_widget_glade },
275 	{ E_CONFIG_SECTION, (gchar *) "00.general/00.proxy", (gchar *) "proxy-vbox", emnp_widget_glade },
276 };
277 
278 static void
279 emnp_free (EConfig *ec,
280            GSList *items,
281            gpointer data)
282 {
283 	/* the prefs data is freed automagically */
284 
285 	g_slist_free (items);
286 }
287 
288 static void
289 emnp_set_markups (EMNetworkPrefs *prefs)
290 {
291 	GtkWidget *child;
292 
293 	child = gtk_bin_get_child (GTK_BIN (prefs->sys_proxy));
294 	gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
295 
296 	child = gtk_bin_get_child (GTK_BIN (prefs->no_proxy));
297 	gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
298 
299 	child = gtk_bin_get_child (GTK_BIN (prefs->manual_proxy));
300 	gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
301 }
302 
303 static void
304 em_network_prefs_construct (EMNetworkPrefs *prefs)
305 {
306 	GtkWidget *toplevel;
307 	GSList *l;
308 	gchar **ignore;
309 	gchar *buf;
310 	EMConfig *ec;
311 	EMConfigTargetPrefs *target;
312 	gboolean locked;
313 	gint i, val, port;
314 
315 	prefs->proxy_settings = g_settings_new ("org.gnome.evolution.shell.network-config");
316 	g_object_set_data_full (G_OBJECT (prefs), "proxy-settings-obj", prefs->proxy_settings, g_object_unref);
317 
318 	/* Make sure our custom widget classes are registered with
319 	 * GType before we load the GtkBuilder definition file. */
320 	E_TYPE_MAIL_JUNK_OPTIONS;
321 	EM_TYPE_FOLDER_SELECTION_BUTTON;
322 
323 	prefs->builder = gtk_builder_new ();
324 	e_load_ui_builder_definition (prefs->builder, "mail-config.ui");
325 
326 	/** @HookPoint-EMConfig: Network Preferences
327 	 * @Id: org.gnome.evolution.mail.networkPrefs
328 	 * @Type: E_CONFIG_BOOK
329 	 * @Class: org.gnome.evolution.mail.config:1.0
330 	 * @Target: EMConfigTargetPrefs
331 	 *
332 	 * The network preferences settings page.
333 	 */
334 	ec = em_config_new (E_CONFIG_BOOK, "org.gnome.evolution.mail.networkPrefs");
335 	l = NULL;
336 	for (i = 0; i < G_N_ELEMENTS (emnp_items); i++)
337 		l = g_slist_prepend (l, &emnp_items[i]);
338 	e_config_add_items ((EConfig *) ec, l, emnp_free, prefs);
339 
340 	/* Proxy tab */
341 
342 	/* Default Behavior */
343 	locked = !g_settings_is_writable (prefs->proxy_settings, "proxy-type");
344 
345 	val = g_settings_get_int (prefs->proxy_settings, "proxy-type");
346 
347 	/* no auto-proxy at the moment */
348 	if (val == NETWORK_PROXY_AUTOCONFIG)
349 		val = NETWORK_PROXY_SYS_SETTINGS;
350 
351 	prefs->sys_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoSysSettings"));
352 	gtk_toggle_button_set_active (prefs->sys_proxy, val == NETWORK_PROXY_SYS_SETTINGS);
353 	if (locked)
354 		gtk_widget_set_sensitive ((GtkWidget *) prefs->sys_proxy, FALSE);
355 
356 	d (g_print ("Sys settings ----!!! \n"));
357 
358 	prefs->no_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoNoProxy"));
359 	gtk_toggle_button_set_active (prefs->no_proxy, val == NETWORK_PROXY_DIRECT_CONNECTION);
360 	if (locked)
361 		gtk_widget_set_sensitive ((GtkWidget *) prefs->no_proxy, FALSE);
362 
363 	d (g_print ("No proxy settings ----!!! \n"));
364 
365 	/* no auto-proxy at the moment */
366 #if 0
367 	prefs->auto_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoAutoConfig"));
368 	prefs->auto_proxy_url = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAutoConfigUrl"));
369 
370 	gtk_toggle_button_set_active (prefs->auto_proxy, val == NETWORK_PROXY_AUTOCONFIG);
371 
372 	SET_KEY_NAME (prefs->auto_proxy_url, "autoconfig-url");
373 	g_signal_connect (
374 		prefs->auto_proxy_url, "changed",
375 		G_CALLBACK (widget_entry_changed_cb), prefs->proxy_settings);
376 	if (locked)
377 		gtk_widget_set_sensitive ((GtkWidget *) prefs->auto_proxy, FALSE);
378 #endif
379 
380 	d (g_print ("Auto config settings ----!!! \n"));
381 
382 	prefs->manual_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoManualProxy"));
383 	prefs->http_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtHttpHost"));
384 	prefs->https_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtHttpsHost"));
385 	prefs->socks_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtSocksHost"));
386 	prefs->ignore_hosts = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtIgnoreHosts"));
387 	prefs->http_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnHttpPort"));
388 	prefs->https_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnHttpsPort"));
389 	prefs->socks_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnSocksPort"));
390 	prefs->lbl_http_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpHost"));
391 	prefs->lbl_http_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpPort"));
392 	prefs->lbl_https_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpsHost"));
393 	prefs->lbl_https_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpsPort"));
394 	prefs->lbl_socks_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksHost"));
395 	prefs->lbl_socks_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksPort"));
396 	prefs->lbl_ignore_hosts = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblIgnoreHosts"));
397 	prefs->use_auth = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "chkUseAuth"));
398 	toggle_button_init (prefs, prefs->use_auth, "use-authentication");
399 	prefs->lbl_auth_user = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblAuthUser"));
400 	prefs->lbl_auth_pwd = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblAuthPwd"));
401 	prefs->auth_user = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAuthUser"));
402 	prefs->auth_pwd = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAuthPwd"));
403 
404 	/* Manual proxy options */
405 	SET_KEY_NAME (prefs->http_host, "http-host");
406 	g_signal_connect (
407 		prefs->http_host, "changed",
408 		G_CALLBACK (widget_entry_changed_cb),
409 		prefs->proxy_settings);
410 	SET_KEY_NAME (prefs->https_host, "secure-host");
411 	g_signal_connect (
412 		prefs->https_host, "changed",
413 		G_CALLBACK (widget_entry_changed_cb),
414 		prefs->proxy_settings);
415 	SET_KEY_NAME (prefs->ignore_hosts, "ignore-hosts");
416 	g_signal_connect (
417 		prefs->ignore_hosts, "changed",
418 		G_CALLBACK (ignore_hosts_entry_changed_cb),
419 		prefs->proxy_settings);
420 	SET_KEY_NAME (prefs->http_port, "http-port");
421 	g_signal_connect (
422 		prefs->http_port, "value_changed",
423 		G_CALLBACK (widget_entry_changed_cb),
424 		prefs->proxy_settings);
425 	SET_KEY_NAME (prefs->https_port, "secure-port");
426 	g_signal_connect (
427 		prefs->https_port, "value_changed",
428 		G_CALLBACK (widget_entry_changed_cb),
429 		prefs->proxy_settings);
430 	SET_KEY_NAME (prefs->socks_host, "socks-host");
431 	g_signal_connect (
432 		prefs->socks_host, "changed",
433 		G_CALLBACK (widget_entry_changed_cb),
434 		prefs->proxy_settings);
435 	SET_KEY_NAME (prefs->socks_port, "socks-port");
436 	g_signal_connect (
437 		prefs->socks_port, "value_changed",
438 		G_CALLBACK (widget_entry_changed_cb),
439 		prefs->proxy_settings);
440 	SET_KEY_NAME (prefs->auth_user, "authentication-user");
441 	g_signal_connect (
442 		prefs->auth_user, "changed",
443 		G_CALLBACK (widget_entry_changed_cb),
444 		prefs->proxy_settings);
445 	SET_KEY_NAME (prefs->auth_pwd, "authentication-password");
446 	g_signal_connect (
447 		prefs->auth_pwd, "changed",
448 		G_CALLBACK (widget_entry_changed_cb),
449 		prefs->proxy_settings);
450 
451 	gtk_toggle_button_set_active (prefs->manual_proxy, val == NETWORK_PROXY_MANUAL);
452 	g_signal_connect (
453 		prefs->sys_proxy, "toggled",
454 		G_CALLBACK (notify_proxy_type_changed), prefs);
455 	g_signal_connect (
456 		prefs->no_proxy, "toggled",
457 		G_CALLBACK (notify_proxy_type_changed), prefs);
458 #if 0
459 	g_signal_connect (
460 		prefs->auto_proxy, "toggled",
461 		G_CALLBACK (notify_proxy_type_changed), prefs);
462 #endif
463 	g_signal_connect (
464 		prefs->manual_proxy, "toggled",
465 		G_CALLBACK (notify_proxy_type_changed), prefs);
466 
467 	if (locked)
468 		gtk_widget_set_sensitive ((GtkWidget *) prefs->manual_proxy, FALSE);
469 	d (g_print ("Manual settings ----!!! \n"));
470 
471 	buf = g_settings_get_string (prefs->proxy_settings, "http-host");
472 	gtk_entry_set_text (prefs->http_host, buf ? buf : "");
473 	g_free (buf);
474 
475 	buf = g_settings_get_string (prefs->proxy_settings, "secure-host");
476 	gtk_entry_set_text (prefs->https_host, buf ? buf : "");
477 	g_free (buf);
478 
479 	buf = g_settings_get_string (prefs->proxy_settings, "socks-host");
480 	gtk_entry_set_text (prefs->socks_host, buf ? buf : "");
481 	g_free (buf);
482 
483 	buf = NULL;
484 	ignore = g_settings_get_strv (prefs->proxy_settings, "ignore-hosts");
485 	if (ignore) {
486 		/* reconstruct comma-separated list */
487 		buf = g_strjoinv (",", ignore);
488 		g_strfreev (ignore);
489 	}
490 
491 	gtk_entry_set_text (prefs->ignore_hosts, buf ? buf : "");
492 	g_free (buf);
493 
494 	buf = g_settings_get_string (prefs->proxy_settings, "authentication-user");
495 	gtk_entry_set_text (prefs->auth_user, buf ? buf : "");
496 	g_free (buf);
497 
498 	buf = g_settings_get_string (prefs->proxy_settings, "authentication-password");
499 	gtk_entry_set_text (prefs->auth_pwd, buf ? buf : "");
500 	g_free (buf);
501 
502 	port = g_settings_get_int (prefs->proxy_settings, "http-port");
503 	gtk_spin_button_set_value (prefs->http_port, (gdouble) port);
504 
505 	port = g_settings_get_int (prefs->proxy_settings, "secure-port");
506 	gtk_spin_button_set_value (prefs->https_port, (gdouble) port);
507 
508 	port = g_settings_get_int (prefs->proxy_settings, "socks-port");
509 	gtk_spin_button_set_value (prefs->socks_port, (gdouble) port);
510 
511 	emnp_set_markups (prefs);
512 
513 	if (val == NETWORK_PROXY_DIRECT_CONNECTION ||
514 	    val == NETWORK_PROXY_SYS_SETTINGS) {
515 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
516 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE);
517 	} else if (val == NETWORK_PROXY_AUTOCONFIG) {
518 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE);
519 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, TRUE);
520 	} else if (val == NETWORK_PROXY_MANUAL) {
521 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE);
522 		emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, TRUE);
523 	}
524 
525 	/* get our toplevel widget */
526 	target = em_config_target_new_prefs (ec);
527 	e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
528 	toplevel = e_config_create_widget ((EConfig *) ec);
529 	gtk_container_add (GTK_CONTAINER (prefs), toplevel);
530 }
531 
532 GtkWidget *
533 em_network_prefs_new (EPreferencesWindow *window)
534 {
535 	EMNetworkPrefs *new;
536 
537 	new = (EMNetworkPrefs *) g_object_new (em_network_prefs_get_type (), NULL);
538 	em_network_prefs_construct (new);
539 
540 	return (GtkWidget *) new;
541 }