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 task_delete_prelaunching_info.cpp
18 * @author Taejeong Lee (taejeong.lee@samsung.com)
20 * @brief Implementation file for uninstaller task for un-registration
21 * pre-launching webapp
24 #include "task_delete_prelaunching_info.h"
31 #include <dpl/exception.h>
32 #include <dpl/platform.h>
34 #include <widget_uninstall/job_widget_uninstall.h>
35 #include <widget_uninstall/uninstaller_context.h>
36 #include <widget_uninstall/widget_uninstall_errors.h>
37 #include <boost/filesystem.hpp>
39 namespace bf = boost::filesystem;
42 const char* const PRE_LAUNCHING_LIST_DIR = "/opt/usr/etc/wrt_launchpad_daemon/pre_launching_list";
46 namespace WidgetUninstall {
47 using namespace WrtDB;
49 TaskDeletePreLaunchingInfo::TaskDeletePreLaunchingInfo(UninstallerContext& context) :
50 DPL::TaskDecl<TaskDeletePreLaunchingInfo>(this),
52 m_flagWasDeleted(false)
54 AddStep(&TaskDeletePreLaunchingInfo::StartStep);
55 AddStep(&TaskDeletePreLaunchingInfo::StepDeletePreLaunchingInfoFile);
56 AddStep(&TaskDeletePreLaunchingInfo::EndStep);
58 AddAbortStep(&TaskDeletePreLaunchingInfo::StepAbortDeletePreLaunchingInfo);
61 void TaskDeletePreLaunchingInfo::StepAbortDeletePreLaunchingInfo()
63 _D("--------- <StepAbortDeletePreLaunchingInfo> : START ----------");
67 std::string appId = m_context.tzAppid;
68 std::string filePath = std::string(PRE_LAUNCHING_LIST_DIR) + "/" + appId;
71 if (!bf::exists(bf::path(filePath)))
73 std::ofstream(filePath);
75 } Catch (const std::exception& e) {
76 _E("Creating empty file failed : %s", filePath.c_str());
77 _E("Exception cought! %s", e.what());
79 catch (const bf::filesystem_error& ex){
80 _E("boost::filesystem::error: %s", ex.what());
83 if (chmod(filePath.c_str(), 0744) != 0 )
89 _D("--------- <StepAbortDeletePreLaunchingInfo> : END ----------");
93 void TaskDeletePreLaunchingInfo::StartStep()
95 _D("--------- <TaskDeletePreLaunchingInfo> : START ----------");
98 void TaskDeletePreLaunchingInfo::EndStep()
100 _D("--------- <TaskDeletePreLaunchingInfo> : END ----------");
103 void TaskDeletePreLaunchingInfo::StepDeletePreLaunchingInfoFile()
105 std::string appId = m_context.tzAppid;
106 bf::path filePath(std::string(PRE_LAUNCHING_LIST_DIR) + "/" + appId);
109 if (bf::exists(filePath))
111 JobWidgetUninstall::SecureRemove(filePath);
112 if(!bf::exists(filePath)){
113 m_flagWasDeleted = true;
117 _E("Deleted failed : \"%s\"", filePath.c_str());
122 _E("NOT exist! : \"%s\"", filePath.c_str());
124 } catch (const bf::filesystem_error& ex) {
125 _E("boost::filesystem::error: %s", ex.what());
129 } //namespace WidgetUninstall