Fixed if there is no pkgid, widget installation failed.
authorSoyoung Kim <sy037.kim@samsung.com>
Tue, 5 Feb 2013 07:11:27 +0000 (16:11 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Wed, 6 Feb 2013 05:06:18 +0000 (14:06 +0900)
[Issue#] N/A
[Problem] widget installation failed
[Cause] there is a bug to process appid and pkgid.
[Solution] if there is no pkgid, extract pkgid from appid.
[SCMRequest] N/A

Change-Id: I876a265089bc3e544dc1cb79bbd207f1f0811d0e

src/jobs/widget_install/job_widget_install.cpp

index 3672c97..9ba67fc 100644 (file)
@@ -169,10 +169,10 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     m_installerContext.m_quiet = m_jobStruct.m_quiet;
 
     ConfigureResult result = PrePareInstallation(widgetPath);
-    m_installerContext.job->SetProgressFlag(true);
 
     if (result == ConfigureResult::Ok) {
         LogInfo("Configure installation succeeded");
+        m_installerContext.job->SetProgressFlag(true);
 
         AddTask(new TaskRecovery(m_installerContext));
 
@@ -217,6 +217,7 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     } else if (result == ConfigureResult::Updated) {
         LogInfo("Configure installation updated");
         LogInfo("Widget Update");
+        m_installerContext.job->SetProgressFlag(true);
         if (m_installerContext.widgetConfig.packagingType !=
                 WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
             m_installerContext.widgetConfig.packagingType !=
@@ -342,15 +343,11 @@ void JobWidgetInstall::setTizenId(
 
             m_installerContext.widgetConfig.tzPkgid = *configInfo.tizenPkgId;
         } else {
-            std::string appid = DPL::ToUTF8String(*configInfo.tizenAppId);
+            DPL::String appid = *configInfo.tizenAppId;
             if(appid.length() > PACKAGE_ID_LENGTH) {
                 m_installerContext.widgetConfig.tzPkgid =
-                    DPL::FromUTF8String(appid.substr(PACKAGE_ID_LENGTH));
-            } else {
-                m_installerContext.widgetConfig.tzPkgid =
-                    *configInfo.tizenAppId;
-            }
-            shouldMakeAppid = true;
+                    appid.substr(0, PACKAGE_ID_LENGTH);
+            } //else: this means appId is broken anyway
         }
     } else {
         shouldMakeAppid = true;
@@ -463,7 +460,8 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
              result != ConfigureResult::Updated))
     {
         //it is true when tizenId does not fit REG_TIZENID_PATTERN
-        LogError("tizen_id provided but not proper.");
+        LogError("tizen_id provided but not proper or pkgId directory exists");
+            //TODO(t.iwanek): appId is unique, what about installation of abcdefghij.test1 and abcdefghij.test2?
         regfree(&reg);
         return ConfigureResult::Failed;
     }