2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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)
21 #include <app_service.h>
22 #include <Core/Util/Log.h>
23 #include <API/web_provider_livebox_info.h>
24 #include "BoxDaemonUtil.h"
26 const std::string BoxDaemonUtil::boxIdKey("box-id");
27 const std::string BoxDaemonUtil::instanceIdKey("instance-id");
29 bool BoxDaemonUtil::launchApplication(std::string& boxId, std::string& instanceId)
33 const char* appId = web_provider_livebox_get_app_id(boxId.c_str());
35 LogD("no appid of %s", boxId.c_str());
39 service_h handle = NULL;
40 int ret = SERVICE_ERROR_NONE;
42 ret = service_create(&handle);
43 if (ret != SERVICE_ERROR_NONE && !handle) {
44 LogD("failed to create service");
48 ret = service_set_package(handle, appId);
49 if (ret != SERVICE_ERROR_NONE) {
50 LogD("failed to set package");
51 service_destroy(handle);
55 service_add_extra_data(handle, boxIdKey.c_str(), boxId.c_str());
56 service_add_extra_data(handle, instanceIdKey.c_str(), instanceId.c_str());
58 ret = service_send_launch_request(handle, NULL, NULL);
59 if (ret != SERVICE_ERROR_NONE) {
60 LogD("failed to launch package");
61 service_destroy(handle);
65 service_destroy(handle);
66 LogD("success to launch app of %s", boxId.c_str());