Coding style
[platform/core/appfw/wgt-backend.git] / src / wgt / step / configuration / step_parse.cc
index 51c86ca..c15d8af 100644 (file)
@@ -8,7 +8,7 @@
 #include <boost/filesystem/path.hpp>
 
 #include <common/app_installer.h>
-#include <common/backup_paths.h>
+#include <common/paths.h>
 #include <common/installer_context.h>
 #include <common/step/step.h>
 #include <common/utils/glist_range.h>
 #include <wgt_manifest_handlers/background_category_handler.h>
 #include <wgt_manifest_handlers/category_handler.h>
 #include <wgt_manifest_handlers/content_handler.h>
+#include <wgt_manifest_handlers/ime_handler.h>
 #include <wgt_manifest_handlers/metadata_handler.h>
 #include <wgt_manifest_handlers/service_handler.h>
 #include <wgt_manifest_handlers/setting_handler.h>
 #include <wgt_manifest_handlers/tizen_application_handler.h>
 #include <wgt_manifest_handlers/widget_handler.h>
-#include <wgt_manifest_handlers/ime_handler.h>
+#include <wgt_manifest_handlers/w3c_pc_utils.h>
 
 #include <pkgmgr/pkgmgr_parser.h>
 
@@ -38,6 +39,7 @@
 #include <set>
 #include <string>
 #include <vector>
+#include <utility>
 
 #include "wgt/wgt_backend_data.h"
 
@@ -52,8 +54,12 @@ const char kCategoryWatchClock[] = "com.samsung.wmanager.WATCH_CLOCK";
 const std::string kManifestVersion = "1.0.0";
 const char kTizenPackageXmlNamespace[] = "http://tizen.org/ns/packages";
 const char kImeCategoryName[] = "http://tizen.org/category/ime";
+const char kDownloadableFontCategoryName[] =
+    "http://tizen.org/category/downloadable_font";
+const char kTTSCategoryName[] = "http://tizen.org/category/tts";
 
 const char kResWgt[] = "res/wgt";
+const char kConfigFileName[] = "config.xml";
 
 GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) {
   GList* list = nullptr;
@@ -68,6 +74,22 @@ GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) {
   return list;
 }
 
