Drop bookmark type field and save meta boolean properly

This commit is contained in:
Alexander Butenko 2010-07-01 17:03:24 -04:00 committed by Christian Dywan
parent 73376c0ea1
commit f907128904
3 changed files with 14 additions and 13 deletions

View file

@ -447,7 +447,7 @@ midori_bookmarks_initialize (KatzeArray* array,
if (sqlite3_exec (db, if (sqlite3_exec (db,
"CREATE TABLE IF NOT EXISTS " "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);", "desc text, app integer, toolbar integer);",
NULL, NULL, errmsg) != SQLITE_OK) NULL, NULL, errmsg) != SQLITE_OK)
return NULL; return NULL;

View file

@ -842,7 +842,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
#if HAVE_SQLITE #if HAVE_SQLITE
i = 0; i = 0;
n = 1; 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); result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
while ((result = sqlite3_step (statement)) == SQLITE_ROW) 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 " subsqlcmd = g_strdup_printf ("SELECT uri, title, app FROM bookmarks WHERE "
" folder = '%s'", katze_item_get_name (item)); " 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)); katze_item_set_name (KATZE_ITEM (subfolder), katze_item_get_name (item));
midori_bookmarkbar_insert_item (browser->bookmarkbar, KATZE_ITEM (subfolder)); midori_bookmarkbar_insert_item (browser->bookmarkbar, KATZE_ITEM (subfolder));
g_free (subsqlcmd); g_free (subsqlcmd);

View file

@ -177,11 +177,13 @@ midori_bookmarks_insert_item_db (sqlite3* db,
{ {
gchar* sqlcmd; gchar* sqlcmd;
char* errmsg = NULL; char* errmsg = NULL;
int type = 0;
gchar* parent; gchar* parent;
gchar* uri;
if (KATZE_ITEM_IS_BOOKMARK (item)) if (KATZE_ITEM_IS_BOOKMARK (item))
type = 1; uri = g_strdup (katze_item_get_uri (item));
else
uri = g_strdup ("");
if (folder) if (folder)
parent = g_strdup (folder); parent = g_strdup (folder);
@ -194,14 +196,13 @@ midori_bookmarks_insert_item_db (sqlite3* db,
handling of katze_item_get_meta_integer(). */ handling of katze_item_get_meta_integer(). */
/* FIXME: Need proper single quote escaping. */ /* FIXME: Need proper single quote escaping. */
sqlcmd = g_strdup_printf ( sqlcmd = g_strdup_printf (
"INSERT into bookmarks (uri, title, folder, type, toolbar, app) values" "INSERT into bookmarks (uri, title, folder, toolbar, app) values"
" ('%s', '%s', '%s', %d, %d, %d)", " ('%s', '%s', '%s', %d, %d)",
katze_item_get_uri (item), uri,
katze_item_get_name (item), katze_item_get_name (item),
parent, parent,
type, katze_item_get_meta_boolean (item, "toolbar"),
(int)katze_item_get_meta_integer (item, "toolbar"), katze_item_get_meta_boolean (item, "app"));
(int)katze_item_get_meta_integer (item, "app"));
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK) if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
{ {
@ -209,6 +210,7 @@ midori_bookmarks_insert_item_db (sqlite3* db,
sqlite3_free (errmsg); sqlite3_free (errmsg);
} }
g_free (uri);
g_free (parent); g_free (parent);
g_free (sqlcmd); g_free (sqlcmd);
} }
@ -226,8 +228,7 @@ midori_bookmarks_remove_item_from_db (sqlite3* db,
katze_item_get_uri (item)); katze_item_get_uri (item));
else else
sqlcmd = sqlite3_mprintf ( sqlcmd = sqlite3_mprintf (
"DELETE FROM bookmarks WHERE folder = '%q' OR title = '%q'", "DELETE FROM bookmarks WHERE title = '%q'",
katze_item_get_name (item),
katze_item_get_name (item)); katze_item_get_name (item));
if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK) if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)