[Release] wrt-installer_0.1.9
[framework/web/wrt-installer.git] / src / jobs / widget_uninstall / task_remove_files.cpp
index 2e120fe..ac26deb 100644 (file)
@@ -20,6 +20,7 @@
  * @brief   Implementation file for uninstaller task for removing widget files
  */
 
+#include <unistd.h>
 #include <widget_uninstall/task_remove_files.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/uninstaller_context.h>
@@ -37,7 +38,6 @@
 
 namespace Jobs {
 namespace WidgetUninstall {
-
 using namespace WrtDB;
 
 namespace {
@@ -61,8 +61,7 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) :
 }
 
 TaskRemoveFiles::~TaskRemoveFiles()
-{
-}
+{}
 
 void TaskRemoveFiles::StepRemoveInstallationDirectory()
 {
@@ -71,11 +70,11 @@ void TaskRemoveFiles::StepRemoveInstallationDirectory()
     m_context.removeStarted = true;
     std::string widgetDir =
         m_context.locations->getPackageInstallationDir();
-    if(!WrtUtilRemove(widgetDir)){
+    if (!WrtUtilRemove(widgetDir)) {
         LogWarning("Removing widget installation directory failed");
     }
     std::string dataDir = m_context.locations->getUserDataRootDir();
-    if(!WrtUtilRemove(dataDir)){
+    if (!WrtUtilRemove(dataDir)) {
         LogWarning(dataDir + " is already removed");
     }
     m_context.job->UpdateProgress(
@@ -107,13 +106,13 @@ void TaskRemoveFiles::StepRemoveDesktop()
     const char* package = m_context.tzAppid.c_str();
     LogDebug("ail delete : " << package);
 
-    ret = ail_package_get_appinfo(package, &ai);
+    ret = ail_get_appinfo(package, &ai);
     if (ai) {
-        ail_package_destroy_appinfo(ai);
+        ail_destroy_appinfo(ai);
     }
 
     if (AIL_ERROR_OK == ret) {
-        if ( 0 > ail_desktop_remove(package)) {
+        if (0 > ail_desktop_remove(package)) {
             LogWarning("Failed to remove ail information : " << package);
         }
     }
@@ -126,22 +125,19 @@ void TaskRemoveFiles::StepRemoveDesktop()
 void TaskRemoveFiles::StepRemoveManifest()
 {
     std::ostringstream manifest_name;
-    manifest_name << m_context.tzPkgid<< ".xml";
+    manifest_name << m_context.tzPkgid << ".xml";
     std::ostringstream destFile;
     destFile << "/opt/share/packages" << "/"; //TODO constant with path
     destFile << manifest_name.str();
-    int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(destFile.str().c_str(), NULL);
+    int ret1 = pkgmgr_parser_parse_manifest_for_uninstallation(
+            destFile.str().c_str(), NULL);
     int ret2 = unlink(destFile.str().c_str());
-    if(ret1 != 0)
-    {
+    if (ret1 != 0) {
         LogWarning("Manifest file failed to parse for uninstallation");
     }
-    if(ret2 != 0)
-    {
+    if (ret2 != 0) {
         LogWarning("No manifest file found: " << destFile.str());
-    }
-    else
-    {
+    } else {
         LogDebug("Manifest file removed: " << destFile.str());
     }
 }
@@ -153,23 +149,22 @@ void TaskRemoveFiles::StepRemoveExternalLocations()
     WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
     FOREACH(path, externalPaths)
     {
-        if(WrtUtilFileExists(*path))
-        {
+        if (WrtUtilFileExists(*path)) {
             LogDebug("  -> " << *path);
             int ret = remove(path->c_str());
             if (ret != 0) {
-                LogError("Failed to remove the file: " << path->c_str() << " with error: " << strerror(errno));
+                LogError(
+                    "Failed to remove the file: " << path->c_str() <<
+                    " with error: " << strerror(errno));
             }
-        }
-        else if(WrtUtilDirExists(*path))
-        {
+        } else if (WrtUtilDirExists(*path)) {
             LogDebug("  -> " << *path);
-            if(!WrtUtilRemove(*path)){
-                Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+            if (!WrtUtilRemove(*path)) {
+                Throw(
+                    Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+                        RemoveFilesFailed);
             }
-        }
-        else
-        {
+        } else {
             LogWarning("  -> " << *path << "(no such a path)");
         }
     }
@@ -179,8 +174,9 @@ void TaskRemoveFiles::StepRemoveExternalLocations()
 void TaskRemoveFiles::StepRemoveVconf()
 {
     std::string key =
-        WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.tzAppid));
-    if(vconf_unset_recursive(key.c_str())) {
+        WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.
+                                                                        tzAppid));
+    if (vconf_unset_recursive(key.c_str())) {
         LogError("Fail to unset vconf file");
     } else {
         LogDebug("vconf file is removed");
@@ -194,11 +190,12 @@ void TaskRemoveFiles::StepRemoveExternalWidget()
         WidgetInstallToExtSingleton::Instance().uninstallation();
         WidgetInstallToExtSingleton::Instance().deinitialize();
     }
-    Catch (WidgetInstallToExt::Exception::ErrorInstallToExt)
+    Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
     {
-        Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::RemoveFilesFailed);
+        Throw(
+            Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+                RemoveFilesFailed);
     }
 }
-
 } //namespace WidgetUninstall
 } //namespace Jobs