From: Christian Dywan Date: Sun, 17 Oct 2010 21:11:50 +0000 (+0200) Subject: Add item to clear Form History database X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce64fd3e25f7159ac71f7955f4cfc3144300f855;p=midori Add item to clear Form History database --- diff --git a/extensions/formhistory.c b/extensions/formhistory.c index 44958a3f..c0587770 100644 --- a/extensions/formhistory.c +++ b/extensions/formhistory.c @@ -21,7 +21,11 @@ #include #endif -#include +#ifdef G_OS_WIN32 + #define LIBPREFIX "" +#else + #define LIBPREFIX "lib" +#endif static GHashTable* global_keys; static gchar* jsforms; @@ -434,7 +438,7 @@ formhistory_activate_cb (MidoriExtension* extension, config_dir = midori_extension_get_config_dir (extension); katze_mkdir_with_parents (config_dir, 0700); filename = g_build_filename (config_dir, "forms.db", NULL); - if (sqlite3_open (filename, &db)) + if (sqlite3_open (filename, &db) != SQLITE_OK) { g_warning (_("Failed to open database: %s\n"), sqlite3_errmsg (db)); sqlite3_close (db); @@ -487,6 +491,21 @@ formhistory_activate_cb (MidoriExtension* extension, */ #endif +static void +formhistory_clear_database_cb (void) +{ + gchar* filename = g_build_filename (sokoke_set_config_dir (NULL), + "extensions", LIBPREFIX "formhistory." G_MODULE_SUFFIX, "forms.db", NULL); + sqlite3* db; + if (sqlite3_open (filename, &db) == SQLITE_OK) + { + sqlite3_exec (db, "DELETE FROM forms", NULL, NULL, NULL); + sqlite3_close (db); + } + g_free (filename); + +} + MidoriExtension* extension_init (void) { @@ -520,5 +539,8 @@ extension_init (void) g_signal_connect (extension, "activate", G_CALLBACK (formhistory_activate_cb), NULL); + sokoke_register_privacy_item ("formhistory", _("_Form History"), + G_CALLBACK (formhistory_clear_database_cb)); + return extension; }