+void AppendWidgetMetadata(GList** metadatas,
+    const std::vector<std::pair<std::string, std::string>> metadata) {
+  GList* list = *metadatas;
+  for (auto& meta : metadata) {
+    metadata_x* new_meta =
+        static_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
+    new_meta->key = strdup(meta.first.c_str());
+    if (!meta.second.empty())
+      new_meta->value = strdup(meta.second.c_str());
+
+    list = g_list_append(list, new_meta);
+  }
+
+  *metadatas = list;
+}
+
 void SetApplicationXDefaults(application_x* application) {
   application->effectimage_type = strdup("image");
   application->enabled = strdup("true");
@@ -82,6 +104,7 @@ void SetApplicationXDefaults(application_x* application) {
   application->submode = strdup("false");
   application->support_disable = strdup("false");
   application->ui_gadget = strdup("false");
+  application->multiple = strdup("false");
 }
 
 template<typename T>
@@ -94,7 +117,6 @@ void AppendLabel(T* root, const std::string& label,
       strdup(locale.c_str()) : strdup(DEFAULT_LOCALE);
   root->label = g_list_append(root->label, label_item);
 }
-
 }  // namespace
 
 namespace wgt {
@@ -124,16 +146,7 @@ std::string StepParse::GetPackageVersion(
   std::string version = manifest_version.substr(0,
       manifest_version.find_first_not_of("1234567890."));
 
-  utils::VersionNumber version_number(version);
-
-  if (!version_number.IsValidTizenPackageVersion()) {
-    LOG(WARNING) << "Version number: " << manifest_version
-                 << " is not valid version number for tizen package. "
-                 << "Default value will be used.";
-    return kManifestVersion;
-  }
-
-  return version_number.ToString();
+  return version;
 }
 
 bool StepParse::FillInstallationInfo(manifest_x* manifest) {
@@ -146,33 +159,50 @@ bool StepParse::FillInstallationInfo(manifest_x* manifest) {
 }
 
 bool StepParse::FillIconPaths(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::TizenApplicationInfo> app_info =
-      std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
-          parser_->GetManifestData(app_keys::kTizenApplicationKey));
+  auto app_info =
+      GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+             app_keys::kTizenApplicationKey);
   if (!app_info) {
     LOG(ERROR) << "Application info manifest data has not been found.";
     return false;
   }
-  std::shared_ptr<const wgt::parse::ApplicationIconsInfo> icons_info =
-      std::static_pointer_cast<const wgt::parse::ApplicationIconsInfo>(
-          parser_->GetManifestData(app_keys::kIconsKey));
-  if (icons_info.get()) {
-    for (auto& application_icon : icons_info->icons()) {
-      icon_x* icon = reinterpret_cast<icon_x*> (calloc(1, sizeof(icon_x)));
-      bf::path icon_path = context_->root_application_path.get()
-          / app_info->package() / "res" / "wgt" / application_icon.path();
-      icon->text = strdup(icon_path.c_str());
+  auto icons_info =
+    GetManifestDataForKey<const wgt::parse::ApplicationIconsInfo>(
+           app_keys::kIconsKey);
+  if (!icons_info) {
+    icons_info.reset(new wgt::parse::ApplicationIconsInfo());
+  }
+  wgt::parse::LocalizedApplicationIconsInfo localized_list =
+      wgt::parse::GetLocalizedIconList(*icons_info, widget_path_);
+  // We need to generate icon for each locale and icons are already set into
+  // lookup order. There isn't said that all icons should be received from
+  // one <icon> tag position so we iterate utils we run out of icons creating
+  // any icon element that are possible for given locale.
+  std::set<std::string> found_locales;
+  for (auto& application_icon : localized_list) {
+    const std::string& locale = application_icon.locale();
+    if (found_locales.find(locale) != found_locales.end())
+      continue;
+    found_locales.insert(locale);
+
+    icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+    bf::path icon_path = context_->root_application_path.get()
+        / app_info->package() / "res" / "wgt" / application_icon.path();
+    icon->text = strdup(icon_path.c_str());
+    if (!locale.empty())
+      icon->lang = strdup(locale.c_str());
+    else
       icon->lang = strdup(DEFAULT_LOCALE);
-      manifest->icon = g_list_append(manifest->icon, icon);
-    }
+    manifest->icon = g_list_append(manifest->icon, icon);
   }
   return true;
 }
 
 bool StepParse::FillWidgetInfo(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::WidgetInfo> wgt_info =
-      std::static_pointer_cast<const wgt::parse::WidgetInfo>(
-          parser_->GetManifestData(app_keys::kWidgetKey));
+  auto wgt_info =
+      GetManifestDataForKey<const wgt::parse::WidgetInfo>(
+             app_keys::kWidgetKey);
+
   if (!wgt_info.get()) {
     LOG(ERROR) << "Widget info manifest data has not been found.";
     return false;
@@ -199,13 +229,16 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
   manifest->type = strdup("wgt");
   manifest->appsetting = strdup("false");
   manifest->nodisplay_setting = strdup("false");
-  manifest->preload = strdup("false");
+  if (context_->is_preload_request.get())
+    manifest->preload = strdup("true");
+  else
+    manifest->preload = strdup("false");
   manifest->installed_storage = strdup("installed_internal");
 
   // For wgt package use the long name
+  application_x* app =
+      reinterpret_cast<application_x*>(manifest->application->data);
   for (auto& item : wgt_info->name_set()) {
-    application_x* app =
-        reinterpret_cast<application_x*>(manifest->application->data);
     AppendLabel(app, item.second, item.first);
   }
 
@@ -219,10 +252,9 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
   author->lang = strdup(DEFAULT_LOCALE);
   manifest->author = g_list_append(manifest->author, author);
 
-  std::shared_ptr<const wgt::parse::SettingInfo> settings_info =
-      std::static_pointer_cast<const wgt::parse::SettingInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenSettingKey));
+  auto settings_info =
+      GetManifestDataForKey<const wgt::parse::SettingInfo>(
+             wgt::application_widget_keys::kTizenSettingKey);
   if (settings_info) {
     switch (settings_info->install_location()) {
     case wgt::parse::SettingInfo::InstallLocation::AUTO: {
@@ -246,20 +278,23 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
 }
 
 bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::TizenApplicationInfo> app_info =
-      std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
-          parser_->GetManifestData(app_keys::kTizenApplicationKey));
+  auto app_info =
+      GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+             app_keys::kTizenApplicationKey);
   if (!app_info) {
     LOG(ERROR) << "Application info manifest data has not been found.";
     return false;
   }
-  bool has_watch_catergory = false;
+  bool has_watch_category = false;
   bool has_ime = false;
-  std::shared_ptr<const wgt::parse::CategoryInfoList> category_info =
-      std::static_pointer_cast<const wgt::parse::CategoryInfoList>(
-          parser_->GetManifestData(app_keys::kTizenCategoryKey));
+  bool has_downloadable_font = false;
+  bool has_tts = false;
+  auto category_info =
+      GetManifestDataForKey<const wgt::parse::CategoryInfoList>(
+             app_keys::kTizenCategoryKey);
+
   if (category_info) {
-    has_watch_catergory = std::find_if(category_info->categories.begin(),
+    has_watch_category = std::find_if(category_info->categories.begin(),
                                        category_info->categories.end(),
                                        [](const std::string& category) {
       return category == kCategoryWearableClock ||
@@ -269,20 +304,38 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
                                        category_info->categories.end(),
                                        kImeCategoryName)
         != category_info->categories.end();
+    has_downloadable_font = std::find(category_info->categories.begin(),
+                                       category_info->categories.end(),
+                                       kDownloadableFontCategoryName)
+        != category_info->categories.end();
+    has_tts = std::find(category_info->categories.begin(),
+                                       category_info->categories.end(),
+                                       kTTSCategoryName)
+        != category_info->categories.end();
   }
 
   // application data
   application_x* application = reinterpret_cast<application_x*>(
       calloc(1, sizeof(application_x)));
   application->component_type =
-      has_watch_catergory ? strdup("watchapp") : strdup("uiapp");
+      has_watch_category ? strdup("watchapp") : strdup("uiapp");
   application->mainapp = strdup("true");
-  application->multiple = strdup("false");
   application->appid = strdup(app_info->id().c_str());
-  application->nodisplay = has_ime ? strdup("true") : strdup("false");
-  application->taskmanage = has_ime ? strdup("false") : strdup("true");
+  auto settings_info =
+      GetManifestDataForKey<const wgt::parse::SettingInfo>(
+             wgt::application_widget_keys::kTizenSettingKey);
+
+  bool no_display = settings_info ? settings_info->no_display() : false;
+  bool has_no_display_category =
+      has_watch_category || has_ime || has_tts || has_downloadable_font;
+
+  application->nodisplay = (has_no_display_category || no_display) ?
+      strdup("true") : strdup("false");
+  application->taskmanage = has_no_display_category ? strdup("false") :
+      strdup("true");
+
   SetApplicationXDefaults(application);
-  if (has_watch_catergory)
+  if (has_watch_category)
     application->ambient_support =
         strdup(app_info->ambient_support() ? "true" : "false");
   else
@@ -297,14 +350,14 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   application->autorestart = strdup("false");
 
   application->launch_mode = strdup(app_info->launch_mode().c_str());
-  if (manifest->icon) {
-    icon_x* icon = reinterpret_cast<icon_x*>(manifest->icon->data);
+  for (auto& icon : GListRange<icon_x*>(manifest->icon)) {
     icon_x* app_icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
     app_icon->text = strdup(icon->text);
     app_icon->lang = strdup(icon->lang);
     application->icon = g_list_append(application->icon, app_icon);
   }
-  manifest->application = g_list_append(manifest->application, application);
+  // guarantees that the main app will be at the begining of the list
+  manifest->application = g_list_insert(manifest->application, application, 0);
 
   manifest->package = strdup(app_info->package().c_str());
   manifest->mainapp_id = strdup(app_info->id().c_str());
@@ -312,9 +365,9 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
 }
 
 bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::ServiceList> service_list =
-      std::static_pointer_cast<const wgt::parse::ServiceList>(
-          parser_->GetManifestData(app_keys::kTizenServiceKey));
+  auto service_list =
+      GetManifestDataForKey<const wgt::parse::ServiceList>(
+             app_keys::kTizenServiceKey);
   if (!service_list)
     return true;
   for (auto& service_info : service_list->services) {
@@ -322,7 +375,6 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
         (calloc(1, sizeof(application_x)));
     application->component_type = strdup("svcapp");
     application->mainapp = strdup("false");
-    application->multiple = strdup("false");
     application->appid = strdup(service_info.id().c_str());
     application->exec =
         strdup((context_->root_application_path.get() / manifest->package
@@ -343,14 +395,14 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
     }
 
     if (!service_info.icon().empty()) {
+      bf::path icon_path = context_->root_application_path.get()
+          / manifest->package / "res" / "wgt" / service_info.icon();
       icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
-      icon->text = strdup(service_info.icon().c_str());
+      icon->text = strdup(icon_path.c_str());
       icon->lang = strdup(DEFAULT_LOCALE);
       application->icon = g_list_append(application->icon, icon);
     }
 
-    // TODO(t.iwanek): what about description, how is it different from name?
-
     for (auto& category : service_info.categories()) {
       application->category = g_list_append(application->category,
                                             strdup(category.c_str()));
@@ -371,10 +423,9 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
 }
 
 bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::AppWidgetInfo> appwidget_info =
-      std::static_pointer_cast<const wgt::parse::AppWidgetInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenAppWidgetFullKey));
+  auto appwidget_info =
+      GetManifestDataForKey<const wgt::parse::AppWidgetInfo>(
+             wgt::application_widget_keys::kTizenAppWidgetFullKey);
   if (!appwidget_info)
     return true;
   for (auto& app_widget : appwidget_info->app_widgets()) {
@@ -382,13 +433,12 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
         (calloc(1, sizeof(application_x)));
     application->component_type = strdup("widgetapp");
     application->mainapp = strdup("false");
-    application->multiple = strdup("false");
     application->appid = strdup(app_widget.id.c_str());
     application->exec =
         strdup((context_->root_application_path.get() / manifest->package
                 / "bin" / application->appid).c_str());
     application->type = strdup("webapp");
-    application->nodisplay = strdup("false");
+    application->nodisplay = strdup("true");
     application->taskmanage = strdup("false");
     SetApplicationXDefaults(application);
     application->ambient_support = strdup("false");
@@ -409,6 +459,9 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
       application->icon = g_list_append(application->icon, icon);
     }
 
+    if (!app_widget.metadata.empty())
+      AppendWidgetMetadata(&application->metadata, app_widget.metadata);
+
     manifest->application = g_list_append(manifest->application, application);
   }
   return true;
@@ -437,9 +490,9 @@ bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) {
 }
 
 bool StepParse::FillAppControl(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::AppControlInfoList> app_info_list =
-      std::static_pointer_cast<const wgt::parse::AppControlInfoList>(
-          parser_->GetManifestData(app_keys::kTizenApplicationAppControlsKey));
+  auto app_info_list =
+      GetManifestDataForKey<const wgt::parse::AppControlInfoList>(
+             app_keys::kTizenApplicationAppControlsKey);
 
   application_x* app =
       reinterpret_cast<application_x*>(manifest->application->data);
@@ -457,9 +510,9 @@ bool StepParse::FillAppControl(manifest_x* manifest) {
 }
 
 bool StepParse::FillPrivileges(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::PermissionsInfo> perm_info =
-      std::static_pointer_cast<const wgt::parse::PermissionsInfo>(
-          parser_->GetManifestData(app_keys::kTizenPermissionsKey));
+  auto perm_info =
+      GetManifestDataForKey<const wgt::parse::PermissionsInfo>(
+             app_keys::kTizenPermissionsKey);
   std::set<std::string> privileges;
   if (perm_info)
     privileges = ExtractPrivileges(perm_info);
@@ -472,9 +525,9 @@ bool StepParse::FillPrivileges(manifest_x* manifest) {
 }
 
 bool StepParse::FillCategories(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::CategoryInfoList> category_info =
-      std::static_pointer_cast<const wgt::parse::CategoryInfoList>(
-          parser_->GetManifestData(app_keys::kTizenCategoryKey));
+  auto category_info =
+      GetManifestDataForKey<const wgt::parse::CategoryInfoList>(
+             app_keys::kTizenCategoryKey);
   if (!category_info)
     return true;
 
@@ -488,9 +541,9 @@ bool StepParse::FillCategories(manifest_x* manifest) {
 }
 
 bool StepParse::FillMetadata(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::MetaDataInfo> meta_info =
-      std::static_pointer_cast<const wgt::parse::MetaDataInfo>(
-          parser_->GetManifestData(app_keys::kTizenMetaDataKey));
+  auto meta_info =
+      GetManifestDataForKey<const wgt::parse::MetaDataInfo>(
+             app_keys::kTizenMetaDataKey);
   if (!meta_info)
     return true;
 
@@ -505,19 +558,18 @@ bool StepParse::FillAppWidget() {
   WgtBackendData* backend_data =
       static_cast<WgtBackendData*>(context_->backend_data.get());
 
-  std::shared_ptr<const wgt::parse::AppWidgetInfo> appwidget_info =
-      std::static_pointer_cast<const wgt::parse::AppWidgetInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenAppWidgetFullKey));
+  auto appwidget_info =
+      GetManifestDataForKey<const wgt::parse::AppWidgetInfo>(
+             wgt::application_widget_keys::kTizenAppWidgetFullKey);
   if (appwidget_info)
     backend_data->appwidgets.set(*appwidget_info);
   return true;
 }
 
 bool StepParse::FillAccounts(manifest_x* manifest) {
-  std::shared_ptr<const wgt::parse::AccountInfo> account_info =
-      std::static_pointer_cast<const wgt::parse::AccountInfo>(
-          parser_->GetManifestData(app_keys::kAccountKey));
+  auto account_info =
+      GetManifestDataForKey<const wgt::parse::AccountInfo>(
+             app_keys::kAccountKey);
   if (!account_info)
     return true;
   common_installer::AccountInfo info;
@@ -536,8 +588,9 @@ bool StepParse::FillAccounts(manifest_x* manifest) {
 }
 
 bool StepParse::FillImeInfo() {
-  const auto ime_info = std::static_pointer_cast<const wgt::parse::ImeInfo>(
-      parser_->GetManifestData(app_keys::kTizenImeKey));
+  auto ime_info =
+      GetManifestDataForKey<const wgt::parse::ImeInfo>(
+             app_keys::kTizenImeKey);
   if (!ime_info)
     return true;
 
@@ -557,6 +610,7 @@ bool StepParse::FillExtraManifestInfo(manifest_x* manifest) {
 }
 
 bool StepParse::FillManifestX(manifest_x* manifest) {
+  // Fill data for main application
   if (!FillIconPaths(manifest))
     return false;
   if (!FillMainApplicationInfo(manifest))
@@ -573,18 +627,26 @@ bool StepParse::FillManifestX(manifest_x* manifest) {
     return false;
   if (!FillMetadata(manifest))
     return false;
-  // TODO(t.iwanek): fix adding ui application element
-  // for now adding application service is added here because rest of code
-  // assumes that there is one application at manifest->application
-  // so this must execute last. Don't move it above any item
-  if (!FillServiceApplicationInfo(manifest))
-    return false;
-  if (!FillWidgetApplicationInfo(manifest))
-    return false;
   if (!FillBackgroundCategoryInfo(manifest))
     return false;
+
+  // Fill data for other applications
+  if (!FillAdditionalApplications(manifest))
+    return false;
+
+  // Fill extra data, other than manifest_x structure
   if (!FillExtraManifestInfo(manifest))
     return false;
+
+  return true;
+}
+
+
+bool StepParse::FillAdditionalApplications(manifest_x* manifest) {
+  if (!FillServiceApplicationInfo(manifest))
+    return false;
+  if (!FillWidgetApplicationInfo(manifest))
+    return false;
   return true;
 }
 
@@ -619,19 +681,35 @@ common_installer::Step::Status StepParse::process() {
   }
 
   parser_.reset(new wgt::parse::WidgetConfigParser());
-  if (!parser_->ParseManifest(config_)) {
+  if (!parser_->ParseManifest(widget_path_ / kConfigFileName)) {
     LOG(ERROR) << "[Parse] Parse failed. " <<  parser_->GetErrorMessage();
     return common_installer::Step::Status::PARSE_ERROR;
   }
+
+  WgtBackendData* backend_data =
+    static_cast<WgtBackendData*>(context_->backend_data.get());
+
   if (check_start_file_) {
-    if (!parser_->HasValidStartFile()) {
+    if (!parser_->CheckValidStartFile()) {
       LOG(ERROR) << parser_->GetErrorMessage();
       return common_installer::Step::Status::PARSE_ERROR;
     }
-    if (!parser_->HasValidServicesStartFiles()) {
+    if (!parser_->CheckValidServicesStartFiles()) {
       LOG(ERROR) << parser_->GetErrorMessage();
       return common_installer::Step::Status::PARSE_ERROR;
     }
+  } else {
+    // making backup of content data and services content data
+    auto content_info =
+      GetManifestDataForKey<const wgt::parse::ContentInfo>(
+              wgt::application_widget_keys::kTizenContentKey);
+    auto service_list =
+      GetManifestDataForKey<const wgt::parse::ServiceList>(
+              wgt::application_widget_keys::kTizenServiceKey);
+    if (content_info)
+      backend_data->content.set(*content_info);
+    if (service_list)
+      backend_data->service_list.set(*service_list);
   }
 
   manifest_x* manifest =
@@ -643,14 +721,12 @@ common_installer::Step::Status StepParse::process() {
   }
 
   // Copy data from ManifestData to InstallerContext
-  std::shared_ptr<const wgt::parse::TizenApplicationInfo> info =
-      std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenApplicationKey));
-  std::shared_ptr<const wgt::parse::WidgetInfo> wgt_info =
-      std::static_pointer_cast<const wgt::parse::WidgetInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenWidgetKey));
+  auto info =
+      GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
+              wgt::application_widget_keys::kTizenApplicationKey);
+  auto wgt_info =
+      GetManifestDataForKey<const wgt::parse::WidgetInfo>(
+              wgt::application_widget_keys::kTizenWidgetKey);
 
   std::string name;
   const auto& name_set = wgt_info->name_set();
@@ -679,21 +755,16 @@ common_installer::Step::Status StepParse::process() {
     context_->recovery_info.get().recovery_file->WriteAndCommitFileContent();
   }
 
-  std::shared_ptr<const wgt::parse::PermissionsInfo> perm_info =
-      std::static_pointer_cast<const wgt::parse::PermissionsInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenPermissionsKey));
+  auto perm_info =
+      GetManifestDataForKey<const wgt::parse::PermissionsInfo>(
+              wgt::application_widget_keys::kTizenPermissionsKey);
   parser::PermissionSet permissions;
   if (perm_info)
      permissions = perm_info->GetAPIPermissions();
 
-  WgtBackendData* backend_data =
-      static_cast<WgtBackendData*>(context_->backend_data.get());
-
-  std::shared_ptr<const wgt::parse::SettingInfo> settings_info =
-      std::static_pointer_cast<const wgt::parse::SettingInfo>(
-          parser_->GetManifestData(
-              wgt::application_widget_keys::kTizenSettingKey));
+  auto settings_info =
+      GetManifestDataForKey<const wgt::parse::SettingInfo>(
+              wgt::application_widget_keys::kTizenSettingKey);
   if (settings_info)
     backend_data->settings.set(*settings_info);
 
@@ -713,7 +784,6 @@ 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());
 
@@ -722,14 +792,14 @@ common_installer::Step::Status StepParse::process() {
 }
 
 bool StepParse::Check(const boost::filesystem::path& widget_path) {
-  boost::filesystem::path config = widget_path / "config.xml";
+  LOG(DEBUG) << "unpacked widget path: " << widget_path;
 
-  LOG(DEBUG) << "config.xml path: " << config;
+  widget_path_ = widget_path;
 
+  boost::filesystem::path config = widget_path / kConfigFileName;
+  LOG(DEBUG) << "config.xml path: " << config;
   if (!boost::filesystem::exists(config))
     return false;
-
-  config_ = config;
   return true;
 }