diff options
author | Evgeny Grablyk <evgeny.grablyk@gmail.com> | 2009-05-01 20:44:13 +0300 |
---|---|---|
committer | Evgeny Grablyk <evgeny.grablyk@gmail.com> | 2009-05-01 20:44:13 +0300 |
commit | f1abf36c4a8d2b05af81ca8d4f886090f5e01867 (patch) | |
tree | 90f377877bb5c09888f0082a9044014e79828a49 /uzbl.c | |
parent | a77e1a4df94f2aceedf711f22027e283ee967b31 (diff) |
Add support for network settings
Proxy support.
Sopport setting user-agent, max. connections number and such.
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 52 |
1 files changed, 51 insertions, 1 deletions
@@ -1,3 +1,4 @@ +/* -*- c-basic-offset: 4; */ // Original code taken from the example webkit-gtk+ application. see notice below. // Modified code is licensed under the GPL 3. See LICENSE file. @@ -49,6 +50,7 @@ #include <fcntl.h> #include <sys/socket.h> #include <sys/un.h> +#include <libsoup/soup.h> /* housekeeping / internal variables */ static GtkWidget* main_window; @@ -79,6 +81,7 @@ static gboolean insert_mode = FALSE; static gboolean status_top = FALSE; static gchar* modkey = NULL; static guint modmask = 0; +static guint http_debug = 0; /* settings from config: group bindings, key -> action */ static GHashTable *bindings; @@ -106,6 +109,14 @@ typedef void (*Command)(WebKitWebView*, const char *); static char *XDG_CONFIG_HOME_default[256]; static char *XDG_CONFIG_DIRS_default = "/etc/xdg"; +/* libsoup stuff - proxy and friends; networking aptions actually */ +static SoupSession *soup_session; +static SoupLogger *soup_logger; +static char *proxy_url = NULL; +static char *useragent = NULL; +static gint max_conns; +static gint max_conns_host; + static void update_title (GtkWindow* window); @@ -744,6 +755,44 @@ settings_init () { g_strfreev(keys); } + + /* networking options */ + proxy_url = g_key_file_get_value(config, "network", "proxy_server", NULL); + http_debug = g_key_file_get_integer(config, "network", "http_debug", NULL); + useragent = g_key_file_get_value(config, "network", "user-agent", NULL); + max_conns = g_key_file_get_integer(config, "network", "max_conns", NULL); + max_conns_host = g_key_file_get_integer(config, "network", "max_conns_per_host", NULL); + + if(proxy_url){ + g_object_set(G_OBJECT(soup_session), SOUP_SESSION_PROXY_URI, soup_uri_new(proxy_url), NULL); + printf("Proxy configured: %s\n", proxy_url ? proxy_url : "none"); + } + + if(!(http_debug <= 3)){ + http_debug = 0; + fprintf(stderr, "Wrong http_debug level, ignoring.\n"); + } else { + soup_logger = soup_logger_new(http_debug, -1); + soup_session_add_feature(soup_session, SOUP_SESSION_FEATURE(soup_logger)); + printf("HTTP logging level: %d\n", http_debug); + } + + if(useragent){ + g_object_set(G_OBJECT(soup_session), SOUP_SESSION_USER_AGENT, useragent, NULL); + printf("User-agent: %s\n", useragent); + } else { + printf("User-agent: webkit default\n"); + } + + if(max_conns >= 1){ + g_object_set(G_OBJECT(soup_session), SOUP_SESSION_MAX_CONNS, max_conns, NULL); + printf("Maximum connections set to: %d\n", max_conns); + } + if(max_conns_host >= 1){ + g_object_set(G_OBJECT(soup_session), SOUP_SESSION_MAX_CONNS_PER_HOST, max_conns_host, NULL); + printf("Maximum connections per host set to: %d\n", max_conns_host); + } + } int @@ -764,7 +813,8 @@ main (int argc, char* argv[]) { g_option_context_parse (context, &argc, &argv, &error); /* initialize hash table */ bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_action); - + + soup_session = webkit_get_default_session(); settings_init (); commands_hash (); |