2 * Copyright (c) 2012 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_livebox_conf.cpp
18 * @author Tomasz Iwanek (t.iwanek@samsung.com)
20 * @brief Livebox support task
23 #include "task_livebox_conf.h"
25 #include <dpl/log/log.h>
26 #include <dpl/string.h>
27 #include <dpl/utils/wrt_utility.h>
28 #include <dpl/wrt-dao-rw/widget_dao.h>
29 #include <dpl/file_input.h>
30 #include <dpl/file_output.h>
32 #include <dpl/utils/wrt_utility.h>
34 #include <widget_install_context.h>
36 TaskLiveboxConf::TaskLiveboxConf(InstallerContext &inCont) :
37 DPL::TaskDecl<TaskLiveboxConf>(this),
40 AddStep(&TaskLiveboxConf::StepConfigureLivebox);
43 void TaskLiveboxConf::StepConfigureLivebox()
45 const std::string confFile = getLiveboxConfiguration();
46 const std::string liveboxDir = std::string("/opt/live/")
47 + DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
48 const std::string destination = liveboxDir + "/etc/";
49 const std::string targetFile = destination + getLiveboxConfigurationFile();
51 if(WrtUtilFileExists(confFile))
53 WrtUtilMakeDir(destination);
55 LogDebug("Registering widget's livebox directory under /opt/live/");
56 m_context.locations->registerExternalLocation(liveboxDir);
58 LogInfo("Coping livebox configuration file: " << confFile << " -> " << targetFile);
59 DPL::FileInput input(confFile);
60 DPL::FileOutput output(targetFile);
61 DPL::Copy(&input, &output);
65 LogInfo("No livebox configuration file: " << confFile);
69 std::string TaskLiveboxConf::getLiveboxConfigurationDirectory() const
71 return m_context.locations->getSourceDir() + "/livebox/";
74 std::string TaskLiveboxConf::getLiveboxConfigurationFile() const
76 return DPL::ToUTF8String(*m_context.widgetConfig.pkgname) + ".conf";
79 std::string TaskLiveboxConf::getLiveboxConfiguration() const
81 return getLiveboxConfigurationDirectory() + getLiveboxConfigurationFile();