[Release] livebox.web-provider-1.46 submit/tizen_2.2/20130808.075753
authorsung-su.kim <sung-su.kim@samsung.com>
Thu, 8 Aug 2013 07:57:22 +0000 (16:57 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Thu, 8 Aug 2013 07:57:22 +0000 (16:57 +0900)
Change-Id: I652ba45d397494bc4df75221eaa7cc45d71979d5

packaging/livebox.web-provider.spec
src/Core/Box.cpp
src/Core/BoxSchemeHandler.cpp
src/Daemon/BoxDaemonImpl.cpp
src/Daemon/BoxDaemonImpl.h
src/Plugin/AppBoxPlugin/AppBoxManager.cpp
src/Plugin/AppBoxPlugin/AppBoxManager.h
src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp
src/Plugin/BoxPluginConnector.cpp
src/Plugin/BoxPluginConnector.h
src/Plugin/IBoxPluginConnector.h

index 2365e64..c9f6c6c 100755 (executable)
@@ -1,7 +1,7 @@
 #git:framework/web/web-provider
 Name: livebox.web-provider
 Summary: web framework for livebox 
-Version: 1.43
+Version: 1.46
 Release: 1
 Group: main/app
 License: Flora License, Version 1.1
index 0e46e34..10733a2 100644 (file)
@@ -89,7 +89,6 @@ bool Box::show()
         RenderInfoPtr renderInfo = makeRenderInfo(renderTypeCreate, URL_TYPE_BOX);
         m_boxBuffer->stopCanvasUpdate();
         m_view->showBox(renderInfo);
-        ecore_idler_add(startUpdateRenderBufferIdlerCallback, m_boxBuffer.get());
     } catch (...) {
         return false;
     }
@@ -342,7 +341,6 @@ void Box::updateInternal()
     RenderInfoPtr renderInfo = makeRenderInfo(renderTypeUpdate, URL_TYPE_BOX);
     m_boxBuffer->stopCanvasUpdate();
     m_view->showBox(renderInfo);
-    ecore_idler_add(startUpdateRenderBufferIdlerCallback, m_boxBuffer.get());
 }
 
 void Box::setState(IBoxStatePtr state)
index 472d0b5..cbacb14 100755 (executable)
@@ -199,7 +199,7 @@ bool BoxSchemeHandler::handleReload(std::string& instanceId)
     }
 
     // In the future, new content info can be set by caller
-    box->update(time(NULL), box->m_boxInfo->contentInfo);
+    box->updateInternal();
     return true;
 }
 
index ede2908..11b17eb 100755 (executable)
@@ -499,28 +499,29 @@ void BoxDaemonImpl::setProviderCallbacks(ProviderCallbacks& callbacks)
     callbacks.set_period = BoxDaemonImpl::boxPeriodChangeCallback;
 }
 
-const char* BoxDaemonImpl::getBoxType(const char* boxId)
+std::string BoxDaemonImpl::getBoxType(const char* boxId)
 {
     LogD("enter");
 
     if (!boxId) {
-        return NULL;
+        return std::string();
     }
     
     const char* type = web_provider_livebox_get_box_type(boxId);
-    std::string boxType;
     if (!type) {
-        std::string serviceBoxId(boxId);
-        boxType = m_pluginConnector->getBoxType(serviceBoxId);
+        std::string boxType = m_pluginConnector->getBoxType(boxId);
         if (boxType.empty()) {
             LogD("unrecognized box id");
-            return NULL; 
+        } else {
+            LogD("box id: %s, type: %s", boxId, boxType.c_str());
         }
-        type = strdup(boxType.c_str());
+        return boxType;
     }
 
     LogD("box id: %s, type: %s", boxId, type);
-    return type;
+    std::string result{type};
+    free(const_cast<char*>(type));
+    return result;
 }
 
 BoxInfoPtr BoxDaemonImpl::initializeBoxInfo(ProviderEventArgPtr arg)
@@ -536,12 +537,11 @@ BoxInfoPtr BoxDaemonImpl::initializeBoxInfo(ProviderEventArgPtr arg)
         return BoxInfoPtr();
     }
 
-    const char* type = getBoxType(arg->pkgname);
-    if (!type) {
+    std::string type = getBoxType(arg->pkgname);
+    if (type.empty()) {
         return BoxInfoPtr();
     }
     BoxInfoPtr infoPtr = BoxInfoPtr(new BoxInfo(type, arg->pkgname, arg->id));
-    delete[] type;
 
     return infoPtr;
 }
index 66c2276..df4a96f 100644 (file)
@@ -72,7 +72,7 @@ class BoxDaemonImpl {
 
         // common private functions
         void setProviderCallbacks(ProviderCallbacks& callbacks);
-        const char* getBoxType(const char* boxId);
+        std::string getBoxType(const char* boxId);
         BoxInfoPtr initializeBoxInfo(ProviderEventArgPtr arg);
 
         // functions for handling appcontrol per operation
index 61672c7..ea71ad1 100644 (file)
  * @file    AppBoxManager.cpp
  * @author  Yunchan Cho (yunchan.cho@samsung.com)
  */
+#include <map>
 #include <core_module.h>
 #include <Plugin/IBoxPluginFactory.h>
 #include <Core/BoxData.h>
 #include <Core/BoxManager.h>
 #include <Core/IBox.h>
+#include <Core/Util/Log.h>
+#include <API/web_provider_livebox_info.h>
 #include "AppBoxObserver.h"
 #include "AppBoxManager.h"
 
@@ -34,8 +37,6 @@ AppBoxManager::AppBoxManager(IBoxPluginFactoryPtr factory)
     if (!ret) {
         throw; // throw exeception
     }
-    m_defaultEwkContext.reset(
-                ewk_context_new_with_injected_bundle_path(bundlePath.c_str()));
     AppBoxObserver::Instance()->initialize();
 }
 
@@ -47,12 +48,30 @@ AppBoxManager::~AppBoxManager()
 
 bool AppBoxManager::requestAddBox(BoxInfoPtr boxInfo, EwkContextPtr ewkContext)
 {
-    ewkContext = getAvailableEwkContext();
+
+    const char* appId =
+        web_provider_livebox_get_app_id(boxInfo->boxId.c_str());
+
+    if (!appId) {
+        LogD("no appid of %s", boxInfo->boxId.c_str());
+        return false;
+    }
+
+    std::string appIdStr(appId);
+    delete appId;
+
+    auto it = m_ewkContextMap.find(appIdStr);
+    if (it == m_ewkContextMap.end()) {
+        ewkContext = getAvailableEwkContext();
+        insertContextMap(appIdStr, ewkContext);
+    } else {
+        ewkContext = it->second;
+    }
+
     if (!BoxManager::requestAddBox(boxInfo, ewkContext)) {
         return false;
     }
 
-    insertContextMap(ewkContext, boxInfo->instanceId);
     return true;
 }
 
@@ -62,26 +81,22 @@ bool AppBoxManager::requestRemoveBox(std::string& instanceId)
         return false;
     }
 
-    eraseContextMap(instanceId);
     return true; 
 }
 
 EwkContextPtr AppBoxManager::getAvailableEwkContext()
 {
-    // TODO make proper Ewk_Context instance, and update context map 
-    // std::shared_ptr<Ewk_Context> context(
-    //                      ewk_context_new(), 
-    //                      BoxManager::deleteDefaultEwkContext);
-    
-    return m_defaultEwkContext;
+    return EwkContextPtr(
+            ewk_context_new_with_injected_bundle_path(bundlePath.c_str()),
+            BoxManager::EwkContextDeleter());
 }
 
-void AppBoxManager::insertContextMap(EwkContextPtr ewkContext, std::string& instanceId)
+void AppBoxManager::insertContextMap(std::string& appId, EwkContextPtr ewkContext)
 {
-    // not implemented
+    m_ewkContextMap.insert(EwkContextMapPair(appId, ewkContext));
 }
 
-void AppBoxManager::eraseContextMap(std::string& instanceId)
+void AppBoxManager::eraseContextMap(std::string& appId)
 {
-    // not implemented
+    m_ewkContextMap.erase(appId);
 }
index 51d9fcb..150ec50 100644 (file)
@@ -40,14 +40,14 @@ class AppBoxManager: public BoxManager {
         bool requestRemoveBox(std::string& instanceId);
 
         EwkContextPtr getAvailableEwkContext();
-        void insertContextMap(EwkContextPtr context, std::string& instanceId);
-        void eraseContextMap(std::string& instanceId);
+        void insertContextMap(std::string& appId, EwkContextPtr ewkContext);
+        void eraseContextMap(std::string& appId);
         explicit AppBoxManager(IBoxPluginFactoryPtr factory);
 
         // members
-        typedef std::map<EwkContextPtr, IBoxPtr> EwkContextMap;
-        EwkContextMap m_contextMap;
-        EwkContextPtr m_defaultEwkContext;
+        typedef std::map<std::string, EwkContextPtr> EwkContextMap;
+        typedef std::pair<std::string, EwkContextPtr> EwkContextMapPair;
+        EwkContextMap m_ewkContextMap;
 };
 
 
index a7c3939..ce0fbac 100755 (executable)
@@ -71,7 +71,10 @@ AppBoxRenderView::AppBoxRenderView(
     }
 
     m_boxRenderBuffer = AppBoxObserver::Instance()->getRenderBuffer(m_instanceId);
-    m_pdFastOpen = web_provider_livebox_get_pd_fast_open(m_boxId.c_str()) ? true : false;
+
+    // use fastopen to default
+    // m_pdFastOpen = web_provider_livebox_get_pd_fast_open(m_boxId.c_str()) ? true : false;
+    m_pdFastOpen = false;
     AppBoxObserver::Instance()->registerRenderView(m_instanceId, this);
 }
 
index 90fce64..cc3e58a 100644 (file)
@@ -164,7 +164,7 @@ bool BoxPluginConnector::requestCommand(
     return true;
 }
 
-std::string BoxPluginConnector::getBoxType(std::string& serviceBoxId)
+std::string BoxPluginConnector::getBoxType(const std::string& serviceBoxId)
 {
     LogD("enter");
 
index f9744b9..5ada8db 100644 (file)
@@ -35,7 +35,7 @@ class BoxPluginConnector: public IBoxPluginConnector {
         virtual bool shutdown();
         virtual bool requestCommand(
                 const request_cmd_type type, const BoxInfoPtr& boxInfo);
-        virtual std::string getBoxType(std::string& serviceBoxId);
+        virtual std::string getBoxType(const std::string& serviceBoxId);
         virtual ~BoxPluginConnector();
 
     private:
index 7b954e0..3e94fb8 100644 (file)
@@ -31,7 +31,7 @@ class IBoxPluginConnector: Noncopyable {
         virtual bool shutdown() = 0;
         virtual bool requestCommand(
                 const request_cmd_type type, const BoxInfoPtr& boxInfo) = 0;
-        virtual std::string getBoxType(std::string& serviceBoxId) = 0;
+        virtual std::string getBoxType(const std::string& serviceBoxId) = 0;
         virtual ~IBoxPluginConnector() {};
 };