[Release] livebox.web-provider-1.10 submit/tizen_2.1/20130422.092126
authorYunchan Cho <yunchan.cho@samsung.com>
Sat, 20 Apr 2013 05:25:47 +0000 (14:25 +0900)
committerYunchan Cho <yunchan.cho@samsung.com>
Mon, 22 Apr 2013 09:20:05 +0000 (18:20 +0900)
Change-Id: I8d8daaf39ba2bc5d0a450a4fc087586a4cafd78d

15 files changed:
data/web_provider_db.sql
packaging/livebox.web-provider.spec
src/API/web_provider_livebox_info.cpp
src/API/web_provider_livebox_info.h
src/API/web_provider_plugin_info.cpp
src/API/web_provider_plugin_info.h
src/Core/Box.cpp
src/Core/Box.h
src/Core/BoxData.h
src/Core/BoxManager.cpp
src/Core/BoxManager.h
src/Core/IBox.h
src/Daemon/BoxDaemonImpl.cpp
src/Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp
src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp

index 840db90..a304108 100644 (file)
@@ -4,6 +4,7 @@ CREATE TABLE LiveboxInfo (
     app_id TEXT not null,
     box_type TEXT not null,
     auto_launch INT,
+    mouse_event INT,
     PRIMARY KEY (box_id) ,
 CHECK(1) );
 COMMIT;
index 6548804..2311f94 100644 (file)
@@ -1,6 +1,6 @@
 Name: livebox.web-provider
 Summary: web framework for livebox 
-Version: 1.9
+Version: 1.10
 Release: 1
 Group: main/app
 License: Flora License, Version 1.0
index e418d8b..25fbace 100644 (file)
 
 static const std::string infoTable("LiveboxInfo");
 
+enum InfoTableField {
+    BOX_ID = 0,
+    APP_ID,
+    BOX_TYPE,
+    AUTO_LAUNCH,
+    MOUSE_EVENT,
+};
+
 // TODO this default type should be retrieved more automatically
 static const std::string defaultBoxType("app");
 
@@ -54,7 +62,7 @@ const char* web_provider_livebox_get_box_type(const char* box_id)
         return NULL;
     }
     
-    const char* box_type = handle->getText(2);
+    const char* box_type = handle->getText(InfoTableField::BOX_TYPE);
     const char* box_type_dup = NULL;
 
     if (box_type) {
@@ -88,7 +96,7 @@ const char* web_provider_livebox_get_app_id(const char* box_id)
         return NULL;
     }
 
-    const char* app_id = handle->getText(1);
+    const char* app_id = handle->getText(InfoTableField::APP_ID);
     const char* app_id_dup = NULL;
 
     if (app_id) {
@@ -122,17 +130,46 @@ int web_provider_livebox_get_auto_launch(const char* box_id)
         return NULL;
     }
 
-    int autoLaunch  = handle->getInt(3);
+    int autoLaunch  = handle->getInt(InfoTableField::AUTO_LAUNCH);
     handle->closeDB();
 
     return autoLaunch;
 }
 
+int web_provider_livebox_get_mouse_event(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 mouseEvent = handle->getInt(InfoTableField::MOUSE_EVENT);
+    handle->closeDB();
+
+    return mouseEvent;
+}
+
 int web_provider_livebox_insert_box_info(
         const char* box_id, 
         const char* app_id, 
         const char* box_type,
-        int auto_launch)
+        int auto_launch,
+        int mouse_event)
 {
     if (!box_id || !app_id || !box_type) {
         return -1;
@@ -145,9 +182,11 @@ int web_provider_livebox_insert_box_info(
 
     std::string query = 
         "insert into " + infoTable + 
-        " (box_id, app_id, box_type, auto_launch) values (?,?,?,?)";
+        " (box_id, app_id, box_type, auto_launch, mouse_event) values (?,?,?,?,?)";
 
-    if (!handle->setCommand(query, "sssi", box_id, app_id, box_type, auto_launch)) {
+    if (!handle->setCommand(
+                query, "sssii", 
+                box_id, app_id, box_type, auto_launch, mouse_event)) {
         handle->closeDB();
         return -1;
     }
@@ -166,7 +205,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);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
 }
 
 int web_provider_livebox_delete_by_box_id(const char* box_id)
@@ -268,7 +307,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);
+    return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
 }
 
 int web_provider_info_delete_by_box_id(const char* box_id)
