2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file BoxDaemonUtil.cpp
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
22 #include <app_service.h>
23 #include <Core/Util/Log.h>
24 #include <API/web_provider_livebox_info.h>
25 #include "BoxDaemonUtil.h"
27 const std::string BoxDaemonUtil::boxIdKey("box-id");
28 const std::string BoxDaemonUtil::instanceIdKey("instance-id");
30 bool BoxDaemonUtil::launchApplication(std::string& boxId, std::string& instanceId)
34 std::shared_ptr<const char> appId(web_provider_livebox_get_app_id(boxId.c_str()));
36 LogD("no appid of %s", boxId.c_str());
40 service_h handle = NULL;
41 int ret = SERVICE_ERROR_NONE;
43 ret = service_create(&handle);
44 if (ret != SERVICE_ERROR_NONE && !handle) {
45 LogD("failed to create service");
49 ret = service_set_package(handle, appId.get());
50 if (ret != SERVICE_ERROR_NONE) {
51 LogD("failed to set package");
52 service_destroy(handle);
56 service_add_extra_data(handle, boxIdKey.c_str(), boxId.c_str());
57 service_add_extra_data(handle, instanceIdKey.c_str(), instanceId.c_str());
59 ret = service_send_launch_request(handle, NULL, NULL);
60 if (ret != SERVICE_ERROR_NONE) {
61 LogD("failed to launch package");
62 service_destroy(handle);
66 service_destroy(handle);
67 LogD("success to launch app of %s", boxId.c_str());