deb916fcc70c87ff39fd65428b5de69d11f25b70
[surf.git] / surf.c
1 /* See LICENSE file for copyright and license details.
2  *
3  * To understand surf, start reading main().
4  */
5 #include <X11/X.h>
6 #include <X11/Xatom.h>
7 #include <gtk/gtk.h>
8 #include <gdk/gdkx.h>
9 #include <gdk/gdk.h>
10 #include <gdk/gdkkeysyms.h>
11 #include <string.h>
12 #include <unistd.h>
13 #include <getopt.h>
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <webkit/webkit.h>
17 #include <glib/gstdio.h>
18
19 #define LENGTH(x) (sizeof x / sizeof x[0])
20 #define CLEANMASK(mask)         (mask & ~(GDK_MOD2_MASK))
21
22 Display *dpy;
23 Atom urlprop;
24 typedef union Arg Arg;
25 union Arg {
26         const gboolean b;
27         const gint i;
28         const void *v;
29 } ;
30
31 typedef struct Client {
32         GtkWidget *win, *scroll, *vbox, *urlbar, *searchbar, *indicator;
33         WebKitWebView *view;
34         WebKitDownload *download;
35         gchar *title;
36         gint progress;
37         struct Client *next;
38 } Client;
39
40 typedef struct Cookie {
41         char *name;
42         char *value;
43         char *domain;
44         char *path;
45         struct Cookie *next;
46 } Cookie;
47
48 typedef enum {
49     BROWSER = 0x0001,
50     SEARCHBAR = 0x0010,
51     URLBAR = 0x0100,
52     ALWAYS = ~0,
53 } KeyFocus;
54
55 typedef struct {
56         guint mod;
57         guint keyval;
58         void (*func)(Client *c, const Arg *arg);
59         const Arg arg;
60         KeyFocus focus;
61 } Key;
62
63 SoupCookieJar *cookiejar;
64 SoupSession *session;
65 Client *clients = NULL;
66 Cookie *cookies = NULL;
67 gboolean embed = FALSE;
68 gboolean showxid = FALSE;
69 gboolean ignore_once = FALSE;
70 extern char *optarg;
71 extern gint optind;
72
73 static void cleanup(void);
74 static void proccookies(SoupMessage *m, Client *c);
75 static void clipboard(Client *c, const Arg *arg);
76 static void destroyclient(Client *c);
77 static void destroywin(GtkWidget* w, Client *c);
78 static void die(char *str);
79 static void download(WebKitDownload *o, GParamSpec *pspec, Client *c);
80 static void drawindicator(Client *c);
81 static gboolean exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c);
82 static gboolean initdownload(WebKitWebView *view, WebKitDownload *o, Client *c);
83 static gchar *geturi(Client *c);
84 static void hidesearch(Client *c, const Arg *arg);
85 static void hideurl(Client *c, const Arg *arg);
86 static gboolean keypress(GtkWidget* w, GdkEventKey *ev, Client *c);
87 static void linkhover(WebKitWebView* page, const gchar* t, const gchar* l, Client *c);
88 static void loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c);
89 static void loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c);
90 static void loadfile(Client *c, const gchar *f);
91 static void loaduri(Client *c, const Arg *arg);
92 static void navigate(Client *c, const Arg *arg);
93 static Client *newclient();
94 static WebKitWebView *newwindow(WebKitWebView  *v, WebKitWebFrame *f, Client *c);
95 static void pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d);
96 static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
97 static void print(Client *c, const Arg *arg);
98 static void progresschange(WebKitWebView *view, gint p, Client *c);
99 static void request(SoupSession *s, SoupMessage *m, Client *c);
100 static void reload(Client *c, const Arg *arg);
101 static void rereadcookies();
102 static void setcookie(char *name, char *val, char *dom, char *path, long exp);
103 static void setup();
104 static void titlechange(WebKitWebView* view, WebKitWebFrame* frame,
105                 const gchar* title, Client *c);
106 static void searchtext(Client *c, const Arg *arg);
107 static void showsearch(Client *c, const Arg *arg);
108 static void showurl(Client *c, const Arg *arg);
109 static void stop(Client *c, const Arg *arg);
110 static void titlechange(WebKitWebView* view, WebKitWebFrame* frame, const gchar* title, Client *c);
111 static void usage();
112 static void update(Client *c, const gchar *title);
113 static void zoom(Client *c, const Arg *arg);
114
115 #include "config.h"
116
117 void
118 cleanup(void) {
119         while(clients)
120                 destroyclient(clients);
121 }
122
123 void
124 proccookies(SoupMessage *m, Client *c) {
125         GSList *l;
126         SoupCookie *co;
127         long t;
128
129         rereadcookies();
130         for (l = soup_cookies_from_response(m); l; l = l->next){
131                 co = (SoupCookie *)l->data;
132                 t = co->expires ?  soup_date_to_time_t(co->expires) : 0;
133                 setcookie(co->name, co->value, co->domain, co->value, t);
134         }
135         g_slist_free(l);
136 }
137
138 void
139 clipboard(Client *c, const Arg *arg) {
140         gboolean paste = *(gboolean *)arg;
141         if(paste)
142                 gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteurl, c);
143         else
144                 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), webkit_web_view_get_uri(c->view), -1);
145 }
146
147 void
148 destroyclient(Client *c) {
149         Client *p;
150
151         gtk_widget_destroy(GTK_WIDGET(webkit_web_view_new()));
152         gtk_widget_destroy(c->scroll);
153         gtk_widget_destroy(c->urlbar);
154         gtk_widget_destroy(c->searchbar);
155         gtk_widget_destroy(c->vbox);
156         gtk_widget_destroy(c->win);
157         for(p = clients; p && p->next != c; p = p->next);
158         if(p)
159                 p->next = c->next;
160         else
161                 clients = c->next;
162         free(c);
163         if(clients == NULL)
164                 gtk_main_quit();
165 }
166
167 void
168 destroywin(GtkWidget* w, Client *c) {
169         destroyclient(c);
170 }
171
172 void
173 die(char *str) {
174         fputs(str, stderr);
175         exit(EXIT_FAILURE);
176 }
177
178 void
179 drawindicator(Client *c) {
180         gint width;
181         gchar *uri;
182         GtkWidget *w;
183         GdkGC *gc;
184         GdkColor fg;
185
186         uri = geturi(c);
187         w = c->indicator;
188         width = c->progress * w->allocation.width / 100;
189         gc = gdk_gc_new(w->window);
190         gdk_color_parse(strstr(uri, "https://") == uri ?
191                         progress_trust : progress, &fg);
192         gdk_gc_set_rgb_fg_color(gc, &fg);
193         gdk_draw_rectangle(w->window,
194                         w->style->bg_gc[GTK_WIDGET_STATE(w)],
195                         TRUE, 0, 0, w->allocation.width, w->allocation.height);
196         gdk_draw_rectangle(w->window, gc, TRUE, 0, 0, width,
197                         w->allocation.height);
198         g_object_unref(gc);/*g_free(gc);*/
199 }
200
201 gboolean
202 exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c) {
203         drawindicator(c);
204         return TRUE;
205 }
206
207 void
208 download(WebKitDownload *o, GParamSpec *pspec, Client *c) {
209         WebKitDownloadStatus status;
210
211         status = webkit_download_get_status(c->download);
212         if(status == WEBKIT_DOWNLOAD_STATUS_STARTED || status == WEBKIT_DOWNLOAD_STATUS_CREATED) {
213                 c->progress = (gint)(webkit_download_get_progress(c->download)*100);
214         }
215         update(c, NULL);
216 }
217
218 gboolean
219 initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
220         const gchar *home, *filename;
221         gchar *uri, *path, *html;
222
223         stop(c, NULL);
224         c->download = o;
225         home = g_get_home_dir();
226         filename = webkit_download_get_suggested_filename(o);
227         path = g_build_filename(home, ".surf", "dl", 
228                         filename, NULL);
229         uri = g_strconcat("file://", path, NULL);
230         webkit_download_set_destination_uri(c->download, uri);
231         c->progress = 0;
232         g_free(uri);
233         html = g_strdup_printf("Download <b>%s</b>...", filename);
234         webkit_web_view_load_html_string(c->view, html,
235                         webkit_download_get_uri(c->download));
236         g_signal_connect(c->download, "notify::progress", G_CALLBACK(download), c);
237         g_signal_connect(c->download, "notify::status", G_CALLBACK(download), c);
238         webkit_download_start(c->download);
239         update(c, filename);
240         g_free(html);
241         return TRUE;
242 }
243
244 gchar *
245 geturi(Client *c) {
246         gchar *uri;
247
248         if(!(uri = (gchar *)webkit_web_view_get_uri(c->view)))
249                 uri = g_strdup("about:blank");
250         return uri;
251 }
252
253 void
254 hidesearch(Client *c, const Arg *arg) {
255         gtk_widget_hide(c->searchbar);
256         gtk_widget_grab_focus(GTK_WIDGET(c->view));
257 }
258
259 void
260 hideurl(Client *c, const Arg *arg) {
261         gtk_widget_hide(c->urlbar);
262         gtk_widget_grab_focus(GTK_WIDGET(c->view));
263 }
264
265 gboolean
266 keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
267         guint i, focus;
268         gboolean processed = FALSE;
269
270         if(ev->type != GDK_KEY_PRESS)
271                 return FALSE;
272         if(GTK_WIDGET_HAS_FOCUS(c->searchbar))
273                 focus = SEARCHBAR;
274         else if(GTK_WIDGET_HAS_FOCUS(c->urlbar))
275                 focus = URLBAR;
276         else
277                 focus = BROWSER;
278         for(i = 0; i < LENGTH(keys); i++) {
279                 if(focus & keys[i].focus && ev->keyval == keys[i].keyval &&
280                                 (CLEANMASK(ev->state) == keys[i].mod ||
281                                  CLEANMASK(ev->state) & keys[i].mod)
282                                 && keys[i].func) {
283                         keys[i].func(c, &(keys[i].arg));
284                         processed = TRUE;
285                 }
286         }
287         return processed;
288 }
289
290 void
291 linkhover(WebKitWebView* page, const gchar* t, const gchar* l, Client *c) {
292         if(l)
293                 gtk_window_set_title(GTK_WINDOW(c->win), l);
294         else
295                 update(c, NULL);
296 }
297
298 void
299 loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c) {
300         gchar *uri;
301
302         ignore_once = TRUE;
303         uri = geturi(c);
304         XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), urlprop,
305                         XA_STRING, 8, PropModeReplace, (unsigned char *)uri,
306                         strlen(uri) + 1);
307 }
308
309 void
310 loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c) {
311         c->progress = 0;
312         update(c, NULL);
313 }
314
315 void
316 loadfile(Client *c, const gchar *f) {
317         GIOChannel *chan = NULL;
318         GError *e = NULL;
319         GString *code;
320         gchar *line, *uri;
321         Arg arg;
322
323         if(strcmp(f, "-") == 0) {
324                 chan = g_io_channel_unix_new(STDIN_FILENO);
325                 if (chan) {
326                         code = g_string_new("");
327                         while(g_io_channel_read_line(chan, &line, NULL, NULL,
328                                                 &e) == G_IO_STATUS_NORMAL) {
329                                 g_string_append(code, line);
330                                 g_free(line);
331                         }
332                         webkit_web_view_load_html_string(c->view, code->str,
333                                         "file://.");
334                         g_io_channel_shutdown(chan, FALSE, NULL);
335                         g_string_free(code, TRUE);
336                 }
337                 arg.v = uri = g_strdup("stdin");
338         }
339         else {
340                 arg.v = uri = g_strdup_printf("file://%s", f);
341                 loaduri(c, &arg);
342         }
343         update(c, uri);
344         g_free(uri);
345 }
346
347 void
348 loaduri(Client *c, const Arg *arg) {
349         gchar *u;
350         const gchar *uri = (gchar *)arg->v;
351         if(!uri)
352                 uri = gtk_entry_get_text(GTK_ENTRY(c->urlbar));
353         u = g_strrstr(uri, "://") ? g_strdup(uri)
354                 : g_strdup_printf("http://%s", uri);
355         webkit_web_view_load_uri(c->view, u);
356         c->progress = 0;
357         update(c, u);
358         g_free(u);
359 }
360
361 void
362 navigate(Client *c, const Arg *arg) {
363         gint steps = *(gint *)arg;
364         webkit_web_view_go_back_or_forward(c->view, steps);
365 }
366
367 Client *
368 newclient(void) {
369         Client *c;
370         if(!(c = calloc(1, sizeof(Client))))
371                 die("Cannot malloc!\n");
372         /* Window */
373         if(embed) {
374                 c->win = gtk_plug_new(0);
375         }
376         else {
377                 c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
378                 gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf");
379         }
380         gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
381         g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
382         g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c);
383
384         /* VBox */
385         c->vbox = gtk_vbox_new(FALSE, 0);
386
387         /* scrolled window */
388         c->scroll = gtk_scrolled_window_new(NULL, NULL);
389         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
390                         GTK_POLICY_NEVER, GTK_POLICY_NEVER);
391
392         /* webview */
393         c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
394         g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
395         g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c);
396         g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c);
397         g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c);
398         g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
399         g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(newwindow), c);
400         g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
401         g_signal_connect_after(session, "request-started", G_CALLBACK(request), c);
402
403         /* urlbar */
404         c->urlbar = gtk_entry_new();
405         gtk_entry_set_has_frame(GTK_ENTRY(c->urlbar), FALSE);
406
407         /* searchbar */
408         c->searchbar = gtk_entry_new();
409         gtk_entry_set_has_frame(GTK_ENTRY(c->searchbar), FALSE);
410
411         /* indicator */
412         c->indicator = gtk_drawing_area_new();
413         gtk_widget_set_size_request(c->indicator, 0, 2);
414         g_signal_connect (G_OBJECT (c->indicator), "expose_event",
415                         G_CALLBACK (exposeindicator), c);
416
417         /* downloadbar */
418
419         /* Arranging */
420         gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
421         gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
422         gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
423         gtk_container_add(GTK_CONTAINER(c->vbox), c->searchbar);
424         gtk_container_add(GTK_CONTAINER(c->vbox), c->urlbar);
425         gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);
426
427         /* Setup */
428         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->urlbar, FALSE, FALSE, 0, GTK_PACK_START);
429         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->searchbar, FALSE, FALSE, 0, GTK_PACK_START);
430         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START);
431         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START);
432         gtk_widget_grab_focus(GTK_WIDGET(c->view));
433         gtk_widget_hide_all(c->searchbar);
434         gtk_widget_hide_all(c->urlbar);
435         gtk_widget_show(c->vbox);
436         gtk_widget_show(c->indicator);
437         gtk_widget_show(c->scroll);
438         gtk_widget_show(GTK_WIDGET(c->view));
439         gtk_widget_show(c->win);
440         gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
441         gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
442         webkit_web_view_set_full_content_zoom(c->view, TRUE);
443         c->download = NULL;
444         c->title = NULL;
445         c->next = clients;
446         clients = c;
447         if(showxid) {
448                 gdk_display_sync(gtk_widget_get_display(c->win));
449                 printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
450                 fflush(NULL);
451         }
452         return c;
453 }
454
455 WebKitWebView *
456 newwindow(WebKitWebView  *v, WebKitWebFrame *f, Client *c) {
457         Client *n = newclient();
458         return n->view;
459 }
460
461  
462 void
463 pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d) {
464         Arg arg = {.v = text };
465         if(text != NULL)
466                 loaduri((Client *) d, &arg);
467 }
468
469 GdkFilterReturn
470 processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
471         Client *c = (Client *)d;
472         XPropertyEvent *ev;
473         Atom adummy;
474         gint idummy;
475         unsigned long ldummy;
476         unsigned char *buf = NULL;
477         Arg arg;
478
479         if(((XEvent *)e)->type == PropertyNotify) {
480                 ev = &((XEvent *)e)->xproperty;
481                 if(ev->atom == urlprop && ev->state == PropertyNewValue) {
482                         if(ignore_once)
483                                ignore_once = FALSE;
484                         else {
485                                 XGetWindowProperty(dpy, ev->window, urlprop, 0L, BUFSIZ, False, XA_STRING,
486                                         &adummy, &idummy, &ldummy, &ldummy, &buf);
487                                 arg.v = buf;
488                                 loaduri(c, &arg);
489                                 XFree(buf);
490                         }
491                         return GDK_FILTER_REMOVE;
492                 }
493         }
494         return GDK_FILTER_CONTINUE;
495 }
496
497 void
498 print(Client *c, const Arg *arg) {
499         webkit_web_frame_print(webkit_web_view_get_main_frame(c->view));
500 }
501
502 void
503 progresschange(WebKitWebView* view, gint p, Client *c) {
504         c->progress = p;
505         update(c, NULL);
506 }
507
508 void
509 request(SoupSession *s, SoupMessage *m, Client *c) {
510         soup_message_add_header_handler(m, "got-headers", "Set-Cookie",
511                         G_CALLBACK(proccookies), c);
512 }
513
514 void
515 reload(Client *c, const Arg *arg) {
516         gboolean nocache = *(gboolean *)arg;
517         if(nocache)
518                  webkit_web_view_reload_bypass_cache(c->view);
519         else
520                  webkit_web_view_reload(c->view);
521 }
522
523 void
524 rereadcookies() {
525         const gchar *filename, *home;
526
527         home = g_get_home_dir();
528         filename = g_build_filename(home, ".surf", "cookies", NULL);
529 }
530
531 void
532 setcookie(char *name, char *val, char *dom, char *path, long exp) {
533
534 }
535
536 void
537 setup() {
538         dpy = GDK_DISPLAY();
539         session = webkit_get_default_session();
540         urlprop = XInternAtom(dpy, "_SURF_URL", False);
541 }
542
543 void
544 showsearch(Client *c, const Arg *arg) {
545         hideurl(c, NULL);
546         gtk_widget_show(c->searchbar);
547         gtk_widget_grab_focus(c->searchbar);
548 }
549
550 void
551 searchtext(Client *c, const Arg *arg) {
552         gboolean forward = *(gboolean *)arg;
553         webkit_web_view_search_text(c->view,
554                         gtk_entry_get_text(GTK_ENTRY(c->searchbar)),
555                         FALSE,
556                         forward,
557                         TRUE);
558 }
559
560 void
561 showurl(Client *c, const Arg *arg) {
562         gchar *uri;
563
564         hidesearch(c, NULL);
565         uri = geturi(c);
566         gtk_entry_set_text(GTK_ENTRY(c->urlbar), uri);
567         gtk_widget_show(c->urlbar);
568         gtk_widget_grab_focus(c->urlbar);
569 }
570
571 void
572 stop(Client *c, const Arg *arg) {
573         if(c->download)
574                 webkit_download_cancel(c->download);
575         else
576                 webkit_web_view_stop_loading(c->view);
577         c->download = NULL;
578 }
579
580 void
581 titlechange(WebKitWebView *v, WebKitWebFrame *f, const gchar *t, Client *c) {
582         update(c, t);
583 }
584
585 void
586 usage() {
587         fputs("surf - simple browser\n", stderr);
588         die("usage: surf [-e] [-x] [uri]\n");
589 }
590
591 void
592 update(Client *c, const char *title) {
593         gchar *t;
594
595         if(title) {
596                 if(c->title)
597                         g_free(c->title);
598                 c->title = g_strdup(title);
599         }
600         if(c->progress == 100)
601                 t = g_strdup(c->title);
602         else
603                 t = g_strdup_printf("%s [%i%%]", c->title, c->progress);
604         drawindicator(c);
605         gtk_window_set_title(GTK_WINDOW(c->win), t);
606         g_free(t);
607
608 }
609
610 void
611 zoom(Client *c, const Arg *arg) {
612         if(arg->i < 0)          /* zoom out */
613                 webkit_web_view_zoom_out(c->view);
614         else if(arg->i > 0)     /* zoom in */
615                 webkit_web_view_zoom_in(c->view);
616         else                    /* reset */
617                 webkit_web_view_set_zoom_level(c->view, 1.0);
618 }
619
620 int main(int argc, char *argv[]) {
621         SoupSession *s;
622         Client *c;
623         gint o;
624         const gchar *home, *filename;
625         Arg arg;
626
627         gtk_init(NULL, NULL);
628         if (!g_thread_supported())
629                 g_thread_init(NULL);
630         setup();
631         while((o = getopt(argc, argv, "vhxeu:f:")) != -1)
632                 switch(o) {
633                 case 'x':
634                         showxid = TRUE;
635                         break;
636                 case 'e':
637                         showxid = TRUE;
638                         embed = TRUE;
639                         break;
640                 case 'v':
641                         die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n");
642                         break;
643                 default:
644                         usage();
645                 }
646         if(optind + 1 == argc) {
647                 c = newclient();
648                 arg.v = argv[optind];
649                 if(strchr("./", argv[optind][0]) || strcmp("-", argv[optind]) == 0)
650                         loadfile(c, argv[optind]);
651                 else
652                         loaduri(c, &arg);
653
654         }
655         else if(optind != argc)
656                 usage();
657         if(!clients)
658                 newclient();
659
660         /* make dirs */
661         home = g_get_home_dir();
662         filename = g_build_filename(home, ".surf", "dl", NULL);
663         g_mkdir_with_parents(filename, 0755);
664
665         /* cookie persistance */
666         s = webkit_get_default_session();
667         filename = g_build_filename(home, ".surf", "cookies.jar", NULL);
668         cookiejar = soup_cookie_jar_text_new(filename, FALSE);
669         soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
670
671         gtk_main();
672         cleanup();
673         return EXIT_SUCCESS;
674 }