summaryrefslogtreecommitdiff
path: root/src_mobile/Daemon/BoxDaemonUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src_mobile/Daemon/BoxDaemonUtil.cpp')
-rw-r--r--src_mobile/Daemon/BoxDaemonUtil.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src_mobile/Daemon/BoxDaemonUtil.cpp b/src_mobile/Daemon/BoxDaemonUtil.cpp
new file mode 100644
index 0000000..00668a3
--- /dev/null
+++ b/src_mobile/Daemon/BoxDaemonUtil.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 BoxDaemonUtil.cpp
+ * @author Yunchan Cho (yunchan.cho@samsung.com)
+ */
+#include <string>
+#include <memory>
+#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");
+
+ std::shared_ptr<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.get());
+ 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;
+}