index 12ccd27..b7c03d0 100644 (file)
@@ -33,11 +33,13 @@ EXPORT_API const char* web_provider_livebox_get_default_type();
 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_insert_box_info(
         const char* box_id,
         const char* app_id,
         const char* box_type,
-        int auto_launch);
+        int auto_launch, 
+        int mouse_event);
 DEPRECATED_API int web_provider_livebox_insert_box_type(
         const char* box_id,
         const char* app_id,
index 8453323..4d101b8 100644 (file)
 
 // static functions
 static web_provider_plugin_info* get_parsed_json_data(std::string& configPath);
+static bool web_provider_plugin_release_info(web_provider_plugin_info* info);
 
 static const std::string installedPluginDirPath("/usr/lib/web-provider/");
 
 // Json's content for plugin is the following (example)
 // {
 //      "type" : "clip",
-//      "path" : "/usr/lib/web-provider/libweb-provider-plugin-clipbox.so"
+//      "path" : "/usr/lib/web-provider/libweb-provider-plugin-clipbox.so",
 //      "service_boxid" : "org.tizen.browser"
 // }
 //
@@ -50,6 +51,11 @@ static const std::string installedPluginDirPath("/usr/lib/web-provider/");
 static const std::string jsonMemberType("type");
 static const std::string jsonMemberPath("path");
 static const std::string jsonMemberBoxId("service_boxid");
+static const std::string jsonMemberBoxScrollable("box_scrollable");
+
+static const std::string jsonValueBoolTrue("true");
+static const std::string jsonValueBoolFalse("false");
+static const std::string jsonFileExtension(".json");
 
 web_provider_plugin_info** web_provider_plugin_get_installed_list(int* count)
 {
@@ -136,21 +142,30 @@ void web_provider_plugin_release_installed_list(
     }
 
     for (int i = 0; i < count; i++) {
-        if (info_list[i]) {
-            if (info_list[i]->type) {
-                delete[] info_list[i]->type;
-            }
-            if (info_list[i]->path) {
-                delete[] info_list[i]->path;
-            }
-            if (info_list[i]->service_boxid) {
-                delete[] info_list[i]->service_boxid;
-            }
-        }
+        web_provider_plugin_release_info(info_list[i]);
+    }
+}
+
+int web_provider_plugin_get_box_scrollable(const char* plugin_type)
+{
+    if (!plugin_type) {
+        return -1;
     }
-    if (info_list) {
-        delete[] info_list;
+
+    std::string configPath;
+    configPath = installedPluginDirPath;
+    configPath += plugin_type;
+    configPath += jsonFileExtension;
+    web_provider_plugin_info* info = get_parsed_json_data(configPath);
+
+    if (!info) {
+        return -1;
     }
+    int ret = info->box_scrollable;
+    web_provider_plugin_release_info(info);
+
+    LogD("box_scrollable: %d", ret);
+    return ret;
 }
 
 static web_provider_plugin_info* get_parsed_json_data(std::string& configPath)
@@ -206,11 +221,25 @@ static web_provider_plugin_info* get_parsed_json_data(std::string& configPath)
         }
     }
 
+    gboolean hasBoxScrollable =
+        json_object_has_member(object, jsonMemberBoxScrollable.c_str());
+    if (hasBoxScrollable == TRUE) {
+        const char* boxScrollable =
+            static_cast<const char*>(
+                json_object_get_string_member(object, jsonMemberBoxScrollable.c_str()));
+        if (boxScrollable && (jsonValueBoolTrue == boxScrollable)) {
+            info->box_scrollable = 1;
+        } else {
+            info->box_scrollable = 0;
+        }
+    }
+
     LogD("type: %s", info->type);
     LogD("path: %s", info->path);
     if (info->service_boxid) {
         LogD("service_boxid: %s", info->service_boxid);
     }
+    LogD("box_scrollable: %d", info->box_scrollable);
 
     json_node_free(root);
     g_error_free(error);
@@ -218,3 +247,20 @@ static web_provider_plugin_info* get_parsed_json_data(std::string& configPath)
 
     return info; 
 }
+
+bool web_provider_plugin_release_info(web_provider_plugin_info* info)
+{
+    LogD("enter");
+    if (!info) {
+        LogD("empty struct");
+        return false;
+    }
+
+    // only members with buffer are released
+    delete info->type;
+    delete info->path;
+    delete info->service_boxid;
+    delete info;
+
+    return true;
+}
index 203b7ad..57d7a30 100644 (file)
@@ -30,6 +30,7 @@ struct _web_provider_plugin_info {
     const char* type;
     const char* path;
     const char* service_boxid;
+    int box_scrollable;
 };
 typedef _web_provider_plugin_info web_provider_plugin_info;
 
