Remove GUID and refactoring update mode
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_manifest_file.cpp
index 0c66504..a5124a0 100644 (file)
@@ -105,15 +105,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
     m_context(inCont),
     writer(NULL)
 {
-    if (false == m_context.existingWidgetInfo.isExist) {
-        AddStep(&TaskManifestFile::stepCopyIconFiles);
-        AddStep(&TaskManifestFile::stepCreateExecFile);
-        AddStep(&TaskManifestFile::stepGenerateManifest);
-        AddStep(&TaskManifestFile::stepParseManifest);
-        AddStep(&TaskManifestFile::stepFinalize);
-
-        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
-    } else {
+    if (m_context.isUpdateMode) {
         // for widget update.
         AddStep(&TaskManifestFile::stepBackupIconFiles);
         AddStep(&TaskManifestFile::stepCopyIconFiles);
@@ -122,6 +114,14 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         AddStep(&TaskManifestFile::stepUpdateFinalize);
 
         AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
+    } else {
+        AddStep(&TaskManifestFile::stepCopyIconFiles);
+        AddStep(&TaskManifestFile::stepCreateExecFile);
+        AddStep(&TaskManifestFile::stepGenerateManifest);
+        AddStep(&TaskManifestFile::stepParseManifest);
+        AddStep(&TaskManifestFile::stepFinalize);
+
+        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
     }
 }
 
@@ -142,7 +142,7 @@ void TaskManifestFile::stepCreateExecFile()
         if(error)
             LogPedantic("Failed to make a symbolic name for a file "
                     << "[" <<  DPL::GetErrnoString(error) << "]");
-        ThrowMsg(Exceptions::InstallationFailed,
+        ThrowMsg(Exceptions::FileOperationFailed,
                 "Symbolic link creating is not done.");
     }
     m_context.job->UpdateProgress(
@@ -461,7 +461,7 @@ void TaskManifestFile::getFileList(const char* path,
     DIR* dir = opendir(path);
     if (!dir) {
         LogError("icon directory doesn't exist");
-        ThrowMsg(Exceptions::InternalError, path);
+        ThrowMsg(Exceptions::FileOperationFailed, path);
     }
 
     struct dirent entry;
@@ -514,7 +514,7 @@ void TaskManifestFile::stepParseManifest()
 
     if (code != 0) {
         LogError("Manifest parser error: " << code);
-        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
     }
 
     // TODO : It will be removed. AIL update is temporary code request by pkgmgr
@@ -534,7 +534,7 @@ void TaskManifestFile::stepParseUpgradedManifest()
 
     if (code != 0) {
         LogError("Manifest parser error: " << code);
-        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
     }
 
     // TODO : It will be removed. AIL update is temporary code request by pkgmgr
@@ -582,6 +582,7 @@ void TaskManifestFile::writeManifest(const DPL::String & path)
     setAppCategory(uiApp);
     setLiveBoxInfo(manifest);
     setAccount(manifest);
+    setPrivilege(manifest);
 
     manifest.addUiApplication(uiApp);
     manifest.generate(path);
@@ -861,7 +862,7 @@ void TaskManifestFile::stepAbortParseManifest()
 
     if (0 != code) {
         LogWarning("Manifest parser error: " << code);
-        ThrowMsg(ManifestParsingError, "Parser returncode: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
     }
     int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
     if (0 != ret) {
@@ -898,10 +899,6 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
             liveBox.setPrimary(ConfigInfo->m_primary);
         }
 
-        if (ConfigInfo->m_autoLaunch == L"true") {
-            liveBox.setAutoLaunch(appid);
-        }
-
         if (ConfigInfo->m_updatePeriod != L"") {
             liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
         }
@@ -1023,5 +1020,20 @@ void TaskManifestFile::setAccount(Manifest& manifest)
     manifest.addAccount(accountInfo);
 }
 
+void TaskManifestFile::setPrivilege(Manifest& manifest)
+{
+    WrtDB::ConfigParserData::PrivilegeList privileges =
+        m_context.widgetConfig.configInfo.privilegeList;
+
+    PrivilegeType privilege;
+
+    FOREACH(it, privileges)
+    {
+        privilege.addPrivilegeName(it->name);
+    }
+
+    manifest.addPrivileges(privilege);
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs