KatzeItem* item,
sqlite3* db)
{
- gchar* sqlcmd;
- char* errmsg = NULL;
- KatzeItem* old_parent;
- const gchar* uri;
- const gchar* folder = katze_item_get_meta_string (item, "folder");
- const gchar* parent;
-
- if (KATZE_ITEM_IS_BOOKMARK (item))
- uri = katze_item_get_uri (item);
- else
- uri = "";
-
- /* Use folder, otherwise fallback to parent folder */
- old_parent = katze_item_get_parent (item);
- if (folder && *folder)
- parent = folder;
- else if (old_parent && katze_item_get_name (old_parent))
- parent = katze_item_get_name (old_parent);
- else
- parent = "";
-
- sqlcmd = sqlite3_mprintf (
- "INSERT into bookmarks (uri, title, desc, folder, toolbar, app) values"
- " ('%q', '%q', '%q', '%q', %d, %d)",
- uri,
- katze_item_get_name (item),
- katze_item_get_text (item),
- parent,
- katze_item_get_meta_boolean (item, "toolbar"),
- katze_item_get_meta_boolean (item, "app"));
-
- if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
- {
- g_printerr (_("Failed to add bookmark item: %s\n"), errmsg);
- sqlite3_free (errmsg);
- }
-
- sqlite3_free (sqlcmd);
+ midori_bookmarks_insert_item_db (db, item,
+ katze_item_get_meta_string (item, "folder"));
}
static void
{
if (KATZE_IS_ARRAY (item))
midori_bookmarks_import_array_db (db, KATZE_ARRAY (item), folder);
- katze_item_set_meta_string (item, "folder", folder);
- katze_array_add_item (array, item);
+ midori_bookmarks_insert_item_db (db, item, folder);
}
g_list_free (list);
}
g_object_unref (item);
}
+void
+midori_bookmarks_insert_item_db (sqlite3* db,
+ KatzeItem* item,
+ const gchar* folder)
+{
+ gchar* sqlcmd;
+ char* errmsg = NULL;
+ KatzeItem* old_parent;
+ gchar* parent;
+ gchar* uri;
+
+ if (KATZE_ITEM_IS_BOOKMARK (item))
+ uri = g_strdup (katze_item_get_uri (item));
+ else
+ uri = g_strdup ("");
+
+ /* Use folder, otherwise fallback to parent folder */
+ old_parent = katze_item_get_parent (item);
+ if (folder && *folder)
+ parent = g_strdup (folder);
+ else if (old_parent && katze_item_get_name (old_parent))
+ parent = g_strdup (katze_item_get_name (old_parent));
+ else
+ parent = g_strdup ("");
+
+ sqlcmd = sqlite3_mprintf (
+ "INSERT into bookmarks (uri, title, desc, folder, toolbar, app) values"
+ " ('%q', '%q', '%q', '%q', %d, %d)",
+ uri,
+ katze_item_get_name (item),
+ katze_item_get_text (item),
+ parent,
+ katze_item_get_meta_boolean (item, "toolbar"),
+ katze_item_get_meta_boolean (item, "app"));
+
+ if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK)
+ {
+ g_printerr (_("Failed to add bookmark item: %s\n"), errmsg);
+ sqlite3_free (errmsg);
+ }
+
+ g_free (uri);
+ g_free (parent);
+ sqlite3_free (sqlcmd);
+}
+
static void
midori_bookmarks_add_item_cb (KatzeArray* array,
KatzeItem* item,