diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | examples/scripts/cookies.sh | 62 | ||||
-rw-r--r-- | uzbl.c | 15 | ||||
-rw-r--r-- | uzbl.h | 19 |
5 files changed, 30 insertions, 71 deletions
@@ -1,2 +1,3 @@ uzbl -uzblctrl
\ No newline at end of file +uzblctrl +examples/data
\ No newline at end of file @@ -1,4 +1,4 @@ -CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -Wall -W -std=c99 -pedantic +CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -Wall -W LDFLAGS=$(shell pkg-config --libs gtk+-2.0 webkit-1.0) all: uzbl uzblctrl diff --git a/examples/scripts/cookies.sh b/examples/scripts/cookies.sh index 69b786f..d147930 100755 --- a/examples/scripts/cookies.sh +++ b/examples/scripts/cookies.sh @@ -1,62 +1,2 @@ #!/bin/bash -# this is an example script of how you could manage your cookies.. -# you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies) - -# MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :( -# TODO: different cookie paths per config (eg per group of uzbl instances) - -if [ -f /usr/share/uzbl/examples/configs/cookies ] -then - file=/usr/share/uzbl/examples/configs/cookies -else - file=./examples/configs/cookies #useful when developing -fi - -if [ -d $XDG_DATA_HOME/uzbl/cookies ] -then - cookie_dir=$XDG_DATA_HOME/uzbl/cookies -else - cookie_dir=./examples/data -fi - -which zenity &>/dev/null || exit 2 - -uri=$6 -action=$8 # GET/PUT -host=${uri/\/*/} - - - -# $1 = section (TRUSTED or DENY) -# $2 =url -function match () { - sed -n "/$1/,/^\$/p" $file 2>/dev/null | grep -q "^$host" -} - -function readcookie () { - cookie= - while read - do - cookie="$REPLY -" - done -} - -function fetch_cookie () { - cookie=`cat $cookie_dir/$host.cookie` -} - -function store_cookie () { - echo $cookie > $cookie_dir/$host.cookie -} - -if match TRUSTED $host -then - [ $action == PUT ] && readcookie && store_cookie $host - [ $action == GET ] && fetch_cookie && echo "$cookie" -elif ! match DENY $host -then - [ $action == PUT ] && readcookie && zenity --question --title 'Uzbl Cookie handler' --text "Accept cookie from $host ? Contents:\n$cookie" && store_cookie $host - [ $action == GET ] && fetch_cookie && zenity --question --title 'Uzbl Cookie handler' --text "Submit cookie to $host ? Contents:\n$cookie" && echo $cookie -fi -exit 0 +echo $8 - $9 @@ -862,7 +862,8 @@ settings_init () { static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data){ - soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies)); + soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies), NULL); + /* ask handler for cookies, if there are any, use soup_message_headers_replace (msg->request_headers, "Cookie", cookies); @@ -873,7 +874,17 @@ static void handle_cookies (SoupSession *session, static void save_cookies (SoupMessage *msg, gpointer user_data){ - /* give them to handler */ + GSList *ck; + char *req, *cookie; + for (ck = soup_cookies_from_response(msg); ck; ck = ck->next){ + cookie = soup_cookie_to_set_cookie_header(ck->data); + req = malloc(strlen(cookie) + 10); + sprintf(req, "PUT \"%s\"", cookie); + run_command_async(cookie_handler, req); + free(req); + free(cookie); + } + g_slist_free(ck); } int @@ -111,10 +111,17 @@ settings_init (); /* SoupCookie *old_cookie, */ /* SoupCookie *new_cookie, */ /* gpointer user_data); */ -static void -catch_cookies (SoupSession *session, - SoupMessage *msg, - gpointer user_data); - /* SoupSocket *socket, */ - /* gpointer user_data); */ +/* static void */ +/* catch_cookies (SoupSession *session, */ +/* SoupMessage *msg, */ +/* gpointer user_data); */ +/* /\* SoupSocket *socket, *\/ */ +/* /\* gpointer user_data); *\/ */ + +static void handle_cookies (SoupSession *session, + SoupMessage *msg, + gpointer user_data); +static void +save_cookies (SoupMessage *msg, + gpointer user_data); /* vi: set et ts=4: */ |