From f9071289048eea2309c981c902e23e73be8342eb Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Thu, 1 Jul 2010 17:03:24 -0400 Subject: [PATCH] Drop bookmark type field and save meta boolean properly --- midori/main.c | 2 +- midori/midori-browser.c | 4 ++-- panels/midori-bookmarks.c | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/midori/main.c b/midori/main.c index 0b40b412..9c38e3b4 100644 --- a/midori/main.c +++ b/midori/main.c @@ -447,7 +447,7 @@ midori_bookmarks_initialize (KatzeArray* array, if (sqlite3_exec (db, "CREATE TABLE IF NOT EXISTS " - "bookmarks (uri text, title text, folder text, type integer, " + "bookmarks (uri text, title text, folder text, " "desc text, app integer, toolbar integer);", NULL, NULL, errmsg) != SQLITE_OK) return NULL; diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 99488a95..8113567b 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -842,7 +842,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, #if HAVE_SQLITE i = 0; n = 1; - sqlcmd = "SELECT title from bookmarks where type=0"; + sqlcmd = "SELECT title from bookmarks where uri=''"; result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL); while ((result = sqlite3_step (statement)) == SQLITE_ROW) { @@ -6540,7 +6540,7 @@ midori_bookmarkbar_populate (MidoriBrowser* browser) subsqlcmd = g_strdup_printf ("SELECT uri, title, app FROM bookmarks WHERE " " folder = '%s'", katze_item_get_name (item)); - subfolder = katze_array_from_sqlite (db, sqlcmd); + subfolder = katze_array_from_sqlite (db, subsqlcmd); katze_item_set_name (KATZE_ITEM (subfolder), katze_item_get_name (item)); midori_bookmarkbar_insert_item (browser->bookmarkbar, KATZE_ITEM (subfolder)); g_free (subsqlcmd); diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 791f786e..3bd2ef4d 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -177,11 +177,13 @@ midori_bookmarks_insert_item_db (sqlite3* db, { gchar* sqlcmd; char* errmsg = NULL; - int type = 0; gchar* parent; + gchar* uri; if (KATZE_ITEM_IS_BOOKMARK (item)) - type = 1; + uri = g_strdup (katze_item_get_uri (item)); + else + uri = g_strdup (""); if (folder) parent = g_strdup (folder); @@ -194,14 +196,13 @@ midori_bookmarks_insert_item_db (sqlite3* db, handling of katze_item_get_meta_integer(). */ /* FIXME: Need proper single quote escaping. */ sqlcmd = g_strdup_printf ( - "INSERT into bookmarks (uri, title, folder, type, toolbar, app) values" - " ('%s', '%s', '%s', %d, %d, %d)", - katze_item_get_uri (item), + "INSERT into bookmarks (uri, title, folder, toolbar, app) values" + " ('%s', '%s', '%s', %d, %d)", + uri, katze_item_get_name (item), parent, - type, - (int)katze_item_get_meta_integer (item, "toolbar"), - (int)katze_item_get_meta_integer (item, "app")); + katze_item_get_meta_boolean (item, "toolbar"), + katze_item_get_meta_boolean (item, "app")); if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK) { @@ -209,6 +210,7 @@ midori_bookmarks_insert_item_db (sqlite3* db, sqlite3_free (errmsg); } + g_free (uri); g_free (parent); g_free (sqlcmd); } @@ -226,8 +228,7 @@ midori_bookmarks_remove_item_from_db (sqlite3* db, katze_item_get_uri (item)); else sqlcmd = sqlite3_mprintf ( - "DELETE FROM bookmarks WHERE folder = '%q' OR title = '%q'", - katze_item_get_name (item), + "DELETE FROM bookmarks WHERE title = '%q'", katze_item_get_name (item)); if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)