}
static void
-adblock_reload_rules (MidoriExtension* extension)
+adblock_reload_rules (MidoriExtension* extension,
+ gboolean custom_only)
{
- gchar** filters;
+ gchar* custom_list;
gchar* folder;
+ gchar** filters;
guint i = 0;
- filters = midori_extension_get_string_list (extension, "filters", NULL);
- gchar* custom_list;
-
- if (!filters)
- return;
-
- folder = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME,
- "adblock", NULL);
- katze_mkdir_with_parents (folder, 0700);
adblock_init_db ();
- while (filters[i++] != NULL)
- {
- gchar* filename = g_compute_checksum_for_string (G_CHECKSUM_MD5,
- filters[i - 1], -1);
- gchar* path = g_build_filename (folder, filename, NULL);
- if (!adblock_parse_file (path))
- {
- WebKitNetworkRequest* request;
- WebKitDownload* download;
- gchar* destination = g_filename_to_uri (path, NULL, NULL);
- request = webkit_network_request_new (filters[i -1]);
- download = webkit_download_new (request);
- g_object_unref (request);
- webkit_download_set_destination_uri (download, destination);
- g_free (destination);
- g_signal_connect (download, "notify::status",
- G_CALLBACK (adblock_download_notify_status_cb), path);
- webkit_download_start (download);
- }
- else
- g_free (path);
- g_free (filename);
- }
custom_list = g_build_filename (midori_extension_get_config_dir (extension),
CUSTOM_LIST_NAME, NULL);
adblock_parse_file (custom_list);
g_free (custom_list);
- katze_assign (blockscript, adblock_build_js (blockcss, blockcssprivate));
+
+ filters = midori_extension_get_string_list (extension, "filters", NULL);
+ if (!custom_only && filters && *filters)
+ {
+ folder = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME,
+ "adblock", NULL);
+ katze_mkdir_with_parents (folder, 0700);
+ while (filters[i++] != NULL)
+ {
+ gchar* filename = g_compute_checksum_for_string (G_CHECKSUM_MD5,
+ filters[i - 1], -1);
+ gchar* path = g_build_filename (folder, filename, NULL);
+ if (!adblock_parse_file (path))
+ {
+ WebKitNetworkRequest* request;
+ WebKitDownload* download;
+ gchar* destination = g_filename_to_uri (path, NULL, NULL);
+
+ request = webkit_network_request_new (filters[i -1]);
+ download = webkit_download_new (request);
+ g_object_unref (request);
+ webkit_download_set_destination_uri (download, destination);
+ g_free (destination);
+ g_signal_connect (download, "notify::status",
+ G_CALLBACK (adblock_download_notify_status_cb), path);
+ webkit_download_start (download);
+ }
+ else
+ g_free (path);
+ g_free (filename);
+ }
+ g_free (folder);
+ }
g_strfreev (filters);
- g_free (folder);
+
+ katze_assign (blockscript, adblock_build_js (blockcss, blockcssprivate));
}
static void
midori_extension_set_string_list (extension, "filters", filters, i);
g_free (filters);
if (need_reload)
- adblock_reload_rules (extension);
+ adblock_reload_rules (extension, FALSE);
}
static void
g_fprintf (list, "%s\n", uri);
g_fprintf (list, "%s##img[src*=\"%s\"]\n", s_req_domain->host, s_uri->path);
fclose (list);
- adblock_reload_rules (extension);
+ adblock_reload_rules (extension, TRUE);
soup_uri_free (s_req_domain);
soup_uri_free (s_uri);
G_CALLBACK (adblock_session_request_queued_cb), NULL);
#endif
- adblock_reload_rules (extension);
+ adblock_reload_rules (extension, FALSE);
browsers = katze_object_get_object (app, "browsers");
i = 0;