tizen 2.4 release
[framework/web/wrt-installer.git] / src / jobs / widget_uninstall / task_db_update.cpp
similarity index 64%
rename from src_wearable/jobs/widget_uninstall/task_db_update.cpp
rename to src/jobs/widget_uninstall/task_db_update.cpp
index 0c391fd..347b391 100755 (executable)
  * @brief   Implementation file for uninstaller task database updating
  */
 
-#ifdef DBOX_ENABLED
-#include <web_provider_livebox_info.h>
-#endif
+#include <dpl/platform.h>
 #include <widget_uninstall/task_db_update.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/widget_uninstall_errors.h>
+#if USE(WEB_PROVIDER)
+#include <web_provider_widget_info.h>
+#endif
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <dpl/utils/wrt_utility.h>
-#include <dpl/utils/path.h>
-#include <ace_api_install.h>
 #include <dpl/assert.h>
-#include <ace-common/ace_api_common.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
-#include <installer_log.h>
+#include <boost/filesystem.hpp>
+#include <dpl/log/secure_log.h>
 
 using namespace WrtDB;
+namespace bf = boost::filesystem;
 
 namespace Jobs {
 namespace WidgetUninstall {
@@ -46,7 +45,7 @@ TaskDbUpdate::TaskDbUpdate(UninstallerContext& context) :
     AddStep(&TaskDbUpdate::StartStep);
     AddStep(&TaskDbUpdate::StepRemoveExternalLocations);
     AddStep(&TaskDbUpdate::StepDbUpdate);
-#ifdef DBOX_ENABLED
+#if USE(WEB_PROVIDER)
     AddStep(&TaskDbUpdate::StepLiveboxDBDelete);
 #endif
     AddStep(&TaskDbUpdate::EndStep);
@@ -61,7 +60,6 @@ void TaskDbUpdate::StepDbUpdate()
     {
         //TODO: widget handle should not be used any more
         FOREACH(it , m_context.tzAppIdList){
-            ace_unregister_widget(static_cast<ace_widget_handle_t>(WidgetDAOReadOnly::getHandle(*it)));
             WidgetDAO::unregisterWidget(*it);
         }
         _D("Unregistered widget successfully!");
@@ -74,16 +72,16 @@ void TaskDbUpdate::StepDbUpdate()
     }
 }
 
-#ifdef DBOX_ENABLED
+#if USE(WEB_PROVIDER)
 void TaskDbUpdate::StepLiveboxDBDelete()
 {
     FOREACH(it, m_context.tzAppIdList){
     int ret =
-            web_provider_livebox_delete_by_app_id(DPL::ToUTF8String(*it).c_str());
+            web_provider_widget_delete_by_app_id(DPL::ToUTF8String(*it).c_str());
 
-    if (ret < 0) {
-        _D("failed to delete box info");
-    } else {
+        if (ret < 0) {
+            _D("failed to delete box info");
+        } else {
             _D("delete box info: %s", it);
         }
     }
@@ -99,26 +97,16 @@ void TaskDbUpdate::StepRemoveExternalLocations()
             WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
             FOREACH(file, externalPaths)
             {
-                DPL::Utils::Path path(*file);
-                if(path.Exists()){
-                    if(path.IsFile()){
-                        _D("  -> %s", path.Fullpath().c_str());
-                        Try {
-                            DPL::Utils::Remove(path);
-                        } Catch(DPL::Utils::Path::BaseException){
-                            _E("Failed to remove the file: %s", path.Fullpath().c_str());
-                        }
-                    } else if (path.IsDir()){
-                        _D("  -> %s", path.Fullpath().c_str());
-                        Try {
-                            DPL::Utils::Remove(path);
-                        } Catch(DPL::Utils::Path::BaseException){
-                            Throw(Jobs::WidgetUninstall::TaskDbUpdate::
-                                Exception::RemoveFilesFailed);
-                        }
+                bf::path path(*file);
+                try {
+                    if(bf::exists(path)){
+                        JobWidgetUninstall::SecureRemove(path);
+                    } else {
+                        _W("  -> %s(no such a path)", path.c_str());
                     }
-                } else {
-                    _W("  -> %s(no such a path)", path.Fullpath().c_str());
+                } catch (const bf::filesystem_error& ex) {
+                    _E("Failed to remove the file: %s", path.c_str());
+                    Throw(Jobs::WidgetUninstall::TaskDbUpdate::Exception::RemoveFilesFailed);
                 }
             }
             dao.unregisterAllExternalLocations();
@@ -128,7 +116,7 @@ void TaskDbUpdate::StepRemoveExternalLocations()
 
 void TaskDbUpdate::StartStep()
 {
-    LOGD("--------- <TaskDbUpdate> : START ----------");
+    LOGI("--------- <TaskDbUpdate> : START ----------");
 }
 
 void TaskDbUpdate::EndStep()
@@ -137,7 +125,7 @@ void TaskDbUpdate::EndStep()
         UninstallerContext::UNINSTALL_DB_UPDATE,
         "Widget DB Update Finished");
 
-    LOGD("--------- <TaskDbUpdate> : END ----------");
+    LOGI("--------- <TaskDbUpdate> : END ----------");
 }
 } //namespace WidgetUninstall
 } //namespace Jobs