[Release] wrt-installer_0.0.89
[framework/web/wrt-installer.git] / src / jobs / widget_uninstall / job_widget_uninstall.cpp
index fb55919..e6153ff 100644 (file)
@@ -13,6 +13,7 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
+
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
 #include <widget_uninstall/task_check.h>
@@ -20,7 +21,9 @@
 #include <widget_uninstall/task_remove_files.h>
 #include <widget_uninstall/task_smack.h>
 #include <widget_uninstall/task_uninstall_ospsvc.h>
+#include <widget_uninstall/task_delete_certificates.h>
 #include <pkg-manager/pkgmgr_signal.h>
+#include <app2ext_interface.h>
 
 using namespace WrtDB;
 
@@ -53,39 +56,42 @@ class UninstallerTaskFail :
 
 namespace Jobs {
 namespace WidgetUninstall {
-JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
+JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
         const WidgetUninstallationStruct &uninstallerStruct) :
     Job(Uninstallation),
     JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
 {
     using namespace PackageManager;
-    m_context.widgetHandle = widgetHandle;
     m_context.removeStarted = false;
     m_context.removeFinished = false;
     m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
     m_context.job = this;
+    m_context.pkgname = widgetPkgName;
+    m_context.isExternalWidget = getExternalWidgetFlag();
+
+    Try
+    {
+        WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(widgetPkgName));
+        m_context.locations = WidgetLocation(m_context.pkgname);
 
-    Try {
-        WrtDB::WidgetDAOReadOnly dao(widgetHandle);
-        m_context.pkgname = DPL::ToUTF8String(*dao.getPkgname());
         LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
 
         AddTask(new TaskSmack(m_context));
         AddTask(new TaskCheck(m_context));
 
-        if (dao.getPkgType() == PKG_TYPE_TIZEN_WITHSVCAPP) {
+        if (dao.getPackagingType() == PKG_TYPE_HYBRID_WEB_APP) {
             AddTask(new TaskUninstallOspsvc(m_context));
         }
         AddTask(new TaskRemoveFiles(m_context));
         AddTask(new TaskDbUpdate(m_context));
+        AddTask(new TaskDeleteCertificates(m_context));
 
         // send start signal of pkgmgr
-        if (PkgmgrSignalSingleton::Instance().setPkgname(m_context.pkgname)) {
-            PkgmgrSignalSingleton::Instance().sendSignal(
+        if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.pkgname)) {
+            getInstallerStruct().pkgmgrInterface->sendSignal(
                     PKGMGR_START_KEY,
                     PKGMGR_START_UNINSTALL);
         }
-
     } Catch (WidgetDAOReadOnly::Exception::WidgetNotExist) {
         AddTask(new UninstallerTaskFail(true));
     } Catch (WidgetDAOReadOnly::Exception::Base) {
@@ -93,9 +99,9 @@ JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
     }
 }
 
-WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
+std::string JobWidgetUninstall::getRemovedTizenId() const
 {
-    return m_context.widgetHandle;
+    return m_context.pkgname;
 }
 
 bool JobWidgetUninstall::getRemoveStartedFlag() const
@@ -117,7 +123,7 @@ void JobWidgetUninstall::SendProgress()
             // send progress signal of pkgmgr
             std::ostringstream percent;
             percent << static_cast<int>(GetProgressPercent());
-            PkgmgrSignalSingleton::Instance().sendSignal(
+            getInstallerStruct().pkgmgrInterface->sendSignal(
                         PKGMGR_PROGRESS_KEY,
                         percent.str());
 
@@ -133,13 +139,13 @@ void JobWidgetUninstall::SendFinishedSuccess()
 {
     using namespace PackageManager;
     // send signal of pkgmgr
-    PkgmgrSignalSingleton::Instance().sendSignal(
+    getInstallerStruct().pkgmgrInterface->sendSignal(
                 PKGMGR_END_KEY,
                 PKGMGR_END_SUCCESS);
 
     LogDebug("Call widget uninstall success finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-            getRemovedWidgetHandle(),Exceptions::Success);
+            getRemovedTizenId(),Exceptions::Success);
 }
 
 void JobWidgetUninstall::SendFinishedFailure()
@@ -149,13 +155,13 @@ void JobWidgetUninstall::SendFinishedFailure()
     LogError("Message: " << m_exceptionMessage);
 
     // send signal of pkgmgr
-    PkgmgrSignalSingleton::Instance().sendSignal(
+    getInstallerStruct().pkgmgrInterface->sendSignal(
                 PKGMGR_END_KEY,
                 PKGMGR_END_FAILURE);
 
     LogDebug("Call widget uninstall failure finishedCallback");
     getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
-        getRemovedWidgetHandle(), m_exceptionCaught); //TODO
+            getRemovedTizenId(), m_exceptionCaught); //TODO
     LogDebug("[JobWidgetUninstall] Asynchronous failure callback status sent");
 }
 
@@ -164,5 +170,17 @@ void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
     m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
     m_exceptionMessage = e.GetMessage();
 }
+
+bool JobWidgetUninstall::getExternalWidgetFlag() const
+{
+
+    LogDebug("Get external widget");
+    if (APP2EXT_SD_CARD == app2ext_get_app_location(m_context.pkgname.c_str())) {
+        LogDebug("This widget is in external stroage");
+        return true;
+    }
+    return false;
+}
+
 } //namespace WidgetUninstall
 } //namespace Jobs