diff options
author | Enno Boland (tox) <tox@s01.de> | 2009-10-17 13:19:21 +0200 |
---|---|---|
committer | Enno Boland (tox) <tox@s01.de> | 2009-10-17 13:19:21 +0200 |
commit | 9a3c48389301917fb3e71c21fe87a074a0c2a164 (patch) | |
tree | b0f58c43b90009b484d2d2d4537338f154634130 /surf.c | |
parent | e9ee0940b7552f087dc3377f160f5c0800045a36 (diff) | |
download | surf-9a3c48389301917fb3e71c21fe87a074a0c2a164.tar.gz surf-9a3c48389301917fb3e71c21fe87a074a0c2a164.tar.bz2 surf-9a3c48389301917fb3e71c21fe87a074a0c2a164.zip |
using events for changing cookies
Diffstat (limited to 'surf.c')
-rw-r--r-- | surf.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -73,6 +73,7 @@ static char *progname; static const char *autouri(Client *c); static char *buildpath(const char *path); +static void changecookie(SoupCookieJar *jar, SoupCookie *o, SoupCookie *n, gpointer p); static void cleanup(void); static void clipboard(Client *c, const Arg *arg); static void context(WebKitWebView *v, GtkMenu *m, Client *c); @@ -156,6 +157,18 @@ buildpath(const char *path) { } void +changecookie(SoupCookieJar *jar, SoupCookie *oc, SoupCookie *c, gpointer p) { + SoupDate *e; + + if(c && c->expires == NULL) { + e = soup_date_new_from_time_t(time(NULL) + sessiontime); + c = soup_cookie_copy(c); + soup_cookie_set_expires(c, e); + soup_cookie_jar_add_cookie(cookiejar, c); + } +} + +void cleanup(void) { while(clients) destroyclient(clients); @@ -630,22 +643,8 @@ reload(Client *c, const Arg *arg) { void reloadcookie(void) { - GSList *p, *l; - SoupCookie *c; SoupSession *s; - SoupDate *e; - e = soup_date_new_from_time_t(time(NULL) + sessiontime); - for(l = p = soup_cookie_jar_all_cookies(cookiejar); p; p = p->next) { - c = (SoupCookie *)l->data; - if(c->expires == NULL) { - soup_cookie_set_expires(c, e); - soup_cookie_jar_add_cookie(cookiejar, - soup_cookie_copy(c)); - } - } - soup_cookies_free(l); - soup_date_free(e); /* This forces the cookie to be written to hdd */ s = webkit_get_default_session(); soup_session_remove_feature(s, SOUP_SESSION_FEATURE(cookiejar)); @@ -696,6 +695,7 @@ setup(void) { s = webkit_get_default_session(); cookiejar = soup_cookie_jar_text_new(cookiefile, FALSE); soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar)); + g_signal_connect(cookiejar, "changed", G_CALLBACK(changecookie), NULL); } void |