[Title] Initial upload the browser for tizen 2.0
[profile/ivi/org.tizen.browser.git] / src / database / browser-history-db.cpp
index d61ac60..6f672d0 100755 (executable)
@@ -1,18 +1,20 @@
 /*\r
-  * Copyright 2012  Samsung Electronics Co., Ltd\r
-  *\r
-  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license\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
+ * Copyright 2012  Samsung Electronics Co., Ltd\r
+ *\r
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license\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
+\r
 \r
 using namespace std;\r
 \r
@@ -480,3 +482,37 @@ Eina_Bool Browser_History_DB::clear_history(void)
        else\r
                return EINA_FALSE;\r
 }\r
+\r
+Eina_Bool Browser_History_DB::is_in_bookmark(const char* url, int *bookmark_id)\r
+{\r
+       int error = db_util_open(BROWSER_BOOKMARK_DB_PATH, &m_db_descriptor, DB_UTIL_REGISTER_HOOK_METHOD);\r
+       if (error != SQLITE_OK) {\r
+               db_util_close(m_db_descriptor);\r
+               m_db_descriptor = NULL;\r
+               return EINA_FALSE;\r
+       }\r
+\r
+       sqlite3_stmt *sqlite3_stmt = NULL;\r
+       error = sqlite3_prepare_v2(m_db_descriptor, "select id from bookmarks where address=?",\r
+                                                                       -1, &sqlite3_stmt, NULL);\r
+       if (error != SQLITE_OK) {\r
+               db_util_close(m_db_descriptor);\r
+               return EINA_FALSE;\r
+       }\r
+\r
+       if (sqlite3_bind_text(sqlite3_stmt, 1, url, -1, NULL) != SQLITE_OK)\r
+               BROWSER_LOGE("sqlite3_bind_text is failed.\n");\r
+\r
+       error = sqlite3_step(sqlite3_stmt);\r
+\r
+       if (bookmark_id)\r
+               *bookmark_id = sqlite3_column_int(sqlite3_stmt, 0);\r
+\r
+       if (sqlite3_finalize(sqlite3_stmt) != SQLITE_OK)\r
+               BROWSER_LOGE("sqlite3_finalize is failed.\n");\r
+\r
+       db_util_close(m_db_descriptor);\r
+\r
+       return (error == SQLITE_ROW);\r
+}\r
+\r