Add item to clear Form History database

This commit is contained in:
Christian Dywan 2010-10-17 23:11:50 +02:00
parent 6480329bbf
commit ce64fd3e25

View file

@ -21,7 +21,11 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <sqlite3.h> #ifdef G_OS_WIN32
#define LIBPREFIX ""
#else
#define LIBPREFIX "lib"
#endif
static GHashTable* global_keys; static GHashTable* global_keys;
static gchar* jsforms; static gchar* jsforms;
@ -434,7 +438,7 @@ formhistory_activate_cb (MidoriExtension* extension,
config_dir = midori_extension_get_config_dir (extension); config_dir = midori_extension_get_config_dir (extension);
katze_mkdir_with_parents (config_dir, 0700); katze_mkdir_with_parents (config_dir, 0700);
filename = g_build_filename (config_dir, "forms.db", NULL); 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)); g_warning (_("Failed to open database: %s\n"), sqlite3_errmsg (db));
sqlite3_close (db); sqlite3_close (db);
@ -487,6 +491,21 @@ formhistory_activate_cb (MidoriExtension* extension,
</html> */ </html> */
#endif #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* MidoriExtension*
extension_init (void) extension_init (void)
{ {
@ -520,5 +539,8 @@ extension_init (void)
g_signal_connect (extension, "activate", g_signal_connect (extension, "activate",
G_CALLBACK (formhistory_activate_cb), NULL); G_CALLBACK (formhistory_activate_cb), NULL);
sokoke_register_privacy_item ("formhistory", _("_Form History"),
G_CALLBACK (formhistory_clear_database_cb));
return extension; return extension;
} }