2 * Copyright (c) 2011 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 task_install_ospsvc.cpp
18 * @author Soyoung Kim (sy037.kim@samsung.com)
20 * @brief Implementation file for installer task install osp service
22 #include "task_install_ospsvc.h"
27 #include <pkgmgr/pkgmgr_parser.h>
28 #include <pkgmgr-info.h>
30 #include <dpl/log/log.h>
31 #include <dpl/errno_string.h>
32 #include <dpl/foreach.h>
33 #include <dpl/wrt-dao-ro/global_config.h>
34 #include <dpl/utils/bash_utils.h>
36 #include <widget_install/job_widget_install.h>
37 #include <widget_install/widget_install_context.h>
38 #include <widget_install/widget_install_errors.h>
40 using namespace WrtDB;
43 const int MAX_BUF_SIZE = 128;
44 const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/tpk -iv ";
48 namespace WidgetInstall {
49 TaskInstallOspsvc::TaskInstallOspsvc(InstallerContext& context) :
50 DPL::TaskDecl<TaskInstallOspsvc>(this),
53 AddStep(&TaskInstallOspsvc::StartStep);
54 AddStep(&TaskInstallOspsvc::StepInstallOspService);
55 AddStep(&TaskInstallOspsvc::EndStep);
58 void TaskInstallOspsvc::StepInstallOspService()
60 LogDebug("Step: installation for osp service");
62 std::ostringstream commStr;
63 commStr << OSP_INSTALL_STR << BashUtils::escape_arg(
64 m_context.locations->getPackageInstallationDir());
66 LogDebug("osp install command : " << commStr.str());
68 char readBuf[MAX_BUF_SIZE];
70 fd = popen(commStr.str().c_str(), "r");
72 LogError("Failed to installtion osp service");
73 ThrowMsg(Exceptions::InstallOspsvcFailed,
75 install osp service");
78 if (fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
80 LogError("Failed to installtion osp service.\
81 Inability of reading file.");
82 ThrowMsg(Exceptions::InstallOspsvcFailed,
84 install osp service");
86 LogDebug("return value : " << readBuf);
88 int result = atoi(readBuf);
90 ThrowMsg(Exceptions::InstallOspsvcFailed,
92 install osp service");
98 void TaskInstallOspsvc::StartStep()
100 LogDebug("--------- <TaskInstallOspsvc> : START ----------");
103 void TaskInstallOspsvc::EndStep()
105 m_context.job->UpdateProgress(
106 InstallerContext::INSTALL_INSTALL_OSPSVC,
107 "Installed Osp servcie");
109 LogDebug("--------- <TaskInstallOspsvc> : END ----------");
111 } //namespace WidgetInstall