From 99e0ab12adbccba3633e4f5945904252a8c6cf81 Mon Sep 17 00:00:00 2001 From: Sangpyo Kim Date: Thu, 4 Apr 2013 11:55:11 +0900 Subject: make the favorites API to use browser-provider [Title] make the favorites API to use browser-provider [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] make the favorites API to use browser-provider [Developer] sangpyo7.kim Change-Id: I5487c86dce2626ed832e5f6f1f7f65b1843e567a --- CMakeLists.txt | 2 + include/favorites.h | 10 +- include/favorites_private.h | 23 +- packaging/capi-web-favorites.spec | 3 - src/favorites_bookmark.c | 835 ++++++++++++++++++++++++++++++++------ src/favorites_history.c | 18 +- 6 files changed, 748 insertions(+), 143 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc7806d..b2028dd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,8 @@ ADD_DEFINITIONS("-DTIZEN_DEBUG") ADD_DEFINITIONS( -DLOG_TAG=\"favorites\" ) +#ADD_DEFINITIONS("-DBROWSER_BOOKMARK_SYNC") +ADD_DEFINITIONS("-DROOT_IS_ZERO") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") diff --git a/include/favorites.h b/include/favorites.h index a137104..8000481 100644 --- a/include/favorites.h +++ b/include/favorites.h @@ -53,14 +53,14 @@ typedef enum favorites_error{ typedef struct { char* address; /**< Bookmark URL */ char* title; /**< The title of the bookmark */ - char* creation_date; /**< The date of creation */ - char* update_date; /**< The last updated date */ - char* visit_date; /**< The last visit date */ + char* creation_date; /**< The date of creation(yyyy-mm-dd hh:mm:ss) */ + char* update_date; /**< The last updated date(yyyy-mm-dd hh:mm:ss) */ + char* visit_date; /**< The last visit date(yyyy-mm-dd hh:mm:ss) */ int id; /**< The unique ID of bookmark */ - bool is_folder; /**< property bookmark or folder\n @c true: folder, @c false: bookmark */ + bool is_folder; /**< property bookmark or folder\n @c 1: folder, @c 0: bookmark */ int folder_id; /**< The ID of parent folder */ int order_index; /**< The order index of bookmarks when show the list at the browser */ - bool editable; /**< The flag of editability\n @c true : writable, @c false: read-only, not ediable */ + bool editable; /**< The flag of editability\n @c 1 : writable, @c 0: read-only, not ediable */ } favorites_bookmark_entry_s; /** diff --git a/include/favorites_private.h b/include/favorites_private.h index b23f235..db298e6 100644 --- a/include/favorites_private.h +++ b/include/favorites_private.h @@ -24,21 +24,11 @@ extern "C" { /********************************************** * Logging macro **********************************************/ -#define FAVORITES_LOGD(fmt, args...) LOGD(\ - "[%s: %s: %d] "fmt, (rindex(__FILE__, '/')? rindex(__FILE__, '/') + 1 : __FILE__),\ - __FUNCTION__, __LINE__, ##args) -#define FAVORITES_LOGI(fmt, args...) LOGI(\ - "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\ - __FUNCTION__, __LINE__, ##args) -#define FAVORITES_LOGW(fmt, args...) LOGW(\ - "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\ - __FUNCTION__, __LINE__, ##args) -#define FAVORITES_LOGE(fmt, args...) LOGE(\ - "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\ - __FUNCTION__, __LINE__, ##args) -#define FAVORITES_LOGE_IF(cond, fmt, args...) LOGE_IF(cond,\ - "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\ - __FUNCTION__, __LINE__, ##args) +#define FAVORITES_LOGD(fmt, args...) LOGD(fmt, ##args) +#define FAVORITES_LOGI(fmt, args...) LOGI(fmt, ##args) +#define FAVORITES_LOGW(fmt, args...) LOGW(fmt, ##args) +#define FAVORITES_LOGE(fmt, args...) LOGE(fmt, ##args) +#define FAVORITES_LOGE_IF(cond, fmt, args...) LOGE_IF(cond, fmt, ##args) /********************************************** * Argument checking macro @@ -122,6 +112,9 @@ int _get_exists_bookmark(const char *address); int _get_exists_folder(const char *title, int parent_id); int _get_bookmark_id(const char *address); int _get_folder_id(const char *title, const int parent); +int _get_count_by_folder(int parent_id); +int _get_list_by_folder(int parent_id, bookmark_list_h *list); +int _set_full_tree_to_html_recur(int parent_id, FILE *fp, int depth); /* history internal API */ void _favorites_history_db_close(void); diff --git a/packaging/capi-web-favorites.spec b/packaging/capi-web-favorites.spec index f382eb8..900b05a 100755 --- a/packaging/capi-web-favorites.spec +++ b/packaging/capi-web-favorites.spec @@ -95,9 +95,6 @@ then ); create index idx_bookmarks_on_parent_type on bookmarks(parent, type); - INSERT INTO bookmarks (type, parent, title, creationdate, editable, sequence, accesscount, created_date) - VALUES(1, 0, "Bookmarks", DATETIME("now"), 0, 1, 0, strftime("%s","now")*1000); - CREATE TABLE tags( tag );' diff --git a/src/favorites_bookmark.c b/src/favorites_bookmark.c index 0b6087a..d548b5d 100644 --- a/src/favorites_bookmark.c +++ b/src/favorites_bookmark.c @@ -19,6 +19,10 @@ #include #include #include +#if defined(BROWSER_BOOKMARK_SYNC) +#include "bookmark-adaptor.h" +#include "time.h" +#endif sqlite3 *gl_internet_bookmark_db = 0; @@ -197,7 +201,7 @@ int _favorites_bookmark_get_folder_count(void) /* folder + bookmark */ nError = sqlite3_prepare_v2(gl_internet_bookmark_db, - "select count(*) from bookmarks where type=1 and parent != 0", + "select count(*) from bookmarks where type=1", -1, &stmt, NULL); if (nError != SQLITE_OK) { FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", @@ -365,7 +369,7 @@ bookmark_list_h _favorites_bookmark_get_folder_list(void) /* Get bookmarks list only under given folder */ sprintf(query, "select id, type, parent, address, title, editable,\ creationdate, updatedate, sequence \ - from bookmarks where type=1 and parent != 0 order by sequence"); + from bookmarks where type=1 order by sequence"); FAVORITES_LOGE("query: %s", query); if (_favorites_open_bookmark_db() < 0) { @@ -454,14 +458,20 @@ bookmark_list_h _favorites_bookmark_get_folder_list(void) } m_list->count = i; - if (i <= 0) { - FAVORITES_LOGE("sqlite3_step is failed"); - _favorites_close_bookmark_db(); - _favorites_free_bookmark_list(m_list); - return NULL; + if (nError == SQLITE_DONE) { + if (m_list->count > 0) { + _favorites_finalize_bookmark_db(stmt); + return m_list; + } else if (m_list->count == 0) { + FAVORITES_LOGE("There is no folders"); + _favorites_finalize_bookmark_db(stmt); + _favorites_free_bookmark_list(m_list); + return NULL; + } } + FAVORITES_LOGE("sqlite3_step is failed"); _favorites_finalize_bookmark_db(stmt); - return m_list; + return NULL; } int _favorites_get_unixtime_from_datetime(char *datetime) @@ -525,7 +535,71 @@ int _add_bookmark(const char *title, const char *address, int parent_id, int *sa FAVORITES_LOGD("Not Allow file://"); return FAVORITES_ERROR_INVALID_PARAMETER; } +#if defined(BROWSER_BOOKMARK_SYNC) + if (parent_id != _get_root_folder_id()) { + /* check whether folder is exist or not. */ + if (_get_exists_id(parent_id) <= 0) { + FAVORITES_LOGE("Not found parent folder (%d)\n", parent_id); + return FAVORITES_ERROR_NO_SUCH_FILE; + } + } + FAVORITES_LOGD("[%s][%s][%d]", title, address, parent_id); + int id = -1; + int *ids = NULL; + int ids_count = -1; + bp_bookmark_adaptor_get_duplicated_url_ids_p(&ids, &ids_count, 1, + -1, -1, 0, 0, address, 0); + if (ids_count > 0) + id = ids[0]; + free(ids); + + if (ids_count > 0) { + FAVORITES_LOGE("same URI is already exist"); + return FAVORITES_ERROR_ITEM_ALREADY_EXIST; + } + bp_bookmark_info_fmt info; + memset(&info, 0x00, sizeof(bp_bookmark_info_fmt)); + info.type = 0; + info.parent = parent_id; + info.sequence = -1; + info.access_count = -1; + info.editable = 1; + time_t seconds = 0; + info.date_created = time(&seconds); + info.date_modified = time(&seconds); + if (address != NULL && strlen(address) > 0) + info.url = strdup(address); + if (title != NULL && strlen(title) > 0) + info.title = strdup(title); + + int ret = bp_bookmark_adaptor_easy_create(&id, &info); + if (ret == 0) { + ret = bp_bookmark_adaptor_set_sequence(id, -1); // max sequence + bp_bookmark_adaptor_easy_free(&info); + if (ret == 0) { + *saved_bookmark_id = id; + FAVORITES_LOGD("bp_bookmark_adaptor_easy_create is success(id:%d)", *saved_bookmark_id); + bp_bookmark_adaptor_publish_notification(); + return FAVORITES_ERROR_NONE; + } + } + int errcode = bp_bookmark_adaptor_get_errorcode(); + bp_bookmark_adaptor_easy_free(&info); + FAVORITES_LOGE("bp_bookmark_adaptor_easy_create is failed[%d]", errcode); + return FAVORITES_ERROR_DB_FAILED; +#else + int nError; + sqlite3_stmt *stmt; +#if defined(ROOT_IS_ZERO) + if (parent_id != _get_root_folder_id()) { + /* check whether folder is exist or not. */ + if (_get_exists_id(parent_id) <= 0) { + FAVORITES_LOGE("Not found parent folder (%d)\n", parent_id); + return FAVORITES_ERROR_NO_SUCH_FILE; + } + } +#else if (parent_id > 0) { /* check whether folder is exist or not. */ if (_get_exists_id(parent_id) <= 0) { @@ -535,6 +609,7 @@ int _add_bookmark(const char *title, const char *address, int parent_id, int *sa } else { parent_id = _get_root_folder_id(); } +#endif FAVORITES_LOGD("[%s][%s][%d]", title, address, parent_id); int uid = _get_exists_bookmark(address); @@ -555,9 +630,6 @@ int _add_bookmark(const char *title, const char *address, int parent_id, int *sa return FAVORITES_ERROR_DB_FAILED; } - int nError; - sqlite3_stmt *stmt; - nError = sqlite3_prepare_v2(gl_internet_bookmark_db, "INSERT INTO bookmarks (type, parent, address, title, creationdate,\ @@ -608,6 +680,7 @@ int _add_bookmark(const char *title, const char *address, int parent_id, int *sa FAVORITES_LOGE("sqlite3_step is failed"); _favorites_close_bookmark_db(); return FAVORITES_ERROR_DB_FAILED; +#endif } int _add_folder(const char *title, int parent_id, int *saved_folder_id) @@ -617,6 +690,62 @@ int _add_folder(const char *title, int parent_id, int *saved_folder_id) FAVORITES_LOGD("Invalid param: Title is empty"); return FAVORITES_ERROR_INVALID_PARAMETER; } +#if defined(BROWSER_BOOKMARK_SYNC) + if (parent_id != _get_root_folder_id()) { + /* check whether folder is exist or not. */ + if (_get_exists_id(parent_id) <= 0) { + FAVORITES_LOGE("Not found parent folder (%d)\n", parent_id); + return FAVORITES_ERROR_NO_SUCH_FILE; + } + } + int id = -1; + int *ids = NULL; + int ids_count = -1; + bp_bookmark_adaptor_get_duplicated_title_ids_p(&ids, &ids_count, 1, + -1, parent_id, 1, 0, title, 0); + if (ids_count > 0) + id = ids[0]; + free(ids); + + if (ids_count > 0) { + FAVORITES_LOGE("same title with same parent is already exist"); + return FAVORITES_ERROR_ITEM_ALREADY_EXIST; + } + + bp_bookmark_info_fmt info; + memset(&info, 0x00, sizeof(bp_bookmark_info_fmt)); + info.type = 1; + info.parent = parent_id; + info.sequence = -1; + info.access_count = -1; + info.editable = 1; + if (title != NULL && strlen(title) > 0) + info.title = strdup(title); + int ret = bp_bookmark_adaptor_easy_create(&id, &info); + if (ret == 0) { + ret = bp_bookmark_adaptor_set_sequence(id, -1); // max sequence + bp_bookmark_adaptor_easy_free(&info); + if (ret == 0) { + *saved_folder_id = id; + FAVORITES_LOGD("bmsvc_add_bookmark is success(id:%d)", *saved_folder_id); + bp_bookmark_adaptor_publish_notification(); + return FAVORITES_ERROR_NONE; + } + } + int errcode = bp_bookmark_adaptor_get_errorcode(); + bp_bookmark_adaptor_easy_free(&info); + FAVORITES_LOGE("bp_bookmark_adaptor_easy_create is failed[%d]", errcode); + return FAVORITES_ERROR_DB_FAILED; +#else +#if defined(ROOT_IS_ZERO) + if (parent_id != _get_root_folder_id()) { + /* check whether folder is exist or not. */ + if (_get_exists_id(parent_id) <= 0) { + FAVORITES_LOGE("Not found parent folder (%d)\n", parent_id); + return FAVORITES_ERROR_NO_SUCH_FILE; + } + } +#else if (parent_id > 0) { /* check whether folder is exist or not. */ if (_get_exists_id(parent_id) <= 0) { @@ -626,12 +755,13 @@ int _add_folder(const char *title, int parent_id, int *saved_folder_id) } else { parent_id = _get_root_folder_id(); } +#endif FAVORITES_LOGD("[%s][%d]", title, parent_id); int uid = _get_exists_folder(title, parent_id); /* ignore this call.. already exist. */ if (uid > 0) { - FAVORITES_LOGE("Bookmark is already exist. cancel the add operation."); + FAVORITES_LOGE("Folder is already exist. cancel the add operation."); return FAVORITES_ERROR_ITEM_ALREADY_EXIST; } @@ -693,17 +823,44 @@ int _add_folder(const char *title, int parent_id, int *saved_folder_id) FAVORITES_LOGE("sqlite3_step is failed"); _favorites_close_bookmark_db(); return FAVORITES_ERROR_DB_FAILED; +#endif } int _get_root_folder_id(void) { +#if defined(BROWSER_BOOKMARK_SYNC) + FAVORITES_LOGE("SYNC"); + int root_id = -1; + bp_bookmark_adaptor_get_root(&root_id); + return root_id; +#else +#if defined(ROOT_IS_ZERO) + return 0; +#else + FAVORITES_LOGE("NOT SYNC"); return 1; +#endif +#endif } int _get_exists_id(int id) { - FAVORITES_LOGE("\n"); + FAVORITES_LOGE(""); +#if defined(BROWSER_BOOKMARK_SYNC) + int value = -1; + int ret = -1; + int errorcode = -1; + ret = bp_bookmark_adaptor_get_type(id, &value); + if (ret < 0) { + errorcode = bp_bookmark_adaptor_get_errorcode(); + if (errorcode == BP_BOOKMARK_ERROR_NO_DATA) + return 0; + else + return -1; + } + return 1; +#else int nError; sqlite3_stmt *stmt; @@ -744,6 +901,7 @@ int _get_exists_id(int id) _favorites_close_bookmark_db(); return -1; +#endif } int _get_exists_bookmark(const char *address) @@ -839,6 +997,22 @@ int _get_exists_folder(const char *title, int parent_id) int _get_bookmark_id(const char *address) { FAVORITES_LOGE(""); +#if defined(BROWSER_BOOKMARK_SYNC) + int id = -1; + int *ids = NULL; + int ids_count = -1; + bp_bookmark_adaptor_get_duplicated_url_ids_p(&ids, &ids_count, 1, + -1, -1, 0, 0, address, 0); + if (ids_count > 0) + id = ids[0]; + free(ids); + + if (ids_count > 0) { + return id; + } + FAVORITES_LOGE("There is no such bookmark url exists."); + return -1; +#else int nError; sqlite3_stmt *stmt; @@ -879,11 +1053,28 @@ int _get_bookmark_id(const char *address) sqlite3_errmsg(gl_internet_bookmark_db)); _favorites_close_bookmark_db(); return -1; +#endif } int _get_folder_id(const char *title, const int parent) { FAVORITES_LOGE(""); +#if defined(BROWSER_BOOKMARK_SYNC) + int id = -1; + int *ids = NULL; + int ids_count = -1; + bp_bookmark_adaptor_get_duplicated_title_ids_p(&ids, &ids_count, 1, + -1, parent, 1, 0, title, 0); + if (ids_count > 0) + id = ids[0]; + free(ids); + + if (ids_count > 0) { + return id; + } + FAVORITES_LOGE("There is no such folder exists."); + return -1; +#else int nError; sqlite3_stmt *stmt; @@ -929,6 +1120,290 @@ int _get_folder_id(const char *title, const int parent) sqlite3_errmsg(gl_internet_bookmark_db)); _favorites_close_bookmark_db(); return -1; +#endif +} + +int _get_count_by_folder(int parent_id) +{ + int nError; + sqlite3_stmt *stmt; + FAVORITES_LOGE(""); + + if (_favorites_open_bookmark_db() < 0) { + FAVORITES_LOGE("db_util_open is failed\n"); + return -1; + } + + /*bookmark */ + nError = sqlite3_prepare_v2(gl_internet_bookmark_db, + "select count(*) from bookmarks where parent=?", + -1, &stmt, NULL); + if (nError != SQLITE_OK) { + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_bookmark_db)); + _favorites_finalize_bookmark_db(stmt); + return -1; + } + + if (sqlite3_bind_int(stmt, 1, parent_id) != SQLITE_OK) { + FAVORITES_LOGE("sqlite3_bind_int is failed"); + _favorites_finalize_bookmark_db(stmt); + return -1; + } + + nError = sqlite3_step(stmt); + if (nError == SQLITE_ROW) { + int count = sqlite3_column_int(stmt, 0); + _favorites_finalize_bookmark_db(stmt); + FAVORITES_LOGE("count: %d", count); + return count; + } else if (nError == SQLITE_DONE) { + FAVORITES_LOGE("No rows"); + _favorites_finalize_bookmark_db(stmt); + return -1; + } + FAVORITES_LOGE("sqlite3_step is failed"); + _favorites_close_bookmark_db(); + return -1; +} + + +int _get_list_by_folder(int parent_id, bookmark_list_h *list) +{ + FAVORITES_LOGD(""); +#if defined(BROWSER_BOOKMARK_SYNC) + int *ids = NULL; + int ids_count = -1; + bp_bookmark_info_fmt info; + if (bp_bookmark_adaptor_get_sequence_child_ids_p(&ids, &ids_count, -1, 0, parent_id, -1, 0) < 0) { + FAVORITES_LOGE("bp_bookmark_adaptor_get_sequence_child_ids_p is failed"); + return FAVORITES_ERROR_DB_FAILED; + } + + FAVORITES_LOGD("ids_count: %d", ids_count); + if (ids_count < 0) { + FAVORITES_LOGE("bookmark list is empty"); + return FAVORITES_ERROR_DB_FAILED; + } + + *list = (bookmark_list_h) calloc(1, sizeof(bookmark_list_s)); + (*list)->count = 0; + (*list)->item = + (bookmark_entry_internal_h) calloc(ids_count, sizeof(bookmark_entry_internal_s)); + int i = 0; + for(i = 0; i < ids_count; i++) { + (*list)->item[i].id = ids[i]; + if (bp_bookmark_adaptor_get_info(ids[i], (BP_BOOKMARK_O_TYPE | + BP_BOOKMARK_O_PARENT | BP_BOOKMARK_O_SEQUENCE | + BP_BOOKMARK_O_IS_EDITABLE | BP_BOOKMARK_O_URL | + BP_BOOKMARK_O_TITLE | BP_BOOKMARK_O_DATE_CREATED | + BP_BOOKMARK_O_DATE_MODIFIED), &info) == 0) { + (*list)->item[i].is_folder = info.type; + (*list)->item[i].folder_id = info.parent; + (*list)->item[i].orderIndex = info.sequence; + (*list)->item[i].editable = info.editable; + + if (info.url != NULL && strlen(info.url) > 0) + (*list)->item[i].address = strdup(info.url); + if (info.title != NULL && strlen(info.title) > 0) + (*list)->item[i].title = strdup(info.title); + FAVORITES_LOGD("Title: %s", (*list)->item[i].title); + + (*list)->item[i].creationdate = NULL; + (*list)->item[i].creationdate = (char *)calloc(128, sizeof(char)); + strftime((*list)->item[i].creationdate,128,"%Y-%m-%d %H:%M:%S",localtime((time_t *)&(info.date_created))); + + (*list)->item[i].updatedate = NULL; + (*list)->item[i].updatedate = (char *)calloc(128, sizeof(char)); + strftime((*list)->item[i].updatedate,128,"%Y-%m-%d %H:%M:%S",localtime((time_t *)&(info.date_modified))); + } + bp_bookmark_adaptor_easy_free(&info); + } + (*list)->count = i; + FAVORITES_LOGE("bookmark list count : %d", (*list)->count); + free(ids); + return FAVORITES_ERROR_NONE; +#else + int nError; + sqlite3_stmt *stmt; + + int item_count = _get_count_by_folder(parent_id); + if (item_count < 0) { + FAVORITES_LOGD("_get_count_by_folder is failed"); + return FAVORITES_ERROR_DB_FAILED; + } + + if (_favorites_open_bookmark_db() < 0) { + FAVORITES_LOGE("db_util_open is failed\n"); + return FAVORITES_ERROR_DB_FAILED; + } + nError = sqlite3_prepare_v2(gl_internet_bookmark_db, + "select id, type, parent, address, title, editable,\ + creationdate, updatedate, sequence \ + from bookmarks where parent=? order by sequence", + -1, &stmt, NULL); + if (nError != SQLITE_OK) { + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_bookmark_db)); + _favorites_finalize_bookmark_db(stmt); + return FAVORITES_ERROR_DB_FAILED; + } + + if (sqlite3_bind_int(stmt, 1, parent_id) != SQLITE_OK) { + FAVORITES_LOGE("sqlite3_bind_int is failed.\n"); + _favorites_finalize_bookmark_db(stmt); + return -1; + } + + *list = (bookmark_list_h) calloc(1, sizeof(bookmark_list_s)); + (*list)->count = 0; + (*list)->item = + (bookmark_entry_internal_h) calloc(item_count, sizeof(bookmark_entry_internal_s)); + int i = 0; + while ((nError = sqlite3_step(stmt)) == SQLITE_ROW && (i < item_count)) { + (*list)->item[i].id = sqlite3_column_int(stmt, 0); + (*list)->item[i].is_folder = sqlite3_column_int(stmt, 1); + (*list)->item[i].folder_id = sqlite3_column_int(stmt, 2); + + (*list)->item[i].address = NULL; + if (!(*list)->item[i].is_folder) { + const char *url = (const char *)(sqlite3_column_text(stmt, 3)); + if (url) { + int length = strlen(url); + if (length > 0) { + (*list)->item[i].address = (char *)calloc(length + 1, sizeof(char)); + memcpy((*list)->item[i].address, url, length); + FAVORITES_LOGE ("url:%s\n", url); + } + } + } + + const char *title = (const char *)(sqlite3_column_text(stmt, 4)); + (*list)->item[i].title = NULL; + if (title) { + int length = strlen(title); + if (length > 0) { + (*list)->item[i].title = (char *)calloc(length + 1, sizeof(char)); + memcpy((*list)->item[i].title, title, length); + } + } + (*list)->item[i].editable = sqlite3_column_int(stmt, 5); + + const char *creationdate = (const char *)(sqlite3_column_text(stmt, 6)); + (*list)->item[i].creationdate = NULL; + if (creationdate) { + int length = strlen(creationdate); + if (length > 0) { + (*list)->item[i].creationdate = (char *)calloc(length + 1, sizeof(char)); + memcpy((*list)->item[i].creationdate, creationdate, length); + } + } + const char *updatedate = (const char *)(sqlite3_column_text(stmt, 7)); + (*list)->item[i].updatedate = NULL; + if (updatedate) { + int length = strlen(updatedate); + if (length > 0) { + (*list)->item[i].updatedate = (char *)calloc(length + 1, sizeof(char)); + memcpy((*list)->item[i].updatedate, updatedate, length); + } + } + + (*list)->item[i].orderIndex = sqlite3_column_int(stmt, 8); + i++; + } + + (*list)->count = i; + FAVORITES_LOGE("bookmark list count : %d", (*list)->count); + + if ((nError != SQLITE_ROW) && (nError != SQLITE_DONE)) { + FAVORITES_LOGE("sqlite3_step is failed(%s).\n", + sqlite3_errmsg(gl_internet_bookmark_db)); + _favorites_finalize_bookmark_db(stmt); + return FAVORITES_ERROR_DB_FAILED; + } + + _favorites_finalize_bookmark_db(stmt); + return FAVORITES_ERROR_NONE; +#endif +} + +int _set_full_tree_to_html_recur(int parent_id, FILE *fp, int depth) +{ + FAVORITES_LOGD("depth: %d", depth); + if (parent_id < 0) + return FAVORITES_ERROR_INVALID_PARAMETER; + if (fp == NULL) + return FAVORITES_ERROR_INVALID_PARAMETER; + if (depth < 0) + return FAVORITES_ERROR_INVALID_PARAMETER; + + bookmark_list_h child_list = NULL; + + int ret = _get_list_by_folder(parent_id, &child_list); + + if (ret != FAVORITES_ERROR_NONE) + return FAVORITES_ERROR_DB_FAILED; + + int i = 0; + int j = 0; + FAVORITES_LOGD("list->count: %d", child_list->count); + for (i=0; i < (child_list->count); i++) { + FAVORITES_LOGD("title: %s", child_list->item[i].title); + if (child_list->item[i].is_folder) { + for (j=0 ; j < depth ; j++) { + fputs("\t", fp); + } + int folder_adddate_unixtime = 0; + folder_adddate_unixtime = + _favorites_get_unixtime_from_datetime( + child_list->item[i].creationdate); + fprintf(fp, "

%s

\n", + folder_adddate_unixtime, child_list->item[i].title); + for (j=0 ; j < depth ; j++) { + fputs("\t", fp); + } + fputs("

\n", fp); + ret = _set_full_tree_to_html_recur(child_list->item[i].id, fp, depth+1); + if (ret != FAVORITES_ERROR_NONE) { + _favorites_free_bookmark_list(child_list); + return ret; + } + for (j=0 ; j < depth ; j++) { + fputs("\t", fp); + } + fputs("

\n", fp); + }else { + int bookmark_adddate_unixtime = + _favorites_get_unixtime_from_datetime( + child_list->item[i].creationdate); + + if(bookmark_adddate_unixtime<0) + bookmark_adddate_unixtime=0; + + int bookmark_updatedate_unixtime = + _favorites_get_unixtime_from_datetime( + child_list->item[i].updatedate); + + if(bookmark_updatedate_unixtime<0) + bookmark_updatedate_unixtime=0; + + for (j=0 ; j < depth ; j++) { + fputs("\t", fp); + } + fprintf(fp,"

item[i].address); + fprintf(fp,"ADD_DATE=\"%d\" ", + bookmark_adddate_unixtime); + fprintf(fp,"LAST_VISIT=\"%d\" ", + bookmark_updatedate_unixtime); + fprintf(fp,"LAST_MODIFIED=\"%d\">", + bookmark_updatedate_unixtime); + fprintf(fp,"%s\n", child_list->item[i].title ); + } + } + + _favorites_free_bookmark_list(child_list); + return FAVORITES_ERROR_NONE; } /************************************************************* @@ -936,10 +1411,12 @@ int _get_folder_id(const char *title, const int parent) *************************************************************/ int favorites_bookmark_get_root_folder_id(int *root_id) { + FAVORITES_LOGE(""); if (!root_id) return FAVORITES_ERROR_INVALID_PARAMETER; *root_id = _get_root_folder_id(); + FAVORITES_LOGE("root_id: %d", *root_id); return FAVORITES_ERROR_NONE; } @@ -984,6 +1461,19 @@ int favorites_bookmark_add(const char *title, const char *url, int parent_id, in int favorites_bookmark_get_count(int *count) { FAVORITES_LOGD(""); +#if defined(BROWSER_BOOKMARK_SYNC) + int ids_count = 0; + int *ids = NULL; + bp_bookmark_adaptor_get_full_ids_p(&ids, &ids_count); + *count = ids_count; + free(ids); + + if (*count <0) { + FAVORITES_LOGE("bp_bookmark_adaptor_get_full_ids_p is failed\n"); + return FAVORITES_ERROR_DB_FAILED; + } + return FAVORITES_ERROR_NONE; +#else int nError; sqlite3_stmt *stmt; @@ -995,9 +1485,15 @@ int favorites_bookmark_get_count(int *count) } /* folder + bookmark */ +#if defined(ROOT_IS_ZERO) + nError = sqlite3_prepare_v2(gl_internet_bookmark_db, + "select count(*) from bookmarks", + -1, &stmt, NULL); +#else nError = sqlite3_prepare_v2(gl_internet_bookmark_db, "select count(*) from bookmarks where parent != 0", -1, &stmt, NULL); +#endif if (nError != SQLITE_OK) { FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", sqlite3_errmsg(gl_internet_bookmark_db)); @@ -1016,11 +1512,81 @@ int favorites_bookmark_get_count(int *count) } _favorites_close_bookmark_db(); return FAVORITES_ERROR_DB_FAILED; +#endif } int favorites_bookmark_foreach(favorites_bookmark_foreach_cb callback,void *user_data) { FAVORITES_NULL_ARG_CHECK(callback); +#if defined(BROWSER_BOOKMARK_SYNC) + int ids_count = 0; + int *ids = NULL; + int func_ret = 0; + int is_folder = -1; + int editable = -1; + + if (bp_bookmark_adaptor_get_full_ids_p(&ids, &ids_count) < 0) { + FAVORITES_LOGE ("bp_bookmark_adaptor_get_full_ids_p is failed.\n"); + return FAVORITES_ERROR_DB_FAILED; + } + + FAVORITES_LOGD("bp_bookmark_adaptor_get_full_ids_p count : %d", ids_count); + if (ids_count > 0) { + int i = 0; + for (i = 0; i < ids_count; i++) { + FAVORITES_LOGD("I[%d] id : %d", i, ids[i]); + favorites_bookmark_entry_s result; + memset(&result, 0x00, sizeof(favorites_bookmark_entry_s)); + result.id = ids[i]; + bp_bookmark_adaptor_get_type(result.id, &is_folder); + if (is_folder > 0) + result.is_folder = 1; + else + result.is_folder = 0; + FAVORITES_LOGD("is_folder : %d", result.is_folder); + bp_bookmark_adaptor_get_parent_id(result.id, &(result.folder_id)); + FAVORITES_LOGD("folder_id : %d", result.folder_id); + bp_bookmark_adaptor_get_url(result.id, &(result.address)); + FAVORITES_LOGD("address : %s", result.address); + bp_bookmark_adaptor_get_title(result.id, &(result.title)); + FAVORITES_LOGD("title : %s", result.title); + bp_bookmark_adaptor_get_is_editable(result.id, &editable); + if (editable > 0) + result.editable = 1; + else + result.editable = 0; + bp_bookmark_adaptor_get_sequence(result.id, &(result.order_index)); + FAVORITES_LOGD("order_index : %d", result.order_index); + + result.creation_date = NULL; + int recv_int = -1; + bp_bookmark_adaptor_get_date_created(result.id, &recv_int); + result.creation_date = (char *)calloc(128, sizeof(char)); + strftime(result.creation_date,128,"%Y-%m-%d %H:%M:%S",localtime((time_t *)&recv_int)); + FAVORITES_LOGD("Creationdata:%s", result.creation_date); + + result.update_date = NULL; + bp_bookmark_adaptor_get_date_modified(result.id, &recv_int); + result.update_date = (char *)calloc(128, sizeof(char)); + strftime(result.update_date,128,"%Y-%m-%d %H:%M:%S",localtime((time_t *)&recv_int)); + FAVORITES_LOGD("update_date:%s", result.update_date); + + result.visit_date = NULL; + bp_bookmark_adaptor_get_date_visited(result.id, &recv_int); + result.visit_date = (char *)calloc(128, sizeof(char)); + strftime(result.visit_date,128,"%Y-%m-%d %H:%M:%S",localtime((time_t *)&recv_int)); + FAVORITES_LOGD("visit_date:%s", result.visit_date); + + func_ret = callback(&result, user_data); + _favorites_free_bookmark_entry(&result); + if(func_ret == 0) + break; + } + } + free(ids); + FAVORITES_LOGE ("There are no more bookmarks.\n"); + return FAVORITES_ERROR_NONE; +#else int nError; int func_ret = 0; sqlite3_stmt *stmt; @@ -1029,11 +1595,19 @@ int favorites_bookmark_foreach(favorites_bookmark_foreach_cb callback,void *user FAVORITES_LOGE("db_util_open is failed\n"); return FAVORITES_ERROR_DB_FAILED; } +#if defined(ROOT_IS_ZERO) + nError = sqlite3_prepare_v2(gl_internet_bookmark_db, + "select id, type, parent, address, title, editable,\ + creationdate, updatedate, sequence \ + from bookmarks order by sequence", + -1, &stmt, NULL); +#else nError = sqlite3_prepare_v2(gl_internet_bookmark_db, "select id, type, parent, address, title, editable,\ creationdate, updatedate, sequence \ from bookmarks where parent != 0 order by sequence", -1, &stmt, NULL); +#endif if (nError != SQLITE_OK) { FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", sqlite3_errmsg(gl_internet_bookmark_db)); @@ -1068,6 +1642,7 @@ int favorites_bookmark_foreach(favorites_bookmark_foreach_cb callback,void *user if (length > 0) { result.title = (char *)calloc(length + 1, sizeof(char)); memcpy(result.title, title, length); + FAVORITES_LOGE ("title:%s\n", title); } } result.editable = sqlite3_column_int(stmt, 5); @@ -1102,26 +1677,21 @@ int favorites_bookmark_foreach(favorites_bookmark_foreach_cb callback,void *user FAVORITES_LOGE ("There are no more bookmarks.\n"); _favorites_finalize_bookmark_db(stmt); return FAVORITES_ERROR_NONE; +#endif } -int favorites_bookmark_export_list(const char * file_path) +int favorites_bookmark_export_list(const char *file_path) { FAVORITES_NULL_ARG_CHECK(file_path); - FILE *fp = NULL; - bookmark_list_h folders_list = NULL; - bookmark_list_h bookmarks_list = NULL; - /* Get list of all bookmarks */ - folders_list = _favorites_bookmark_get_folder_list(); - if(folders_list == NULL ) { - FAVORITES_LOGE("There is no folders even root folder"); - return FAVORITES_ERROR_DB_FAILED; - } + int root_id = -1; + favorites_bookmark_get_root_folder_id(&root_id); - fp = fopen( file_path, "w"); - if(fp == NULL) { + FILE *fp = NULL; + FAVORITES_LOGE("file_path: %s", file_path); + fp = fopen(file_path, "w"); + if (fp == NULL) { FAVORITES_LOGE("file opening is failed."); - _favorites_free_bookmark_list(folders_list); return FAVORITES_ERROR_INVALID_PARAMETER; } fputs("\n", fp); @@ -1133,105 +1703,68 @@ int favorites_bookmark_export_list(const char * file_path) fputs("Bookmarks\n", fp); fputs("

Bookmarks

\n", fp); fputs("

\n", fp); - /*Set subfolders and its bookmark items */ - int i = 0; - int folder_adddate_unixtime = 0; - int k=0; - int bookmark_adddate_unixtime = 0; - int bookmark_updatedate_unixtime = 0; - for(i=0; i < (folders_list->count); i++) { - folder_adddate_unixtime = - _favorites_get_unixtime_from_datetime( - folders_list->item[i].creationdate); - FAVORITES_LOGE("TITLE: %s", folders_list->item[i].title); - - fprintf(fp, "\t

%s

\n", - folder_adddate_unixtime, folders_list->item[i].title); - fputs("\t

\n", fp); - /* Get bookmarks under this folder and put the list into the file*/ - _favorites_free_bookmark_list(bookmarks_list); - bookmarks_list = NULL; - bookmarks_list = _favorites_get_bookmark_list_at_folder( - folders_list->item[i].id); - if(bookmarks_list!= NULL){ - for(k=0;k<(bookmarks_list->count); k++){ - bookmark_adddate_unixtime = - _favorites_get_unixtime_from_datetime( - bookmarks_list->item[k].creationdate); - - if(bookmark_adddate_unixtime<0) - bookmark_adddate_unixtime=0; - - bookmark_updatedate_unixtime = - _favorites_get_unixtime_from_datetime( - bookmarks_list->item[k].updatedate); - - if(bookmark_updatedate_unixtime<0) - bookmark_updatedate_unixtime=0; - - fprintf(fp,"\t\t

item[k].address); - fprintf(fp,"ADD_DATE=\"%d\" ", - bookmark_adddate_unixtime); - fprintf(fp,"LAST_VISIT=\"%d\" ", - bookmark_updatedate_unixtime); - fprintf(fp,"LAST_MODIFIED=\"%d\">", - bookmark_updatedate_unixtime); - fprintf(fp,"%s\n", bookmarks_list->item[k].title ); - } - } - fputs("\t

\n", fp); - } - - /*Set root folder's bookmark items */ - _favorites_free_bookmark_list(bookmarks_list); - bookmarks_list = NULL; - bookmarks_list = _favorites_get_bookmark_list_at_folder(1); - if(bookmarks_list!= NULL){ - for(k=0;k<(bookmarks_list->count); k++){ - bookmark_adddate_unixtime = - _favorites_get_unixtime_from_datetime( - bookmarks_list->item[k].creationdate); - - if(bookmark_adddate_unixtime<0) - bookmark_adddate_unixtime=0; - - bookmark_updatedate_unixtime = - _favorites_get_unixtime_from_datetime( - bookmarks_list->item[k].updatedate); - - if(bookmark_updatedate_unixtime<0) - bookmark_updatedate_unixtime=0; - fprintf(fp,"\t

item[k].address); - fprintf(fp,"ADD_DATE=\"%d\" ", - bookmark_adddate_unixtime); - fprintf(fp,"LAST_VISIT=\"%d\" ", - bookmark_updatedate_unixtime); - fprintf(fp,"LAST_MODIFIED=\"%d\">", - bookmark_updatedate_unixtime); - fprintf(fp,"%s\n", bookmarks_list->item[k].title ); - } + int ret = -1; + ret = _set_full_tree_to_html_recur(root_id, fp, 1); + if (ret != FAVORITES_ERROR_NONE) { + fclose(fp); + return FAVORITES_ERROR_DB_FAILED; } + fputs("

\n", fp); fclose(fp); - _favorites_free_bookmark_list(bookmarks_list); - _favorites_free_bookmark_list(folders_list); - return FAVORITES_ERROR_NONE; } int favorites_bookmark_get_favicon(int id, Evas *evas, Evas_Object **icon) { + FAVORITES_LOGD(""); FAVORITES_INVALID_ARG_CHECK(id<0); FAVORITES_NULL_ARG_CHECK(evas); FAVORITES_NULL_ARG_CHECK(icon); - - sqlite3_stmt *stmt; - char query[1024]; +#if defined(BROWSER_BOOKMARK_SYNC) + void *favicon_data_temp=NULL; + favicon_entry_h favicon; + favicon = (favicon_entry_h) calloc(1, sizeof(favicon_entry_s)); + int ret = bp_bookmark_adaptor_get_favicon(id, (unsigned char **)&favicon_data_temp, &(favicon->length)); + if (ret == 0) { + if (bp_bookmark_adaptor_get_favicon_width(id, &(favicon->w)) == 0) { + if (bp_bookmark_adaptor_get_favicon_height(id, &(favicon->h)) == 0) { + FAVORITES_LOGD("favicon is successfully loaded."); + } else { + FAVORITES_LOGE("bp_bookmark_adaptor_set_favicon_height is failed"); + *icon = NULL; + return FAVORITES_ERROR_DB_FAILED; + } + } else { + FAVORITES_LOGE("bp_bookmark_adaptor_set_favicon_width is failed"); + *icon = NULL; + return FAVORITES_ERROR_DB_FAILED; + } + } else { + FAVORITES_LOGE("bp_bookmark_adaptor_set_favicon is failed"); + *icon = NULL; + return FAVORITES_ERROR_DB_FAILED; + } + FAVORITES_LOGD("len: %d, w:%d, h:%d", favicon->length, favicon->w, favicon->h); + if (favicon->length > 0){ + *icon = evas_object_image_filled_add(evas); + evas_object_image_colorspace_set(*icon, EVAS_COLORSPACE_ARGB8888); + evas_object_image_size_set(*icon, favicon->w, favicon->h); + evas_object_image_fill_set(*icon, 0, 0, favicon->w, favicon->h); + evas_object_image_filled_set(*icon, EINA_TRUE); + evas_object_image_alpha_set(*icon,EINA_TRUE); + evas_object_image_data_set(*icon, favicon_data_temp); + return FAVORITES_ERROR_NONE; + } + *icon = NULL; + FAVORITES_LOGE("favicon length is 0"); + return FAVORITES_ERROR_DB_FAILED; +#else void *favicon_data_temp=NULL; favicon_entry_h favicon; + sqlite3_stmt *stmt; + char query[1024]; int nError; memset(&query, 0x00, sizeof(char)*1024); @@ -1284,15 +1817,40 @@ int favorites_bookmark_get_favicon(int id, Evas *evas, Evas_Object **icon) _favorites_close_bookmark_db(); return FAVORITES_ERROR_NONE; +#endif } int favorites_bookmark_set_favicon(int bookmark_id, Evas_Object *icon) { + FAVORITES_LOGD(""); FAVORITES_INVALID_ARG_CHECK(bookmark_id<0); FAVORITES_NULL_ARG_CHECK(icon); - - int nError; - sqlite3_stmt *stmt; +#if defined(BROWSER_BOOKMARK_SYNC) + int icon_w = 0; + int icon_h = 0; + int stride = 0; + int icon_length = 0; + void *icon_data = (void *)evas_object_image_data_get(icon, EINA_TRUE); + evas_object_image_size_get(icon, &icon_w, &icon_h); + stride = evas_object_image_stride_get(icon); + icon_length = icon_h * stride; + FAVORITES_LOGD("favicon size w:%d, h:%d, stride: %d", icon_w, icon_h, stride); + int ret = bp_bookmark_adaptor_set_favicon(bookmark_id,(const unsigned char *)icon_data, icon_length); + if (ret == 0) { + if (bp_bookmark_adaptor_set_favicon_width(bookmark_id, icon_w) == 0) { + if (bp_bookmark_adaptor_set_favicon_height(bookmark_id, icon_h) == 0) { + FAVORITES_LOGE("favicon is successfully saved."); + bp_bookmark_adaptor_publish_notification(); + return FAVORITES_ERROR_NONE; + } else + FAVORITES_LOGE("bp_bookmark_adaptor_set_favicon_height is failed"); + } else + FAVORITES_LOGE("bp_bookmark_adaptor_set_favicon_width is failed"); + } else + FAVORITES_LOGE("bp_bookmark_adaptor_set_favicon is failed"); + FAVORITES_LOGE("set favicon is failed"); + return FAVORITES_ERROR_DB_FAILED; +#else int icon_w = 0; int icon_h = 0; int stride = 0; @@ -1302,6 +1860,8 @@ int favorites_bookmark_set_favicon(int bookmark_id, Evas_Object *icon) stride = evas_object_image_stride_get(icon); icon_length = icon_h * stride; FAVORITES_LOGD("favicon size w:%d, h:%d, stride: %d", icon_w, icon_h, stride); + int nError; + sqlite3_stmt *stmt; if (_favorites_open_bookmark_db() < 0) { FAVORITES_LOGE("db_util_open is failed\n"); @@ -1356,11 +1916,21 @@ int favorites_bookmark_set_favicon(int bookmark_id, Evas_Object *icon) FAVORITES_LOGE("sqlite3_step is failed"); _favorites_close_bookmark_db(); return FAVORITES_ERROR_DB_FAILED; +#endif } int favorites_bookmark_delete_bookmark(int id) { + FAVORITES_LOGE(""); FAVORITES_INVALID_ARG_CHECK(id<0); +#if defined(BROWSER_BOOKMARK_SYNC) + if (bp_bookmark_adaptor_delete(id) < 0) + return FAVORITES_ERROR_DB_FAILED; + else { + bp_bookmark_adaptor_publish_notification(); + return FAVORITES_ERROR_NONE; + } +#else int nError; sqlite3_stmt *stmt; @@ -1369,8 +1939,13 @@ int favorites_bookmark_delete_bookmark(int id) return FAVORITES_ERROR_DB_FAILED; } +#if defined(ROOT_IS_ZERO) + nError = sqlite3_prepare_v2(gl_internet_bookmark_db, + "delete from bookmarks where id=?", -1, &stmt, NULL); +#else nError = sqlite3_prepare_v2(gl_internet_bookmark_db, "delete from bookmarks where id=? and parent != 0", -1, &stmt, NULL); +#endif if (nError != SQLITE_OK) { FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", sqlite3_errmsg(gl_internet_bookmark_db)); @@ -1391,10 +1966,36 @@ int favorites_bookmark_delete_bookmark(int id) FAVORITES_LOGE("sqlite3_step is failed"); _favorites_close_bookmark_db(); return FAVORITES_ERROR_DB_FAILED; +#endif } int favorites_bookmark_delete_all_bookmarks(void) { + FAVORITES_LOGD(""); +#if defined(BROWSER_BOOKMARK_SYNC) + int ids_count = 0; + int *ids = NULL; + + if (bp_bookmark_adaptor_get_full_ids_p(&ids, &ids_count) < 0) { + FAVORITES_LOGE ("bp_bookmark_adaptor_get_full_ids_p is failed.\n"); + return FAVORITES_ERROR_DB_FAILED; + } + + FAVORITES_LOGD("bp_bookmark_adaptor_get_full_ids_p count : %d", ids_count); + if (ids_count > 0) { + int i = 0; + for (i = 0; i < ids_count; i++) { + FAVORITES_LOGD("I[%d] id : %d", i, ids[i]); + if (bp_bookmark_adaptor_delete(ids[i]) < 0) { + free(ids); + return FAVORITES_ERROR_DB_FAILED; + } else + bp_bookmark_adaptor_publish_notification(); + } + } + free(ids); + return FAVORITES_ERROR_NONE; +#else int nError; sqlite3_stmt *stmt; @@ -1403,8 +2004,13 @@ int favorites_bookmark_delete_all_bookmarks(void) return FAVORITES_ERROR_DB_FAILED; } +#if defined(ROOT_IS_ZERO) + nError = sqlite3_prepare_v2(gl_internet_bookmark_db, + "delete from bookmarks", -1, &stmt, NULL); +#else nError = sqlite3_prepare_v2(gl_internet_bookmark_db, "delete from bookmarks where parent !=0", -1, &stmt, NULL); +#endif if (nError != SQLITE_OK) { FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", sqlite3_errmsg(gl_internet_bookmark_db)); @@ -1419,5 +2025,6 @@ int favorites_bookmark_delete_all_bookmarks(void) FAVORITES_LOGE("sqlite3_step is failed"); _favorites_close_bookmark_db(); return FAVORITES_ERROR_DB_FAILED; +#endif } diff --git a/src/favorites_history.c b/src/favorites_history.c index 456c8b3..d72d28d 100644 --- a/src/favorites_history.c +++ b/src/favorites_history.c @@ -86,7 +86,8 @@ int favorites_history_get_count(int *count) "select count(*) from history", -1, &stmt, NULL); if (nError != SQLITE_OK) { - FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n"); + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_history_db)); _favorites_history_db_finalize(stmt); return FAVORITES_ERROR_DB_FAILED; } @@ -118,7 +119,8 @@ int favorites_history_foreach(favorites_history_foreach_cb callback,void *user_d -1, &stmt, NULL); if (nError != SQLITE_OK) { - FAVORITES_LOGE ("sqlite3_prepare_v2 is failed.\n"); + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_history_db)); _favorites_history_db_finalize(stmt); return FAVORITES_ERROR_DB_FAILED; } @@ -188,7 +190,8 @@ int favorites_history_delete_history(int id) nError = sqlite3_prepare_v2(gl_internet_history_db, "delete from history where id=?", -1, &stmt, NULL); if (nError != SQLITE_OK) { - FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n"); + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_history_db)); _favorites_history_db_finalize(stmt); return FAVORITES_ERROR_DB_FAILED; } @@ -226,7 +229,8 @@ int favorites_history_delete_history_by_url(const char *url) nError = sqlite3_prepare_v2(gl_internet_history_db, "delete from history where address=?", -1, &stmt, NULL); if (nError != SQLITE_OK) { - FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n"); + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_history_db)); _favorites_history_db_finalize(stmt); return FAVORITES_ERROR_DB_FAILED; } @@ -257,7 +261,8 @@ int favorites_history_delete_all_histories(void) nError = sqlite3_prepare_v2(gl_internet_history_db, "delete from history", -1, &stmt, NULL); if (nError != SQLITE_OK) { - FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n"); + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_history_db)); _favorites_history_db_finalize(stmt); return FAVORITES_ERROR_DB_FAILED; } @@ -301,7 +306,8 @@ int favorites_history_delete_history_by_term(const char *begin, const char *end) query, -1, &stmt, NULL); if (nError != SQLITE_OK) { - FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n"); + FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n", + sqlite3_errmsg(gl_internet_history_db)); _favorites_history_db_finalize(stmt); return FAVORITES_ERROR_DB_FAILED; } -- cgit v1.2.3