upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 07:58:24 +0000 (16:58 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 07:58:24 +0000 (16:58 +0900)
16 files changed:
CMakeLists.txt [new file with mode: 0755]
capi-web-favorites.pc.in [new file with mode: 0755]
debian/capi-web-favorites-dev.install [new file with mode: 0644]
debian/capi-web-favorites-dev.postinst [new file with mode: 0644]
debian/capi-web-favorites.install [new file with mode: 0644]
debian/capi-web-favorites.postinst [new file with mode: 0644]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0755]
debian/control [new file with mode: 0644]
debian/rules [new file with mode: 0755]
include/favorites.h [new file with mode: 0644]
include/favorites_private.h [new file with mode: 0644]
packaging/capi-web-favorites.spec [new file with mode: 0755]
packaging/capi-web-favorites.spec~ [new file with mode: 0755]
src/favorites_bookmark.c [new file with mode: 0644]
src/favorites_history.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..3c93fe5
--- /dev/null
@@ -0,0 +1,98 @@
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-web-favorites")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(requires "db-util dlog sqlite3 evas capi-base-common")
+SET(pc_requires "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${requires})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+ADD_DEFINITIONS(
+               -DLOG_TAG=\"favorites\"
+)
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/web
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_requires})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/web)
+
+CONFIGURE_FILE(
+    ${fw_name}.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean 
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    . 
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
+
diff --git a/capi-web-favorites.pc.in b/capi-web-favorites.pc.in
new file mode 100755 (executable)
index 0000000..71f9891
--- /dev/null
@@ -0,0 +1,14 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/web
+
+Name: @PC_NAME@
+Description: Internet bookmark and history control API
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/debian/capi-web-favorites-dev.install b/debian/capi-web-favorites-dev.install
new file mode 100644 (file)
index 0000000..761a28b
--- /dev/null
@@ -0,0 +1,4 @@
+/usr/include/*
+/usr/include/*/*
+/usr/lib/pkgconfig/*.pc
+
diff --git a/debian/capi-web-favorites-dev.postinst b/debian/capi-web-favorites-dev.postinst
new file mode 100644 (file)
index 0000000..1a24852
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/capi-web-favorites.install b/debian/capi-web-favorites.install
new file mode 100644 (file)
index 0000000..4a755a4
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/lib*.so*
diff --git a/debian/capi-web-favorites.postinst b/debian/capi-web-favorites.postinst
new file mode 100644 (file)
index 0000000..1a24852
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..13452bb
--- /dev/null
@@ -0,0 +1,26 @@
+capi-web-favorites (0.0.3) unstable; urgency=low
+
+  * Git: api/favorites
+  * Tag: capi-web-favorites_0.0.3
+
+  * Applying modification to fix miss typing and some wrong settings.
+
+ -- Sangpyo Kim <sangpyo7.kim@samsung.com>  Thu, 15 Mar 2012 17:42:44 +0900
+
+capi-web-favorites (0.0.2) unstable; urgency=low
+
+  * Git: api/favorites
+  * Tag: capi-web-favorites_0.0.2
+
+  * moving location of history database file
+  * SO versioning fixed
+
+ -- Sangpyo Kim <sangpyo7.kim@samsung.com>  Fri, 17 Feb 2012 15:23:59 +0900
+
+capi-web-favorites (0.0.1) unstable; urgency=low
+
+  * Git: api/favorites
+  * Tag: capi-web-favorites_0.0.1
+  * first upload
+
+ -- Sangpyo Kim <sangpyo7.kim@samsung.com>  Wed, 24 Aug 2011 21:12:42 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100755 (executable)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..a6d7bf3
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Source: capi-web-favorites\r
+Section: libs\r
+Priority: extra\r
+Uploaders: Sangpyo Kim <sangpyo7.kim@samsung.com>, Inbum Chang <ibchang@samsung.com>\r
+Maintainer: Sangpyo Kim <sangpyo7.kim@samsung.com>, Inbum Chang <ibchang@samsung.com>\r
+Build-Depends: debhelper (>= 5), dlog-dev, libslp-db-util-dev, libsqlite3-dev, libevas-dev(>=0.1), capi-base-common-dev\r
+\r
+Package: capi-web-favorites\r
+Architecture: any\r
+Depends: ${shlibs:Depends}, ${misc:Depends}\r
+Description: Internet Bookmark and history control API\r
+\r
+Package: capi-web-favorites-dev\r
+Architecture: any\r
+Depends:  ${shlibs:Depends}, ${misc:Depends}, capi-web-favorites(= ${Source-Version}), capi-base-common-dev\r
+Description: Internet Bookmark and history control API for Developer\r
+\r
+Package: capi-web-favorites-dbg\r
+Architecture: any\r
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-web-favorites(= ${Source-Version})\r
+Description: Internet Bookmark and history control API (unstripped)\r
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..e28a316
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/make -f
+
+FULLVER ?= $(shell dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2 | cut -d '-' -f 1)
+MAJORVER ?= $(shell echo $(FULLVER) | cut -d '.' -f 1)
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+CMAKE_ROOT_DIR ?= $(CURDIR)
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER}
+       touch configure-stamp
+
+build: build-stamp
+build-stamp: configure-stamp
+       dh_testdir
+       cd $(CMAKE_BUILD_DIR) && $(MAKE)
+       touch $@
+
+clean:
+       cd $(CMAKE_ROOT_DIR)
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+       # Add here commands to clean up after the build process.
+       rm -f
+       rm -rf $(CMAKE_BUILD_DIR)
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=capi-web-favorites-dbg
+       dh_fixperms
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
+
diff --git a/include/favorites.h b/include/favorites.h
new file mode 100644 (file)
index 0000000..d16cfe2
--- /dev/null
@@ -0,0 +1,301 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef __TIZEN_WEB_FAVORITES_H__\r
+#define __TIZEN_WEB_FAVORITES_H__\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <Evas.h>\r
+#include <tizen.h>\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+/**\r
+ * @addtogroup CAPI_WEB_FAVORITES_MODULE\r
+ * @{\r
+ */\r
+\r
+/**\r
+ * @brief Enumerations for favorites error.\r
+ */\r
+typedef enum favorites_error{\r
+       FAVORITES_ERROR_NONE                    = TIZEN_ERROR_NONE,              /**< Successful */\r
+       FAVORITES_ERROR_INVALID_PARAMETER       = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */\r
+       FAVORITES_ERROR_DB_FAILED               = TIZEN_ERROR_WEB_CLASS | 0x62,  /**< Database operation failure */\r
+       FAVORITES_ERROR_ITEM_ALREADY_EXIST      = TIZEN_ERROR_WEB_CLASS | 0x63 /**< Requested data already exists */\r
+} favorites_error_e;\r
+\r
+/**\r
+ * @brief   The structure of bookmark entry in search results.\r
+ *\r
+ * @details This structure is passed to callback function in all bookmark related\r
+ * iterations through list received from search functions.\r
+ *\r
+ * @see  bookmark_foreach_cb()\r
+ */\r
+typedef struct {\r
+       char* address;  /**< Bookmark URL */\r
+       char* title;    /**< The title of the bookmark */\r
+       char* creation_date;    /**< The date of creation */\r
+       char* update_date;      /**< The last updated date */\r
+       char* visit_date;       /**< The last visit date */\r
+       int id; /**< The unique ID of bookmark */\r
+       bool is_folder; /**< property bookmark or folder\n @c true: folder, @c false: bookmark */\r
+       int folder_id;  /**< The ID of parent folder */\r
+       int order_index;        /**< The order index of bookmarks when show the list at the browser */\r
+       bool editable;  /**< The flag of editability\n @c true : writable, @c false: read-only, not ediable */\r
+} favorites_bookmark_entry_s;\r
+\r
+/**\r
+ * @brief       Called to get bookmark details for each found bookmark.\r
+ *\r
+ * @param[in]   item   The bookmark entry handle or folder entry handle\r
+ * @param[in]   user_data      The user data passed from the foreach function\r
+ *\r
+ * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.\r
+ *\r
+ * @pre                favorites_bookmark_foreach() will invoke this callback.\r
+ *\r
+ * @see                favorites_bookmark_foreach()\r
+ */\r
+typedef bool (*favorites_bookmark_foreach_cb)(favorites_bookmark_entry_s *item, void *user_data);\r
+\r
+/**\r
+ * @brief       Adds an entry to bookmark list.\r
+ *\r
+ * @remarks  If a folder named @a "foldername" doesn't exist, it will be created.\r
+ * @remarks  The folder named "Bookmarks" is reserved for the root folder.\r
+ * @param[in]  url     Book URL\r
+ * @param[in]  title   The title of the bookmark\r
+ * @param[in]  folder_name The name of parent folder\r
+ * @param[out] bookmark_id: The unique id of the added bookmark\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE        Successful\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED   Database failed\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_ITEM_ALREADY_EXIST        Requested data already exists\r
+ *\r
+ */\r
+int favorites_bookmark_add_bookmark(const char *url, const char *title, const char *folder_name, int *bookmark_id);\r
+\r
+/**\r
+ * @brief       Deletes the bookmark item of given bookmark id.\r
+ *\r
+ * @param[in]   bookmark_id    The unique ID of bookmark to delete\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_bookmark_delete_bookmark(int bookmark_id);\r
+\r
+/**\r
+ * @brief       Deletes all bookmarks and sub folders.\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_bookmark_delete_all_bookmarks(void);\r
+\r
+/**\r
+ * @brief       Gets a number of bookmark list items.\r
+ *\r
+ * @param[out]  count   The number of bookmarks and sub folders.\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE        Successful\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED   Database failed\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ *\r
+ */\r
+int favorites_bookmark_get_count(int *count);\r
+\r
+/**\r
+ * @brief       Retrieves all bookmarks and folders by invoking the given callback function iteratively.\r
+ *\r
+ * @remarks  All bookmarks and folders data are also used by browser application\r
+ * @param[in]   callback       The callback function to invoke\r
+ * @param[in]   user_data      The user data to be passed to the callback function\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ * @post       This function invokes bookmark_foreach_cb() repeatedly for each bookmark.\r
+ *\r
+ * @see bookmark_foreach_cb()\r
+ */\r
+int favorites_bookmark_foreach(favorites_bookmark_foreach_cb callback, void *user_data);\r
+\r
+/**\r
+ * @brief       Exports a whole bookmark list as a netscape HTML bookmark file.\r
+ *\r
+ * @param[in]   file_path      The absolute path of the export file. This must includes html file name.\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_bookmark_export_list(const char *file_path);\r
+\r
+/**\r
+ * @brief       Gets the bookmark's favicon as a evas object type\r
+ *\r
+ * @param[in]   bookmark_id    The unique ID of bookmark\r
+ * @param[in]   evas   The given canvas\r
+ * @param[out]  icon   Retrieved favicon evas object of bookmark.\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_bookmark_get_favicon(int bookmark_id, Evas *evas, Evas_Object **icon);\r
+\r
+/**\r
+ * @brief   The structure of history entry in search results.\r
+ *\r
+ * @details This structure is passed to callback function in all history related\r
+ * iterations through list received from search functions.\r
+ *\r
+ * @see  history_foreach_cb()\r
+ */\r
+typedef struct {\r
+       char* address;  /**< URL history */\r
+       char* title;    /**< The title of history */\r
+       int count;      /**< The visit count */\r
+       char* visit_date;       /**< The last visit date */\r
+       int id; /**< The unique ID of history */\r
+} favorites_history_entry_s;\r
+\r
+/**\r
+ * @brief       Called to get history details for each found history.\r
+ *\r
+ * @param[in]   item   The history entry handle\r
+ * @param[in]   user_data      The user data passed from the foreach function\r
+ *\r
+ * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.\r
+ *\r
+ * @pre                favorites_history_foreach() will invoke this callback.\r
+ *\r
+ * @see                favorites_history_foreach()\r
+ */\r
+typedef bool (*favorites_history_foreach_cb)(favorites_history_entry_s *item, void *user_data);\r
+\r
+/**\r
+ * @brief       Gets a number of history list items.\r
+ *\r
+ * @param[out]  count   The number of histories.\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE        Successful\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED   Database failed\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ *\r
+ */\r
+int favorites_history_get_count(int *count);\r
+\r
+/**\r
+ * @brief       Retrieves all histories by invoking the given callback function iteratively.\r
+ *\r
+ * @param[in]   callback       The callback function to invoke\r
+ * @param[in]   user_data      The user data to be passed to the callback function\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ * @post       This function invokes history_foreach_cb().\r
+ *\r
+ * @see history_foreach_cb()\r
+ */\r
+int favorites_history_foreach(favorites_history_foreach_cb callback, void *user_data);\r
+\r
+/**\r
+ * @brief       Deletes the history item of given history id.\r
+ *\r
+ * @param[in]   history_id     The history ID to delete\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_history_delete_history(int history_id);\r
+\r
+/**\r
+ * @brief       Deletes the history item of given history url.\r
+ *\r
+ * @param[in]   url         history url which wants to be deleted\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_history_delete_history_by_url(const char *url);\r
+\r
+/**\r
+ * @brief       Deletes all histories.\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_history_delete_all_histories(void);\r
+\r
+/**\r
+ * @brief       Deletes all histories accessed with the browser within the specified time period.\r
+ *\r
+ * @param[in]   begin_date         The start date of the period\r
+ * @param[in]   end_date           The end date of the period\r
+ *\r
+ * @remarks  Date format must be "yyyy-mm-dd hh:mm:ss" ex: "2000-01-01 01:20:35".\r
+ *\r
+ * @return  0 on success, otherwise a negative error value.\r
+ * @retval  #FAVORITES_ERROR_NONE                Successful\r
+ * @retval  #FAVORITES_ERROR_INVALID_PARAMETER   Invalid parameter\r
+ * @retval  #FAVORITES_ERROR_DB_FAILED           Database failed\r
+ *\r
+ */\r
+int favorites_history_delete_history_by_term(const char *begin_date, const char *end_date);\r
+\r
+/**\r
+ * @}\r
+ */\r
+\r
+#ifdef __cplusplus\r
+};\r
+#endif\r
+\r
+#endif /* __TIZEN_WEB_FAVORITES_H__ */\r
diff --git a/include/favorites_private.h b/include/favorites_private.h
new file mode 100644 (file)
index 0000000..e370b0a
--- /dev/null
@@ -0,0 +1,133 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef __TIZEN_WEB_FAVORITES_PRIVATE_H__\r
+#define __TIZEN_WEB_FAVORITES_PRIVATE_H__\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**********************************************\r
+ * Logging macro\r
+ **********************************************/\r
+#define FAVORITES_LOGD(fmt, args...) LOGD(\\r
+               "[%s: %s: %d] "fmt, (rindex(__FILE__, '/')? rindex(__FILE__, '/') + 1 : __FILE__),\\r
+               __FUNCTION__, __LINE__, ##args)\r
+#define FAVORITES_LOGI(fmt, args...) LOGI(\\r
+               "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\\r
+               __FUNCTION__, __LINE__, ##args)\r
+#define FAVORITES_LOGW(fmt, args...) LOGW(\\r
+               "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\\r
+               __FUNCTION__, __LINE__, ##args)\r
+#define FAVORITES_LOGE(fmt, args...) LOGE(\\r
+               "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\\r
+               __FUNCTION__, __LINE__, ##args)\r
+#define FAVORITES_LOGE_IF(cond, fmt, args...) LOGE_IF(cond,\\r
+               "[%s: %s: %d] "fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/') + 1 : __FILE__),\\r
+               __FUNCTION__, __LINE__, ##args)\r
+\r
+/**********************************************\r
+ * Argument checking macro\r
+ **********************************************/\r
+#define FAVORITES_NULL_ARG_CHECK(_arg_)        do { \\r
+       if(_arg_ == NULL) { \\r
+        LOGE("[%s] FAVORITES_ERR_INVALID_PARAMETER(0x%08x)", __FUNCTION__,\\r
+        FAVORITES_ERROR_INVALID_PARAMETER); \\r
+        return FAVORITES_ERROR_INVALID_PARAMETER; \\r
+    } \\r
+}while(0)\r
+\r
+#define FAVORITES_INVALID_ARG_CHECK(_condition_)       do { \\r
+       if(_condition_) { \\r
+        LOGE("[%s] FAVORITES_ERR_INVALID_PARAMETER(0x%08x)", __FUNCTION__,\\r
+        FAVORITES_ERROR_INVALID_PARAMETER); \\r
+        return FAVORITES_ERROR_INVALID_PARAMETER; \\r
+    } \\r
+}while(0)\r
+\r
+#define _FAVORITES_FREE(_srcx_)        {       if(NULL != _srcx_) free(_srcx_);        }\r
+#define _FAVORITES_STRDUP(_srcx_)      (NULL != _srcx_) ? strdup(_srcx_):NULL\r
+\r
+struct bookmark_entry_internal{\r
+       char* address;          /**< URL of the bookmark */\r
+       char* title;                    /**< Title of the bookmark */\r
+       char* creationdate;     /**< date of created */\r
+       char* updatedate;       /**< date of last updated */\r
+       char* visitdate;                /**< date of last visited */\r
+       int id;                         /**< uniq id of bookmark */\r
+       int is_folder;                  /**< property bookmark or folder 1: bookmark 1: folder */\r
+       int folder_id;                  /**< parent folder id */\r
+       int orderIndex;         /**< order sequence */\r
+       int editable;                   /**< flag of editability 1 : WRITABLE   0: READ ONLY */\r
+};\r
+typedef struct bookmark_entry_internal bookmark_entry_internal_s;\r
+typedef struct bookmark_entry_internal *bookmark_entry_internal_h;\r
+\r
+struct bookmark_list {\r
+       int count;\r
+       bookmark_entry_internal_h item;\r
+};\r
+\r
+/**\r
+ * @brief The bookmark entry list handle.\r
+ */\r
+typedef struct bookmark_list bookmark_list_s;\r
+\r
+/**\r
+ * @brief The bookmark entry list structure.\r
+ */\r
+typedef struct bookmark_list *bookmark_list_h;\r
+\r
+struct favicon_entry {\r
+       void *data;     /* favicon image data pointer. ( Allocated memory) */\r
+       int length;     /* favicon image data's length */\r
+       int w;          /* favicon image width */\r
+       int h;          /* favicon image height */\r
+};\r
+typedef struct favicon_entry favicon_entry_s;\r
+typedef struct favicon_entry *favicon_entry_h;\r
+\r
+/* bookmark internal API */\r
+void _favorites_close_bookmark_db(void);\r
+void _favorites_finalize_bookmark_db(sqlite3_stmt *stmt);\r
+const char *_favorites_get_bookmark_db_name(void);\r
+int _favorites_open_bookmark_db(void);\r
+void _favorites_free_bookmark_list(bookmark_list_h m_list);\r
+int _favorites_free_bookmark_entry(favorites_bookmark_entry_s *entry);\r
+int _favorites_get_bookmark_lastindex(int locationId);\r
+int _favorites_bookmark_get_folderID(const char *foldername);\r
+int _favorites_bookmark_is_folder_exist(const char *foldername);\r
+int _favorites_bookmark_create_folder(const char *foldername);\r
+int _favorites_bookmark_is_bookmark_exist(const char *url, const char *title, const int folderId);\r
+int _favorites_get_bookmark_count_at_folder(int folderId);\r
+int _favorites_bookmark_get_folder_count(void);\r
+bookmark_list_h _favorites_get_bookmark_list_at_folder(int folderId);\r
+bookmark_list_h _favorites_bookmark_get_folder_list(void);\r
+int _favorites_get_unixtime_from_datetime(char *datetime);\r
+int _favorites_bookmark_get_bookmark_id(const char *url, const char *title, const int folder_id);\r
+\r
+/* history internal API */\r
+void _favorites_history_db_close(void);\r
+void _favorites_history_db_finalize(sqlite3_stmt *stmt);\r
+int _favorites_history_db_open(void);\r
+int _favorites_free_history_entry(favorites_history_entry_s *entry);\r
+\r
+#ifdef __cplusplus\r
+};\r
+#endif\r
+\r
+#endif /* __TIZEN_WEB_FAVORITES_PRIVATE_H__ */\r
diff --git a/packaging/capi-web-favorites.spec b/packaging/capi-web-favorites.spec
new file mode 100755 (executable)
index 0000000..e569467
--- /dev/null
@@ -0,0 +1,54 @@
+Name:       capi-web-favorites
+Summary:    Internet bookmark and history API
+Version:    0.0.3
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    TO BE FILLED IN
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig  
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary:  Internet Bookmark and History in Tizen Native API (Development)
+Group:    TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%{_libdir}/libcapi-web-favorites.so
+
+%files devel
+%{_includedir}/web/*.h
+%{_libdir}/pkgconfig/*.pc
+
+
diff --git a/packaging/capi-web-favorites.spec~ b/packaging/capi-web-favorites.spec~
new file mode 100755 (executable)
index 0000000..904f6fa
--- /dev/null
@@ -0,0 +1,54 @@
+Name:       capi-web-favorites
+Summary:    Internet bookmark and history API
+Version:    0.0.1
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    TO BE FILLED IN
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig  
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary:  Internet Bookmark and History in Tizen Native API (Development)
+Group:    TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%{_libdir}/libcapi-web-favorites.so
+
+%files devel
+%{_includedir}/web/*.h
+%{_libdir}/pkgconfig/*.pc
+
+
diff --git a/src/favorites_bookmark.c b/src/favorites_bookmark.c
new file mode 100644 (file)
index 0000000..85f1927
--- /dev/null
@@ -0,0 +1,1149 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License. \r
+ */\r
+\r
+#include <string.h>\r
+#include <dlog.h>\r
+#include <db-util.h>\r
+#include <favorites.h>\r
+#include <favorites_private.h>\r
+\r
+__thread sqlite3 *gl_internet_bookmark_db = 0;\r
+\r
+/* Private Functions */\r
+void _favorites_close_bookmark_db(void)\r
+{\r
+       if (gl_internet_bookmark_db) {\r
+               /* ASSERT(currentThread() == m_openingThread); */\r
+               db_util_close(gl_internet_bookmark_db);\r
+               gl_internet_bookmark_db = 0;\r
+       }\r
+}\r
+\r
+void _favorites_finalize_bookmark_db(sqlite3_stmt *stmt)\r
+{\r
+       if (sqlite3_finalize(stmt) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_finalize is failed");\r
+       }\r
+       _favorites_close_bookmark_db();\r
+}\r
+const char *_favorites_get_bookmark_db_name(void)\r
+{\r
+       return "/opt/dbspace/.internet_bookmark.db";\r
+}\r
+int _favorites_open_bookmark_db(void)\r
+{\r
+       _favorites_close_bookmark_db();\r
+       if (db_util_open\r
+           (_favorites_get_bookmark_db_name(), &gl_internet_bookmark_db,\r
+            DB_UTIL_REGISTER_HOOK_METHOD) != SQLITE_OK) {\r
+               db_util_close(gl_internet_bookmark_db);\r
+               gl_internet_bookmark_db = 0;\r
+               return -1;\r
+       }\r
+       return gl_internet_bookmark_db ? 0 : -1;\r
+}\r
+\r
+void _favorites_free_bookmark_list(bookmark_list_h m_list)\r
+{\r
+       FAVORITES_LOGE(" ");\r
+\r
+       int i = 0;\r
+       if (m_list == NULL)\r
+               return;\r
+\r
+       if (m_list->item != NULL) {\r
+               for (i = 0; i < m_list->count; i++) {\r
+                       if (m_list->item[i].address != NULL)\r
+                               free(m_list->item[i].address);\r
+                       if (m_list->item[i].title != NULL)\r
+                               free(m_list->item[i].title);\r
+                       if (m_list->item[i].creationdate != NULL)\r
+                               free(m_list->item[i].creationdate);\r
+                       if (m_list->item[i].updatedate != NULL)\r
+                               free(m_list->item[i].updatedate);\r
+               }\r
+               free(m_list->item);\r
+       }\r
+       free(m_list);\r
+       m_list = NULL;\r
+}\r
+\r
+int _favorites_free_bookmark_entry(favorites_bookmark_entry_s *entry)\r
+{\r
+       FAVORITES_NULL_ARG_CHECK(entry);\r
+\r
+       if (entry->address != NULL)\r
+               free(entry->address);\r
+       if (entry->title != NULL)\r
+               free(entry->title);\r
+       if (entry->creation_date != NULL)\r
+               free(entry->creation_date);\r
+       if (entry->update_date != NULL)\r
+               free(entry->update_date);\r
+\r
+       return FAVORITES_ERROR_NONE;\r
+}\r
+\r
+/* search last of sequence(order's index) */\r
+int _favorites_get_bookmark_lastindex(int locationId)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       nError =\r
+           sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              "select sequence from bookmarks where parent=? order by sequence desc",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+       if (sqlite3_bind_int(stmt, 1, locationId) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_bind_int is failed");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       if ((nError = sqlite3_step(stmt)) == SQLITE_ROW) {\r
+               int index = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return index;\r
+       }\r
+       FAVORITES_LOGE("Not found items in This Folder");\r
+       _favorites_close_bookmark_db();\r
+       return 0;\r
+}\r
+\r
+int _favorites_bookmark_get_folderID(const char *foldername)\r
+{\r
+       FAVORITES_LOGE("foldername: %s", foldername);\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+\r
+       /* If there is no identical folder name, create new folder */\r
+       if (_favorites_bookmark_is_folder_exist(foldername)==0){\r
+               if(_favorites_bookmark_create_folder(foldername)!=1){\r
+                       FAVORITES_LOGE("folder creating is failed.");\r
+                       return -1;\r
+               }\r
+       }\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       sprintf(query, "select id from bookmarks where type=1 AND title='%s'"\r
+                       , foldername);\r
+\r
+       /* check foldername in the bookmark table */\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,query\r
+                               ,-1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               int folderId = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return folderId;\r
+       }\r
+       _favorites_close_bookmark_db();\r
+       return 1;\r
+}\r
+\r
+int _favorites_bookmark_is_folder_exist(const char *foldername)\r
+{\r
+       FAVORITES_LOGE("\n");\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+\r
+       if (!foldername || (strlen(foldername) <= 0)) {\r
+               FAVORITES_LOGE("foldername is empty\n");\r
+               return -1;\r
+       }\r
+       FAVORITES_LOGE("foldername: %s", foldername);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       sprintf(query, "select id from bookmarks where type=1 AND title='%s'"\r
+                       , foldername);\r
+\r
+       /* check foldername in the bookmark table */\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,query\r
+                              ,-1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               /* The given foldername is exist on the bookmark table */\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return 1;\r
+       }\r
+       _favorites_close_bookmark_db();\r
+       return 0;\r
+}\r
+\r
+int _favorites_bookmark_create_folder(const char *foldername)\r
+{\r
+       FAVORITES_LOGE("\n");\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+       int lastIndex = 0;\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+\r
+       if (!foldername || (strlen(foldername) <= 0)) {\r
+               FAVORITES_LOGE("foldername is empty\n");\r
+               return -1;\r
+       }\r
+\r
+       if ((lastIndex = _favorites_get_bookmark_lastindex(1)) < 0) {\r
+               FAVORITES_LOGE("Database::getLastIndex() is failed.\n");\r
+               return -1;\r
+       }\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       sprintf(query, "insert into bookmarks \\r
+               (type, parent, title, creationdate, sequence, updatedate, editable)\\r
+               values (1, 1, '%s', DATETIME('now'), %d, DATETIME('now'), 1)"\r
+               , foldername, lastIndex);\r
+\r
+       FAVORITES_LOGE("query:%s\n", query);\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                               query, -1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n",\r
+                       sqlite3_errmsg(gl_internet_bookmark_db));\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+       \r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return 1;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_close_bookmark_db();\r
+       return 0;\r
+}\r
+\r
+int _favorites_bookmark_is_bookmark_exist\r
+       (const char *url, const char *title, const int folderId)\r
+{\r
+       FAVORITES_LOGE("folderId: %d", folderId);\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+               \r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       sprintf(query, "select id from bookmarks where \\r
+                       type=0 AND address='%s' AND title='%s' AND parent=%d"\r
+                       , url, title, folderId);\r
+       FAVORITES_LOGE("query: %s", query);\r
+\r
+       /* check bookmark in the bookmark table */\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,query\r
+                              ,-1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               /* There is same bookmark exist. */\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return 1;\r
+       }\r
+\r
+       FAVORITES_LOGE("there is no identical bookmark\n");\r
+       _favorites_close_bookmark_db();\r
+       /* there is no identical bookmark*/\r
+       return 0;\r
+}\r
+\r
+int _favorites_get_bookmark_count_at_folder(int folderId)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       FAVORITES_LOGE("");\r
+       \r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       /*bookmark */\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              "select count(*) from bookmarks where parent=? and type=0",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       if (sqlite3_bind_int(stmt, 1, folderId) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_bind_int is failed");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               int count = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               FAVORITES_LOGE("count: %d", count);\r
+               return count;\r
+       }\r
+       _favorites_close_bookmark_db();\r
+       FAVORITES_LOGE("End");\r
+       return 0;\r
+}\r
+\r
+int _favorites_bookmark_get_folder_count(void)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       FAVORITES_LOGE("");\r
+       \r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       /* folder + bookmark */\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              "select count(*) from bookmarks where type=1 and parent != 0",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               int count = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return count;\r
+       }\r
+       _favorites_close_bookmark_db();\r
+       return 0;\r
+}\r
+\r
+bookmark_list_h _favorites_get_bookmark_list_at_folder(int folderId)\r
+{\r
+       bookmark_list_h m_list = NULL;\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       FAVORITES_LOGE("folderId: %d", folderId);\r
+       if(folderId<=0){\r
+               FAVORITES_LOGE("folderId is wrong");\r
+               return NULL;\r
+       }\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+\r
+       /* check the total count of items */\r
+       int item_count = 0;\r
+       item_count = _favorites_get_bookmark_count_at_folder(folderId);\r
+\r
+       if (item_count <= 0)\r
+               return NULL;\r
+\r
+       /* Get bookmarks list only under given folder */\r
+       sprintf(query, "select id, type, parent, address, title, editable,\\r
+                              creationdate, updatedate, sequence \\r
+                              from bookmarks where type=0 and parent =%d order by sequence"\r
+                       , folderId);\r
+       FAVORITES_LOGE("query: %s", query);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return NULL;\r
+       }\r
+       \r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              query, -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE ("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return NULL;\r
+       }\r
+\r
+       /*  allocation .... Array for Items */\r
+       m_list = (bookmark_list_h) calloc(1, sizeof(bookmark_list_s));\r
+       m_list->item =\r
+           (bookmark_entry_internal_h) calloc(item_count, sizeof(bookmark_entry_internal_s));\r
+       m_list->count = item_count;\r
+       int i = 0;\r
+       while ((nError = sqlite3_step(stmt)) == SQLITE_ROW \r
+               && (i < item_count)) {\r
+               m_list->item[i].id = sqlite3_column_int(stmt, 0);\r
+               m_list->item[i].is_folder = sqlite3_column_int(stmt, 1);\r
+               m_list->item[i].folder_id = sqlite3_column_int(stmt, 2);\r
+\r
+               if (!m_list->item[i].is_folder) {\r
+                       const char *url =\r
+                           (const char *)(sqlite3_column_text(stmt, 3));\r
+                       m_list->item[i].address = NULL;\r
+                       if (url) {\r
+                               int length = strlen(url);\r
+                               if (length > 0) {\r
+                                       m_list->item[i].address =\r
+                                           (char *)calloc(length + 1,\r
+                                                          sizeof(char));\r
+                                       memcpy(m_list->item[i].address, url,\r
+                                              length);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               const char *title =\r
+                   (const char *)(sqlite3_column_text(stmt, 4));\r
+               m_list->item[i].title = NULL;\r
+               if (title) {\r
+                       int length = strlen(title);\r
+                       if (length > 0) {\r
+                               m_list->item[i].title =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(m_list->item[i].title, title, length);\r
+                       }\r
+                       FAVORITES_LOGE("Bookmark Title:%s\n", m_list->item[i].title);\r
+               }\r
+               m_list->item[i].editable = sqlite3_column_int(stmt, 5);\r
+\r
+               const char *creationdate =\r
+                   (const char *)(sqlite3_column_text(stmt, 6));\r
+               m_list->item[i].creationdate = NULL;\r
+               if (creationdate) {\r
+                       int length = strlen(creationdate);\r
+                       if (length > 0) {\r
+                               m_list->item[i].creationdate =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(m_list->item[i].creationdate,\r
+                                      creationdate, length);\r
+                       }\r
+               }\r
+               const char *updatedate =\r
+                   (const char *)(sqlite3_column_text(stmt, 7));\r
+               m_list->item[i].updatedate = NULL;\r
+               if (updatedate) {\r
+                       int length = strlen(updatedate);\r
+                       if (length > 0) {\r
+                               m_list->item[i].updatedate =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(m_list->item[i].updatedate, updatedate,\r
+                                      length);\r
+                       }\r
+               }\r
+\r
+               m_list->item[i].orderIndex = sqlite3_column_int(stmt, 8);\r
+               i++;\r
+       }\r
+       m_list->count = i;\r
+\r
+       if (i <= 0) {\r
+               FAVORITES_LOGE("sqlite3_step is failed");\r
+               _favorites_close_bookmark_db();\r
+               _favorites_free_bookmark_list(m_list);\r
+               return NULL;\r
+       }\r
+       _favorites_finalize_bookmark_db(stmt);\r
+       return m_list;\r
+}\r
+\r
+bookmark_list_h _favorites_bookmark_get_folder_list(void)\r
+{\r
+       bookmark_list_h m_list = NULL;\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       FAVORITES_LOGE("");\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+\r
+       /* check the total count of items */\r
+       int item_count = 0;\r
+       item_count = _favorites_bookmark_get_folder_count();\r
+\r
+       if (item_count <= 0)\r
+               return NULL;\r
+\r
+       /* Get bookmarks list only under given folder */\r
+       sprintf(query, "select id, type, parent, address, title, editable,\\r
+                              creationdate, updatedate, sequence \\r
+                              from bookmarks where type=1 and parent != 0 order by sequence");\r
+       FAVORITES_LOGE("query: %s", query);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return NULL;\r
+       }\r
+       \r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              query, -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE ("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return NULL;\r
+       }\r
+\r
+       /*  allocation .... Array for Items */\r
+       m_list = (bookmark_list_h) calloc(1, sizeof(bookmark_list_s));\r
+       m_list->item =\r
+           (bookmark_entry_internal_h) calloc(item_count, sizeof(bookmark_entry_internal_s));\r
+       m_list->count = item_count;\r
+       int i = 0;\r
+       while ((nError = sqlite3_step(stmt)) == SQLITE_ROW \r
+               && (i < item_count)) {\r
+               m_list->item[i].id = sqlite3_column_int(stmt, 0);\r
+               m_list->item[i].is_folder = sqlite3_column_int(stmt, 1);\r
+               m_list->item[i].folder_id = sqlite3_column_int(stmt, 2);\r
+\r
+               if (!m_list->item[i].is_folder) {\r
+                       const char *url =\r
+                           (const char *)(sqlite3_column_text(stmt, 3));\r
+                       m_list->item[i].address = NULL;\r
+                       if (url) {\r
+                               int length = strlen(url);\r
+                               if (length > 0) {\r
+                                       m_list->item[i].address =\r
+                                           (char *)calloc(length + 1,\r
+                                                          sizeof(char));\r
+                                       memcpy(m_list->item[i].address, url,\r
+                                              length);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               const char *title =\r
+                   (const char *)(sqlite3_column_text(stmt, 4));\r
+               m_list->item[i].title = NULL;\r
+               if (title) {\r
+                       int length = strlen(title);\r
+                       if (length > 0) {\r
+                               m_list->item[i].title =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(m_list->item[i].title, title, length);\r
+                       }\r
+                       FAVORITES_LOGE("Bookmark Title:%s\n", m_list->item[i].title);\r
+               }\r
+               m_list->item[i].editable = sqlite3_column_int(stmt, 5);\r
+\r
+               const char *creationdate =\r
+                   (const char *)(sqlite3_column_text(stmt, 6));\r
+               m_list->item[i].creationdate = NULL;\r
+               if (creationdate) {\r
+                       int length = strlen(creationdate);\r
+                       if (length > 0) {\r
+                               m_list->item[i].creationdate =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(m_list->item[i].creationdate,\r
+                                      creationdate, length);\r
+                       }\r
+               }\r
+               const char *updatedate =\r
+                   (const char *)(sqlite3_column_text(stmt, 7));\r
+               m_list->item[i].updatedate = NULL;\r
+               if (updatedate) {\r
+                       int length = strlen(updatedate);\r
+                       if (length > 0) {\r
+                               m_list->item[i].updatedate =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(m_list->item[i].updatedate, updatedate,\r
+                                      length);\r
+                       }\r
+               }\r
+\r
+               m_list->item[i].orderIndex = sqlite3_column_int(stmt, 8);\r
+               i++;\r
+       }\r
+       m_list->count = i;\r
+\r
+       if (i <= 0) {\r
+               FAVORITES_LOGE("sqlite3_step is failed");\r
+               _favorites_close_bookmark_db();\r
+               _favorites_free_bookmark_list(m_list);\r
+               return NULL;\r
+       }\r
+       _favorites_finalize_bookmark_db(stmt);\r
+       return m_list;\r
+}\r
+\r
+int _favorites_get_unixtime_from_datetime(char *datetime)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if(datetime == NULL ) {\r
+               FAVORITES_LOGE("datetime is NULL\n");\r
+               return -1;\r
+       }\r
+\r
+       FAVORITES_LOGE("datetime: %s\n", datetime);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              "SELECT strftime('%s', ?)",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       if (sqlite3_bind_text(stmt, 1, datetime, -1, NULL) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_bind_text is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               int unixtime = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return unixtime;\r
+       }\r
+       _favorites_close_bookmark_db();\r
+       return 1;\r
+}\r
+\r
+/* search last of sequence(order's index) */\r
+int _favorites_bookmark_get_bookmark_id(const char *url, const char *title, const int folder_id)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       /* Get the id of bookmark */\r
+       sprintf(query, "select id from bookmarks where \\r
+                       type=0 AND address='%s' AND title='%s' AND parent=%d"\r
+                       , url, title, folder_id);\r
+       FAVORITES_LOGE("query: %s", query);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return -1;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                               query, -1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return -1;\r
+       }\r
+\r
+       if ((nError = sqlite3_step(stmt)) == SQLITE_ROW) {\r
+               int bookmark_id = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return bookmark_id;\r
+       }\r
+       FAVORITES_LOGE("No match with given url");\r
+       _favorites_close_bookmark_db();\r
+       return 0;\r
+}\r
+\r
+/*************************************************************\r
+ *     APIs for Internet favorites\r
+ *************************************************************/\r
+int favorites_bookmark_add_bookmark(const char *url, const char *title, const char *foldername, int *bookmark_id)\r
+{\r
+       FAVORITES_LOGE("");\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       int folderId = 1;\r
+       char    query[1024];\r
+       int lastIndex = 0;\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+       if (!url || (strlen(url) <= 0)) {\r
+               FAVORITES_LOGE("url is empty\n");\r
+               return FAVORITES_ERROR_INVALID_PARAMETER;\r
+       }\r
+\r
+       if (!title || (strlen(title) <= 0)) {\r
+               FAVORITES_LOGE("title is empty\n");\r
+               return FAVORITES_ERROR_INVALID_PARAMETER;\r
+       }\r
+\r
+       /* check the foldername is exist and get a folderid */\r
+       if (!foldername || (strlen(foldername) <= 0)) {\r
+               FAVORITES_LOGE("foldername is empty. id is now root.\n");\r
+               folderId = 1;\r
+       }else if (!strcmp("Bookmarks", foldername)){\r
+               /*root folder name is "Bookmarks".*/\r
+               folderId = 1;\r
+       } else {\r
+               folderId = _favorites_bookmark_get_folderID(foldername);\r
+               if(folderId<0){\r
+                       return FAVORITES_ERROR_DB_FAILED;\r
+               }\r
+       }\r
+\r
+       /* Check the bookmarks is already exist*/\r
+       if(_favorites_bookmark_is_bookmark_exist(url, title, folderId)!=0){\r
+               FAVORITES_LOGE("The bookmark is already exist.\n");\r
+               return FAVORITES_ERROR_ITEM_ALREADY_EXIST;\r
+       }\r
+\r
+       /* get a last index for order of bookmark items */\r
+       if ((lastIndex = _favorites_get_bookmark_lastindex(folderId)) < 0) {\r
+               FAVORITES_LOGE("Database::getLastIndex() is failed.\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       /* Creating SQL query sentence. */\r
+       sprintf(query, "insert into bookmarks\\r
+                       (type, parent, address, title, creationdate, editable, sequence, accesscount)\\r
+                       values(0, %d, '%s', '%s',  DATETIME('now'), 1, %d, 0);"\r
+                       , folderId, url, title, lastIndex);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                               query, -1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       \r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               if (bookmark_id != NULL) {\r
+                       *bookmark_id = _favorites_bookmark_get_bookmark_id(url, title, folderId);\r
+               }\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_close_bookmark_db();\r
+\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
+int favorites_bookmark_get_count(int *count)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       FAVORITES_NULL_ARG_CHECK(count);\r
+       \r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       /* folder + bookmark */\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              "select count(*) from bookmarks where parent != 0",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               *count = sqlite3_column_int(stmt, 0);\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       _favorites_close_bookmark_db();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
+int favorites_bookmark_foreach(favorites_bookmark_foreach_cb callback,void *user_data)\r
+{\r
+       FAVORITES_NULL_ARG_CHECK(callback);\r
+       int nError;\r
+       int func_ret = 0;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                              "select id, type, parent, address, title, editable,\\r
+                              creationdate, updatedate, sequence \\r
+                              from bookmarks where parent != 0 order by sequence",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE ("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       while ((nError = sqlite3_step(stmt)) == SQLITE_ROW) {\r
+               favorites_bookmark_entry_s result;\r
+               memset(&result, 0x00, sizeof(favorites_bookmark_entry_s));\r
+               result.id = sqlite3_column_int(stmt, 0);\r
+               result.is_folder = sqlite3_column_int(stmt, 1);\r
+               result.folder_id = sqlite3_column_int(stmt, 2);\r
+\r
+               result.address = NULL;\r
+               if (!result.is_folder) {\r
+                       const char *url = (const char *)(sqlite3_column_text(stmt, 3));\r
+                       if (url) {\r
+                               int length = strlen(url);\r
+                               if (length > 0) {\r
+                                       result.address = (char *)calloc(length + 1, sizeof(char));\r
+                                       memcpy(result.address, url, length);\r
+                                       FAVORITES_LOGE ("url:%s\n", url);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               const char *title = (const char *)(sqlite3_column_text(stmt, 4));\r
+               result.title = NULL;\r
+               if (title) {\r
+                       int length = strlen(title);\r
+                       if (length > 0) {\r
+                               result.title = (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(result.title, title, length);\r
+                       }\r
+               }\r
+               result.editable = sqlite3_column_int(stmt, 5);\r
+\r
+               const char *creation_date = (const char *)(sqlite3_column_text(stmt, 6));\r
+               result.creation_date = NULL;\r
+               if (creation_date) {\r
+                       int length = strlen(creation_date);\r
+                       if (length > 0) {\r
+                               result.creation_date = (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(result.creation_date, creation_date, length);\r
+                       }\r
+               }\r
+               const char *update_date = (const char *)(sqlite3_column_text(stmt, 7));\r
+               result.update_date = NULL;\r
+               if (update_date) {\r
+                       int length = strlen(update_date);\r
+                       if (length > 0) {\r
+                               result.update_date = (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(result.update_date, update_date, length);\r
+                       }\r
+               }\r
+\r
+               result.order_index = sqlite3_column_int(stmt, 8);\r
+\r
+               func_ret = callback(&result, user_data);\r
+               _favorites_free_bookmark_entry(&result);\r
+               if(func_ret == 0) \r
+                       break;\r
+       }\r
+\r
+       FAVORITES_LOGE ("There are no more bookmarks.\n");\r
+       _favorites_finalize_bookmark_db(stmt);\r
+       return FAVORITES_ERROR_NONE;\r
+}\r
+\r
+int favorites_bookmark_export_list(const char * file_path)\r
+{\r
+       FAVORITES_NULL_ARG_CHECK(file_path);\r
+       FILE *fp = NULL;\r
+       bookmark_list_h folders_list = NULL;\r
+       bookmark_list_h bookmarks_list = NULL;\r
+\r
+       /* Get list of all bookmarks */\r
+       folders_list = _favorites_bookmark_get_folder_list();\r
+       if(folders_list == NULL ) {\r
+               FAVORITES_LOGE("There is no folders even root folder");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       fp = fopen( file_path, "w");\r
+       if(fp == NULL) {\r
+               FAVORITES_LOGE("file opening is failed.");\r
+               return FAVORITES_ERROR_INVALID_PARAMETER;\r
+       }\r
+       fputs("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", fp);\r
+       fputs("<!-- This is an automatically generated file.\n", fp);\r
+       fputs("It will be read and overwritten.\n", fp);\r
+       fputs("Do Not Edit! -->\n", fp);\r
+       fputs("<META HTTP-EQUIV=\"Content-Type\" ", fp);\r
+       fputs("CONTENT=\"text/html; charset=UTF-8\">\n", fp);\r
+       fputs("<TITLE>Bookmarks</TITLE>\n", fp);\r
+       fputs("<H1>Bookmarks</H1>\n", fp);\r
+       fputs("<DL><p>\n", fp);\r
+       /*Set subfolders and its bookmark items */\r
+       int i = 0;\r
+       int folder_adddate_unixtime = 0;\r
+       int k=0;\r
+       int bookmark_adddate_unixtime = 0;\r
+       int bookmark_updatedate_unixtime = 0;\r
+       for(i=0; i < (folders_list->count); i++) {\r
+               folder_adddate_unixtime =\r
+                       _favorites_get_unixtime_from_datetime(\r
+                               folders_list->item[i].creationdate);\r
+               FAVORITES_LOGE("TITLE: %s", folders_list->item[i].title);\r
+\r
+               fprintf(fp, "\t<DT><H3 FOLDED ADD_DATE=\"%d\">%s</H3>\n", \r
+                               folder_adddate_unixtime, folders_list->item[i].title);\r
+               fputs("\t<DL><p>\n", fp);\r
+               /* Get bookmarks under this folder and put the list into the file*/\r
+               _favorites_free_bookmark_list(bookmarks_list);\r
+               bookmarks_list = NULL;\r
+               bookmarks_list = _favorites_get_bookmark_list_at_folder(\r
+                                               folders_list->item[i].id);\r
+               if(bookmarks_list!= NULL){\r
+                       for(k=0;k<(bookmarks_list->count); k++){\r
+                               bookmark_adddate_unixtime =\r
+                                       _favorites_get_unixtime_from_datetime(\r
+                                       bookmarks_list->item[k].creationdate);\r
+\r
+                               if(bookmark_adddate_unixtime<0)\r
+                                       bookmark_adddate_unixtime=0;\r
+\r
+                               bookmark_updatedate_unixtime =\r
+                                       _favorites_get_unixtime_from_datetime(\r
+                                       bookmarks_list->item[k].updatedate);\r
+\r
+                               if(bookmark_updatedate_unixtime<0)\r
+                                       bookmark_updatedate_unixtime=0;\r
+\r
+                               fprintf(fp,"\t\t<DT><A HREF=\"%s\" ", \r
+                                               bookmarks_list->item[k].address);\r
+                               fprintf(fp,"ADD_DATE=\"%d\" ",\r
+                                               bookmark_adddate_unixtime);\r
+                               fprintf(fp,"LAST_VISIT=\"%d\" ",\r
+                                               bookmark_updatedate_unixtime);\r
+                               fprintf(fp,"LAST_MODIFIED=\"%d\">",\r
+                                               bookmark_updatedate_unixtime);\r
+                               fprintf(fp,"%s</A>\n", bookmarks_list->item[k].title );\r
+                       }\r
+               }\r
+               fputs("\t</DL><p>\n", fp);\r
+       }\r
+\r
+       /*Set root folder's bookmark items */\r
+       _favorites_free_bookmark_list(bookmarks_list);\r
+       bookmarks_list = NULL;\r
+       bookmarks_list = _favorites_get_bookmark_list_at_folder(1);\r
+       if(bookmarks_list!= NULL){\r
+               for(k=0;k<(bookmarks_list->count); k++){\r
+                       bookmark_adddate_unixtime =\r
+                               _favorites_get_unixtime_from_datetime(\r
+                               bookmarks_list->item[k].creationdate);\r
+\r
+                       if(bookmark_adddate_unixtime<0)\r
+                               bookmark_adddate_unixtime=0;\r
+\r
+                       bookmark_updatedate_unixtime =\r
+                               _favorites_get_unixtime_from_datetime(\r
+                               bookmarks_list->item[k].updatedate);\r
+\r
+                       if(bookmark_updatedate_unixtime<0)\r
+                               bookmark_updatedate_unixtime=0;\r
+\r
+                       fprintf(fp,"\t<DT><A HREF=\"%s\" ", \r
+                                       bookmarks_list->item[k].address);\r
+                       fprintf(fp,"ADD_DATE=\"%d\" ",\r
+                                       bookmark_adddate_unixtime);\r
+                       fprintf(fp,"LAST_VISIT=\"%d\" ",\r
+                                       bookmark_updatedate_unixtime);\r
+                       fprintf(fp,"LAST_MODIFIED=\"%d\">",\r
+                                       bookmark_updatedate_unixtime);\r
+                       fprintf(fp,"%s</A>\n", bookmarks_list->item[k].title );\r
+               }\r
+       }\r
+       fputs("</DL><p>\n", fp);\r
+       fclose(fp);\r
+\r
+       return FAVORITES_ERROR_NONE;\r
+}\r
+\r
+int favorites_bookmark_get_favicon(int id, Evas *evas, Evas_Object **icon)\r
+{\r
+       FAVORITES_INVALID_ARG_CHECK(id<0);\r
+       FAVORITES_NULL_ARG_CHECK(evas);\r
+       FAVORITES_NULL_ARG_CHECK(icon);\r
+\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+       void *favicon_data_temp=NULL;\r
+       favicon_entry_h favicon;\r
+       int nError;\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+       sprintf(query, "select favicon, favicon_length, favicon_w, favicon_h from bookmarks\\r
+                       where id=%d"\r
+                       , id);\r
+       FAVORITES_LOGE("query: %s", query);\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                       query, -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed(%s).\n",\r
+                       sqlite3_errmsg(gl_internet_bookmark_db));\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               favicon = (favicon_entry_h) calloc(1, sizeof(favicon_entry_s));\r
+               /* loading favicon from bookmark db */\r
+               favicon_data_temp = (void *)sqlite3_column_blob(stmt,0);\r
+               favicon->length = sqlite3_column_int(stmt,1);\r
+               favicon->w = sqlite3_column_int(stmt,2);\r
+               favicon->h = sqlite3_column_int(stmt,3);\r
+\r
+               if (favicon->length > 0){\r
+                       favicon->data = calloc(1, favicon->length);\r
+                       memcpy(favicon->data, favicon_data_temp, favicon->length);\r
+                       /* transforming to evas object */\r
+                       *icon = evas_object_image_filled_add(evas);\r
+                       evas_object_image_colorspace_set(*icon,\r
+                                                       EVAS_COLORSPACE_ARGB8888);\r
+                       evas_object_image_size_set(*icon, favicon->w, favicon->h);\r
+                       evas_object_image_fill_set(*icon, 0, 0, favicon->w,\r
+                                                                       favicon->h);\r
+                       evas_object_image_filled_set(*icon, EINA_TRUE);\r
+                       evas_object_image_alpha_set(*icon,EINA_TRUE);\r
+                       evas_object_image_data_set(*icon, favicon->data);\r
+               }\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+\r
+       _favorites_close_bookmark_db();\r
+       return FAVORITES_ERROR_NONE;\r
+}\r
+\r
+int favorites_bookmark_delete_bookmark(int id)\r
+{\r
+       FAVORITES_INVALID_ARG_CHECK(id<0);\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                               "delete from bookmarks where id=? and parent != 0", -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       // bind\r
+       if (sqlite3_bind_int(stmt, 1, id) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_bind_int is failed");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_close_bookmark_db();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
+int favorites_bookmark_delete_all_bookmarks(void)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (_favorites_open_bookmark_db() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_bookmark_db,\r
+                               "delete from bookmarks where parent !=0", -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_finalize_bookmark_db(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_close_bookmark_db();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
diff --git a/src/favorites_history.c b/src/favorites_history.c
new file mode 100644 (file)
index 0000000..de6ffa1
--- /dev/null
@@ -0,0 +1,320 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License. \r
+ */\r
+\r
+#include <string.h>\r
+#include <dlog.h>\r
+#include <db-util.h>\r
+#include <favorites.h>\r
+#include <favorites_private.h>\r
+\r
+__thread sqlite3 *gl_internet_history_db = 0;\r
+\r
+#define INTERNET_HISTORY_DB_NAME "/opt/dbspace/.browser-history.db"\r
+\r
+/* Private Functions */\r
+void _favorites_history_db_close(void)\r
+{\r
+       if (gl_internet_history_db) {\r
+               /* ASSERT(currentThread() == m_openingThread); */\r
+               db_util_close(gl_internet_history_db);\r
+               gl_internet_history_db = 0;\r
+       }\r
+}\r
+\r
+void _favorites_history_db_finalize(sqlite3_stmt *stmt)\r
+{\r
+       if (sqlite3_finalize(stmt) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_finalize is failed");\r
+       }\r
+       _favorites_history_db_close();\r
+}\r
+int _favorites_history_db_open(void)\r
+{\r
+       _favorites_history_db_close();\r
+       if (db_util_open\r
+           (INTERNET_HISTORY_DB_NAME, &gl_internet_history_db,\r
+            DB_UTIL_REGISTER_HOOK_METHOD) != SQLITE_OK) {\r
+               db_util_close(gl_internet_history_db);\r
+               gl_internet_history_db = 0;\r
+               return -1;\r
+       }\r
+       return gl_internet_history_db ? 0 : -1;\r
+}\r
+\r
+int _favorites_free_history_entry(favorites_history_entry_s *entry)\r
+{\r
+       FAVORITES_NULL_ARG_CHECK(entry);\r
+\r
+       if (entry->address != NULL)\r
+               free(entry->address);\r
+       if (entry->title != NULL)\r
+               free(entry->title);\r
+       if (entry->visit_date != NULL)\r
+               free(entry->visit_date);\r
+\r
+       return FAVORITES_ERROR_NONE;\r
+}\r
+/*************************************************************\r
+ *     APIs for Internet favorites\r
+ *************************************************************/\r
+int favorites_history_get_count(int *count)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       FAVORITES_LOGE("");\r
+               \r
+       if (_favorites_history_db_open() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       /* folder + bookmark */\r
+       nError = sqlite3_prepare_v2(gl_internet_history_db,\r
+                              "select count(*) from history",\r
+                              -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_ROW) {\r
+               *count = sqlite3_column_int(stmt, 0);\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       _favorites_history_db_close();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+/* Public CAPI */\r
+int favorites_history_foreach(favorites_history_foreach_cb callback,void *user_data)\r
+{\r
+       FAVORITES_NULL_ARG_CHECK(callback);\r
+       int nError;\r
+       int func_ret = 0;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (_favorites_history_db_open() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       nError = sqlite3_prepare_v2(gl_internet_history_db,\r
+                              "select id, address, title, counter, visitdate\\r
+                              from history order by visitdate desc",\r
+                              -1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE ("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       while ((nError = sqlite3_step(stmt)) == SQLITE_ROW) {\r
+               favorites_history_entry_s result;\r
+               result.id = sqlite3_column_int(stmt, 0);\r
+\r
+               result.address = NULL;\r
+               const char *url = (const char *)(sqlite3_column_text(stmt, 1));\r
+               if (url) {\r
+                       int length = strlen(url);\r
+                       if (length > 0) {\r
+                               result.address = (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(result.address, url, length);\r
+                               FAVORITES_LOGE ("url:%s\n", url);\r
+                       }\r
+               }\r
+\r
+               const char *title = (const char *)(sqlite3_column_text(stmt, 2));\r
+               result.title = NULL;\r
+               if (title) {\r
+                       int length = strlen(title);\r
+                       if (length > 0) {\r
+                               result.title = (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(result.title, title, length);\r
+                       }\r
+               }\r
+               result.count = sqlite3_column_int(stmt, 3);\r
+\r
+               const char *visit_date =\r
+                   (const char *)(sqlite3_column_text(stmt, 4));\r
+               result.visit_date = NULL;\r
+               if (visit_date) {\r
+                       int length = strlen(visit_date);\r
+                       if (length > 0) {\r
+                               result.visit_date =\r
+                                   (char *)calloc(length + 1, sizeof(char));\r
+                               memcpy(result.visit_date,\r
+                                      visit_date, length);\r
+                               FAVORITES_LOGE("Date:%s\n", result.visit_date);\r
+                       }\r
+               }\r
+\r
+               func_ret = callback(&result, user_data);\r
+               _favorites_free_history_entry(&result);\r
+               if(func_ret == 0) \r
+                       break;\r
+       }\r
+\r
+       _favorites_history_db_finalize(stmt);\r
+       return FAVORITES_ERROR_NONE;\r
+}\r
+\r
+int favorites_history_delete_history(int id)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       FAVORITES_INVALID_ARG_CHECK(id<0);\r
+\r
+       if (_favorites_history_db_open() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_history_db,\r
+                               "delete from history where id=?", -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       // bind\r
+       if (sqlite3_bind_int(stmt, 1, id) != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_bind_int is failed");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_history_db_close();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
+int favorites_history_delete_history_by_url(const char *url)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (!url || (strlen(url) <= 0)) {\r
+               FAVORITES_LOGE("url is empty\n");\r
+               return FAVORITES_ERROR_INVALID_PARAMETER;\r
+       }\r
+               \r
+       if (_favorites_history_db_open() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_history_db,\r
+                               "delete from history where address=?", -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       // bind\r
+       if (sqlite3_bind_text(stmt, 1, url, -1, NULL) != SQLITE_OK)\r
+               FAVORITES_LOGE("sqlite3_bind_text is failed.\n");\r
+       \r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_history_db_close();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
+int favorites_history_delete_all_histories(void)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+\r
+       if (_favorites_history_db_open() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_prepare_v2(gl_internet_history_db,\r
+                               "delete from history", -1, &stmt, NULL);\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_history_db_close();\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r
+int favorites_history_delete_history_by_term(const char *begin, const char *end)\r
+{\r
+       int nError;\r
+       sqlite3_stmt *stmt;\r
+       char    query[1024];\r
+\r
+       memset(&query, 0x00, sizeof(char)*1024);\r
+\r
+       if (!begin || (strlen(begin) <= 0)) {\r
+               FAVORITES_LOGE("begin date is empty\n");\r
+               return FAVORITES_ERROR_INVALID_PARAMETER;\r
+       }\r
+\r
+       if (!end || (strlen(end) <= 0)) {\r
+               FAVORITES_LOGE("end date is empty\n");\r
+               end = "now";\r
+       }\r
+\r
+       sprintf(query, "delete from history where visitdate\\r
+               between datetime('%s') and datetime('%s')", begin, end);\r
+               \r
+       if (_favorites_history_db_open() < 0) {\r
+               FAVORITES_LOGE("db_util_open is failed\n");\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+       nError = sqlite3_prepare_v2(gl_internet_history_db,\r
+                               query, -1, &stmt, NULL);\r
+\r
+       if (nError != SQLITE_OK) {\r
+               FAVORITES_LOGE("sqlite3_prepare_v2 is failed.\n");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_DB_FAILED;\r
+       }\r
+\r
+       nError = sqlite3_step(stmt);\r
+       if (nError == SQLITE_OK || nError == SQLITE_DONE) {\r
+               FAVORITES_LOGE("sqlite3_step is DONE");\r
+               _favorites_history_db_finalize(stmt);\r
+               return FAVORITES_ERROR_NONE;\r
+       }\r
+       FAVORITES_LOGE("sqlite3_step is failed");\r
+       _favorites_history_db_close();\r
+\r
+       return FAVORITES_ERROR_DB_FAILED;\r
+}\r
+\r