static Display *dpy;
static Atom uriprop;
-static SoupCookieJar *cookiejar;
++static SoupCookieJar *cookies;
+ static SoupSession *session;
static Client *clients = NULL;
static GdkNativeWindow embed = 0;
static gboolean showxid = FALSE;
static gboolean ignore_once = FALSE;
static char winid[64];
static char *progname;
++static gboolean lockcookie = FALSE;
static const char *autouri(Client *c);
static char *buildpath(const char *path);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
static void print(Client *c, const Arg *arg);
static void progresschange(WebKitWebView *v, gint p, Client *c);
++static void reloadcookies();
static void reload(Client *c, const Arg *arg);
- static void request(SoupSession *s, SoupMessage *m, gpointer p);
-static void reloadcookie();
static void sigchld(int unused);
- static void setcookie(SoupMessage *m, gpointer p);
static void setup(void);
static void spawn(Client *c, const Arg *arg);
static void scroll(Client *c, const Arg *arg);
return apath;
}
-changecookie(SoupCookieJar *jar, SoupCookie *oc, SoupCookie *c, gpointer p) {
+ void
- soup_cookie_jar_add_cookie(cookiejar, c);
++changecookie(SoupCookieJar *j, SoupCookie *oc, SoupCookie *c, gpointer p) {
+ SoupDate *e;
++ SoupCookieJar *jar;
+
++ if(lockcookie)
++ return;
+ 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);
+ }
++
++ jar = soup_cookie_jar_text_new(cookiefile, FALSE);
++ if(c)
++ soup_cookie_jar_add_cookie(jar, soup_cookie_copy(c));
++ else
++ soup_cookie_jar_delete_cookie(jar, oc);
++ g_object_unref(jar);
+ }
+
void
cleanup(void) {
while(clients)
XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), uriprop,
XA_STRING, 8, PropModeReplace, (unsigned char *)uri,
strlen(uri) + 1);
-}
+
-void
-loadfinished(WebKitWebView *v, WebKitWebFrame *f, Client *c) {
- reloadcookie();
++ reloadcookies();
}
void
webkit_web_view_reload(c->view);
}
-reloadcookie(void) {
- SoupSession *s;
-
- /* This forces the cookie to be written to hdd */
- s = webkit_get_default_session();
- soup_session_remove_feature(s, SOUP_SESSION_FEATURE(cookiejar));
- soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
-}
+ void
++reloadcookies() {
++ SoupCookieJar *jar;
++ GSList *l, *e;
++
++ lockcookie = TRUE;
++ for(l = e = soup_cookie_jar_all_cookies(cookies); e; e = e->next)
++ soup_cookie_jar_delete_cookie(cookies, (SoupCookie *)e->data);
++ soup_cookies_free(l);
++ jar = soup_cookie_jar_text_new(cookiefile, TRUE);
++ for(l = e = soup_cookie_jar_all_cookies(jar); e; e = e->next)
++ soup_cookie_jar_add_cookie(cookies, (SoupCookie *)e->data);
++ g_slist_free(l);
++ lockcookie = FALSE;
++ g_object_unref(jar);
++}
+
void
scroll(Client *c, const Arg *arg) {
gdouble v;
/* cookie persistance */
s = webkit_get_default_session();
- g_signal_connect_after(s, "request-queued", G_CALLBACK(request), NULL);
- 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);
++ cookies = soup_cookie_jar_new();
++ soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookies));
++ g_signal_connect(cookies, "changed", G_CALLBACK(changecookie), NULL);
++ reloadcookies();
}
void