[Release] livebox.web-provider-1.4
[platform/framework/web/web-provider.git] / src / API / web_provider_livebox_info.cpp
index 04ceb06..cbc7687 100644 (file)
@@ -66,10 +66,73 @@ const char* web_provider_livebox_get_box_type(const char* box_id)
     return box_type_dup;
 }
 
-int web_provider_livebox_insert_box_type(
+const char* web_provider_livebox_get_app_id(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;
+    }
+
+    const char* app_id = handle->getText(1);
+    const char* app_id_dup = NULL;
+
+    if (app_id) {
+        app_id_dup = strdup(app_id);
+    }
+
+    handle->closeDB();
+
+    return app_id_dup;
+}
+
+int web_provider_livebox_get_auto_launch(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 autoLaunch  = handle->getInt(3);
+    handle->closeDB();
+
+    return autoLaunch;
+}
+
+int web_provider_livebox_insert_box_info(
         const char* box_id, 
         const char* app_id, 
-        const char* box_type)
+        const char* box_type,
+        int auto_launch)
 {
     if (!box_id || !app_id || !box_type) {
         return -1;
@@ -81,9 +144,10 @@ int web_provider_livebox_insert_box_type(
     }
 
     std::string query = 
-        "insert into " + infoTable + " (box_id, app_id, box_type) values (?,?,?)";
+        "insert into " + infoTable + 
+        " (box_id, app_id, box_type, auto_launch) values (?,?,?,?)";
 
-    if (!handle->setCommand(query, "sss", box_id, app_id, box_type)) {
+    if (!handle->setCommand(query, "sssi", box_id, app_id, box_type, auto_launch)) {
         handle->closeDB();
         return -1;
     }
@@ -97,6 +161,14 @@ int web_provider_livebox_insert_box_type(
     return 0;
 }
 
+int web_provider_livebox_insert_box_type(
+        const char* box_id,
+        const char* app_id,
+        const char* box_type)
+{
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0);
+}
+
 int web_provider_livebox_delete_by_box_id(const char* box_id)
 {
     if (!box_id) {
@@ -196,7 +268,7 @@ int web_provider_info_insert_box_type(
         const char* app_id,
         const char* box_type)
 {
-    return web_provider_livebox_insert_box_type(box_id, app_id, box_type);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0);
 }
 
 int web_provider_info_delete_by_box_id(const char* box_id)