const Arg arg;
} Item;
-typedef struct Cookie {
- char *name;
- char *value;
- char *domain;
- char *path;
- struct Cookie *next;
-} Cookie;
-
typedef enum {
Browser = 0x0001,
SearchBar = 0x0010,
static SoupCookieJar *cookiejar;
static SoupSession *session;
static Client *clients = NULL;
-/*static Cookie *cookies = NULL;*/
static GdkNativeWindow embed = 0;
static gboolean showxid = FALSE;
static gboolean ignore_once = FALSE;
static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c);
static void loadcommit(WebKitWebView *v, WebKitWebFrame *f, Client *c);
+static void loadfinished(WebKitWebView *v, WebKitWebFrame *f, Client *c);
static void loadstart(WebKitWebView *v, WebKitWebFrame *f, Client *c);
static void loaduri(Client *c, const Arg *arg);
static void navigate(Client *c, const Arg *arg);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
static void print(Client *c, const Arg *arg);
-static void proccookies(SoupMessage *m, Client *c);
static void progresschange(WebKitWebView *v, gint p, Client *c);
-static void request(SoupSession *s, SoupMessage *m, Client *c);
static void reload(Client *c, const Arg *arg);
-static void rereadcookies(void);
+static void reloadcookie();
static void sigchld(int unused);
-static void setcookie(char *name, char *val, char *dom, char *path, long exp);
static void setup(void);
static void spawn(Client *c, const Arg *arg);
-static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c);
static void scroll(Client *c, const Arg *arg);
static void searchtext(Client *c, const Arg *arg);
static void source(Client *c, const Arg *arg);
if(parent)
gtk_container_remove(parent, c->items[i]);
gtk_menu_shell_append(GTK_MENU_SHELL(m), c->items[i]);
- g_signal_connect(G_OBJECT(c->items[i]), "activate",
- G_CALLBACK(itemclick), c);
gtk_widget_show(c->items[i]);
}
}
strlen(uri) + 1);
}
+void
+loadfinished(WebKitWebView *v, WebKitWebFrame *f, Client *c) {
+ reloadcookie();
+}
+
void
loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c) {
+ reloadcookie();
c->progress = 0;
update(c);
}
die("Cannot malloc!\n");
/* contextmenu */
- for(i = 0; i < LENGTH(items); i++)
+ for(i = 0; i < LENGTH(items); i++) {
c->items[i] = gtk_menu_item_new_with_label(items[i].label);
+ g_signal_connect(G_OBJECT(c->items[i]), "activate",
+ G_CALLBACK(itemclick), c);
+ }
/* VBox */
c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c);
+ g_signal_connect(G_OBJECT(c->view), "load-finished", G_CALLBACK(loadfinished), c);
g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c);
g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c);
g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
g_signal_connect(G_OBJECT(c->view), "new-window-policy-decision-requested", G_CALLBACK(decidewindow), c);
g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c);
- g_signal_connect_after(session, "request-started", G_CALLBACK(request), c);
g_signal_connect(G_OBJECT(c->view), "focus-in-event", G_CALLBACK(focusview), c);
g_signal_connect(G_OBJECT(c->view), "populate-popup", G_CALLBACK(context), c);
webkit_web_frame_print(webkit_web_view_get_main_frame(c->view));
}
-void
-proccookies(SoupMessage *m, Client *c) {
- GSList *l;
- SoupCookie *co;
- long t;
-
- rereadcookies();
- for (l = soup_cookies_from_response(m); l; l = l->next){
- co = (SoupCookie *)l->data;
- t = co->expires ? soup_date_to_time_t(co->expires) : 0;
- setcookie(co->name, co->value, co->domain, co->value, t);
- }
- g_slist_free(l);
-}
-
void
progresschange(WebKitWebView *v, gint p, Client *c) {
c->progress = p;
update(c);
}
-void
-request(SoupSession *s, SoupMessage *m, Client *c) {
- soup_message_add_header_handler(m, "got-headers", "Set-Cookie",
- G_CALLBACK(proccookies), c);
-}
-
void
reload(Client *c, const Arg *arg) {
gboolean nocache = *(gboolean *)arg;
}
void
-rereadcookies(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));
+ soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
+}
void
scroll(Client *c, const Arg *arg) {
while(0 < waitpid(-1, NULL, WNOHANG));
}
-void
-setcookie(char *name, char *val, char *dom, char *path, long exp) {
-
-}
-
void
setup(void) {
SoupSession *s;
dpy = GDK_DISPLAY();
session = webkit_get_default_session();
- uriprop = XInternAtom(dpy, "_SURF_uri", False);
+ uriprop = XInternAtom(dpy, "_SURF_URI", False);
/* create dirs and files */
cookiefile = buildpath(cookiefile);