@@ -38,6 +39,7 @@ EXPORT_API web_provider_plugin_info** web_provider_plugin_get_installed_list(
 EXPORT_API void web_provider_plugin_release_installed_list(
                 web_provider_plugin_info** info_list, 
                 int count);
+EXPORT_API int web_provider_plugin_get_box_scrollable(const char* plugin_type);
 
 #ifdef __cplusplus
 }
index 927518e..4e71f58 100644 (file)
@@ -163,13 +163,15 @@ bool Box::pause()
     return true;
 }
 
-bool Box::openPd(int width, int height)
+bool Box::openPd(int width, int height, double x, double y)
 {
     LogD("enter");
     CHECK_BOX_STATE(m_state, permitOpenPd);
 
     m_boxInfo->pdWidth = width;
     m_boxInfo->pdHeight = height;
+    m_boxInfo->pdX = x;
+    m_boxInfo->pdY = y;
 
     try {
         m_updateTimer->stop();
@@ -232,7 +234,12 @@ bool Box::changePeriod(float period)
 
 RenderInfoPtr Box::makeRenderInfo(const std::string& renderType) const
 {
+    LogD("enter");
     RenderInfoPtr renderInfo(new RenderInfo);
+
+    // add width, height, operation type
+    renderInfo->defaultUrlParams = "?type=" + renderType;
+
     // set width, height
     if (renderType == renderTypeOpenPd) {
         renderInfo->width = m_boxInfo->pdWidth;
@@ -241,12 +248,26 @@ RenderInfoPtr Box::makeRenderInfo(const std::string& renderType) const
         renderInfo->width = m_boxInfo->boxWidth;
         renderInfo->height = m_boxInfo->boxHeight;
     }
-    // add width, height, operation type
-    renderInfo->defaultUrlParams = "?type=" + renderType; 
     char buff[32];
     sprintf(buff, "&width=%d&height=%d", renderInfo->width, renderInfo->height);
     renderInfo->defaultUrlParams += buff;
 
+    // if needed, set pd information
+    if (renderType == renderTypeOpenPd) {
+        renderInfo->defaultUrlParams += "&pdopen-direction=";
+        if (m_boxInfo->pdY == 0.0f) {
+            renderInfo->defaultUrlParams += "down";
+        } else {
+            renderInfo->defaultUrlParams += "up";
+        }
+
+        char buff[32];
+        sprintf(buff, "&pdopen-arrow-xpos=%d",
+                static_cast<int>((m_boxInfo->pdX) * (m_boxInfo->pdWidth)));
+        renderInfo->defaultUrlParams += buff;
+    }
+
+
     // add content info
     if (!m_boxInfo->contentInfo.empty()) {
         renderInfo->defaultUrlParams += "&" + m_boxInfo->contentInfo;
index f639ccf..cb08a8e 100644 (file)
@@ -47,7 +47,7 @@ class Box: public IBox, public IBoxContext {
         bool resize(int width, int height);
         bool resume();
         bool pause();
-        bool openPd(int width, int height);
+        bool openPd(int width, int height, double x, double y);
         bool closePd();
         bool update();
         bool changePeriod(float period);
index ef700ca..821430f 100644 (file)
@@ -32,6 +32,8 @@ struct BoxInfo
     int boxHeight;
     int pdWidth;
     int pdHeight;
+    double pdX;
+    double pdY;
     int priority;
     float period;
     std::string contentInfo;
@@ -47,6 +49,8 @@ struct BoxInfo
         boxHeight(0),
         pdWidth(0),
         pdHeight(0),
+        pdX(0.0f),
+        pdY(0.0f),
         priority(0),
         period(0),
         contentInfo()
index d81449f..1634b4d 100644 (file)
@@ -65,7 +65,9 @@ bool BoxManager::doCommand(const request_cmd_type type, const BoxInfoPtr& boxInf
         result = requestPauseAll();
         break;
     case REQUEST_CMD_OPEN_PD:
-        result = requestOpenPd(boxInfo->instanceId, boxInfo->pdWidth, boxInfo->pdHeight);
+        result = requestOpenPd(boxInfo->instanceId,
+                    boxInfo->pdWidth, boxInfo->pdHeight,
+                    boxInfo->pdX, boxInfo->pdY);
         break;
     case REQUEST_CMD_CLOSE_PD:
         result = requestClosePd(boxInfo->instanceId);
@@ -177,7 +179,9 @@ bool BoxManager::requestPauseAll()
     return true;
 }
 
-bool BoxManager::requestOpenPd(std::string& instanceId, int width, int height)
+bool BoxManager::requestOpenPd(
+        std::string& instanceId,
+        int width, int height, double x, double y)
 {
     LogD("enter");
     IBoxPtr box = searchBoxMap(instanceId);
@@ -185,7 +189,7 @@ bool BoxManager::requestOpenPd(std::string& instanceId, int width, int height)
         return false;
     }
     
-    return box->openPd(width, height);
+    return box->openPd(width, height, x, y);
 }
 
 bool BoxManager::requestClosePd(std::string& instanceId)
index 966f85b..3703917 100644 (file)
@@ -48,7 +48,9 @@ class EXPORT_CLASS BoxManager: public IBoxManager {
         virtual bool requestPauseBox(std::string& instanceId);
         virtual bool requestResumeAll();
         virtual bool requestPauseAll();
-        virtual bool requestOpenPd(std::string& instanceId, int width, int height);
+        virtual bool requestOpenPd(
+                        std::string& instanceId,
+                        int width, int height, double x, double y);
         virtual bool requestClosePd(std::string& instanceId);
         virtual bool requestChangePeriod(std::string& instanceId, float period);
         // ewk context deleter 
index 81eeae6..63acccf 100644 (file)
@@ -29,7 +29,7 @@ class IBox {
         virtual bool resize(int width, int height) = 0;
         virtual bool resume() = 0;
         virtual bool pause() = 0;
-        virtual bool openPd(int width, int height) = 0;
+        virtual bool openPd(int width, int height, double x, double y) = 0;
         virtual bool closePd() = 0;
         virtual bool update() = 0;
         virtual bool changePeriod(float period) = 0;
index 89edcd6..1d38bfc 100755 (executable)
@@ -231,12 +231,16 @@ int BoxDaemonImpl::pdCreateCallback(ProviderEventArgPtr arg, void* data)
 
     info->pdWidth = arg->info.pd_create.w;
     info->pdHeight = arg->info.pd_create.h;
+    info->pdX = arg->info.pd_create.x;
+    info->pdY = arg->info.pd_create.y;
 
     LogD("--------------------------------------------");
     LogD("boxId: %s", info->boxId.c_str());
     LogD("InstanceId: %s", info->instanceId.c_str());
     LogD("width: %d", info->pdWidth);
     LogD("height: %d", info->pdHeight);
+    LogD("x: %f", info->pdX);
+    LogD("y: %f", info->pdY);
     LogD("--------------------------------------------");
 
     return ecore_job_add(
index 6358b47..0c2d9c3 100644 (file)
@@ -18,7 +18,7 @@
  * @author  Yunchan Cho (yunchan.cho@samsung.com)
  */
 #include <string>
-#include <livebox-service.h>
+#include <API/web_provider_livebox_info.h>
 #include <Core/Buffer/RenderBuffer.h>
 #include <Core/Util/Log.h>
 #include "AppBoxRenderView.h"
@@ -38,7 +38,7 @@ AppBoxRenderBuffer::AppBoxRenderBuffer(
     , m_renderView()
 {
     LogD("enter");
-    if (livebox_service_mouse_event(m_boxId.c_str())) {
+    if (web_provider_livebox_get_mouse_event(m_boxId.c_str())) {
         m_mouseEventRecievable = true;
     }
 
index 4eab4e5..e6a667d 100644 (file)
@@ -78,7 +78,7 @@ void AppBoxRenderView::showBox(RenderInfoPtr renderInfo)
     deleteRenderTimer();
 
     // stop touch timer
-    if (livebox_service_mouse_event(m_boxId.c_str())) {
+    if (web_provider_livebox_get_mouse_event(m_boxId.c_str())) {
         m_renderBuffer->deleteTouchTimer();
     }
 
@@ -289,7 +289,7 @@ Eina_Bool AppBoxRenderView::fireRenderTimerCallback(void* data)
     This->m_fireRenderTimer = NULL;
 
     This->m_renderBuffer->stopCanvasUpdate();
-    if (livebox_service_mouse_event(This->m_boxId.c_str())) {
+    if (web_provider_livebox_get_mouse_event(This->m_boxId.c_str())) {
         // stop touch timer
         This->m_renderBuffer->deleteTouchTimer();
         This->m_view->Suspend();