diff options
Diffstat (limited to 'src/uzbl-core.c')
-rw-r--r-- | src/uzbl-core.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 5834f8b..a309bf8 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -2393,16 +2393,15 @@ void handle_authentication (SoupSession *session, SoupMessage *msg, SoupAuth *au } } -void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data){ +void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data) { (void) session; (void) user_data; - //if (!uzbl.behave.cookie_handler) - // return; - soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies), NULL); + soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies_http), NULL); GString *s = g_string_new (""); SoupURI * soup_uri = soup_message_get_uri(msg); g_string_printf(s, "GET '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path); + if(uzbl.behave.cookie_handler) run_handler(uzbl.behave.cookie_handler, s->str); @@ -2419,7 +2418,8 @@ void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data) char *cookies = (char *) g_malloc(len+1); strncpy(cookies, uzbl.comm.sync_stdout, len+1); - g_object_disconnect((GObject*)uzbl.net.soup_cookie_jar, "any_signal", (GCallback)cookie_handler_cb, NULL, NULL); + /* Disconnect to avoid recusion */ + g_object_disconnect(G_OBJECT(uzbl.net.soup_cookie_jar), "any_signal", G_CALLBACK(save_cookies_js), NULL, NULL); p = cookies - 1; while(p != NULL) { @@ -2430,10 +2430,11 @@ void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data) p = strchr(p, ';'); } - g_object_connect((GObject*)uzbl.net.soup_cookie_jar, "signal::changed", (GCallback)cookie_handler_cb, NULL, NULL); + g_object_connect(G_OBJECT(uzbl.net.soup_cookie_jar), "signal::changed", G_CALLBACK(save_cookies_js), NULL, NULL); g_free(cookies); } } + if (uzbl.comm.sync_stdout) uzbl.comm.sync_stdout = strfree(uzbl.comm.sync_stdout); @@ -2441,23 +2442,6 @@ void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data) } void -save_cookies (SoupMessage *msg, gpointer user_data){ - (void) user_data; - GSList *ck; - char *cookie; - for (ck = soup_cookies_from_response(msg); ck; ck = ck->next){ - cookie = soup_cookie_to_set_cookie_header(ck->data); - SoupURI * soup_uri = soup_message_get_uri(msg); - GString *s = g_string_new (""); - g_string_printf(s, "PUT '%s' '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path, cookie); - run_handler(uzbl.behave.cookie_handler, s->str); - g_free (cookie); - g_string_free(s, TRUE); - } - g_slist_free(ck); -} - -void dump_var_hash(gpointer k, gpointer v, gpointer ud) { (void) ud; uzbl_cmdprop *c = v; @@ -2558,7 +2542,7 @@ initialize(int argc, char *argv[]) { uzbl.net.soup_cookie_jar = soup_cookie_jar_new(); soup_session_add_feature(uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_cookie_jar)); - g_object_connect((GObject*)uzbl.net.soup_cookie_jar, "signal::changed", (GCallback)cookie_handler_cb, NULL, NULL); + g_object_connect(G_OBJECT(uzbl.net.soup_cookie_jar), "signal::changed", G_CALLBACK(save_cookies_js), NULL, NULL); for(i=0; sigs[i]; i++) { if(setup_signal(sigs[i], catch_signal) == SIG_ERR) |