Extend C APIs for inserting and reading 'fast-open' attribute
authorYunchan Cho <yunchan.cho@samsung.com>
Fri, 26 Apr 2013 01:54:07 +0000 (10:54 +0900)
committerYunchan Cho <yunchan.cho@samsung.com>
Sat, 27 Apr 2013 15:29:20 +0000 (00:29 +0900)
[Issue#] N/A
[Problem] There is no C APIs that can be used for inserting value 'fast-open' to web-provider DB,
          and reading its value from the DB.
[Cause] 'fast-open' attribute of <tizen:pd> is newly added for support of fast opening PD by web-provider
[Solution] For this, existing API regarding insert to DB is extended and new API for reading the value is added

Change-Id: I9cadd7f35a1f6b1ee99613695c52a76a6ffd9182

data/web_provider_db.sql
src/API/web_provider_livebox_info.cpp
src/API/web_provider_livebox_info.h

index a304108..df1a0c5 100644 (file)
@@ -5,6 +5,7 @@ CREATE TABLE LiveboxInfo (
     box_type TEXT not null,
     auto_launch INT,
     mouse_event INT,
+    pd_fast_open INT,
     PRIMARY KEY (box_id) ,
 CHECK(1) );
 COMMIT;
index 25fbace..84a2549 100644 (file)
@@ -30,6 +30,7 @@ enum InfoTableField {
     BOX_TYPE,
     AUTO_LAUNCH,
     MOUSE_EVENT,
+    PD_FAST_OPEN,
 };
 
 // TODO this default type should be retrieved more automatically
@@ -164,12 +165,41 @@ int web_provider_livebox_get_mouse_event(const char* box_id)
     return mouseEvent;
 }
 
+int web_provider_livebox_get_pd_fast_open(const char* box_id)
+{
+    if (!box_id) {
+        return NULL;
+    }
+
+    std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
+    if (!handle->openDB()) {
+        return NULL;
+    }
+
+    std::string query = "select * from " + infoTable + " where box_id = ?";
+    if (!handle->setCommand(query, "s", box_id)) {
+        handle->closeDB();
+        return NULL;
+    }
+
+    if (!handle->executeCommand()) {
+        handle->closeDB();
+        return NULL;
+    }
+
+    int pdFastOpen = handle->getInt(InfoTableField::PD_FAST_OPEN);
+    handle->closeDB();
+
+    return pdFastOpen;
+}
+
 int web_provider_livebox_insert_box_info(
         const char* box_id, 
         const char* app_id, 
         const char* box_type,
         int auto_launch,
-        int mouse_event)
+        int mouse_event,
+        int pd_fast_open)
 {
     if (!box_id || !app_id || !box_type) {
         return -1;
@@ -182,11 +212,12 @@ int web_provider_livebox_insert_box_info(
 
     std::string query = 
         "insert into " + infoTable + 
-        " (box_id, app_id, box_type, auto_launch, mouse_event) values (?,?,?,?,?)";
+        " (box_id, app_id, box_type, auto_launch, mouse_event, pd_fast_open) \
+         values (?,?,?,?,?,?)";
 
     if (!handle->setCommand(
-                query, "sssii", 
-                box_id, app_id, box_type, auto_launch, mouse_event)) {
+                query, "sssiii",
+                box_id, app_id, box_type, auto_launch, mouse_event, pd_fast_open)) {
         handle->closeDB();
         return -1;
     }
@@ -205,7 +236,7 @@ int web_provider_livebox_insert_box_type(
         const char* app_id,
         const char* box_type)
 {
-    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0, 0);
 }
 
 int web_provider_livebox_delete_by_box_id(const char* box_id)
@@ -307,7 +338,7 @@ int web_provider_info_insert_box_type(
         const char* app_id,
         const char* box_type)
 {
-    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0, 0);
 }
 
 int web_provider_info_delete_by_box_id(const char* box_id)
index b7c03d0..8f55d21 100644 (file)
@@ -34,12 +34,14 @@ EXPORT_API const char* web_provider_livebox_get_box_type(const char* box_id);
 EXPORT_API const char* web_provider_livebox_get_app_id(const char* box_id);
 EXPORT_API int web_provider_livebox_get_auto_launch(const char* box_id);
 EXPORT_API int web_provider_livebox_get_mouse_event(const char* box_id);
+EXPORT_API int web_provider_livebox_get_pd_fast_open(const char* box_id);
 EXPORT_API int web_provider_livebox_insert_box_info(
         const char* box_id,
         const char* app_id,
         const char* box_type,
         int auto_launch, 
-        int mouse_event);
+        int mouse_event,
+        int pd_fast_open);
 DEPRECATED_API int web_provider_livebox_insert_box_type(
         const char* box_id,
         const char* app_id,