diff options
author | portix <portix@gmx.net> | 2013-05-14 18:17:26 +0200 |
---|---|---|
committer | portix <portix@gmx.net> | 2013-05-14 18:17:26 +0200 |
commit | 8d23c9c31dbe597a48beda34eb68c682a27afc32 (patch) | |
tree | a86ffd16d581ba69ddadfbfb720445628573889f | |
parent | b0efd96352f031eef5c031cb601fb8594f7d3e7e (diff) | |
download | dwb-8d23c9c31dbe597a48beda34eb68c682a27afc32.zip |
New command 'adblock_reload_rules'
-rw-r--r-- | doc/dwb.1 | 14 | ||||
-rw-r--r-- | doc/dwb.1.txt | 1 | ||||
-rw-r--r-- | m4/keys.m4 | 1 | ||||
-rw-r--r-- | src/adblock.c | 34 | ||||
-rw-r--r-- | src/adblock.h | 7 | ||||
-rw-r--r-- | src/commands.c | 7 | ||||
-rw-r--r-- | src/commands.h | 1 | ||||
-rw-r--r-- | src/config.h | 6 |
8 files changed, 66 insertions, 5 deletions
@@ -2,12 +2,12 @@ .\" Title: dwb .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 05/09/2013 +.\" Date: 05/14/2013 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "DWB" "1" "05/09/2013" "\ \&" "\ \&" +.TH "DWB" "1" "05/14/2013" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1407,9 +1407,19 @@ lt lt lt lt lt lt lt lt lt lt lt lt +lt lt lt lt lt lt. T{ .sp +adblock_reload_rules +T}:T{ +.sp +T}:T{ +.sp +Reload adblocker rules +T} +T{ +.sp allow_cookie T}:T{ .sp diff --git a/doc/dwb.1.txt b/doc/dwb.1.txt index 870c3004..f8267270 100644 --- a/doc/dwb.1.txt +++ b/doc/dwb.1.txt @@ -736,6 +736,7 @@ COMMAND OVERVIEW [options="header"] |================ |Command |Alias |Description +|adblock_reload_rules | |Reload adblocker rules |allow_cookie |cookie |Allow persistent cookies for current site |allow_session_cookie |scookie |Allow session cookies for currrent site |allow_session_cookie_tmp|tcookie |Allow session cookies for current site @@ -158,6 +158,7 @@ html_input(proxy, text, Toggle proxy) html_header(Miscellaneous) dnl +html_input(adblock_reload_rules, text, Reload adblock rules) html_input(allow_cookie, text, Allow persistent cookies for current site) html_input(allow_session_cookie, text, Allow session cookies for current site) html_input(allow_session_cookie_tmp, text, Allow session cookies for current site temporarily) diff --git a/src/adblock.c b/src/adblock.c index 4bdf86bd..4ffd0270 100644 --- a/src/adblock.c +++ b/src/adblock.c @@ -906,29 +906,52 @@ error_out: void adblock_end() { + if (!s_init) + return; for (GSList *l = s_css_hider_list; l; l=l->next) g_free(l->data); g_slist_free(s_css_hider_list); + s_css_hider_list = NULL; + if (s_css_exceptions != NULL) + { g_string_free(s_css_exceptions, true); + s_css_exceptions = NULL; + } if (s_rules != NULL) + { g_ptr_array_free(s_rules, true); + s_rules = NULL; + } if (s_simple_rules != NULL) + { g_ptr_array_free(s_simple_rules, true); + s_simple_rules = NULL; + } if (s_simple_exceptions != NULL) + { g_ptr_array_free(s_simple_exceptions, true); + s_simple_exceptions = NULL; + } if(s_exceptions != NULL) + { g_ptr_array_free(s_exceptions, true); + s_exceptions = NULL; + } if (s_hider_rules != NULL) + { g_hash_table_remove_all(s_hider_rules); + } if (s_hider_list != NULL) { for (GSList *l = s_hider_list; l; l=l->next) adblock_element_hider_free((AdblockElementHider*)l->data); g_slist_free(s_hider_list); + s_hider_list = NULL; } + s_init = false; }/*}}}*/ /* adblock_init() {{{*/ @@ -965,3 +988,14 @@ adblock_init() return true; }/*}}}*//*}}}*/ +gboolean +adblock_reload() +{ + for (GList *gl = dwb.state.views; gl; gl=gl->next) + adblock_disconnect(gl); + adblock_end(); + gboolean ret = adblock_init(); + for (GList *gl = dwb.state.views; gl; gl=gl->next) + adblock_connect(gl); + return ret; +} diff --git a/src/adblock.h b/src/adblock.h index a8d617bb..462d9707 100644 --- a/src/adblock.h +++ b/src/adblock.h @@ -19,9 +19,10 @@ #ifndef __DWB_ADBLOCK_H__ #define __DWB_ADBLOCK_H__ -gboolean adblock_init(); -gboolean adblock_running(); -void adblock_end(); +gboolean adblock_init(void); +gboolean adblock_running(void); +void adblock_end(void); +gboolean adblock_reload(void); void adblock_connect(GList *gl); void adblock_disconnect(GList *gl); diff --git a/src/commands.c b/src/commands.c index 1e01d593..24d225c2 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1077,3 +1077,10 @@ commands_tabdo(KeyMap *km, Arg *arg) dwb_focus_view(current, "tabdo"); return STATUS_OK; } +DwbStatus +commands_adblock_reload_rules(KeyMap *km, Arg *arg) +{ + adblock_reload(); + dwb_set_normal_message(dwb.state.fview, true, "Adblock rules reloaded"); + return STATUS_OK; +} diff --git a/src/commands.h b/src/commands.h index 5f267c12..a4fece94 100644 --- a/src/commands.h +++ b/src/commands.h @@ -96,5 +96,6 @@ DwbStatus commands_reload_bookmarks(KeyMap *, Arg *); DwbStatus commands_reload_quickmarks(KeyMap *, Arg *); DwbStatus commands_print_preview(KeyMap *, Arg *); DwbStatus commands_tabdo(KeyMap *, Arg *); +DwbStatus commands_adblock_reload_rules(KeyMap *, Arg *); #endif diff --git a/src/config.h b/src/config.h index 51b4e98d..cba31ea0 100644 --- a/src/config.h +++ b/src/config.h @@ -189,6 +189,7 @@ static KeyValue KEYS[] = { { "reload_bookmarks", { NULL, 0, 0 }, }, { "reload_quickmarks", { NULL, 0, 0 }, }, { "print_preview", { NULL, 0, 0 }, }, + { "adblock_reload_rules", { NULL, 0, 0 }, }, }; /* FUNCTION_MAP{{{*/ @@ -206,6 +207,11 @@ static FunctionMap FMAP [] = { { { "reload_bookmarks", "Reload bookmarks", }, CP_COMMANDLINE, (Func)commands_reload_bookmarks, NULL, ALWAYS_SM, { .p = NULL }, EP_NONE, { NULL }, }, + + { { "adblock_reload_rules", "Reload adblock rulse", }, CP_COMMANDLINE, + (Func)commands_adblock_reload_rules, NULL, POST_SM, + { .p = NULL }, EP_NONE, { NULL }, }, + { { "toggle_tab", "Toggle between last and current tab", }, CP_COMMANDLINE, (Func)commands_toggle_tab, NULL, ALWAYS_SM, { .p = NULL }, EP_NONE, { "ttab" }, }, |