From 77aa722af0a6a7afaa2a6a453f20e0bf3df6a7fa Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Thu, 23 Dec 2010 17:15:17 +0000 Subject: Add basic stats for blocked cookies. Might be an idea to keep those in a database for postmortem purposes. --- xxxterm.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'xxxterm.c') 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 { @@ -998,6 +999,34 @@ focus(struct tab *t, struct karg *args) return (0); } +int +stats(struct tab *t, struct karg *args) +{ + char *stats; + + if (t == NULL) + errx(1, "stats"); + + stats = g_strdup_printf(XT_DOCTYPE + "" + "" + "Statistics" + "" + "

Statistics

" + "" + "Cookies blocked(*) this session: %llu\n" + "

* results vary based on settings" + "" + "", + 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) { @@ -1006,7 +1035,6 @@ about(struct tab *t, struct karg *args) if (t == NULL) errx(1, "about"); - about = g_strdup_printf(XT_DOCTYPE "" "" @@ -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 "" "" @@ -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); -- cgit 1.4.1-2-gfad0