diff -r 70bc02545634 Makefile --- a/Makefile Fri Oct 12 20:11:11 2012 -0300 +++ b/Makefile Fri Oct 12 20:19:20 2012 -0300 @@ -18,7 +18,7 @@ @echo CC $< @${CC} -c ${CFLAGS} $< -${OBJ}: config.h config.mk +${OBJ}: config.h config.mk cookie.c config.h: @echo creating $@ from config.def.h diff -r 70bc02545634 surf.c --- a/surf.c Fri Oct 12 20:11:11 2012 -0300 +++ b/surf.c Fri Oct 12 20:19:20 2012 -0300 @@ -79,9 +79,7 @@ static gboolean exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c); static void find(Client *c, const Arg *arg); static const char *getatom(Client *c, int a); -static const char *getcookies(SoupURI *uri); static char *geturi(Client *c); -void gotheaders(SoupMessage *msg, gpointer user_data); static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c); static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c); static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c); @@ -90,7 +88,6 @@ static void navigate(Client *c, const Arg *arg); static Client *newclient(void); static void newwindow(Client *c, const Arg *arg); -static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v); static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); static void print(Client *c, const Arg *arg); static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d); @@ -100,7 +97,6 @@ static void scroll_v(Client *c, const Arg *arg); static void scroll(GtkAdjustment *a, const Arg *arg); static void setatom(Client *c, int a, const char *v); -static void setcookie(SoupCookie *c); static void setup(void); static void sigchld(int unused); static void source(Client *c, const Arg *arg); @@ -116,6 +112,7 @@ /* configuration, allows nested code to access above variables */ #include "config.h" +#include "cookie.c" char * buildpath(const char *path) { @@ -296,15 +293,6 @@ } const char * -getcookies(SoupURI *uri) { - const char *c; - SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, TRUE); - c = soup_cookie_jar_get_cookies(j, uri, TRUE); - g_object_unref(j); - return c; -} - -const char * getatom(Client *c, int a) { static char buf[BUFSIZ]; Atom adummy; @@ -332,17 +320,6 @@ return uri; } -void -gotheaders(SoupMessage *msg, gpointer v) { - GSList *l, *p; - - for(p = l = soup_cookies_from_response(msg); p; - p = g_slist_next(p)) { - setcookie((SoupCookie *)p->data); - } - soup_cookies_free(l); -} - gboolean initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) { Arg arg; @@ -555,19 +532,6 @@ } void -newrequest(SoupSession *s, SoupMessage *msg, gpointer v) { - SoupMessageHeaders *h = msg->request_headers; - SoupURI *uri; - const char *c; - - soup_message_headers_remove(h, "Cookie"); - uri = soup_message_get_uri(msg); - if((c = getcookies(uri))) - soup_message_headers_append(h, "Cookie", c); - g_signal_connect_after(G_OBJECT(msg), "got-headers", G_CALLBACK(gotheaders), NULL); -} - -void newwindow(Client *c, const Arg *arg) { guint i = 0; const char *cmd[10], *uri; @@ -683,25 +647,6 @@ } void -setcookie(SoupCookie *c) { - int lock; - - lock = open(cookiefile, 0); - flock(lock, LOCK_EX); - SoupDate *e; - SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, FALSE); - c = soup_cookie_copy(c); - if(c->expires == NULL && sessiontime) { - e = soup_date_new_from_time_t(time(NULL) + sessiontime); - soup_cookie_set_expires(c, e); - } - soup_cookie_jar_add_cookie(j, c); - g_object_unref(j); - flock(lock, LOCK_UN); - close(lock); -} - -void setatom(Client *c, int a, const char *v) { XSync(dpy, False); XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), atoms[a], @@ -737,9 +682,7 @@ /* request handler */ s = webkit_get_default_session(); - soup_session_remove_feature_by_type(s, soup_cookie_get_type()); - soup_session_remove_feature_by_type(s, soup_cookie_jar_get_type()); - g_signal_connect_after(G_OBJECT(s), "request-started", G_CALLBACK(newrequest), NULL); + soup_session_add_feature(s, SOUP_SESSION_FEATURE(surf_cookie_jar_new(cookiefile, FALSE))); /* ssl */ g_object_set(G_OBJECT(s), "ssl-ca-file", cafile, NULL);