-/*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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 task_livebox_conf.cpp
- * @author Tomasz Iwanek (t.iwanek@samsung.com)
- * @version 1.0
- * @brief Livebox support task
- */
-
-#include "task_livebox_conf.h"
-
-#include <dpl/log/log.h>
-#include <dpl/string.h>
-#include <dpl/utils/wrt_utility.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/file_input.h>
-#include <dpl/file_output.h>
-#include <dpl/copy.h>
-#include <dpl/utils/wrt_utility.h>
-
-#include <widget_install_context.h>
-
-TaskLiveboxConf::TaskLiveboxConf(InstallerContext &inCont) :
- DPL::TaskDecl<TaskLiveboxConf>(this),
- m_context(inCont)
-{
- AddStep(&TaskLiveboxConf::StepConfigureLivebox);
-}
-
-void TaskLiveboxConf::StepConfigureLivebox()
-{
- const std::string confFile = getLiveboxConfiguration();
- const std::string liveboxDir = std::string("/opt/live/")
- + DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
- const std::string destination = liveboxDir + "/etc/";
- const std::string targetFile = destination + getLiveboxConfigurationFile();
-
- if(WrtUtilFileExists(confFile))
- {
- WrtUtilMakeDir(destination);
-
- LogDebug("Registering widget's livebox directory under /opt/live/");
- m_context.locations->registerExternalLocation(liveboxDir);
-
- LogInfo("Coping livebox configuration file: " << confFile << " -> " << targetFile);
- DPL::FileInput input(confFile);
- DPL::FileOutput output(targetFile);
- DPL::Copy(&input, &output);
- }
- else
- {
- LogInfo("No livebox configuration file: " << confFile);
- }
-}
-
-std::string TaskLiveboxConf::getLiveboxConfigurationDirectory() const
-{
- return m_context.locations->getSourceDir() + "/livebox/";
-}
-
-std::string TaskLiveboxConf::getLiveboxConfigurationFile() const
-{
- return DPL::ToUTF8String(*m_context.widgetConfig.pkgname) + ".conf";
-}
-
-std::string TaskLiveboxConf::getLiveboxConfiguration() const
-{
- return getLiveboxConfigurationDirectory() + getLiveboxConfigurationFile();
-}