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_delete_pkginfo.cpp
18 * @author Leerang Song(leerang.song@samsung.com)
20 * @brief Implementation file for uninstaller delete package information
24 #include <widget_uninstall/task_delete_pkginfo.h>
25 #include <widget_uninstall/job_widget_uninstall.h>
26 #include <widget_uninstall/widget_uninstall_errors.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <pkgmgr/pkgmgr_parser.h>
29 #include <dpl/assert.h>
30 #include <boost/filesystem.hpp>
31 #include <dpl/log/secure_log.h>
33 namespace bf = boost::filesystem;
36 namespace WidgetUninstall {
37 TaskDeletePkgInfo::TaskDeletePkgInfo(
38 UninstallerContext& context) :
39 DPL::TaskDecl<TaskDeletePkgInfo>(this),
42 AddStep(&TaskDeletePkgInfo::StartStep);
43 AddStep(&TaskDeletePkgInfo::StepDeletePkgInfo);
44 AddStep(&TaskDeletePkgInfo::EndStep);
47 void TaskDeletePkgInfo::StartStep()
49 LOGI("--------- <TaskDeletePkgInfo> : START ----------");
52 void TaskDeletePkgInfo::EndStep()
54 LOGI("--------- <TaskDeletePkgInfo> : END ----------");
57 void TaskDeletePkgInfo::StepDeletePkgInfo()
59 std::ostringstream manifest_name;
60 manifest_name << m_context.tzPkgid << ".xml";
61 bf::path pre_manifest("/usr/share/packages");
62 pre_manifest /= manifest_name.str();
64 if (!(bf::exists(m_context.manifestFile) == 0 && bf::exists(pre_manifest))) {
65 if (0 != pkgmgr_parser_parse_manifest_for_uninstallation(
66 m_context.manifestFile.c_str(), NULL)) {
67 _W("Manifest file failed to parse for uninstallation");
70 if (bf::remove_all(bf::path(m_context.manifestFile))) {
71 _D("Manifest file removed: %s", m_context.manifestFile.c_str());
73 _W("No manifest file found: %s", m_context.manifestFile.c_str());
75 } catch (const bf::filesystem_error& ex) {
76 _E("boost::filesystem::error: %s", ex.what());
79 } //namespace WidgetUninstall