From 07de4738131b81aba77df0ef2623649e81d6dbf7 Mon Sep 17 00:00:00 2001
From: Przemyslaw Ciezkowski
Date: Tue, 18 Dec 2012 11:15:53 +0100
Subject: [PATCH] [Custom handler] Remove custom handlers during uninstall
[Issue#] N/A
[Problem] Custom handlers are not removed when widget is uninstalled.
[Cause] N/A
[Solution] Added new job to uninstall process: remove from appsvc and
from custom handlers db.
[ScmRequest] wrt-commons
Depends on: https://tizendev.org/gerrit/#/c/22499/
[Verification] Install custom_handlers.wgt from manual tests
from wrt-extra. Run widget, register protocol and content handlers.
Uninstall widget. Check if widget is removed from database (wrt_custom_handlers.db
and appsvc.db)
Change-Id: I2c84086f47c7f9ffcfa80905d16d10148dc90d48
---
packaging/wrt-installer.spec | 1 +
src/CMakeLists.txt | 3 ++
src/jobs/widget_uninstall/job_widget_uninstall.cpp | 2 +
.../task_remove_custom_handlers.cpp | 55 ++++++++++++++++++++++
.../widget_uninstall/task_remove_custom_handlers.h | 45 ++++++++++++++++++
5 files changed, 106 insertions(+)
create mode 100644 src/jobs/widget_uninstall/task_remove_custom_handlers.cpp
create mode 100644 src/jobs/widget_uninstall/task_remove_custom_handlers.h
diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec
index 1e54895..7220332 100644
--- a/packaging/wrt-installer.spec
+++ b/packaging/wrt-installer.spec
@@ -10,6 +10,7 @@ Source0: %{name}-%{version}.tar.gz
Source100: wrt-preinstall-widgets.service
BuildRequires: cmake
BuildRequires: edje-tools
+BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(dpl-efl)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6da67e5..c07dbab 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -85,6 +85,7 @@ SET(INSTALLER_SOURCES
${INSTALLER_JOBS}/widget_uninstall/job_widget_uninstall.cpp
${INSTALLER_JOBS}/widget_uninstall/task_check.cpp
${INSTALLER_JOBS}/widget_uninstall/task_remove_files.cpp
+ ${INSTALLER_JOBS}/widget_uninstall/task_remove_custom_handlers.cpp
${INSTALLER_JOBS}/widget_uninstall/task_db_update.cpp
${INSTALLER_JOBS}/widget_uninstall/task_smack.cpp
${INSTALLER_JOBS}/widget_uninstall/task_uninstall_ospsvc.cpp
@@ -117,6 +118,7 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
dpl-utils-efl
dpl-wrt-dao-ro
dpl-wrt-dao-rw
+ wrt-commons-custom-handler-dao-rw
dpl-encryption
wrt-plugins-types
pkgmgr-installer
@@ -125,6 +127,7 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
)
PKG_CHECK_MODULES(SYS_INSTALLER_STATIC_DEP
+ appsvc
libxml-2.0
openssl
cert-svc-vcore
diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.cpp b/src/jobs/widget_uninstall/job_widget_uninstall.cpp
index e6153ff..3cb8d82 100644
--- a/src/jobs/widget_uninstall/job_widget_uninstall.cpp
+++ b/src/jobs/widget_uninstall/job_widget_uninstall.cpp
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -84,6 +85,7 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
}
AddTask(new TaskRemoveFiles(m_context));
AddTask(new TaskDbUpdate(m_context));
+ AddTask(new TaskRemoveCustomHandlers(m_context));
AddTask(new TaskDeleteCertificates(m_context));
// send start signal of pkgmgr
diff --git a/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp b/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp
new file mode 100644
index 0000000..5c020a9
--- /dev/null
+++ b/src/jobs/widget_uninstall/task_remove_custom_handlers.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 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_remove_custom_handlers.cpp
+ * @author Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
+ * @version 1.0
+ * @brief File for uninstaller - remove custom handlers
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace Jobs {
+namespace WidgetUninstall {
+TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) :
+ DPL::TaskDecl(this),
+ m_context(context)
+{
+ AddStep(&TaskRemoveCustomHandlers::Step);
+}
+
+void TaskRemoveCustomHandlers::Step()
+{
+ LogDebug("Removing widget from appsvc");
+ int result = appsvc_unset_defapp(m_context.pkgname.c_str());
+ LogDebug("Result: " << result);
+
+ CustomHandlerDB::Interface::attachDatabaseRW();
+ CustomHandlerDB::CustomHandlerDAO handlersDao(
+ DPL::FromASCIIString(m_context.pkgname));
+ handlersDao.removeWidgetProtocolHandlers();
+ handlersDao.removeWidgetContentHandlers();
+ CustomHandlerDB::Interface::detachDatabase();
+}
+
+} //namespace WidgetUninstall
+} //namespace Jobs
diff --git a/src/jobs/widget_uninstall/task_remove_custom_handlers.h b/src/jobs/widget_uninstall/task_remove_custom_handlers.h
new file mode 100644
index 0000000..c0812c1
--- /dev/null
+++ b/src/jobs/widget_uninstall/task_remove_custom_handlers.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 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_remove_custom_handlers.h
+ * @author Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
+ * @version 1.0
+ * @brief Header file for uninstaller - remove custom handlers
+ */
+#ifndef INSTALLER_CORE_JOBS_WIDGET_UNINSTALL_TASK_REMOVE_CUSTOM_HANDLERS_H
+#define INSTALLER_CORE_JOBS_WIDGET_UNINSTALL_TASK_REMOVE_CUSTOM_HANDLERS_H
+
+#include
+
+class UninstallerContext;
+
+namespace Jobs {
+namespace WidgetUninstall {
+class TaskRemoveCustomHandlers:
+ public DPL::TaskDecl
+{
+ private:
+ UninstallerContext& m_context;
+
+ void Step();
+
+ public:
+ TaskRemoveCustomHandlers(UninstallerContext& context);
+};
+} //namespace WidgetUninstall
+} //namespace Jobs
+
+#endif /* INSTALLER_CORE_JOBS_WIDGET_UNINSTALL_TASK_REMOVE_CUSTOM_HANDLERS_H */
--
2.7.4