X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fjobs%2Fwidget_uninstall%2Ftask_remove_files.cpp;h=7d501beffe756f12c70d4f59f4e3cfcfe1762b35;hb=ae944cb4e48008ab1a3991e91ab160a9451fe007;hp=5f661223ce4d8956ae6184642a7c75a1c7aa5c19;hpb=72544dac715065d25470b5292442d0d7afef5d41;p=framework%2Fweb%2Fwrt-installer.git diff --git a/src/jobs/widget_uninstall/task_remove_files.cpp b/src/jobs/widget_uninstall/task_remove_files.cpp index 5f66122..7d501be 100644 --- a/src/jobs/widget_uninstall/task_remove_files.cpp +++ b/src/jobs/widget_uninstall/task_remove_files.cpp @@ -48,12 +48,7 @@ TaskRemoveFiles::TaskRemoveFiles(UninstallerContext& context) : DPL::TaskDecl(this), m_context(context) { - if (!m_context.isExternalWidget) { - AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory); - } else { - AddStep(&TaskRemoveFiles::StepRemoveExternalWidget); - } - //AddStep(&TaskRemoveFiles::StepRemoveDesktop); + AddStep(&TaskRemoveFiles::StepRemoveInstallationDirectory); AddStep(&TaskRemoveFiles::StepRemoveManifest); AddStep(&TaskRemoveFiles::StepRemoveExternalLocations); AddStep(&TaskRemoveFiles::StepRemoveVconf); @@ -66,16 +61,32 @@ TaskRemoveFiles::~TaskRemoveFiles() void TaskRemoveFiles::StepRemoveInstallationDirectory() { LogInfo("StepRemoveInstallationDirectory started"); - - m_context.removeStarted = true; - std::string widgetDir = - m_context.locations->getPackageInstallationDir(); - if (!WrtUtilRemove(widgetDir)) { - LogWarning("Removing widget installation directory failed"); - } - std::string dataDir = m_context.locations->getUserDataRootDir(); - if (!WrtUtilRemove(dataDir)) { - LogWarning(dataDir + " is already removed"); + if (APP2EXT_SD_CARD != + app2ext_get_app_location(m_context.tzPkgid.c_str())) + { + LogDebug("Removing directory"); + m_context.removeStarted = true; + std::string widgetDir = + m_context.locations->getPackageInstallationDir(); + if (!WrtUtilRemove(widgetDir)) { + LogWarning("Removing widget installation directory failed"); + } + std::string dataDir = m_context.locations->getUserDataRootDir(); + if (!WrtUtilRemove(dataDir)) { + LogWarning(dataDir + " is already removed"); + } + } else { + LogDebug("Removing sdcard directory"); + Try { + WidgetInstallToExtSingleton::Instance().initialize(m_context.tzPkgid); + WidgetInstallToExtSingleton::Instance().uninstallation(); + WidgetInstallToExtSingleton::Instance().deinitialize(); + } + Catch(WidgetInstallToExt::Exception::ErrorInstallToExt) + { + Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception:: + RemoveFilesFailed); + } } m_context.job->UpdateProgress( UninstallerContext::UNINSTALL_REMOVE_WIDGETDIR, @@ -91,37 +102,6 @@ void TaskRemoveFiles::StepRemoveFinished() "Widget remove steps Finished"); } -void TaskRemoveFiles::StepRemoveDesktop() -{ - std::ostringstream desktopFile; - - desktopFile << GlobalConfig::GetUserWidgetDesktopPath() << "/"; - desktopFile << m_context.tzAppid << ".desktop"; - - unlink(desktopFile.str().c_str()); - - ail_appinfo_h ai = NULL; - ail_error_e ret; - - const char* package = m_context.tzAppid.c_str(); - LogDebug("ail delete : " << package); - - ret = ail_package_get_appinfo(package, &ai); - if (ai) { - ail_package_destroy_appinfo(ai); - } - - if (AIL_ERROR_OK == ret) { - if (0 > ail_desktop_remove(package)) { - LogWarning("Failed to remove ail information : " << package); - } - } - - m_context.job->UpdateProgress( - UninstallerContext::UNINSTALL_REMOVE_DESKTOP, - "Widget remove desktop Finished"); -} - void TaskRemoveFiles::StepRemoveManifest() { std::ostringstream manifest_name; @@ -144,57 +124,46 @@ void TaskRemoveFiles::StepRemoveManifest() void TaskRemoveFiles::StepRemoveExternalLocations() { - WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid)); - LogDebug("Removing external locations:"); - WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations(); - FOREACH(path, externalPaths) - { - 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)); + if (!m_context.removeAbnormal) { + WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid)); + LogDebug("Removing external locations:"); + WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations(); + FOREACH(path, externalPaths) + { + 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)); + } + } else if (WrtUtilDirExists(*path)) { + LogDebug(" -> " << *path); + if (!WrtUtilRemove(*path)) { + Throw( + Jobs::WidgetUninstall::TaskRemoveFiles::Exception:: + RemoveFilesFailed); + } + } else { + LogWarning(" -> " << *path << "(no such a path)"); } - } else if (WrtUtilDirExists(*path)) { - LogDebug(" -> " << *path); - if (!WrtUtilRemove(*path)) { - Throw( - Jobs::WidgetUninstall::TaskRemoveFiles::Exception:: - RemoveFilesFailed); - } - } else { - LogWarning(" -> " << *path << "(no such a path)"); } + dao.unregisterAllExternalLocations(); } - dao.unregisterAllExternalLocations(); } void TaskRemoveFiles::StepRemoveVconf() { - std::string key = - 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"); - } -} - -void TaskRemoveFiles::StepRemoveExternalWidget() -{ - Try { - WidgetInstallToExtSingleton::Instance().initialize(m_context.tzPkgid); - WidgetInstallToExtSingleton::Instance().uninstallation(); - WidgetInstallToExtSingleton::Instance().deinitialize(); - } - Catch(WidgetInstallToExt::Exception::ErrorInstallToExt) - { - Throw( - Jobs::WidgetUninstall::TaskRemoveFiles::Exception:: - RemoveFilesFailed); + if (!m_context.removeAbnormal) { + std::string key = + 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"); + } } } } //namespace WidgetUninstall