diff options
author | Yunchan Cho <yunchan.cho@samsung.com> | 2013-03-25 10:04:25 +0900 |
---|---|---|
committer | Yunchan Cho <yunchan.cho@samsung.com> | 2013-03-27 23:10:32 +0900 |
commit | da735acf34550c03dae2d28ecc9bdd94e3286398 (patch) | |
tree | 85eb94c02ea3179de87a5a64e4f7d88d0697dcaf | |
parent | 09fe97c2d234a4367d51d119c06d1a992b0cb7cd (diff) | |
download | web-provider-da735acf34550c03dae2d28ecc9bdd94e3286398.tar.gz web-provider-da735acf34550c03dae2d28ecc9bdd94e3286398.tar.bz2 web-provider-da735acf34550c03dae2d28ecc9bdd94e3286398.zip |
[Release] livebox.web-provider-1.4
Change-Id: I0e35a61dbba376e3add66a2780abc8f12225f977
-rw-r--r-- | data/web_provider_db.sql | 1 | ||||
-rw-r--r-- | packaging/livebox.web-provider.spec | 2 | ||||
-rw-r--r-- | src/API/web_provider_livebox_info.cpp | 82 | ||||
-rw-r--r-- | src/API/web_provider_livebox_info.h | 9 | ||||
-rw-r--r-- | src/Core/BoxData.h | 2 | ||||
-rw-r--r-- | src/Daemon/BoxDaemonImpl.cpp | 15 | ||||
-rw-r--r-- | src/Daemon/BoxDaemonUtil.cpp | 68 | ||||
-rw-r--r-- | src/Daemon/BoxDaemonUtil.h | 35 | ||||
-rw-r--r-- | src/Daemon/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp | 13 |
10 files changed, 214 insertions, 15 deletions
diff --git a/data/web_provider_db.sql b/data/web_provider_db.sql index ee5c0aa..840db90 100644 --- a/data/web_provider_db.sql +++ b/data/web_provider_db.sql @@ -3,6 +3,7 @@ CREATE TABLE LiveboxInfo ( box_id TEXT not null, app_id TEXT not null, box_type TEXT not null, + auto_launch INT, PRIMARY KEY (box_id) , CHECK(1) ); COMMIT; diff --git a/packaging/livebox.web-provider.spec b/packaging/livebox.web-provider.spec index 4e47965..55ce494 100644 --- a/packaging/livebox.web-provider.spec +++ b/packaging/livebox.web-provider.spec @@ -1,6 +1,6 @@ Name: livebox.web-provider Summary: web framework for livebox -Version: 1.3 +Version: 1.4 Release: 1 Group: main/app License: Apache License, Version 2.0 diff --git a/src/API/web_provider_livebox_info.cpp b/src/API/web_provider_livebox_info.cpp index 04ceb06..cbc7687 100644 --- a/src/API/web_provider_livebox_info.cpp +++ b/src/API/web_provider_livebox_info.cpp @@ -66,10 +66,73 @@ const char* web_provider_livebox_get_box_type(const char* box_id) return box_type_dup; } -int web_provider_livebox_insert_box_type( +const char* web_provider_livebox_get_app_id(const char* box_id) +{ + if (!box_id) { + return NULL; + } + + std::shared_ptr<WebProviderDB> handle(new WebProviderDB()); + if (!handle->openDB()) { + return NULL; + } + + std::string query = "select * from " + infoTable + " where box_id = ?"; + if (!handle->setCommand(query, "s", box_id)) { + handle->closeDB(); + return NULL; + } + + if (!handle->executeCommand()) { + handle->closeDB(); + return NULL; + } + + const char* app_id = handle->getText(1); + const char* app_id_dup = NULL; + + if (app_id) { + app_id_dup = strdup(app_id); + } + + handle->closeDB(); + + return app_id_dup; +} + +int web_provider_livebox_get_auto_launch(const char* box_id) +{ + if (!box_id) { + return NULL; + } + + std::shared_ptr<WebProviderDB> handle(new WebProviderDB()); + if (!handle->openDB()) { + return NULL; + } + + std::string query = "select * from " + infoTable + " where box_id = ?"; + if (!handle->setCommand(query, "s", box_id)) { + handle->closeDB(); + return NULL; + } + + if (!handle->executeCommand()) { + handle->closeDB(); + return NULL; + } + + int autoLaunch = handle->getInt(3); + handle->closeDB(); + + return autoLaunch; +} + +int web_provider_livebox_insert_box_info( const char* box_id, const char* app_id, - const char* box_type) + const char* box_type, + int auto_launch) { if (!box_id || !app_id || !box_type) { return -1; @@ -81,9 +144,10 @@ int web_provider_livebox_insert_box_type( } std::string query = - "insert into " + infoTable + " (box_id, app_id, box_type) values (?,?,?)"; + "insert into " + infoTable + + " (box_id, app_id, box_type, auto_launch) values (?,?,?,?)"; - if (!handle->setCommand(query, "sss", box_id, app_id, box_type)) { + if (!handle->setCommand(query, "sssi", box_id, app_id, box_type, auto_launch)) { handle->closeDB(); return -1; } @@ -97,6 +161,14 @@ int web_provider_livebox_insert_box_type( return 0; } +int web_provider_livebox_insert_box_type( + const char* box_id, + const char* app_id, + const char* box_type) +{ + return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0); +} + int web_provider_livebox_delete_by_box_id(const char* box_id) { if (!box_id) { @@ -196,7 +268,7 @@ int web_provider_info_insert_box_type( const char* app_id, const char* box_type) { - return web_provider_livebox_insert_box_type(box_id, app_id, box_type); + return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0); } int web_provider_info_delete_by_box_id(const char* box_id) diff --git a/src/API/web_provider_livebox_info.h b/src/API/web_provider_livebox_info.h index 16cda1e..2797c5a 100644 --- a/src/API/web_provider_livebox_info.h +++ b/src/API/web_provider_livebox_info.h @@ -31,7 +31,14 @@ extern "C" { 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 int web_provider_livebox_insert_box_type( +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_insert_box_info( + const char* box_id, + const char* app_id, + const char* box_type, + int auto_launch); +DEPRECATED_API int web_provider_livebox_insert_box_type( const char* box_id, const char* app_id, const char* box_type); diff --git a/src/Core/BoxData.h b/src/Core/BoxData.h index 5457cbc..a43b437 100644 --- a/src/Core/BoxData.h +++ b/src/Core/BoxData.h @@ -33,7 +33,7 @@ struct BoxInfo int pdWidth; int pdHeight; int priority; - int period; + float period; std::string contentInfo; // initialization diff --git a/src/Daemon/BoxDaemonImpl.cpp b/src/Daemon/BoxDaemonImpl.cpp index fd56cc2..c37898c 100644 --- a/src/Daemon/BoxDaemonImpl.cpp +++ b/src/Daemon/BoxDaemonImpl.cpp @@ -29,6 +29,7 @@ #include <Plugin/IBoxPluginConnector.h> #include <Plugin/BoxPluginConnector.h> #include <API/web_provider_livebox_info.h> +#include "BoxDaemonUtil.h" #include "BoxDaemonImpl.h" #define MASTER_PROVIDER_PING_TIME 120.0f @@ -173,7 +174,7 @@ int BoxDaemonImpl::boxReCreateCallback(ProviderEventArgPtr arg, void* data) LogD("InstanceId: %s", info->instanceId.c_str()); LogD("width: %d", info->boxWidth); LogD("height: %d", info->boxHeight); - LogD("update period: %d", info->period); + LogD("update period: %f", info->period); LogD("--------------------------------------------"); JobInfo* jobInfo = new JobInfo(REQUEST_CMD_ADD_BOX, info, This); @@ -254,6 +255,18 @@ int BoxDaemonImpl::clickedCallback(ProviderEventArgPtr arg, void* data) { LogD("enter"); + BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data); + BoxInfoPtr info = This->initializeBoxInfo(arg); + if (!info) { + return -1; + } + + int flag = web_provider_livebox_get_auto_launch(info->boxId.c_str()); + if (!flag) { + return -1; + } + + BoxDaemonUtil::launchApplication(info->boxId, info->instanceId); return 0; } diff --git a/src/Daemon/BoxDaemonUtil.cpp b/src/Daemon/BoxDaemonUtil.cpp new file mode 100644 index 0000000..55add03 --- /dev/null +++ b/src/Daemon/BoxDaemonUtil.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 BoxDaemonUtil.cpp + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#include <string> +#include <app_service.h> +#include <Core/Util/Log.h> +#include <API/web_provider_livebox_info.h> +#include "BoxDaemonUtil.h" + +const std::string BoxDaemonUtil::boxIdKey("box-id"); +const std::string BoxDaemonUtil::instanceIdKey("instance-id"); + +bool BoxDaemonUtil::launchApplication(std::string& boxId, std::string& instanceId) +{ + 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 false; + } + + service_h handle = NULL; + int ret = SERVICE_ERROR_NONE; + + ret = service_create(&handle); + if (ret != SERVICE_ERROR_NONE && !handle) { + LogD("failed to create service"); + return false; + } + + ret = service_set_package(handle, appId); + if (ret != SERVICE_ERROR_NONE) { + LogD("failed to set package"); + service_destroy(handle); + return false; + } + + service_add_extra_data(handle, boxIdKey.c_str(), boxId.c_str()); + service_add_extra_data(handle, instanceIdKey.c_str(), instanceId.c_str()); + + ret = service_send_launch_request(handle, NULL, NULL); + if (ret != SERVICE_ERROR_NONE) { + LogD("failed to launch package"); + service_destroy(handle); + return false; + } + + service_destroy(handle); + LogD("success to launch app of %s", boxId.c_str()); + return true; +} diff --git a/src/Daemon/BoxDaemonUtil.h b/src/Daemon/BoxDaemonUtil.h new file mode 100644 index 0000000..b502c8d --- /dev/null +++ b/src/Daemon/BoxDaemonUtil.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 BoxDaemonUtil.h + * @author Yunchan Cho (yunchan.cho@samsung.com) + */ +#ifndef BOX_DAEMON_UTIL_H +#define BOX_DAEMON_UTIL_H + +#include <string> + +class BoxDaemonUtil { + public: + static bool launchApplication(std::string& boxId, std::string& instanceId); + + private: + static const std::string boxIdKey; + static const std::string instanceIdKey; + +}; + +#endif // BOX_DAEMON_UTIL_H diff --git a/src/Daemon/CMakeLists.txt b/src/Daemon/CMakeLists.txt index 6a49929..1ab7eaa 100644 --- a/src/Daemon/CMakeLists.txt +++ b/src/Daemon/CMakeLists.txt @@ -25,6 +25,7 @@ PKG_CHECK_MODULES(${DEPS} ecore-x provider livebox-service + capi-appfw-application dlog REQUIRED ) @@ -34,6 +35,7 @@ SET(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BoxDaemon.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BoxDaemonImpl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/BoxDaemonUtil.cpp ) SET(HEADERS diff --git a/src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp b/src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp index 9869c5b..be75a58 100644 --- a/src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp +++ b/src/Plugin/AppBoxPlugin/AppBoxRenderView.cpp @@ -28,6 +28,7 @@ #include <Core/View/IRenderView.h> #include <Core/View/IPdHelper.h> #include <Core/View/PdHelper.h> +#include <API/web_provider_livebox_info.h> #include <Core/Util/Log.h> #include "AppBoxObserver.h" #include "AppBoxRenderBuffer.h" @@ -203,15 +204,15 @@ void AppBoxRenderView::hidePd() std::string AppBoxRenderView::getAppId(std::string& boxId) { - // TODO more exact and safe parsing is needed - std::string temp = std::string(boxId); - int found = temp.find_last_of("."); - if (found == std::string::npos) { + 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(); } - temp.assign(temp, 0, found); - return temp; + return std::string(appId); } std::string AppBoxRenderView::getStartUrl(UrlType type, std::string& defaultParams) |