649
651
return (char **) g_ptr_array_free (argv, FALSE);
657
conf_get_string (GConfClient *conf,
661
value = gconf_client_get_string (conf, key, NULL);
662
if (G_UNLIKELY (value && *value == '\0'))
672
* @env_table: a #GHashTable
673
* @key: the env var name
674
* @value: the env var value
676
* Adds @value for @key to @env_table, taking care to never overwrite an
677
* existing value for @key. @value is consumed.
680
set_proxy_env (GHashTable *env_table,
684
char *key1 = NULL, *key2 = NULL;
685
char *value1 = NULL, *value2 = NULL;
690
if (g_hash_table_lookup (env_table, key) == NULL)
691
key1 = g_strdup (key);
693
key2 = g_ascii_strup (key, -1);
694
if (g_hash_table_lookup (env_table, key) != NULL)
703
value2 = g_strdup (value);
713
g_hash_table_replace (env_table, key1, value1);
715
g_hash_table_replace (env_table, key2, value2);
719
setup_http_proxy_env (GHashTable *env_table,
722
gchar *host, *auth = NULL;
726
if (!gconf_client_get_bool (conf, CONF_HTTP_PROXY_PREFIX "/use_http_proxy", NULL))
729
if (gconf_client_get_bool (conf, CONF_HTTP_PROXY_PREFIX "/use_authentication", NULL))
731
char *user, *password;
732
user = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/authentication_user");
733
password = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/authentication_password");
738
auth = g_strdup_printf ("%s:%s", user, password);
747
host = conf_get_string (conf, CONF_HTTP_PROXY_PREFIX "/host");
748
port = gconf_client_get_int (conf, CONF_HTTP_PROXY_PREFIX "/port", NULL);
753
proxy = g_strdup_printf ("http://%s@%s:%d/", auth, host, port);
755
proxy = g_strdup_printf ("http://%s:%d/", host, port);
756
set_proxy_env (env_table, "http_proxy", proxy);
763
ignore = gconf_client_get_list (conf, CONF_HTTP_PROXY_PREFIX "/ignore_hosts", GCONF_VALUE_STRING, NULL);
766
GString *buf = g_string_sized_new (64);
767
while (ignore != NULL)
772
g_string_append_c (buf, ',');
773
g_string_append (buf, ignore->data);
776
ignore = g_slist_next (ignore);
778
g_slist_free_1 (old);
780
set_proxy_env (env_table, "no_proxy", g_string_free (buf, FALSE));
785
setup_https_proxy_env (GHashTable *env_table,
791
host = conf_get_string (conf, CONF_PROXY_PREFIX "/secure_host");
792
port = gconf_client_get_int (conf, CONF_PROXY_PREFIX "/secure_port", NULL);
796
proxy = g_strdup_printf ("https://%s:%d/", host, port);
797
set_proxy_env (env_table, "https_proxy", proxy);
803
setup_ftp_proxy_env (GHashTable *env_table,
809
host = conf_get_string (conf, CONF_PROXY_PREFIX "/ftp_host");
810
port = gconf_client_get_int (conf, CONF_PROXY_PREFIX "/ftp_port", NULL);
814
proxy = g_strdup_printf ("ftp://%s:%d/", host, port);
815
set_proxy_env (env_table, "ftp_proxy", proxy);
821
setup_socks_proxy_env (GHashTable *env_table,
827
host = conf_get_string (conf, CONF_PROXY_PREFIX "/socks_host");
828
port = gconf_client_get_int (conf, CONF_PROXY_PREFIX "/socks_port", NULL);
832
proxy = g_strdup_printf ("socks://%s:%d/", host, port);
833
set_proxy_env (env_table, "all_proxy", proxy);
839
setup_autoconfig_proxy_env (GHashTable *env_table,
844
url = conf_get_string (conf, CONF_PROXY_PREFIX "/autoconfig_url");
847
/* XXX Not sure what to do with it. See bug 596688
849
proxy = g_strdup_printf ("pac+%s", url);
850
set_proxy_env (env_table, "http_proxy", proxy);
857
* terminal_util_add_proxy_env:
858
* @env_table: a #GHashTable
860
* Adds the proxy env variables to @env_table.
863
terminal_util_add_proxy_env (GHashTable *env_table)
868
conf = gconf_client_get_default ();
870
/* If mode is not manual, nothing to set */
871
proxymode = conf_get_string (conf, CONF_PROXY_PREFIX "/mode");
872
if (proxymode && 0 == strcmp (proxymode, "manual"))
874
setup_http_proxy_env (env_table, conf);
875
setup_https_proxy_env (env_table, conf);
876
setup_ftp_proxy_env (env_table, conf);
877
setup_socks_proxy_env (env_table, conf);
879
else if (proxymode && 0 == strcmp (proxymode, "auto"))
881
setup_autoconfig_proxy_env (env_table, conf);
885
g_object_unref (conf);
652
888
/* Bidirectional object/widget binding */