Fixed package manager doesn't receive signal for widget update failed.
authorSoyoung Kim <sy037.kim@samsung.com>
Wed, 12 Dec 2012 06:06:27 +0000 (15:06 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Wed, 12 Dec 2012 06:21:32 +0000 (15:21 +0900)
[Issue#] N/A
[Problem] package manager doesn't recevie message for version checking failed.
[Cause] didn't set up signal to package manager after version checking.
[Solution] set up signal after set package name.
[SCMRequest] N/A

src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h

index ce0026c..70ce1c0 100644 (file)
@@ -314,18 +314,30 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
 }
 
 bool JobWidgetInstall::setTizenId(
-        const WrtDB::ConfigParserData &configInfo, ConfigureResult result,
+        const WrtDB::ConfigParserData &configInfo,
+        const WidgetUpdateInfo &update,
         bool preload)
 {
+    using namespace PackageManager;
     regex_t reg;
     if(regcomp(&reg, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
         LogDebug("Regcomp failed");
     }
 
-    struct stat dirStat;
-
+    ConfigureResult result = checkWidgetUpdate(update);
     if(!!configInfo.tizenId) {
         LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
+        // send start signal of pkgmgr
+        PkgmgrSignalSingleton::Instance().setPkgname(
+                DPL::ToUTF8String(*(configInfo.tizenId)));
+        PkgmgrSignalSingleton::Instance().sendSignal(
+                PKGMGR_START_KEY,
+                PKGMGR_START_INSTALL);
+
+        if (result == ConfigureResult::Failed) {
+            return false;
+        }
+
         if ((regexec(&reg, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
              static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
             (checkTizenIdExist(DPL::ToUTF8String(*(configInfo.tizenId))) &&
@@ -358,6 +370,12 @@ bool JobWidgetInstall::setTizenId(
             m_installerContext.widgetConfig.pkgname = tizenId;
         }
         LogInfo("tizen_id name was generated by WRT: " << tizenId);
+        // send start signal of pkgmgr
+        PkgmgrSignalSingleton::Instance().setPkgname(DPL::ToUTF8String(
+                    *m_installerContext.widgetConfig.pkgname));
+        PkgmgrSignalSingleton::Instance().sendSignal(
+                PKGMGR_START_KEY,
+                PKGMGR_START_INSTALL);
     }
     regfree(&reg);
 
@@ -384,6 +402,27 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         const WidgetUpdateInfo &update,
         const std::string &tempPath)
 {
+
+    if (!setTizenId(configData, update, m_jobStruct.m_preload)) {
+        return ConfigureResult::Failed;
+    } else {
+        LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
+
+        configureWidgetLocation(widgetSource, tempPath);
+    }
+
+    // Init installer context
+    m_installerContext.installStep = InstallerContext::INSTALL_START;
+    m_installerContext.job = this;
+    m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
+    m_installerContext.widgetConfig.shareHref = std::string();
+
+    return ConfigureResult::Ok;
+}
+
+JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
+        const WidgetUpdateInfo &update)
+{
     LogInfo(
         "Widget install/update: incoming guid = '" <<
         update.incomingGUID << "'");
@@ -393,7 +432,6 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
 
     // Check policy
     WidgetUpdateMode::Type updateTypeCheckBit;
-    JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok;
 
     if (update.existingWidgetInfo.isExist == false) {
         LogInfo("Widget info does not exist");
@@ -430,7 +468,6 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
             } else {
                 LogInfo(
                     "Widget is already running. Policy is not update according to WAC");
-                LogInfo("Installation aborted: " << widgetSource);
 
                 return ConfigureResult::Failed;
             }
@@ -449,37 +486,12 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
                 WidgetUpdateMode::PolicyDirectoryForceInstall)
         {
             LogInfo("Whether widget policy allow proceed ok");
-            ret = ConfigureResult::Updated;
+            return ConfigureResult::Updated;
         }
         else
             return ConfigureResult::Failed;
     }
-
-    if (!setTizenId(configData, ret, m_jobStruct.m_preload)) {
-        return ConfigureResult::Failed;
-    } else {
-        using namespace PackageManager;
-        LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
-
-        configureWidgetLocation(widgetSource, tempPath);
-
-        // send start signal of pkgmgr
-        PkgmgrSignalSingleton::Instance().setPkgname(
-                    DPL::ToUTF8String(
-                        *m_installerContext.widgetConfig.pkgname));
-        PkgmgrSignalSingleton::Instance().sendSignal(
-                    PKGMGR_START_KEY,
-                    PKGMGR_START_INSTALL);
-    }
-
-    // Init installer context
-    m_installerContext.installStep = InstallerContext::INSTALL_START;
-    m_installerContext.job = this;
-    m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
-    m_installerContext.widgetConfig.shareHref = std::string();
-
-    // Return result
-    return ret;
+    return ConfigureResult::Ok;
 }
 
 WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
index ad8dedb..550214c 100644 (file)
@@ -72,7 +72,7 @@ class JobWidgetInstall :
             const OptionalWidgetVersion &existingVersion,
             const OptionalWidgetVersion &incomingVersion) const;
     bool setTizenId(const WrtDB::ConfigParserData &configInfo,
-                    ConfigureResult result,
+                    const WidgetUpdateInfo &update,
                     bool preload);
     void displayWidgetInfo();
     void configureWidgetLocation(const std::string & widgetPath,
@@ -85,6 +85,7 @@ class JobWidgetInstall :
     bool isDRMWidget(std::string widgetPath);
     bool DecryptDRMWidget(std::string widgetPath, std::string destPath);
     ConfigureResult PrePareInstallation(const std::string &widgetPath);
+    ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update);
 
   public:
     /**