WidgetHandle removal - part 2. Task order change
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 17 Oct 2012 09:26:57 +0000 (11:26 +0200)
committerTaejeong Lee <taejeong.lee@samsung.com>
Fri, 2 Nov 2012 07:12:33 +0000 (16:12 +0900)
[Issue#]       N/A
[Feature]      Removing widget handle usage from wrt-installer. Tasks are reordered to task_database be the last one
[Cause]        N/A
[Solution]     N/A
[Verification] Do follwing steps:
1. Install, uninstall, update any widget - use each option, listed in help.
2. Checks database content of WidgetInfo after installling several widgets. Database should contains autoincremented value of WidgetHandle value.
3. Run installed widgets as well after installing and reinstalling.
4. Install just one widget before and after appling change -> make dumps and compare them (echo ".dump" | sqlite3 /opt/dbspace/.wrt.db > dumps/dump.sql).
They should be almost equal - widgethandle value, schema of WidgetInfo, DB hash and sequence creation for WidgetInfo may differs.

[SCMRequest]   This change should be merged same time as following wrt-commons changes (change id given):
-   Ib82cbbf575d88a9ce764652fa65037a7b990340a

Change-Id: I05a81d43a97f2a490d490edf62a5ef874c3477f5

31 files changed:
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_database.cpp
src/jobs/widget_install/task_database.h
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_file_manipulation.h
src/jobs/widget_install/task_livebox_conf.cpp
src/jobs/widget_install/task_remove_backup.cpp
src/jobs/widget_install/task_remove_backup.h
src/jobs/widget_install/task_update_files.cpp
src/jobs/widget_install/task_update_files.h
src/jobs/widget_install/widget_install_context.h
src/jobs/widget_install/widget_update_info.cpp
src/jobs/widget_install/widget_update_info.h
src/jobs/widget_uninstall/job_widget_uninstall.cpp
src/jobs/widget_uninstall/job_widget_uninstall.h
src/jobs/widget_uninstall/task_check.cpp
src/jobs/widget_uninstall/task_db_update.cpp
src/jobs/widget_uninstall/task_remove_files.cpp
src/jobs/widget_uninstall/task_smack.cpp
src/jobs/widget_uninstall/task_uninstall_ospsvc.cpp
src/jobs/widget_uninstall/uninstaller_context.h
src/logic/installer_controller.cpp
src/logic/installer_controller.h
src/logic/installer_logic.cpp
src/logic/installer_logic.h
src/wrt-installer/wrt_installer.cpp
src/wrt-installer/wrt_installer.h
src/wrt-installer/wrt_installer_api.cpp
src/wrt-installer/wrt_installer_api.h

index ca3feb3..11e2b25 100755 (executable)
@@ -144,13 +144,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     struct timeval tv;
     gettimeofday(&tv, NULL);
     srand(time(NULL) + tv.tv_usec);
-    WrtDB::DbWidgetHandle handle;
-    do {
-        handle = rand() % INT_MAX + 1;
-        LogInfo("Random widget handle: " << handle);
-    } while (WidgetDAOReadOnly::isWidgetInstalled(handle));
 
-    m_installerContext.widgetHandle = handle;   //TODO: mvoe to wrt-commons (ace_widget_handle_t not int needed)
     m_installerContext.m_quiet = m_jobStruct.m_quiet;
 
     if(!browserRequest)
@@ -189,12 +183,11 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         if (needEncryption) {
             AddTask(new TaskEncryptResource(m_installerContext));
         }
-        AddTask(new TaskDatabase(m_installerContext)); //TODO: this should belast task (or almost)
         AddTask(new TaskFileManipulation(m_installerContext));
         // TODO: Update progress information for this task
 
         AddTask(new TaskPrivateStorage(m_installerContext));
-        AddTask(new TaskAceCheck(m_installerContext));
+
         //This is sort of quick solution, because ACE verdicts are based upon
         //data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
         //task.
@@ -210,6 +203,9 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         AddTask(new TaskLiveboxConf(m_installerContext));
 #endif
         AddTask(new TaskPluginsCopy(m_installerContext));
+
+        AddTask(new TaskDatabase(m_installerContext));
+        AddTask(new TaskAceCheck(m_installerContext));
     } else if (result == ConfigureResult::Updated) {
         LogInfo("Configure installation updated");
         LogInfo("Widget Update");
@@ -224,22 +220,28 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
 
         AddTask(new TaskCertify(m_installerContext));
         AddTask(new TaskUpdateFiles(m_installerContext));
-        AddTask(new TaskDatabase(m_installerContext)); //TODO: this should belast task (or almost)
 
         /* TODO : To backup file, save md5 values */
-        AddTask(new TaskAceCheck(m_installerContext));
         AddTask(new TaskSmack(m_installerContext));
 
         AddTask(new TaskManifestFile(m_installerContext));
-        AddTask(new TaskRemoveBackupFiles(m_installerContext));
         if (m_installerContext.widgetConfig.pType ==
                 PKG_TYPE_TIZEN_WITHSVCAPP) {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
+        AddTask(new TaskRemoveBackupFiles(m_installerContext));
 #ifdef LB_SUPPORT
         AddTask(new TaskLiveboxConf(m_installerContext));
 #endif
         AddTask(new TaskPluginsCopy(m_installerContext));
+
+        AddTask(new TaskDatabase(m_installerContext));
+
+        AddTask(new TaskAceCheck(m_installerContext));
+        //TODO: remove widgetHandle from this task and move before database task
+        // by now widget handle is needed in ace check
+        // Any error in acecheck while update will break widget
+
     } else if (result == ConfigureResult::Deferred) {
         // Installation is deferred
         LogInfo("Configure installation deferred");
@@ -270,9 +272,6 @@ std::string JobWidgetInstall::generateTizenId() {
 bool JobWidgetInstall::setTizenId(
         const WrtDB::ConfigParserData &configInfo, ConfigureResult result)
 {
-    Assert(!!m_installerContext.widgetHandle
-           && "Widget Handle should be initialized");
-
     regex_t reg;
     regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED);
     struct stat dirStat;
@@ -280,8 +279,9 @@ bool JobWidgetInstall::setTizenId(
         LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
         if ((regexec(&reg, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
              static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
-            (stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
-                   + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0))
+            ((stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+                   + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0)
+             && result != ConfigureResult::Updated))
         {
             //it is true when tizenId does not fit REG_TIZENID_PATTERN
             LogError("tizen_id provided but not proper.");
@@ -326,11 +326,6 @@ bool JobWidgetInstall::setTizenId(
     return true;
 }
 
-DPL::Optional<WidgetHandle> JobWidgetInstall::getNewWidgetHandle() const
-{
-    return m_installerContext.widgetHandle;
-}
-
 DPL::OptionalString JobWidgetInstall::getNewTizenId() const
 {
     return m_installerContext.widgetConfig.pkgname;
@@ -359,18 +354,16 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
 
     // Check policy
     WidgetUpdateMode::Type updateTypeCheckBit;
-    bool isUpdate = false;
     JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok;
 
     if (update.existingWidgetInfo.isExist == false) {
         LogInfo("Widget info does not exist");
         updateTypeCheckBit = WidgetUpdateMode::NotInstalled;
     } else {
-        LogInfo("Widget info exists. Handle: " <<
-                update.existingWidgetInfo.existingHandle);
+        LogInfo("Widget info exists. PkgName: " <<
+                update.existingWidgetInfo.pkgname);
 
-        DPL::OptionalString pkgname =
-            WidgetDAOReadOnly(update.existingWidgetInfo.existingHandle).getPkgname();
+        DPL::OptionalString pkgname = update.existingWidgetInfo.pkgname;
 
         if(pkgname.IsNull()) {
             LogInfo("But package name doesn't exist");
@@ -424,7 +417,6 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         return ConfigureResult::Failed;
     } else {
         using namespace PackageManager;
-        LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
         LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
 
         configureWidgetLocation(widgetSource, browserRequest);
@@ -582,7 +574,7 @@ WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
             widgetGUID,
             widgetVersion,
             WidgetUpdateInfo::ExistingWidgetInfo(
-                dao.getHandle(), dao.getVersion()));
+                *dao.getPkgname(), dao.getVersion()));
     }
     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
     {
@@ -666,14 +658,11 @@ void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
 
 void JobWidgetInstall::displayWidgetInfo()
 {
-    DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
-    Assert(!!handle);
-
-    WidgetDAOReadOnly dao(*handle);
+    WidgetDAOReadOnly dao(m_installerContext.locations->getPkgname());
 
     std::ostringstream out;
     WidgetLocalizedInfo localizedInfo =
-        W3CFileLocalization::getLocalizedInfo(*handle);
+        W3CFileLocalization::getLocalizedInfo(dao.getHandle()); //TODO: pkgname arg
 
     out << std::endl <<
         "===================================== INSTALLED WIDGET INFO ========="\
@@ -684,7 +673,7 @@ void JobWidgetInstall::displayWidgetInfo()
     out << std::endl << "Width:                       " << size.width;
     out << std::endl << "Height:                      " << size.height;
     out << std::endl << "Start File:                  " <<
-        W3CFileLocalization::getStartFile(*handle);
+        W3CFileLocalization::getStartFile(dao.getHandle()); //TODO: pkgname arg
     out << std::endl << "Version:                     " << dao.getVersion();
     out << std::endl << "Licence:                     " <<
         localizedInfo.license;
@@ -699,7 +688,7 @@ void JobWidgetInstall::displayWidgetInfo()
         dao.isDistributorSigned();
     out << std::endl << "Widget trusted:              " << dao.isTrusted();
 
-    OptionalWidgetIcon icon = W3CFileLocalization::getIcon(*handle);
+    OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getHandle()); //TODO: pkgname arg
     DPL::OptionalString iconSrc =
         !!icon ? icon->src : DPL::OptionalString::Null;
     out << std::endl << "Icon:                        " << iconSrc;
index 0cc096d..671f7fd 100644 (file)
@@ -86,7 +86,6 @@ class JobWidgetInstall :
     JobWidgetInstall(std::string const & widgetPath,
             const WidgetInstallationStruct &installerStruct);
 
-    DPL::Optional<WidgetHandle> getNewWidgetHandle() const;
     DPL::OptionalString getNewTizenId() const;
 
     //overrides
index a8a6a6e..616a1bd 100644 (file)
@@ -51,9 +51,9 @@ TaskAceCheck::TaskAceCheck(InstallerContext& context) :
 
 void TaskAceCheck::StepPrepareForAce()
 {
-    Assert(!!m_context.widgetHandle);
+    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
     m_context.featureLogic =
-        FeatureLogicPtr(new FeatureLogic(*m_context.widgetHandle));
+        FeatureLogicPtr(new FeatureLogic(dao.getHandle()));
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_ACE_PREPARE,
         "Widget Access Control Check Prepared");
@@ -61,7 +61,7 @@ void TaskAceCheck::StepPrepareForAce()
 
 void TaskAceCheck::StepAceCheck()
 {
-
+    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
     LogInfo("StepAceCheck!");
     // This widget does not use any device cap
     if (m_context.featureLogic->isDone()) {
@@ -74,12 +74,11 @@ void TaskAceCheck::StepAceCheck()
     LogInfo("StepAceCheck!");
     LogInfo("DevCap is : " << deviceCap);
 
-    Assert(!!m_context.widgetHandle);
     std::string devCapStr = DPL::ToUTF8String(deviceCap);
     ace_policy_result_t policyResult = ACE_DENY;
     ace_return_t ret = ace_get_policy_result(
             const_cast<const ace_resource_t>(devCapStr.c_str()),
-            *m_context.widgetHandle,
+            dao.getHandle(),
             &policyResult);
     if (ACE_OK != ret) {
         ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
@@ -95,6 +94,7 @@ void TaskAceCheck::StepAceCheck()
 
 void TaskAceCheck::StepProcessAceResponse()
 {
+    WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
     if (m_context.locations->browserRequest()) {
         return;
     }
@@ -126,7 +126,7 @@ void TaskAceCheck::StepProcessAceResponse()
             list.items[i].smack_granted =
                     devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
         }
-        ace_return_t ret = ace_set_requested_dev_caps(*(m_context.widgetHandle),  //TODO: (ace_widget_handle_t not int needed)
+        ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(),  //TODO: (ace_widget_handle_t not int needed)
                                                       &list);
         if (ACE_OK != ret) {
             ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
@@ -153,9 +153,7 @@ void TaskAceCheck::StepProcessAceResponse()
             i++;
         }
 
-        ret = ace_set_accepted_feature(
-          *(m_context.widgetHandle),
-          &featureList);
+        ret = ace_set_accepted_feature(dao.getHandle(), &featureList);
 
         delete [] featureList.items;
 
@@ -186,7 +184,7 @@ void TaskAceCheck::StepCheckAceResponse()
     for(;it != end; ++it){
         LogInfo("  |-  Feature: " << it->name << " has reject status: " << it->rejected);
         if (it->rejected) {
-            WrtDB::WidgetDAO dao(*(m_context.widgetHandle));
+            WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
             dao.updateFeatureRejectStatus(*it);
         }
     }
index 759112b..f861c85 100644 (file)
@@ -29,6 +29,7 @@
 //#include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/foreach.h>
+#include <dpl/utils/wrt_utility.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 //#include <dpl/wrt-dao-ro/global_config.h>
@@ -43,6 +44,7 @@ TaskDatabase::TaskDatabase(InstallerContext& context) :
     DPL::TaskDecl<TaskDatabase>(this),
     m_context(context)
 {
+    AddStep(&TaskDatabase::StepRegisterExternalFiles);
     AddStep(&TaskDatabase::StepDBInsert);
 
     AddAbortStep(&TaskDatabase::StepAbortDBInsert);
@@ -55,24 +57,28 @@ void TaskDatabase::StepDBInsert()
         /* Set install Time */
         time(&m_context.widgetConfig.installedTime);
 
-        LogInfo("Registering widget...");
-
-        WidgetDAO::registerWidget(
-                *(m_context.widgetHandle),
-                m_context.widgetConfig,
-                m_context.wacSecurity);
+        if (m_context.existingWidgetInfo.isExist) //update
+        {
+            LogInfo("Registering widget... (update)");
+            WidgetDAO::registerOrUpdateWidget(
+                    m_context.locations->getPkgname(),
+                    m_context.widgetConfig,
+                    m_context.wacSecurity);
+        }
+        else //new installation
+        {
+            LogInfo("Registering widget...");
+            WidgetDAO::registerWidget(
+                    m_context.locations->getPkgname(),
+                    m_context.widgetConfig,
+                    m_context.wacSecurity);
+        }
 
         FOREACH (cap, m_context.staticPermittedDevCaps) {
             LogInfo("staticPermittedDevCaps : " << cap->first
                     << " smack status: " << cap->second);
         }
 
-        Assert(!!m_context.widgetConfig.pkgname
-               && "pkgName should be initialized");
-
-        WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
-        widgetDao.setPkgName(m_context.widgetConfig.pkgname);
-
         LogInfo("Widget registered");
     }
     Catch(WidgetDAO::Exception::DatabaseError)
@@ -91,13 +97,54 @@ void TaskDatabase::StepDBInsert()
         "New Widget DB UPDATE Finished");
 }
 
+void TaskDatabase::StepRegisterExternalFiles()
+{
+    WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
+    if (m_context.existingWidgetInfo.isExist) //update
+    {
+        WidgetDAO dao(m_context.locations->getPkgname());
+        WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
+        LogDebug("Removing external files:");
+        FOREACH(file, externalLocationsDB)
+        {
+            if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
+            {
+                if(WrtUtilFileExists(*file))
+                {
+                    LogDebug("  -> " << *file);
+                    remove(file->c_str());
+                }
+                else if(WrtUtilDirExists(*file))
+                {
+                    LogDebug("  -> " << *file);
+                    if(!WrtUtilRemove(*file)){
+                        ThrowMsg(Exceptions::RemovingFolderFailure,
+                                "Failed to remove external directory");
+                    }
+                }
+                else
+                {
+                    LogWarning("  -> " << *file << "(no such a path)");
+                }
+            }
+        }
+    }
+    LogDebug("Registering external files:");
+    FOREACH(file, externalLocationsUpdate)
+    {
+        LogDebug("  -> " << *file);
+    }
+
+    //set external lcoations to be registered
+    m_context.widgetConfig.externalLocations = externalLocationsUpdate;
+}
+
 void TaskDatabase::StepAbortDBInsert()
 {
     LogWarning("[DB Update Task] Aborting... (DB Clean)");
-    Assert(!!m_context.widgetHandle);
     Try
     {
-        WidgetDAO::unregisterWidget(*m_context.widgetHandle); //TODO: unregister by pkgname (ace_widget_handle_t not int needed)
+        WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
 
         LogDebug("Cleaning DB successful!");
     }
index c0ff0eb..ce01985 100644 (file)
@@ -36,6 +36,7 @@ class TaskDatabase:
     InstallerContext& m_context;
 
     void StepDBInsert();
+    void StepRegisterExternalFiles();
 
     void StepAbortDBInsert();
 
index c240bc3..48abe91 100644 (file)
@@ -40,7 +40,6 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
 {
     AddStep(&TaskFileManipulation::StepCreateDirs);
     AddStep(&TaskFileManipulation::StepRenamePath);
-    AddStep(&TaskFileManipulation::StepRegisterExternalFiles);
 
     AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
 }
@@ -105,18 +104,6 @@ void TaskFileManipulation::StepRenamePath()
         "Widget Rename path Finished");
 }
 
-void TaskFileManipulation::StepRegisterExternalFiles()
-{
-    LogDebug("Registering external files:");
-    WrtDB::ExternalLocationList externalPaths = m_context.locations->listExternalLocations();
-    FOREACH(path, externalPaths)
-    {
-        LogDebug("  -> " << *path);
-    }
-    WidgetDAO dao(m_context.locations->getPkgname());
-    dao.registerExternalLocations(externalPaths);
-}
-
 void TaskFileManipulation::StepAbortRenamePath()
 {
     LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
index db567b7..162dbbf 100644 (file)
@@ -36,7 +36,6 @@ class TaskFileManipulation :
 
     void StepCreateDirs();
     void StepRenamePath();
-    void StepRegisterExternalFiles();
 
     void StepAbortRenamePath();
 
index 0e99c2c..cc20d76 100644 (file)
@@ -53,10 +53,7 @@ void TaskLiveboxConf::StepConfigureLivebox()
         WrtUtilMakeDir(destination);
 
         LogDebug("Registering widget's livebox directory under /opt/live/");
-        WrtDB::ExternalLocationList list;
-        list.push_back(liveboxDir);
-        WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
-        dao.registerExternalLocations(list);
+        m_context.locations->registerExternalLocation(liveboxDir);
 
         LogInfo("Coping livebox configuration file: " << confFile << " -> " << targetFile);
         DPL::FileInput input(confFile);
index f23ea70..bcf7317 100644 (file)
@@ -24,7 +24,6 @@
 #include <sys/stat.h>
 #include <string>
 #include <sstream>
-#include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/foreach.h>
 #include <dpl/log/log.h>
@@ -42,34 +41,9 @@ TaskRemoveBackupFiles::TaskRemoveBackupFiles(InstallerContext& context) :
     DPL::TaskDecl<TaskRemoveBackupFiles>(this),
     m_context(context)
 {
-    AddStep(&TaskRemoveBackupFiles::StepDeleteDB);
     AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
 }
 
-void TaskRemoveBackupFiles::StepDeleteDB()
-{
-    LogInfo("Delete old widget DB");
-    Try
-    {
-        // If there is existing model, remove its database data
-        if (true == m_context.existingWidgetInfo.isExist) {
-            WidgetHandle old = m_context.existingWidgetInfo.existingHandle;
-            LogInfo("Unregistering widget...: " << old);
-            WidgetDAO::unregisterWidget(old);
-            LogInfo("Widget unregistered");
-        }
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base)
-    {
-        LogError("Failed to clean up old widget DB!");
-        ReThrowMsg(Exceptions::RemoveBackupFailed, "Database failure!");
-    }
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_DELETE_OLD_DB,
-        "Backup widget db delete Finished");
-}
-
 void TaskRemoveBackupFiles::StepRemoveBackupFiles()
 {
     std::ostringstream backupDir;
index 639060b..b12cec7 100644 (file)
@@ -34,7 +34,6 @@ class TaskRemoveBackupFiles:
   private:
     InstallerContext& m_context;
 
-    void StepDeleteDB();
     void StepRemoveBackupFiles();
 
   public:
index 0ba0a07..30589a9 100644 (file)
@@ -37,7 +37,6 @@
 #include <widget_install/widget_install_errors.h>
 #include <widget_install/job_widget_install.h>
 
-#include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/exception.h>
 #include <dpl/errno_string.h>
@@ -62,7 +61,6 @@ TaskUpdateFiles::TaskUpdateFiles(InstallerContext& context) :
     AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
     AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
     AddStep(&TaskUpdateFiles::StepExecFileBackup);
-    AddStep(&TaskUpdateFiles::StepUpdateExternalFiles);
 
     AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
     AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
@@ -282,43 +280,5 @@ void TaskUpdateFiles::StepAbortCreateBackupFolder()
     }
 }
 
-void TaskUpdateFiles::StepUpdateExternalFiles()
-{
-    WidgetDAO dao(m_context.locations->getPkgname());
-    WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
-    WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
-    LogDebug("Removing external files:");
-    FOREACH(file, externalLocationsDB)
-    {
-        if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
-        {
-            if(WrtUtilFileExists(*file))
-            {
-                LogDebug("  -> " << *file);
-                remove(file->c_str());
-            }
-            else if(WrtUtilDirExists(*file))
-            {
-                LogDebug("  -> " << *file);
-                if(!WrtUtilRemove(*file)){
-                    ThrowMsg(Exceptions::RemovingFolderFailure,
-                            "Failed to remove external directory");
-                }
-            }
-            else
-            {
-                LogWarning("  -> " << *file << "(no such a path)");
-            }
-        }
-    }
-    dao.unregisterAllExternalLocations();
-    LogDebug("Registering(update) external files:");
-    FOREACH(file, externalLocationsUpdate)
-    {
-        LogDebug("  -> " << *file);
-    }
-    dao.registerExternalLocations(externalLocationsUpdate);
-}
-
 } //namespace WidgetInstall
 } //namespace Jobs
index c9e9806..b95e5c9 100644 (file)
@@ -44,7 +44,6 @@ class TaskUpdateFiles :
     void StepCreateBackupFolder();
     void StepResourceFilesBackup();
     void StepExecFileBackup();
-    void StepUpdateExternalFiles();
 
     void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
 
index 607505a..4fa010b 100755 (executable)
@@ -87,7 +87,6 @@ struct InstallerContext
 
     // Installation state variables
     WrtDB::WidgetRegisterInfo widgetConfig;      ///< WidgetConfigInfo
-    DPL::Optional<WrtDB::DbWidgetHandle> widgetHandle;
     DPL::Optional<WidgetLocation> locations;
     Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information.
     InstallStep installStep;              ///< current step of installation
index e0b124c..3e93084 100644 (file)
 #include "widget_update_info.h"
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo() :
-    isExist(false),
-    existingHandle(0)
+    isExist(false)
 {
 }
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
-    const WidgetHandle handle,
+    const WrtDB::WidgetPkgName & name,
     const DPL::Optional<WidgetVersion> &version) :
+    pkgname(name),
     isExist(true),
-    existingHandle(handle),
     existingVersion(version)
 {
 }
 
 WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
-    const WidgetHandle handle,
+    const WrtDB::WidgetPkgName & name,
     const DPL::Optional<DPL::String> &version) :
-    isExist(true),
-    existingHandle(handle)
+    pkgname(name),
+    isExist(true)
 {
     if (!!version) {
         existingVersion = WidgetVersion(*version);
index d08540e..9f10cb3 100644 (file)
@@ -34,14 +34,14 @@ struct WidgetUpdateInfo
 {
     struct ExistingWidgetInfo
     {
+        WrtDB::WidgetPkgName pkgname;
         bool isExist;
-        WidgetHandle existingHandle;
         DPL::Optional<WidgetVersion> existingVersion;
 
         ExistingWidgetInfo();
-        ExistingWidgetInfo(const WidgetHandle handle,
+        ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
                            const DPL::Optional<WidgetVersion> &version);
-        ExistingWidgetInfo(const WidgetHandle handle,
+        ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
                            const DPL::Optional<DPL::String> &version);
     };
 
index 08ab319..0bfc879 100644 (file)
@@ -55,22 +55,21 @@ 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;
 
     Try
     {
-        WrtDB::WidgetDAOReadOnly dao(widgetHandle);
-        m_context.pkgname = DPL::ToUTF8String(*dao.getPkgname());
+        WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(widgetPkgName));
         m_context.locations = WidgetLocation(m_context.pkgname);
 
         LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
@@ -98,11 +97,6 @@ JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
     }
 }
 
-WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
-{
-    return m_context.widgetHandle;
-}
-
 std::string JobWidgetUninstall::getRemovedTizenId() const
 {
     return m_context.pkgname;
index 77115b3..98cd62c 100644 (file)
@@ -47,12 +47,11 @@ class JobWidgetUninstall :
     /**
      * @brief Uninstaller must to know which widget to uninstall.
      *
-     * @param[in] const int& widget_id - wdget to uninstall
+     * @param[in] WrtDB::WidgetPkgName widgetPkgName - widget to uninstall
      */
-    JobWidgetUninstall(WidgetHandle widgetHandle,
+    JobWidgetUninstall(const std::string &widgetPkgName,
             const WidgetUninstallationStruct& uninstallerStruct);
 
-    WidgetHandle getRemovedWidgetHandle() const;
     std::string getRemovedTizenId() const;
     bool getRemoveStartedFlag() const;
     bool getRemoveFinishedFlag() const;
index 20f33af..8670ac5 100644 (file)
@@ -43,7 +43,7 @@ TaskCheck::~TaskCheck()
 
 void TaskCheck::StepUninstallPreCheck()
 {
-    LogInfo("Uninstall check for widget Handle: " << m_context.widgetHandle);
+    LogInfo("Uninstall check for pkgname: " << m_context.locations->getPkgname());
     //check if deferred
     //TODO if widget to be updated, then remove it from Deferred list?
 
@@ -64,7 +64,7 @@ void TaskCheck::StepUninstallPreCheck()
         //TODO or defer uninstall?
     }
 
-    LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
+    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.locations->getPkgname());
     m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK,
                                   "Uninstall pre-checking Finished");
 }
index 2b6bf76..b18feb0 100644 (file)
@@ -45,7 +45,7 @@ void TaskDbUpdate::StepDbUpdate()
 {
     Try
     {
-        WidgetDAO::unregisterWidget(m_context.widgetHandle);
+        WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
 
         LogDebug("Unregistered widget successfully!");
     }
index ea67ab0..2dfe92e 100644 (file)
@@ -130,7 +130,7 @@ void TaskRemoveFiles::StepRemoveManifest()
 
 void TaskRemoveFiles::StepRemoveExternalLocations()
 {
-    WidgetDAO dao(m_context.widgetHandle);
+    WidgetDAO dao(m_context.locations->getPkgname());
     LogDebug("Removing external locations:");
     WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
     FOREACH(path, externalPaths)
index 3db0319..c6c1a57 100644 (file)
@@ -42,7 +42,7 @@ void TaskSmack::Step()
     LogInfo("------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
 #ifdef WRT_SMACK_ENABLED
     try {
-      WrtDB::WidgetDAOReadOnly dao(m_context.widgetHandle);
+      WrtDB::WidgetDAOReadOnly dao(m_context.locations->getPkgname());
       DPL::OptionalString pkgName = dao.getPkgname();
       Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
       const char *devCap = "";
index f3c4824..187d958 100644 (file)
@@ -75,7 +75,7 @@ void TaskUninstallOspsvc::StepUninstallOspsvc()
 
     pclose(fd);
     
-    LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
+    LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.pkgname);
     m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC,
                                   "Uninstall OSP service finished");
 }
index 873852f..1aeb086 100644 (file)
@@ -48,8 +48,6 @@ struct UninstallerContext
         UNINSTALL_END
     };
 
-    WidgetHandle widgetHandle;
-
     ///< flag that indicates whether installer starts
     //to remove files.rStruct;
     bool removeStarted;
index 8026350..8995d33 100644 (file)
@@ -45,9 +45,9 @@ void InstallerController::OnEventReceived(
 void InstallerController::OnEventReceived(
         const InstallerControllerEvents::UninstallWidgetEvent &event)
 {
-    WidgetHandle widgetHandle = event.GetArg0();
+    std::string widgetPkgName = event.GetArg0();
     WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
-    m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
+    m_installerLogic.UninstallWidget(widgetPkgName, uninstallerStruct);
 }
 
 Eina_Bool InstallerController::AddNextStep(void *data)
index e611d0c..938e7ee 100644 (file)
@@ -55,7 +55,7 @@ DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct)
  * WidgetHandler is used to point witch widget shuld be uninstalled
  */
 DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent,
-                        WidgetHandle,
+                        std::string,
                         WidgetUninstallationStruct)
 
 /**
index aee7de8..2cd734e 100644 (file)
@@ -72,8 +72,7 @@ Jobs::JobHandle InstallerLogic::AddAndStartJob(Jobs::Job *job)
 
 //InstallWidget, UninstallWidget InstallPlugin method are almost the same
 // But each Job has different constructor, so creating new Job is specific
-// i.e. widgetHandle, path etc...
-Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
+Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath,
         const WidgetInstallationStruct &installerStruct)
 {
     LogDebug("New Widget Installation:");
@@ -84,13 +83,13 @@ Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
     return AddAndStartJob(job);
 }
 
-Jobs::JobHandle InstallerLogic::UninstallWidget(WidgetHandle widgetHandle,
+Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgName,
         const WidgetUninstallationStruct &uninstallerStruct)
 {
     LogDebug("New Widget Uninstallation");
 
     Jobs::Job *job =
-        new Jobs::WidgetUninstall::JobWidgetUninstall(widgetHandle,
+        new Jobs::WidgetUninstall::JobWidgetUninstall(widgetPkgName,
                                                       uninstallerStruct);
 
     return AddAndStartJob(job);
index 9314602..479313e 100644 (file)
@@ -51,10 +51,10 @@ class InstallerLogic
 
     void Terminate();
 
-    Jobs::JobHandle InstallWidget(std::string const & widgetPath,
+    Jobs::JobHandle InstallWidget(const std::string & widgetPath,
             const WidgetInstallationStruct &installerStruct);
 
-    Jobs::JobHandle UninstallWidget(WidgetHandle widgetHandle,
+    Jobs::JobHandle UninstallWidget(const std::string & widgetPkgName,
             const WidgetUninstallationStruct &uninstallerStruct);
 
     Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
index 98157b9..ba86072 100644 (file)
@@ -158,13 +158,6 @@ void WrtInstaller::OnCreate()
             m_packagePath = m_argv[2];
             m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
             AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-u" || arg == "--uninstall") {
-            if (m_argc != 3) {
-                return showHelpAndQuit();
-            }
-
-            m_handle = atoi(m_argv[2]);
-            AddStep(&WrtInstaller::uninstallStep);
         } else if (arg == "-un" || arg == "--uninstall-name") {
             if (m_argc != 3) {
                 return showHelpAndQuit();
@@ -277,14 +270,12 @@ void WrtInstaller::showHelpAndQuit()
            "install or update widget package for given path\n"
            "  -if,   --install-force                        "
            "install forcibly widget package for given path\n"
-           "  -u,    --uninstall                            "
-           "uninstall widget for given ID\n"
-           "  -un,   --uninstall for given package name     "
+           "  -un,   --uninstall-name                       "
            "uninstall widget for given package name\n"
            "  -ug,   --uninstall-guid                       "
-           "uninstall widget for given package path\n"
-           "  -up,   --uninstall-packagepath                "
            "uninstall widget for given Global Unique IDentifier\n"
+           "  -up,   --uninstall-packagepath                "
+           "uninstall widget for given package file path\n"
            "\n");
 
     Quit();
@@ -422,39 +413,23 @@ void WrtInstaller::installPluginsStep()
     }
 }
 
-void WrtInstaller::uninstallStep()
+void WrtInstaller::uninstallPkgNameStep()
 {
     LogDebug("Uninstalling widget ...");
-    wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+    LogDebug("Package name : " << m_name);
+    wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
             (!m_quiet || m_installByPkgmgr)
             ? &staticWrtUninstallProgressCallback : NULL);
 }
 
-void WrtInstaller::uninstallPkgNameStep()
-{
-    LogDebug("Uninstalling widget ...");
-    WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
-    if (status == WRT_SUCCESS) {
-        LogDebug("Get Widget Handle by package name : " << m_handle);
-        wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
-                (!m_quiet || m_installByPkgmgr)
-                ? &staticWrtUninstallProgressCallback : NULL);
-    } else {
-        printf("failed: can not uninstall widget\n");
-        LogError("Fail to uninstalling widget... ");
-        m_returnStatus = -1;
-        DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
-            WRTInstallerNS::QuitEvent());
-    }
-}
-
 void WrtInstaller::uninstallGuidStep()
 {
     LogDebug("Uninstalling widget ...");
-    WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
+    std::string pkgname;
+    WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
     if (status == WRT_SUCCESS) {
-        LogDebug("Get Widget Handle by guid : " << m_handle);
-        wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+        LogDebug("Guid : " << m_name);
+        wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
                 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
     } else {
         printf("failed: can not uninstall widget\n");
@@ -497,10 +472,11 @@ void WrtInstaller::unistallWgtFileStep()
 
         std::string guid = DPL::ToUTF8String(*widgetGUID);
 
-        WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
+        std::string pkgname;
+        WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
         if (status == WRT_SUCCESS) {
-            LogDebug("Get Widget Handle by guid : " << m_handle);
-            wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+            LogDebug("Pkgname from packagePath : " << pkgname);
+            wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
                     !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
         } else {
             LogError("Fail to uninstalling widget... ");
@@ -587,8 +563,7 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
     {
         resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
         printMsg = "installed";
-    } else if (current == &WrtInstaller::uninstallStep ||
-            current == &WrtInstaller::uninstallPkgNameStep ||
+    } else if (current == &WrtInstaller::uninstallPkgNameStep ||
             current == &WrtInstaller::uninstallGuidStep ||
             current == &WrtInstaller::unistallWgtFileStep)
     {
index d06092a..d6e2315 100644 (file)
@@ -99,7 +99,6 @@ class WrtInstaller :
     void installStep();
     void installNewPlugins();
     void installPluginsStep();
-    void uninstallStep();
     void uninstallPkgNameStep();
     void uninstallGuidStep();
     void unistallWgtFileStep();
index 2a3d48c..21fcc72 100755 (executable)
@@ -341,19 +341,20 @@ extern "C"
         UNHANDLED_EXCEPTION_HANDLER_END
     }
 
-    EXPORT_API void wrt_uninstall_widget(int widget_handle,
+    EXPORT_API void wrt_uninstall_widget(const char * const pkg_name,
                                          void* userdata,
                                          WrtInstallerStatusCallback status_cb,
                                          WrtProgressCallback progress_cb)
     {
         UNHANDLED_EXCEPTION_HANDLER_BEGIN
         {
-            LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
+            std::string widgetPkgName(pkg_name);
+            LogInfo("[WRT-API] UNINSTALL WIDGET: " << widgetPkgName);
             // Post uninstallation event
             CONTROLLER_POST_EVENT(
                 Logic::InstallerController,
                 InstallerControllerEvents::UninstallWidgetEvent(
-                    widget_handle,
+                    widgetPkgName,
                     WidgetUninstallationStruct(
                         InstallerCallbacksTranslate::uninstallFinishedCallback,
                         InstallerCallbacksTranslate::installProgressCallback,
@@ -576,43 +577,17 @@ extern "C"
         }
     }
 
-    EXPORT_API WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
-            int *widget_handle)
+    EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & pkgname,
+                                                   const std::string guid)
     {
         try
         {
-            LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
-                    << pkgname);
-
-            WidgetHandle handle = WidgetDAOReadOnly::getHandle(
-                    DPL::FromASCIIString(pkgname));
-            *widget_handle = static_cast<int>(handle);
-            return WRT_SUCCESS;
-        }
-        catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
-        {
-            LogError("Error package name is not found");
-            return WRT_ERROR_PKGNAME_NOT_FOUND;
-        }
-        catch (const DPL::Exception& ex)
-        {
-            LogError("Internal Error during get widget id by package name");
-            DPL::Exception::DisplayKnownException(ex);
-            return WRT_ERROR_INTERNAL;
-        }
-    }
-
-    EXPORT_API WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
-            int *widget_handle)
-    {
-        try
-        {
-            LogInfo("[WRT-API] GETTING WIDGET HANDLE BY WidgetID : "
+            LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
                     << guid);
 
             WidgetGUID widget_guid = DPL::FromUTF8String(guid);
-            WidgetHandle handle = WidgetDAOReadOnly::getHandle(widget_guid);
-            *widget_handle = static_cast<int>(handle);
+            WrtDB::WidgetDAOReadOnly dao(widget_guid);
+            pkgname = DPL::ToUTF8String(*dao.getPkgname());
             return WRT_SUCCESS;
         }
         catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
index 9bc7146..cd83c5b 100755 (executable)
@@ -234,15 +234,15 @@ void wrt_install_widget(const char *path,
         bool quiet);
 
 /**
- * @fn void wrt_installer_uninstall_widget (int widget_handle,
+ * @fn void wrt_installer_uninstall_widget (const char * const pkg_name,
  *                                void* userdata,
  *                                WrtInstallerStatusCallback cb)
- * @brief Uninstalls widget using its id
+ * @brief Uninstalls widget using its name
  *
- * This method is used to uninstall the widget specified by its handle.
+ * This method is used to uninstall the widget specified by its pkgname.
  * The callback function is called when the uninstall operation is done.
  *
- * @param [in]  widget_handle - widget id
+ * @param [in]  pkg_name    - package name
  * @param [in]  userdata    - user parameters to be passed to the callback
  * @param [in]  status_cb   - Call to this one will be done at the end of
  *                            operation
@@ -261,7 +261,7 @@ void wrt_install_widget(const char *path,
  *
  * @see wrt_installer_install_widget
  */
-void wrt_uninstall_widget (int widget_handle,
+void wrt_uninstall_widget (const char * const pkg_name,
         void* userdata,
         WrtInstallerStatusCallback status_cb,
         WrtProgressCallback progress_cb);
@@ -326,11 +326,13 @@ int wrt_installer_init_for_tests(void *userdata,
  */
 void wrt_installer_shutdown_for_tests();
 
-WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
-        int *widget_handle);
-
-WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
-        int *widget_handle);
+/**
+ * @brief wrt_get_widget_by_guid Returns pkgname by pkg guid (widgetId)
+ * @param pkgname pkgname argument ot be set
+ * @param guid guid that we look for
+ * @return error code
+ */
+WrtErrStatus wrt_get_widget_by_guid(std::string &pkgname, const std::string guid);
 #ifdef __cplusplus
 }
 #endif