diff options
author | Marco Peereboom <marco@conformal.com> | 2010-12-23 17:15:17 +0000 |
---|---|---|
committer | Marco Peereboom <marco@conformal.com> | 2010-12-23 17:15:17 +0000 |
commit | 77aa722af0a6a7afaa2a6a453f20e0bf3df6a7fa (patch) | |
tree | c0d60ce4a8c9a50fa20636cfbe93f9861c86f4cd | |
parent | 0fa9c4f02bda70b8b38f4cb1f522d43fbdeec556 (diff) | |
download | xombrero-77aa722af0a6a7afaa2a6a453f20e0bf3df6a7fa.tar.gz |
Add basic stats for blocked cookies. Might be an idea to keep those in a
database for postmortem purposes.
-rw-r--r-- | xxxterm.1 | 3 | ||||
-rw-r--r-- | xxxterm.c | 35 |
2 files changed, 35 insertions, 3 deletions
diff --git a/xxxterm.1 b/xxxterm.1 index 93eedb5..927d20a 100644 --- a/xxxterm.1 +++ b/xxxterm.1 @@ -301,6 +301,9 @@ Global history Show help page. .It Cm about, version Show about page. +.It Cm stats +Show blocked cookies statistics. +These statistics vary based on settings and are not persistent. .It Cm open, op, o <URI> Open URI. .It Cm tabnew, tabedit, tabe [URI] diff --git a/xxxterm.c b/xxxterm.c index 752b4d0..8b6f51a 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -316,6 +316,7 @@ struct domain_list js_wl; int updating_dl_tabs = 0; int updating_hl_tabs = 0; char *global_search; +uint64_t blocked_cookies = 0; /* mime types */ struct mime_type { @@ -999,6 +1000,34 @@ focus(struct tab *t, struct karg *args) } int +stats(struct tab *t, struct karg *args) +{ + char *stats; + + if (t == NULL) + errx(1, "stats"); + + stats = g_strdup_printf(XT_DOCTYPE + "<html>" + "<head>" + "<title>Statistics</title>" + "</head>" + "<h1>Statistics</h1>" + "<body>" + "Cookies blocked(*) this session: %llu\n" + "<p><small><b>*</b> results vary based on settings" + "</body>" + "</html>", + blocked_cookies + ); + + webkit_web_view_load_string(t->wv, stats, NULL, NULL, ""); + g_free(stats); + + return (0); +} + +int about(struct tab *t, struct karg *args) { char *about; @@ -1006,7 +1035,6 @@ about(struct tab *t, struct karg *args) if (t == NULL) errx(1, "about"); - about = g_strdup_printf(XT_DOCTYPE "<html>" "<head>" @@ -1028,8 +1056,8 @@ about(struct tab *t, struct karg *args) ); webkit_web_view_load_string(t->wv, about, NULL, NULL, ""); - g_free(about); + return (0); } @@ -1041,7 +1069,6 @@ help(struct tab *t, struct karg *args) if (t == NULL) errx(1, "help"); - help = XT_DOCTYPE "<html>" "<head>" @@ -2027,6 +2054,7 @@ struct cmd { { "qa!", 0, quit, {0} }, { "help", 0, help, {0} }, { "about", 0, about, {0} }, + { "stats", 0, stats, {0} }, { "version", 0, about, {0} }, /* favorites */ @@ -3394,6 +3422,7 @@ cookiejar_changed_cb(SoupCookieJar *jar, SoupCookie *old_cookie, if (new_cookie) { if ((d = wl_find(new_cookie->domain, &c_wl)) == NULL) { + blocked_cookies++; DNPRINTF(XT_D_COOKIE, "cookiejar_changed_cb: reject %s\n", new_cookie->domain); |