Implement hybrid webapplication installation
[platform/core/appfw/wgt-backend.git] / src / wgt / step / step_parse.cc
index ac36e10..392196e 100644 (file)
@@ -455,22 +455,22 @@ bool StepParse::LocateConfigFile() {
 common_installer::Step::Status StepParse::process() {
   if (!LocateConfigFile()) {
     LOG(ERROR) << "No config.xml";
-    return common_installer::Step::Status::ERROR;
+    return common_installer::Step::Status::MANIFEST_NOT_FOUND;
   }
 
   parser_.reset(new wgt::parse::WidgetConfigParser());
   if (!parser_->ParseManifest(config_)) {
     LOG(ERROR) << "[Parse] Parse failed. " <<  parser_->GetErrorMessage();
-    return common_installer::Step::Status::ERROR;
+    return common_installer::Step::Status::PARSE_ERROR;
   }
   if (check_start_file_) {
     if (!parser_->HasValidStartFile()) {
       LOG(ERROR) << parser_->GetErrorMessage();
-      return common_installer::Step::Status::ERROR;
+      return common_installer::Step::Status::PARSE_ERROR;
     }
     if (!parser_->HasValidServicesStartFiles()) {
       LOG(ERROR) << parser_->GetErrorMessage();
-      return common_installer::Step::Status::ERROR;
+      return common_installer::Step::Status::PARSE_ERROR;
     }
   }
 
@@ -479,7 +479,7 @@ common_installer::Step::Status StepParse::process() {
   if (!FillManifestX(manifest)) {
     LOG(ERROR) << "[Parse] Storing manifest_x failed. "
                <<  parser_->GetErrorMessage();
-    return common_installer::Step::Status::ERROR;
+    return common_installer::Step::Status::PARSE_ERROR;
   }
 
   // Copy data from ManifestData to InstallerContext
@@ -526,7 +526,8 @@ common_installer::Step::Status StepParse::process() {
   if (perm_info)
      permissions = perm_info->GetAPIPermissions();
 
-  std::unique_ptr<WgtBackendData> backend_data(new WgtBackendData());
+  WgtBackendData* backend_data =
+      static_cast<WgtBackendData*>(context_->backend_data.get());
 
   std::shared_ptr<const SettingInfo> settings_info =
       std::static_pointer_cast<const SettingInfo>(
@@ -535,8 +536,6 @@ common_installer::Step::Status StepParse::process() {
   if (settings_info)
     backend_data->settings.set(*settings_info);
 
-  context_->backend_data.set(backend_data.release());
-
   LOG(DEBUG) << " Read data -[ ";
   LOG(DEBUG) << "App id: " << info->id();
   LOG(DEBUG) << "  package     = " <<  info->package();
@@ -553,13 +552,16 @@ common_installer::Step::Status StepParse::process() {
   LOG(DEBUG) << "  ]-";
   LOG(DEBUG) << "]-";
 
+  // TODO(t.iwanek): In delta mode this step is running two times
+  if (context_->manifest_data.get())
+    pkgmgr_parser_free_manifest_xml(context_->manifest_data.get());
+
   context_->manifest_data.set(manifest);
   return common_installer::Step::Status::OK;
 }
 
 bool StepParse::Check(const boost::filesystem::path& widget_path) {
-  boost::filesystem::path config = widget_path;
-  config /= "config.xml";
+  boost::filesystem::path config = widget_path / "config.xml";
 
   LOG(DEBUG) << "config.xml path: " << config;