From 06e76f4e3d3b109dae626ce06c6ad4ffbfda6e82 Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:52:36 +0900 Subject: Initialize Tizen 2.3 --- src_mobile/Plugin/AppBoxPlugin/AppBoxManager.cpp | 153 +++++ src_mobile/Plugin/AppBoxPlugin/AppBoxManager.h | 55 ++ src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.cpp | 156 +++++ src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.h | 59 ++ src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp | 89 +++ src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.h | 55 ++ .../Plugin/AppBoxPlugin/AppBoxPluginFactory.cpp | 41 ++ .../Plugin/AppBoxPlugin/AppBoxPluginFactory.h | 45 ++ .../Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp | 119 ++++ .../Plugin/AppBoxPlugin/AppBoxRenderBuffer.h | 60 ++ .../Plugin/AppBoxPlugin/AppBoxRenderView.cpp | 683 +++++++++++++++++++++ src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.h | 136 ++++ src_mobile/Plugin/AppBoxPlugin/CMakeLists.txt | 75 +++ src_mobile/Plugin/AppBoxPlugin/app.json | 5 + .../Plugin/AppBoxPlugin/box_plugin_interface.cpp | 55 ++ src_mobile/Plugin/BoxPluginConnector.cpp | 186 ++++++ src_mobile/Plugin/BoxPluginConnector.h | 51 ++ src_mobile/Plugin/CMakeLists.txt | 67 ++ src_mobile/Plugin/IBoxPluginConnector.h | 40 ++ src_mobile/Plugin/IBoxPluginFactory.h | 47 ++ src_mobile/Plugin/box_plugin_interface.h | 77 +++ 21 files changed, 2254 insertions(+) create mode 100755 src_mobile/Plugin/AppBoxPlugin/AppBoxManager.cpp create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxManager.h create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.cpp create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.h create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.h create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.cpp create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.h create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.h create mode 100755 src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.cpp create mode 100644 src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.h create mode 100644 src_mobile/Plugin/AppBoxPlugin/CMakeLists.txt create mode 100644 src_mobile/Plugin/AppBoxPlugin/app.json create mode 100644 src_mobile/Plugin/AppBoxPlugin/box_plugin_interface.cpp create mode 100644 src_mobile/Plugin/BoxPluginConnector.cpp create mode 100644 src_mobile/Plugin/BoxPluginConnector.h create mode 100644 src_mobile/Plugin/CMakeLists.txt create mode 100644 src_mobile/Plugin/IBoxPluginConnector.h create mode 100644 src_mobile/Plugin/IBoxPluginFactory.h create mode 100644 src_mobile/Plugin/box_plugin_interface.h (limited to 'src_mobile/Plugin') diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxManager.cpp b/src_mobile/Plugin/AppBoxPlugin/AppBoxManager.cpp new file mode 100755 index 0000000..6285b5c --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxManager.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxManager.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "AppBoxObserver.h" +#include "AppBoxManager.h" + +static const std::string bundlePath("/usr/lib/libwrt-injected-bundle.so"); + +AppBoxManager::AppBoxManager(IBoxPluginFactoryPtr factory) + : BoxManager(factory) +{ + bool ret = WRT::CoreModuleSingleton::Instance().Init(); + if (!ret) { + throw; // throw exeception + } + AppBoxObserver::Instance()->initialize(); +} + +AppBoxManager::~AppBoxManager() +{ + AppBoxObserver::Instance()->shutdown(); +} + +bool AppBoxManager::requestAddBox(BoxInfoPtr boxInfo, EwkContextPtr ewkContext) +{ + + 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(appIdStr); + insertContextMap(appIdStr, ewkContext); + } else { + ewkContext = it->second; + } + + if (!BoxManager::requestAddBox(boxInfo, ewkContext)) { + return false; + } + + return true; +} + +bool AppBoxManager::requestRemoveBox(std::string& instanceId) +{ + if (!BoxManager::requestRemoveBox(instanceId)) { + return false; + } + + return true; +} + +EwkContextPtr AppBoxManager::getAvailableEwkContext(const std::string& appId) +{ + + // get the base executable path + std::string baseExecutablePath = getBaseExecutablePath(appId); + if (baseExecutablePath.empty()) { + return EwkContextPtr(); + } + + // get web process path for this box + std::string webProcessPath = baseExecutablePath + ".d-box"; + + // get plugin process path for this box + std::string pluginProcessPath = baseExecutablePath + ".npruntime"; + + // box manager should set webprocess path as value of 'WEB_PROCESS_PATH' + // before calling ewk_context_new_with_injected_bundle_path(). + setenv("WEB_PROCESS_EXECUTABLE_PATH", webProcessPath.c_str(), 1); + setenv("PLUGIN_PROCESS_EXECUTABLE_PATH", pluginProcessPath.c_str(), 1); + + EwkContextPtr newEwkContext( + ewk_context_new_with_injected_bundle_path(bundlePath.c_str()), + BoxManager::EwkContextDeleter()); + + // unset the following env variables not to affect other ewk context creation + unsetenv("WEB_PROCESS_EXECUTABLE_PATH"); + unsetenv("PLUGIN_PROCESS_EXECUTABLE_PATH"); + + return newEwkContext; +} + +void AppBoxManager::insertContextMap(std::string& appId, EwkContextPtr ewkContext) +{ + m_ewkContextMap.insert(EwkContextMapPair(appId, ewkContext)); +} + +void AppBoxManager::eraseContextMap(std::string& appId) +{ + m_ewkContextMap.erase(appId); +} + +std::string AppBoxManager::getBaseExecutablePath(const std::string& appId) +{ + ail_error_e ret; + ail_appinfo_h handle = NULL; + + char* retStr = NULL; + ret = ail_get_appinfo(appId.c_str(), &handle); + if (ret != AIL_ERROR_OK) { + return std::string(); + } + + ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &retStr); + if (ret != AIL_ERROR_OK || !retStr) { + return std::string(); + } + + std::string basePath(retStr); + + ret = ail_destroy_appinfo(handle); + if (ret != AIL_ERROR_OK) { + return std::string(); + } + + return basePath; +} diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxManager.h b/src_mobile/Plugin/AppBoxPlugin/AppBoxManager.h new file mode 100644 index 0000000..89f942f --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxManager.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxManager.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef APP_BOX_MANAGER_H +#define APP_BOX_MANAGER_H + +#include +#include +#include +#include +#include + +class AppBoxManager: public BoxManager { + public: + static IBoxManagerPtr create(IBoxPluginFactoryPtr factory) + { + return IBoxManagerPtr(new AppBoxManager(factory)); + }; + ~AppBoxManager(); + + private: + // BoxManager implementation + bool requestAddBox(BoxInfoPtr boxInfo, EwkContextPtr ewkContext); + bool requestRemoveBox(std::string& instanceId); + + EwkContextPtr getAvailableEwkContext(const std::string& appId); + void insertContextMap(std::string& appId, EwkContextPtr ewkContext); + void eraseContextMap(std::string& appId); + std::string getBaseExecutablePath(const std::string& appId); + explicit AppBoxManager(IBoxPluginFactoryPtr factory); + + // members + typedef std::map EwkContextMap; + typedef std::pair EwkContextMapPair; + EwkContextMap m_ewkContextMap; +}; + + +#endif // APP_BOX_MANAGER_H diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.cpp b/src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.cpp new file mode 100644 index 0000000..45514e8 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxObserver.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ + +#include +#include +#include +#include +#include +#include +#include "AppBoxRenderView.h" +#include "AppBoxRenderBuffer.h" +#include "AppBoxObserver.h" + +// static variable intialization +AppBoxObserver* AppBoxObserver::s_instance = NULL; + +static const std::string bundlePath("/usr/lib/libwrt-injected-bundle.so"); + +AppBoxObserver::AppBoxObserver() + : m_initialized(false) + , m_renderViewMap() + , m_renderBufferMap() +{ + LogD("enter"); + Ewk_Context* ctx = ewk_context_new_with_injected_bundle_path(bundlePath.c_str()); + m_pdEwkContext.reset(ctx, ewk_context_delete); + // create dummy webview to keep PD's WebProcess alive + //Evas_Object* win = elm_win_add(NULL, "dummy-win", ELM_WIN_BASIC); + //Evas_Object* webview = + // ewk_view_add_with_context(evas_object_evas_get(win), m_pdEwkContext.get()); +} + +AppBoxObserver::~AppBoxObserver() +{ + LogD("enter"); + if (m_pdEwkContext) { + ewk_context_delete(m_pdEwkContext.get()); + } +} + +AppBoxObserver* AppBoxObserver::Instance() +{ + LogD("enter"); + if (!s_instance) { + s_instance = new AppBoxObserver(); + } + + return s_instance; +} + +void AppBoxObserver::initialize() +{ + LogD("enter"); + if (m_initialized) { + LogD("already initialized"); + return; + } + + m_initialized = true; +} + +void AppBoxObserver::shutdown() +{ + LogD("enter"); + if (!m_initialized) { + LogD("not yet initialized"); + return; + } + + m_initialized = false; +} + +AppBoxRenderView* AppBoxObserver::getRenderView(std::string instanceId) +{ + LogD("enter"); + + auto it = m_renderViewMap.find(instanceId); + if (it != m_renderViewMap.end()) { + LogD("registered: %s (%p)", it->first.c_str(), it->second); + return it->second; + } + + return NULL; +} + +std::shared_ptr AppBoxObserver::getPdEwkContext() +{ + LogD("enter"); + return m_pdEwkContext; +} + +void AppBoxObserver::registerRenderView(std::string instanceId, AppBoxRenderView* view) +{ + LogD("enter"); + + if (getRenderView(instanceId)) { + LogD("already registered"); + return; + } + + m_renderViewMap.insert(RenderViewMapPair(instanceId, view)); +} + +void AppBoxObserver::unregisterRenderView(std::string instanceId) +{ + LogD("enter"); + m_renderViewMap.erase(instanceId); +} + +AppBoxRenderBuffer* AppBoxObserver::getRenderBuffer(std::string instanceId) +{ + LogD("enter"); + + auto it = m_renderBufferMap.find(instanceId); + if (it != m_renderBufferMap.end()) { + LogD("registered: %s (%p)", it->first.c_str(), it->second); + return it->second; + } + + return NULL; +} + +void AppBoxObserver::registerRenderBuffer(std::string instanceId, AppBoxRenderBuffer* buffer) +{ + LogD("enter"); + + if (getRenderBuffer(instanceId)) { + LogD("already registered"); + return; + } + + m_renderBufferMap.insert(RenderBufferMapPair(instanceId, buffer)); +} + +void AppBoxObserver::unregisterRenderBuffer(std::string instanceId) +{ + LogD("enter"); + m_renderBufferMap.erase(instanceId); +} diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.h b/src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.h new file mode 100644 index 0000000..8042f33 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxObserver.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxObserver.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef APP_BOX_OBSERVER_H +#define APP_BOX_OBSERVER_H + +#include +#include +#include + +class AppBoxRenderView; +class AppBoxRenderBuffer; + +class AppBoxObserver { + public: + static AppBoxObserver* Instance(); + void initialize(); + void shutdown(); + void registerRenderView(std::string instanceId, AppBoxRenderView* view); + void unregisterRenderView(std::string instanceId); + void registerRenderBuffer(std::string instanceId, AppBoxRenderBuffer* view); + void unregisterRenderBuffer(std::string instanceId); + AppBoxRenderView* getRenderView(std::string instanceId); + AppBoxRenderBuffer* getRenderBuffer(std::string instanceId); + std::shared_ptr getPdEwkContext(); + + private: + AppBoxObserver(); + ~AppBoxObserver(); + + typedef std::map RenderViewMap; + typedef std::pair RenderViewMapPair; + typedef std::map RenderBufferMap; + typedef std::pair RenderBufferMapPair; + + bool m_initialized; + RenderViewMap m_renderViewMap; + RenderBufferMap m_renderBufferMap; + std::shared_ptr m_pdEwkContext; + static AppBoxObserver* s_instance; +}; + +#endif //APP_BOX_OBSERVER_H diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp b/src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp new file mode 100644 index 0000000..46e0fb9 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxPdHelper.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include "AppBoxPdHelper.h" + +AppBoxPdHelper::AppBoxPdHelper(Evas_Object* pdWin) + : m_win(pdWin) + , m_boxWebView() + , m_pdWebView() + , m_opened(false) +{ +} + +AppBoxPdHelper::~AppBoxPdHelper() +{ +} + +void AppBoxPdHelper::startOpen() +{ + LogD("enter"); +} + +void AppBoxPdHelper::finishOpen(Evas_Object* child) +{ + LogD("enter"); + m_opened = true; + setPdWebView(child); +} + +void AppBoxPdHelper::close() +{ + LogD("enter"); +} + +void AppBoxPdHelper::setBoxWebView(Evas_Object* webview) +{ + LogD("enter"); + m_boxWebView = webview; +} + +void AppBoxPdHelper::setPdWebView(Evas_Object* webview) +{ + LogD("enter"); + m_pdWebView = webview; +} + +Evas_Object* AppBoxPdHelper::getBoxWebView() const +{ + LogD("enter"); + return m_boxWebView; +} + +Evas_Object* AppBoxPdHelper::getPdWebView() const +{ + LogD("enter"); + return m_pdWebView; +} + +Evas* AppBoxPdHelper::getPdCanvas() const +{ + LogD("enter"); + return evas_object_evas_get(m_win); +} + +bool AppBoxPdHelper::isPdOpened() const +{ + LogD("enter"); + return m_opened; +} diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.h b/src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.h new file mode 100644 index 0000000..ae49863 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxPdHelper.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxPdHelper.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ + +#ifndef APP_BOX_PD_HELPER_H +#define APP_BOX_PD_HELPER_H + +#include +#include +#include + +class AppBoxPdHelper: public IPdHelper { + public: + static IPdHelperPtr create(Evas_Object* pdWin) + { + return IPdHelperPtr(new AppBoxPdHelper(pdWin)); + } + virtual void startOpen(); + virtual void finishOpen(Evas_Object* child); + virtual void close(); + virtual void setBoxWebView(Evas_Object* webview); + virtual void setPdWebView(Evas_Object* webview); + virtual Evas_Object* getBoxWebView() const; + virtual Evas_Object* getPdWebView() const; + virtual Evas* getPdCanvas() const; + virtual bool isPdOpened() const; + virtual ~AppBoxPdHelper(); + + private: + AppBoxPdHelper(Evas_Object* pdWin); + + //members + Evas_Object* m_win; + Evas_Object* m_boxWebView; + Evas_Object* m_pdWebView; + bool m_opened; +}; + +#endif // APP_BOX_PD_HELPER_H diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.cpp b/src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.cpp new file mode 100644 index 0000000..8f0bfb2 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxPluginFactory.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include "AppBoxRenderView.h" +#include "AppBoxRenderBuffer.h" +#include "AppBoxPluginFactory.h" + +IRenderViewPtr AppBoxPluginFactory::createRenderView( + std::string boxId, std::string instanceId, + std::shared_ptr ewkContext) +{ + return AppBoxRenderView::create(boxId, instanceId, ewkContext); +} + +IRenderBufferPtr AppBoxPluginFactory::createBoxRenderBuffer( + std::string boxId, std::string instanceId, + int width, int height, std::string data) +{ + // use appbox render buffer + return AppBoxRenderBuffer::create(boxId, instanceId, width, height, data); +} diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.h b/src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.h new file mode 100644 index 0000000..ca5a5f2 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxPluginFactory.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxPluginFactory.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef APP_BOX_PLUGIN_FACTORY_H +#define APP_BOX_PLUGIN_FACTORY_H + +#include +#include +#include +#include +#include +#include +#include + +class AppBoxPluginFactory: public IBoxPluginFactory { + public: + IRenderViewPtr createRenderView( + std::string boxId, std::string instanceId, + std::shared_ptr ewkContext); + + IRenderBufferPtr createBoxRenderBuffer( + std::string boxId, std::string instanceId, + int width, int height, std::string data); + + AppBoxPluginFactory() {}; + ~AppBoxPluginFactory() {}; +}; + +#endif //APP_BOX_PLUGIN_FACTORY_H diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp new file mode 100644 index 0000000..f0c0ae0 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxRenderBuffer.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include +#include "AppBoxRenderView.h" +#include "AppBoxRenderBuffer.h" +#include "AppBoxObserver.h" + +#define MAX_WAIT_TIME 5.0 + +AppBoxRenderBuffer::AppBoxRenderBuffer( + std::string boxId, std::string instanceId, + int width, int height, std::string data) + : BoxRenderBuffer(boxId, instanceId, width, height) + , m_boxId(boxId) + , m_instanceId(instanceId) + , m_mouseEventRecievable(false) + , m_touchTimer() + , m_renderView() +{ + LogD("enter"); + UNUSED_PARAM(data); + + if (web_provider_livebox_get_mouse_event(m_boxId.c_str())) { + m_mouseEventRecievable = true; + } + + AppBoxObserver::Instance()->registerRenderBuffer(m_instanceId, this); +} + +AppBoxRenderBuffer::~AppBoxRenderBuffer() +{ + LogD("enter"); + AppBoxObserver::Instance()->unregisterRenderBuffer(m_instanceId); +} + +void AppBoxRenderBuffer::didHandleTouchEvent( + TouchType type, double timestamp, double x, double y) +{ + LogD("enter"); + if (!m_mouseEventRecievable) { + return; + } + + m_renderView = AppBoxObserver::Instance()->getRenderView(m_instanceId); + + if (!m_renderView || !(m_renderView->m_boxWrt)) { + LogD("no matched render view"); + return; + } + + // if needed, resume render view + if (m_renderView->m_fireRenderTimer) { + m_renderView->deleteTimer(&(m_renderView->m_fireRenderTimer)); + } else { + if (!m_touchTimer) { + startCanvasUpdate(); + + // temp condition + if (m_renderView->m_boxWrt_isSuspended == true) + { + m_renderView->m_boxWrt_isSuspended = false; + m_renderView->m_boxWrt->Resume(); + } + } else { + deleteTouchTimer(); + } + } + + BoxRenderBuffer::didHandleTouchEvent(type, timestamp, x, y); + m_touchTimer = ecore_timer_add(MAX_WAIT_TIME, fireTouchTimerCallback, this); +} + +void AppBoxRenderBuffer::deleteTouchTimer() +{ + LogD("enter"); + if (m_touchTimer) { + ecore_timer_del(m_touchTimer); + m_touchTimer = NULL; + } +} + +Eina_Bool AppBoxRenderBuffer::fireTouchTimerCallback(void* data) +{ + LogD("enter"); + AppBoxRenderBuffer* This = static_cast(data); + This->stopCanvasUpdate(); + + // temp condition + if (This->m_renderView->m_boxWrt_isSuspended == false) + { + This->m_renderView->m_boxWrt_isSuspended = true; + This->m_renderView->m_boxWrt->Suspend(); + } + + This->m_touchTimer = NULL; + + return ECORE_CALLBACK_CANCEL; +} diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.h b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.h new file mode 100644 index 0000000..ba8462a --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderBuffer.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxRenderBuffer.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef APP_BOX_RENDER_BUFFER_H +#define APP_BOX_RENDER_BUFFER_H + +#include +#include + +struct _Ecore_Timer; +typedef _Ecore_Timer Ecore_Timer; + +class AppBoxRenderBuffer: public BoxRenderBuffer { + public: + static IRenderBufferPtr create( + std::string boxId, std::string instanceId, + int width, int height, std::string data) + { + return IRenderBufferPtr(new AppBoxRenderBuffer( + boxId, instanceId, width, height, data)); + } + ~AppBoxRenderBuffer(); + + private: + void didHandleTouchEvent( + TouchType type, double timestamp, double x, double y); + void deleteTouchTimer(); + static Eina_Bool fireTouchTimerCallback(void* data); + + AppBoxRenderBuffer( + std::string boxId, std::string instanceId, + int width, int height, std::string data); + + // members + std::string m_boxId; + std::string m_instanceId; + bool m_mouseEventRecievable; + Ecore_Timer* m_touchTimer; + AppBoxRenderView* m_renderView; + + friend class AppBoxRenderView; +}; + +#endif // APP_BOX_RENDER_BUFFER_H diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.cpp b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.cpp new file mode 100755 index 0000000..891e5bb --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.cpp @@ -0,0 +1,683 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxRenderView.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "AppBoxObserver.h" +#include "AppBoxRenderBuffer.h" +#include "AppBoxPdHelper.h" +#include "AppBoxRenderView.h" + +#define RENDER_MAX_TIME 30.0 +#define SNAPSHOT_REMOVE_TIME 1.0 +#define WEB_DBOX_OBJ_MOVE_TO_OUTSIDE_POINT_VALUE -10000 + +// injection javascript file regarding creating js object used by box and pd +static const std::string injectionFile("/usr/share/web-provider/injection.js"); + +AppBoxRenderView::AppBoxRenderView( + std::string boxId, std::string instanceId, + EwkContextPtr ewkContext) + : m_appId() + , m_boxId(boxId) + , m_instanceId(instanceId) + , m_ewkContext(ewkContext) + , m_boxRenderInfo() + , m_boxWrt() + , m_pdWrt() + , m_snapshot() + , m_fireRenderTimer() + , m_removeSnapShotTimer() + , m_pdHelper() + , m_boxRenderBuffer() + , m_pdFastOpen(false) + , m_boxFinishLoad(false) + , m_boxFrameRendered(false) + , m_boxWrt_isSuspended(false) +{ + LogD("enter"); + m_appId = getAppId(m_boxId); + if (m_appId.empty()) { + throw; //exception throw! + } + + m_boxRenderBuffer = AppBoxObserver::Instance()->getRenderBuffer(m_instanceId); + + // use fastopen to default + // m_pdFastOpen = web_provider_livebox_get_pd_fast_open(m_boxId.c_str()) ? true : false; + m_pdFastOpen = true; + AppBoxObserver::Instance()->registerRenderView(m_instanceId, this); +} + +AppBoxRenderView::~AppBoxRenderView() +{ + LogD("enter"); + + destroyWrtCore(m_boxWrt); + destroyWrtCore(m_pdWrt); + AppBoxObserver::Instance()->unregisterRenderView(m_instanceId); +} + +void AppBoxRenderView::showBox(RenderInfoPtr boxRenderInfo) +{ + LogD("enter"); + + // stop updating render buffer + m_boxRenderBuffer->stopCanvasUpdate(); + + // clear snapshot if this is not the case of pd open + if (!m_pdHelper) { + clearSnapShot(); + } + + // delete already running timer + deleteTimer(&m_fireRenderTimer); + + // delete touch timer + if (web_provider_livebox_get_mouse_event(m_boxId.c_str())) { + m_boxRenderBuffer->deleteTouchTimer(); + } + + // set boxFinishLoad and m_boxFrameRendered to false + m_boxFinishLoad = false; + m_boxFrameRendered = false; + + // copy to url + std::string boxStartUrl = getStartUrl(URL_TYPE_BOX, boxRenderInfo->defaultUrlParams); + if (m_boxWrt) { + LogD("existing wrt core is removed"); + destroyBoxWrtCore(); + } + + m_boxWrt = createWrtCore( + URL_TYPE_BOX, boxStartUrl, + boxRenderInfo->window, m_ewkContext); + m_boxWrt_isSuspended = false; + + // in case of showing box by request of pd open + if (m_pdHelper) { + m_pdHelper->setBoxWebView(m_boxWrt->GetCurrentWebview()); + } + + // resize webview fitted to width, height of Box + evas_object_resize( + m_boxWrt->GetCurrentWebview(), + boxRenderInfo->width, + boxRenderInfo->height); + + + evas_object_show(m_boxWrt->GetCurrentWebview()); + // webview window move to outside of viewport because of overlap issue with snapshot image + evas_object_move(m_boxWrt->GetCurrentWebview(), WEB_DBOX_OBJ_MOVE_TO_OUTSIDE_POINT_VALUE, WEB_DBOX_OBJ_MOVE_TO_OUTSIDE_POINT_VALUE); + + m_boxWrt->Show(); + m_boxRenderInfo = boxRenderInfo; +} + +AppBoxRenderView::WrtCorePtr AppBoxRenderView::createWrtCore( + UrlType type, std::string& startUrl, + Evas_Object* win, EwkContextPtr ewkContext) +{ + LogD("enter"); + + WrtCorePtr wrt; + wrt = WRT::CoreModuleSingleton:: + Instance().getRunnableWidgetObject(m_appId); + // prepare webview + if (startUrl.empty()) { + LogD("no start url"); + return WrtCorePtr(); + } + wrt->PrepareView(startUrl, win, ewkContext.get()); + wrt->CheckBeforeLaunch(); + + // set callback functions of RunnableWidgetObject + WRT::UserDelegatesPtr cbs(new WRT::UserDelegates); + cbs->loadStart = DPL::MakeDelegate(this, &AppBoxRenderView::startLoadCallback); + if (type == URL_TYPE_BOX) { + cbs->loadFinish = DPL::MakeDelegate(this, &AppBoxRenderView::finishBoxLoadCallback); + } else { + cbs->loadFinish = DPL::MakeDelegate(this, &AppBoxRenderView::finishPdLoadCallback); + } + + cbs->bufferSet = DPL::MakeDelegate(this, &AppBoxRenderView::setBufferCallback); + cbs->bufferUnset = DPL::MakeDelegate(this, &AppBoxRenderView::unsetBufferCallback); + if (!m_pdFastOpen) { + cbs->windowCreateBefore = + DPL::MakeDelegate(this, &AppBoxRenderView::createWindowBeforeCallback); + cbs->windowCreateAfter = + DPL::MakeDelegate(this, &AppBoxRenderView::createWindowAfterCallback); + } + + cbs->navigationDecide = + DPL::MakeDelegate(this, &AppBoxRenderView::decideNavigationCallback); + cbs->webCrash = DPL::MakeDelegate(this, &AppBoxRenderView::crashWebProcessCallback); + wrt->SetUserDelegates(cbs); + + // set basic webview setting + setWebViewBasicSetting(wrt->GetCurrentWebview()); + return wrt; +} + +void AppBoxRenderView::destroyBoxWrtCore() +{ + LogD("enter"); + + m_boxRenderBuffer->stopCanvasUpdate(); + deleteTimer(&m_fireRenderTimer); + deleteTimer(&m_removeSnapShotTimer); + destroyWrtCore(m_boxWrt); + m_boxWrt.reset(); + + // temp + m_boxWrt_isSuspended = false; +} + +void AppBoxRenderView::destroyPdWrtCore() +{ + LogD("enter"); + + destroyWrtCore(m_pdWrt); + m_pdWrt.reset(); +} + +void AppBoxRenderView::destroyWrtCore(WrtCorePtr wrt) +{ + LogD("enter"); + + if (wrt) { + wrt->Hide(); + } +} + +void AppBoxRenderView::hideBox() +{ + LogD("enter"); + destroyBoxWrtCore(); + if (m_boxRenderInfo->window) { + evas_object_hide(m_boxRenderInfo->window); + } +} + +void AppBoxRenderView::pauseBox() +{ + LogD("enter"); +} + +void AppBoxRenderView::resumeBox() +{ + LogD("enter"); +} + +void AppBoxRenderView::showPd(RenderInfoPtr pdRenderInfo, RenderInfoPtr boxRenderInfo) +{ + LogD("enter"); + + std::string pdStartUrl = getStartUrl(URL_TYPE_PD, pdRenderInfo->defaultUrlParams); + if (m_pdFastOpen) { + destroyPdWrtCore(); + // if you want to launch new Web Process for PD, use the following line. + // EwkContextPtr pdContext = AppBoxObserver::Instance()->getPdEwkContext(); + m_pdWrt = createWrtCore(URL_TYPE_PD, pdStartUrl, pdRenderInfo->window, m_ewkContext); + if (!m_pdWrt) { + LogD("no wrt core instance"); + return; + } + m_pdHelper = AppBoxPdHelper::create(pdRenderInfo->window); + + // resize webview fitted to width, height of pd + evas_object_resize( + m_pdWrt->GetCurrentWebview(), + pdRenderInfo->width, + pdRenderInfo->height); + // show pd + m_pdWrt->Show(); + m_pdHelper->finishOpen(m_pdWrt->GetCurrentWebview()); + } else { + m_pdHelper = PdHelper::create(pdRenderInfo, pdStartUrl); + } + + // show pd window + evas_object_show(pdRenderInfo->window); + + // need to create new snapshot when m_napshot is empty + if (!m_snapshot) { + evas_object_show(getCurrentSnapShot()); + } + + // show box + showBox(boxRenderInfo); + + // start timer for clearing existing snapshot in case of only pd open + addTimer(&m_removeSnapShotTimer, SNAPSHOT_REMOVE_TIME, removeSnapShotTimerCallback); + +} + +void AppBoxRenderView::hidePd() +{ + LogD("enter"); + + if (m_pdFastOpen) { + destroyPdWrtCore(); + } + m_pdHelper->close(); + m_pdHelper.reset(); + + // start timer for clearing existing snapshot in case of only pd open + addTimer(&m_fireRenderTimer, RENDER_MAX_TIME, fireRenderTimerCallback); +} + +Evas_Object* AppBoxRenderView::getBoxWebView() +{ + if (!m_pdHelper) { + return m_boxWrt->GetCurrentWebview(); + } else { + // Here, we can't use GetCurrentWebView() of wrt-core to get Box' webview, + // because in the non fast-open, GetCurrentWebview() returns PD's webview. + return m_pdHelper->getBoxWebView(); + } +} + +Evas_Object* AppBoxRenderView::getPdWebView() +{ + if (!m_pdHelper) { + return NULL; + } + + return m_pdHelper->getPdWebView(); +} + +std::string AppBoxRenderView::getAppId(std::string& boxId) +{ + LogD("enter"); + + const char* appId = web_provider_livebox_get_app_id(boxId.c_str()); + if (!appId) { + LogD("no appid of %s", boxId.c_str()); + return std::string(); + } + + return std::string(appId); +} + +std::string AppBoxRenderView::getStartUrl(UrlType type, std::string& defaultParams) +{ + const char* path; + switch (type) { + case URL_TYPE_BOX: + path = livebox_service_lb_script_path(m_boxId.c_str()); + break; + case URL_TYPE_PD: + path = livebox_service_pd_script_path(m_boxId.c_str()); + break; + default: + LogD("no available type"); + } + + std::string startUrl; + if (path) { + LogD("path : %s", path); + startUrl = path; + } else { + // TODO In this case, fallback page will be loaded. + LogE("Fail to get service lib script path"); + } + + // add default parameters to start url + startUrl += defaultParams; + + return startUrl; +} + +Evas_Object* AppBoxRenderView::getCurrentSnapShot() +{ + LogD("enter"); + clearSnapShot(); + m_snapshot = m_boxRenderBuffer->getSnapshot(); + + return m_snapshot; +} + +void AppBoxRenderView::clearSnapShot() +{ + LogD("enter"); + if (m_snapshot) { + evas_object_del(m_snapshot); + m_snapshot = NULL; + } +} + +void AppBoxRenderView::showSnapShot() +{ + LogD("enter"); + if (m_snapshot) { + evas_object_raise(m_snapshot); + evas_object_show(m_snapshot); + } +} + +void AppBoxRenderView::hideSnapShot() +{ + LogD("enter"); + if (m_snapshot) { + evas_object_hide(m_snapshot); + evas_object_lower(m_snapshot); + } +} + +void AppBoxRenderView::addTimer(Ecore_Timer** timer, double interval, Ecore_Task_Cb callback) +{ + LogD("enter"); + if (*timer) { + deleteTimer(timer); + } + + *timer = ecore_timer_add(interval, callback, this); +} + +void AppBoxRenderView::deleteTimer(Ecore_Timer** timer) +{ + LogD("enter"); + if (*timer) { + ecore_timer_del(*timer); + *timer = NULL; + } +} + +void AppBoxRenderView::stopRenderBox() +{ + deleteTimer(&m_fireRenderTimer); + m_boxRenderBuffer->stopCanvasUpdate(); + if (web_provider_livebox_get_mouse_event(m_boxId.c_str())) { + // stop touch timer + m_boxRenderBuffer->deleteTouchTimer(); + + // temp condition + if (m_boxWrt_isSuspended == false) + { + m_boxWrt_isSuspended = true; + m_boxWrt->Suspend(); + } + } else { + // Before webview should be removed, + // new evas object with last render data should be created + // otherwise, after webview is removed, box is white screen. + evas_object_show(getCurrentSnapShot()); + destroyBoxWrtCore(); + } +} + +void AppBoxRenderView::setWebViewBasicSetting(Evas_Object* webview) +{ + LogD("enter"); + + if (!webview) { + return; + } + Ewk_Settings* setting = ewk_view_settings_get(webview); + // Disable ime features + ewk_settings_default_keypad_enabled_set(setting, EINA_FALSE); + // To support transparent background + evas_object_color_set(webview, 0, 0, 0, 1); + ewk_view_draws_transparent_background_set(webview, EINA_TRUE); + ewk_view_visibility_set(webview, EINA_TRUE); + + // To know starting point for updating buffer + evas_object_smart_callback_add( + webview, + "load,nonemptylayout,finished", + loadNonEmptyLayoutFinishedCallback, + this); + evas_object_smart_callback_add( + webview, + "frame,rendered", + frameRenderedCallback, + this); + // To set font type whenever font changed + ewk_view_use_settings_font(webview); +} + +Eina_Bool AppBoxRenderView::fireRenderTimerCallback(void* data) +{ + LogD("enter"); + + AppBoxRenderView* This = static_cast(data); + This->m_fireRenderTimer = NULL; + This->stopRenderBox(); + + return ECORE_CALLBACK_CANCEL; +} + +Eina_Bool AppBoxRenderView::removeSnapShotTimerCallback(void* data) +{ + LogD("enter"); + + AppBoxRenderView* This = static_cast(data); + if (!(This->m_boxFinishLoad && This->m_boxFrameRendered)) { + return ECORE_CALLBACK_RENEW; + } + + // hide snapshot because valid frame has been prepared generally. + This->clearSnapShot(); + + // move to inside of viewport to prevent overlap with snapshot image + evas_object_move(This->m_boxWrt->GetCurrentWebview(), 0, 0); + evas_object_show(This->m_boxWrt->GetCurrentWebview()); + + This->m_removeSnapShotTimer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +Eina_Bool AppBoxRenderView::openPdIdlerCallback(void* data) +{ + LogD("enter"); + AppBoxRenderView* This = static_cast(data); + if (This && This->m_pdHelper) { + This->m_pdHelper->startOpen(); + } + return ECORE_CALLBACK_CANCEL; +} + +void AppBoxRenderView::executeScriptCallback( + Evas_Object* webview, const char* result, void* data) +{ + LogD("enter"); + UNUSED_PARAM(webview); + UNUSED_PARAM(data); + + std::string resultStr(result ? result : "null"); + LogD("result: %s", resultStr.c_str()); +} + +void AppBoxRenderView::startLoadCallback(Evas_Object* webview) +{ + LogD("enter"); + if(!webview) { + return; + } + // execute injection for creating js objects + std::ifstream jsFile(injectionFile); + std::string script((std::istreambuf_iterator(jsFile)), + std::istreambuf_iterator()); + + LogD("injected js code: %s", script.c_str()); + ewk_view_script_execute(webview, script.c_str(), executeScriptCallback, this); +} + +void AppBoxRenderView::finishBoxLoadCallback(Evas_Object* webview) +{ + LogD("enter"); + if (!webview) { + return; + } + + ewk_view_visibility_set(webview, EINA_TRUE); + + if (!m_pdHelper) { + // start render timer + addTimer(&m_fireRenderTimer, RENDER_MAX_TIME, fireRenderTimerCallback); + } else { + if (!m_pdFastOpen) { + if (!(m_pdHelper->isPdOpened()) && + webview == m_pdHelper->getBoxWebView()) + { + // open pd + ecore_idler_add(openPdIdlerCallback, this); + } + } + } + + // set flag + m_boxFinishLoad = true; +} + +void AppBoxRenderView::finishPdLoadCallback(Evas_Object* webview) +{ + LogD("enter"); + if (!webview) { + return; + } + + ewk_view_visibility_set(webview, EINA_TRUE); +} + +void AppBoxRenderView::createWindowBeforeCallback(Evas** canvas, Evas_Object* parent) +{ + LogD("enter"); + + if (m_pdHelper) { + if (!(m_pdHelper->isPdOpened()) && + parent == m_pdHelper->getBoxWebView()) + { + LogD("pd canvas is used"); + *canvas = m_pdHelper->getPdCanvas(); + return; + } + } + + LogD("canvas of this webview is used"); + *canvas = evas_object_evas_get(parent); +} + +void AppBoxRenderView::createWindowAfterCallback(Evas_Object* parent, Evas_Object* child) +{ + LogD("enter"); + if (!parent) { + return; + } + + if (m_pdHelper) { + Evas* parentCanvas = evas_object_evas_get(parent); + Evas* childCanvas = evas_object_evas_get(child); + + if (parentCanvas != childCanvas) { + // wrt-core change visibility value to false internally + // So plugin should reset this value to true for painting parent webview + ewk_view_visibility_set(parent, EINA_TRUE); + evas_object_show(parent); + m_pdHelper->finishOpen(child); + } + } + + setWebViewBasicSetting(child); + evas_object_show(child); +} + +void AppBoxRenderView::setBufferCallback(Evas_Object* webview) +{ + LogD("enter"); + evas_object_show(webview); + evas_object_focus_set(webview, EINA_TRUE); +} + +void AppBoxRenderView::unsetBufferCallback(Evas_Object* webview) +{ + LogD("enter"); + evas_object_hide(webview); +} + +void AppBoxRenderView::decideNavigationCallback(Evas_Object* webview, std::string& uri) +{ + LogD("enter"); + UNUSED_PARAM(webview); + + // navigation of box scheme should be ignored + if(BoxSchemeHandler::Instance()->isBoxScheme(uri)) { + LogD("box scheme"); + BoxSchemeHandler::Instance()->process(m_instanceId, uri); + } +} + +void AppBoxRenderView::crashWebProcessCallback() +{ + LogD("enter"); + elm_exit(); +} + +void AppBoxRenderView::loadNonEmptyLayoutFinishedCallback( + void* data, Evas_Object* webview, void* eventInfo) +{ + LogD("enter"); + UNUSED_PARAM(data); + UNUSED_PARAM(webview); + UNUSED_PARAM(eventInfo); +} + +void AppBoxRenderView::frameRenderedCallback( + void* data, Evas_Object* webview, void* eventInfo) +{ + LogD("enter"); + UNUSED_PARAM(webview); + UNUSED_PARAM(eventInfo); + + // start to update render buffer! + AppBoxRenderView* This = static_cast(data); + This->m_boxRenderBuffer->startCanvasUpdate(); + + // set flag + This->m_boxFrameRendered = true; + + // move to inside of viewport to prevent overlap with snapshot image + if (!This->m_removeSnapShotTimer) { + evas_object_move(This->m_boxWrt->GetCurrentWebview(), 0, 0); + } + +} diff --git a/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.h b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.h new file mode 100644 index 0000000..4d0d7a7 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/AppBoxRenderView.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file AppBoxRenderView.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef APP_BOX_RENDER_VIEW_H +#define APP_BOX_RENDER_VIEW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class AppBoxRenderBuffer; + +class AppBoxRenderView: public IRenderView { + public: + typedef std::shared_ptr EwkContextPtr; + + static IRenderViewPtr create( + std::string boxId, std::string instanceId, + EwkContextPtr ewkContext) + { + return IRenderViewPtr( + new AppBoxRenderView( + boxId, instanceId, ewkContext)); + }; + virtual void showBox(RenderInfoPtr boxRenderInfo); + virtual void hideBox(); + virtual void pauseBox(); + virtual void resumeBox(); + virtual void showPd(RenderInfoPtr pdRenderInfo, RenderInfoPtr boxRenderInfo); + virtual void hidePd(); + Evas_Object* getBoxWebView(); + Evas_Object* getPdWebView(); + virtual ~AppBoxRenderView(); + + private: + // type definition + typedef std::shared_ptr WrtCorePtr; + enum UrlType { + URL_TYPE_BOX, + URL_TYPE_PD + }; + + WrtCorePtr createWrtCore( + UrlType type, std::string& startUrl, + Evas_Object* win, EwkContextPtr ewkContext); + void setWebViewBasicSetting(Evas_Object* webview); + void destroyWrtCore(WrtCorePtr wrt); + void destroyBoxWrtCore(); + void destroyPdWrtCore(); + std::string getAppId(std::string& boxId); + std::string getStartUrl(UrlType type, std::string& defaultParams); + Evas_Object* getCurrentSnapShot(); + void clearSnapShot(); + void showSnapShot(); + void hideSnapShot(); + void addTimer(Ecore_Timer** timer, double interval, Ecore_Task_Cb callback); + void deleteTimer(Ecore_Timer** timer); + void stopRenderBox(); + + // timer and idler callback + static Eina_Bool fireRenderTimerCallback(void* data); + static Eina_Bool removeSnapShotTimerCallback(void* data); + static Eina_Bool openPdIdlerCallback(void* data); + + // ewk view callback + static void executeScriptCallback( + Evas_Object* webview, const char* result, void* data); + static void loadNonEmptyLayoutFinishedCallback( + void* data, Evas_Object* webview, void* eventInfo); + static void frameRenderedCallback( + void* data, Evas_Object* webview, void* eventInfo); + + // user Callbacks of RunnableWidgetObject + void startLoadCallback(Evas_Object* webview); + void finishBoxLoadCallback(Evas_Object* webview); + void finishPdLoadCallback(Evas_Object* webview); + void createWindowBeforeCallback(Evas** canvas, Evas_Object* parent); + void createWindowAfterCallback(Evas_Object* parent, Evas_Object* child); + void setBufferCallback(Evas_Object* webview); + void unsetBufferCallback(Evas_Object* webview); + void decideNavigationCallback(Evas_Object* webview, std::string& uri); + void crashWebProcessCallback(); + + // constructor + explicit AppBoxRenderView( + std::string boxId, std::string instanceId, + EwkContextPtr ewkContext); + + // members + std::string m_appId; + std::string m_boxId; + std::string m_instanceId; + EwkContextPtr m_ewkContext; + RenderInfoPtr m_boxRenderInfo; + WrtCorePtr m_boxWrt; + WrtCorePtr m_pdWrt; + Evas_Object* m_snapshot; + Ecore_Timer* m_fireRenderTimer; + Ecore_Timer* m_removeSnapShotTimer; + IPdHelperPtr m_pdHelper; + AppBoxRenderBuffer* m_boxRenderBuffer; + + // for check status of webview + bool m_pdFastOpen; + bool m_boxFinishLoad; + bool m_boxFrameRendered; + + // TODO this temporary flag should removed! + bool m_boxWrt_isSuspended; + + friend class AppBoxRenderBuffer; +}; + +#endif // APP_BOX_RENDER_VIEW_H diff --git a/src_mobile/Plugin/AppBoxPlugin/CMakeLists.txt b/src_mobile/Plugin/AppBoxPlugin/CMakeLists.txt new file mode 100644 index 0000000..a072064 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/CMakeLists.txt @@ -0,0 +1,75 @@ +# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Flora License, Version 1.1 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://floralicense.org/license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @author Yunchan Cho (yunchan.cho@samsung.com) + +SET(TARGET_NAME web-provider-plugin-app) +SET(DEPS ${TARGET_NAME}_DEPS) + +PKG_CHECK_MODULES(${DEPS} + ail + ewebkit2 + wrt-core + dpl-efl + evas + ecore + eina + livebox-service + dlog + provider # this should be removed + REQUIRED +) +ADD_DEFINITIONS(${${DEPS}_CFLAGS}) + +SET(SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/box_plugin_interface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxManager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxObserver.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxPluginFactory.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxRenderView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxRenderBuffer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AppBoxPdHelper.cpp +) + +SET(HEADERS + ${${DEPS}_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} +) +INCLUDE_DIRECTORIES(${HEADERS}) + +ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) + +SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + COMPILE_FLAGS -fPIC + LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both" +) + +SET_TARGET_PROPERTIES(${TARGET_NAME} + PROPERTIES + SOVERSION ${CMAKE_PROJECT_API_VERSION} + VERSION ${CMAKE_PROJECT_VERSION} +) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${${DEPS}_LIBRARIES} + ${TARGET_CORE} +) + +INSTALL(TARGETS ${TARGET_NAME} + DESTINATION lib/${PROJECT_NAME} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE +) + +INSTALL_FILE(app.json lib/${PROJECT_NAME}) diff --git a/src_mobile/Plugin/AppBoxPlugin/app.json b/src_mobile/Plugin/AppBoxPlugin/app.json new file mode 100644 index 0000000..6388702 --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/app.json @@ -0,0 +1,5 @@ +{ + "type" : "app", + "path" : "/usr/lib/web-provider/libweb-provider-plugin-app.so", + "supported_size" : ["1x1","2x1","2x2"] +} diff --git a/src_mobile/Plugin/AppBoxPlugin/box_plugin_interface.cpp b/src_mobile/Plugin/AppBoxPlugin/box_plugin_interface.cpp new file mode 100644 index 0000000..ca5e65e --- /dev/null +++ b/src_mobile/Plugin/AppBoxPlugin/box_plugin_interface.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file box_plugin_interface.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include "AppBoxManager.h" +#include "AppBoxPluginFactory.h" + +static std::shared_ptr g_manager; + +int web_provider_plugin_interface_initialize() +{ + LogD("enter"); + IBoxPluginFactoryPtr factory(new AppBoxPluginFactory()); + g_manager = AppBoxManager::create(factory); + + return 0; +} + +int web_provider_plugin_interface_command(const request_cmd_type type, const BoxInfoPtr& boxInfo) +{ + LogD("enter"); + int ret = g_manager->doCommand(type, boxInfo); + + if (!ret) { + return -1; + } + + return 0; +} + +int web_provider_plugin_interface_shutdown() +{ + LogD("enter"); + g_manager.reset(); + return 0; +} diff --git a/src_mobile/Plugin/BoxPluginConnector.cpp b/src_mobile/Plugin/BoxPluginConnector.cpp new file mode 100644 index 0000000..a0cc23a --- /dev/null +++ b/src_mobile/Plugin/BoxPluginConnector.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file BoxPluginConnector.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include +#include +#include +#include +#include +#include "box_plugin_interface.h" +#include "BoxPluginConnector.h" + +BoxPluginConnector::BoxPluginConnector() +{ +} + +BoxPluginConnector::~BoxPluginConnector() +{ +} + +bool BoxPluginConnector::initialize() +{ + LogD("enter"); + + int count; + web_provider_plugin_info** pluginList = NULL; + pluginList = web_provider_plugin_get_installed_list(&count); + + if (!pluginList) { + LogD("failed to get installed plugin's information"); + return false; + } + + if (count <= 0) { + LogD("There is no available livebox plugins"); + return false; + } + + m_pluginMap.clear(); + + // get information of installed plugin + LogD("get information of installed plugin"); + for (int i = 0; i < count; i++) { + if (!pluginList[i]) { + continue; + } + + LogD("plugin path: %s", pluginList[i]->path); + void* handle = dlopen(pluginList[i]->path, RTLD_LAZY); + if (!handle) { + LogD("failed to load plugin so: %s", dlerror()); + continue; + } + + std::shared_ptr pluginInfo(new plugin_interfaces); + + pluginInfo->handle = handle; + pluginInfo->service_boxid = NULL; + if (pluginList[i]->service_boxid) { + pluginInfo->service_boxid = strdup(pluginList[i]->service_boxid); + } + + pluginInfo->initialize = + reinterpret_cast( + dlsym(handle, WEB_PROVIDER_PLUGIN_INTERFACE_SYM_INITIALIZE)); + pluginInfo->command = + reinterpret_cast( + dlsym(handle, WEB_PROVIDER_PLUGIN_INTERFACE_SYM_COMMAND)); + pluginInfo->shutdown = + reinterpret_cast( + dlsym(handle, WEB_PROVIDER_PLUGIN_INTERFACE_SYM_SHUTDOWN)); + + if (!pluginInfo->initialize || !pluginInfo->command || + !pluginInfo->shutdown) + { + LogD("symbol for plugin interface is not found"); + continue; + } + + m_pluginMap[std::string(pluginList[i]->type)] = pluginInfo; + } + + // initialize plugins + for (auto it = m_pluginMap.begin(); + it != m_pluginMap.end(); ++it) + { + if (it->second) { + // TODO add exception or abnormal action on loading plugin + if (it->second->initialize() < 0) { + LogD("fail to intialize plugin"); + continue; + } + } + } + + // release information + LogD("release json data of plugins"); + web_provider_plugin_release_installed_list(pluginList, count); + + return true; +} + +bool BoxPluginConnector::shutdown() +{ + LogD("enter"); + // if needed, unload each plugin's DSO. + for (auto it = m_pluginMap.begin(); + it != m_pluginMap.end(); ++it) + { + if (it->second) { + it->second->shutdown(); + dlclose(it->second->handle); + } + } + + return true; +} + +bool BoxPluginConnector::requestCommand( + const request_cmd_type type, const BoxInfoPtr& boxInfo) +{ + LogD("enter"); + + // in case of request of resume all or pause all, all plugins should handle that. + if (type == REQUEST_CMD_RESUME_ALL || + type == REQUEST_CMD_PAUSE_ALL || + type == REQUEST_CMD_CHANGE_LANGUAGE) { + for (auto it = m_pluginMap.begin(); + it != m_pluginMap.end(); ++it) + { + if (it->second) { + it->second->command(type, boxInfo); + } + } + return true; + } + + const std::shared_ptr plugin = m_pluginMap[boxInfo->boxType]; + if (!plugin) { + LogD("not available livebox type"); + return false; + } + + int ret = plugin->command(type, boxInfo); + if (ret < 0) { + LogD("failed to request command"); + return false; + } + + return true; +} + +std::string BoxPluginConnector::getBoxType(const std::string& serviceBoxId) +{ + LogD("enter"); + + std::string type; + for (auto it = m_pluginMap.begin(); + it != m_pluginMap.end(); ++it) + { + if (it->second && it->second->service_boxid) { + if (serviceBoxId == it->second->service_boxid) { + LogD("service box id is matched!: %s", it->first.c_str()); + type = it->first; + break; + } + } + } + + return type; +} diff --git a/src_mobile/Plugin/BoxPluginConnector.h b/src_mobile/Plugin/BoxPluginConnector.h new file mode 100644 index 0000000..5ada8db --- /dev/null +++ b/src_mobile/Plugin/BoxPluginConnector.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file BoxPluginConnector.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef BOX_PLUGIN_CONNECTOR_H +#define BOX_PLUGIN_CONNECTOR_H + +#include +#include +#include "IBoxPluginConnector.h" +#include "box_plugin_interface.h" + +class BoxPluginConnector: public IBoxPluginConnector { + public: // IBoxPluginConnector + static IBoxPluginConnectorPtr create() + { + return IBoxPluginConnectorPtr(new BoxPluginConnector()); + }; + virtual bool initialize(); + virtual bool shutdown(); + virtual bool requestCommand( + const request_cmd_type type, const BoxInfoPtr& boxInfo); + virtual std::string getBoxType(const std::string& serviceBoxId); + virtual ~BoxPluginConnector(); + + private: + BoxPluginConnector(); + + // type definition + typedef std::map > pluginMap; + + pluginMap m_pluginMap; + +}; + +#endif // BOX_PLUGIN_CONNECTOR_H diff --git a/src_mobile/Plugin/CMakeLists.txt b/src_mobile/Plugin/CMakeLists.txt new file mode 100644 index 0000000..349ddb0 --- /dev/null +++ b/src_mobile/Plugin/CMakeLists.txt @@ -0,0 +1,67 @@ +# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Flora License, Version 1.1 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://floralicense.org/license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @author Yunchan Cho (yunchan.cho@samsung.com) + +SET(TARGET_NAME ${TARGET_PLUGIN}) +SET(DEPS ${TARGET_NAME}_DEPS) + +PKG_CHECK_MODULES(${DEPS} + evas + ewebkit2 + dlog + REQUIRED +) +ADD_DEFINITIONS(${${DEPS}_CFLAGS}) + +SET(SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/BoxPluginConnector.cpp +) + +SET(HEADERS + ${${DEPS}_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} +) +INCLUDE_DIRECTORIES(${HEADERS}) + +ADD_LIBRARY(${TARGET_NAME} STATIC ${SRCS}) + +SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + COMPILE_FLAGS -fPIC + LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both" +) + +SET_TARGET_PROPERTIES(${TARGET_NAME} + PROPERTIES + SOVERSION ${CMAKE_PROJECT_API_VERSION} + VERSION ${CMAKE_PROJECT_VERSION} +) + +TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${${DEPS}_LDFLAGS} "-ldl" + ${${DEPS}_LIBRARIES} +) + +INSTALL(TARGETS ${TARGET_NAME} + DESTINATION lib + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE +) + +GET_FILENAME_COMPONENT(CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) +INSTALL_FILE(IBoxPluginFactory.h include/${PROJECT_NAME}/${CURRENT_DIR_NAME}) +INSTALL_FILE(box_plugin_interface.h include/${PROJECT_NAME}/${CURRENT_DIR_NAME}) + +# openable plugins of web livebox +ADD_SUBDIRECTORY(AppBoxPlugin) diff --git a/src_mobile/Plugin/IBoxPluginConnector.h b/src_mobile/Plugin/IBoxPluginConnector.h new file mode 100644 index 0000000..3e94fb8 --- /dev/null +++ b/src_mobile/Plugin/IBoxPluginConnector.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file IBoxPluginConnector.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef I_BOX_PLUGIN_CONNECTOR_H +#define I_BOX_PLUGIN_CONNECTOR_H + +#include +#include +#include +#include "box_plugin_interface.h" + +class IBoxPluginConnector: Noncopyable { + public: + virtual bool initialize() = 0; + virtual bool shutdown() = 0; + virtual bool requestCommand( + const request_cmd_type type, const BoxInfoPtr& boxInfo) = 0; + virtual std::string getBoxType(const std::string& serviceBoxId) = 0; + virtual ~IBoxPluginConnector() {}; +}; + +typedef std::shared_ptr IBoxPluginConnectorPtr; + +#endif // I_BOX_PLUGIN_CONNECTOR_H diff --git a/src_mobile/Plugin/IBoxPluginFactory.h b/src_mobile/Plugin/IBoxPluginFactory.h new file mode 100644 index 0000000..bbcb1ec --- /dev/null +++ b/src_mobile/Plugin/IBoxPluginFactory.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file IBoxPluginFactory.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef I_BOX_PLUGIN_FACTORY_H +#define I_BOX_PLUGIN_FACTORY_H + +#include +#include +#include +#include + +// forward declaration +class IRenderView; +class IRenderBuffer; + +class IBoxPluginFactory { + public: + virtual std::shared_ptr createRenderView( + std::string boxId, std::string instanceId, + std::shared_ptr ewkContext) = 0; + + virtual std::shared_ptr createBoxRenderBuffer( + std::string boxId, std::string instanceId, + int width, int height, std::string data) = 0; + + virtual ~IBoxPluginFactory() {}; +}; + +typedef std::shared_ptr IBoxPluginFactoryPtr; + +#endif //I_BOX_PLUGIN_FACTORY_H diff --git a/src_mobile/Plugin/box_plugin_interface.h b/src_mobile/Plugin/box_plugin_interface.h new file mode 100644 index 0000000..9cc8a14 --- /dev/null +++ b/src_mobile/Plugin/box_plugin_interface.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file box_plugin_interface.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef BOX_PLUGIN_INTERFACE_H +#define BOX_PLUGIN_INTERFACE_H + +#include +#include + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + +#define WEB_PROVIDER_PLUGIN_INTERFACE_SYM_INITIALIZE "web_provider_plugin_interface_initialize" +#define WEB_PROVIDER_PLUGIN_INTERFACE_SYM_COMMAND "web_provider_plugin_interface_command" +#define WEB_PROVIDER_PLUGIN_INTERFACE_SYM_SHUTDOWN "web_provider_plugin_interface_shutdown" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + REQUEST_CMD_ADD_BOX, + REQUEST_CMD_REMOVE_BOX, + REQUEST_CMD_OPEN_PD, + REQUEST_CMD_CLOSE_PD, + REQUEST_CMD_RESIZE_BOX, + REQUEST_CMD_RESUME_BOX, + REQUEST_CMD_PAUSE_BOX, + REQUEST_CMD_RESUME_ALL, + REQUEST_CMD_PAUSE_ALL, + REQUEST_CMD_CHANGE_PERIOD, + REQUEST_CMD_UPDATE_BOX, + REQUEST_CMD_CHANGE_LANGUAGE +} request_cmd_type; + +// definition of interface function type +typedef int (*plugin_interface_func_initialize)(void); +typedef int (*plugin_interface_func_command)( + const request_cmd_type type, const BoxInfoPtr& boxInfo); +typedef int (*plugin_interface_func_shutdown)(void); + +typedef struct { + void* handle; + const char* service_boxid; + plugin_interface_func_initialize initialize; + plugin_interface_func_command command; + plugin_interface_func_shutdown shutdown; +} plugin_interfaces; + +// inteface functions that should be implemented by each plugin +EXPORT_API int web_provider_plugin_interface_initialize(); +EXPORT_API int web_provider_plugin_interface_command( + const request_cmd_type type, const BoxInfoPtr& boxInfo); +EXPORT_API int web_provider_plugin_interface_shutdown(); + +#ifdef __cplusplus +} +#endif + +#endif // BOX_PLUGIN_INTERFACE_H -- cgit v1.2.3