[Custom handler] Remove custom handlers during uninstall
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Tue, 18 Dec 2012 10:15:53 +0000 (11:15 +0100)
committerGerrit Code Review <gerrit2@kim11>
Mon, 7 Jan 2013 16:15:28 +0000 (01:15 +0900)
[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
src/CMakeLists.txt
src/jobs/widget_uninstall/job_widget_uninstall.cpp
src/jobs/widget_uninstall/task_remove_custom_handlers.cpp [new file with mode: 0644]
src/jobs/widget_uninstall/task_remove_custom_handlers.h [new file with mode: 0644]

index 1e54895..7220332 100644 (file)
@@ -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)
index 6da67e5..c07dbab 100644 (file)
@@ -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
index e6153ff..3cb8d82 100644 (file)
@@ -19,6 +19,7 @@
 #include <widget_uninstall/task_check.h>
 #include <widget_uninstall/task_db_update.h>
 #include <widget_uninstall/task_remove_files.h>
+#include <widget_uninstall/task_remove_custom_handlers.h>
 #include <widget_uninstall/task_smack.h>
 #include <widget_uninstall/task_uninstall_ospsvc.h>
 #include <widget_uninstall/task_delete_certificates.h>
@@ -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 (file)
index 0000000..5c020a9
--- /dev/null
@@ -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 <widget_uninstall/task_remove_custom_handlers.h>
+#include <widget_uninstall/uninstaller_context.h>
+#include <dpl/log/log.h>
+#include <dpl/optional_typedefs.h>
+#include <appsvc.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+#include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
+
+namespace Jobs {
+namespace WidgetUninstall {
+TaskRemoveCustomHandlers::TaskRemoveCustomHandlers(UninstallerContext& context) :
+    DPL::TaskDecl<TaskRemoveCustomHandlers>(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 (file)
index 0000000..c0812c1
--- /dev/null
@@ -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 <dpl/task.h>
+
+class UninstallerContext;
+
+namespace Jobs {
+namespace WidgetUninstall {
+class TaskRemoveCustomHandlers:
+    public DPL::TaskDecl<TaskRemoveCustomHandlers>
+{
+  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 */