Coding style
[platform/core/appfw/wgt-backend.git] / src / wgt / step / configuration / step_parse.cc
index 33bb0b2..c15d8af 100644 (file)
@@ -39,6 +39,7 @@
 #include <set>
 #include <string>
 #include <vector>
+#include <utility>
 
 #include "wgt/wgt_backend_data.h"
 
@@ -53,6 +54,9 @@ 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";
@@ -70,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");
@@ -126,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) {
@@ -276,6 +287,8 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   }
   bool has_watch_category = false;
   bool has_ime = false;
+  bool has_downloadable_font = false;
+  bool has_tts = false;
   auto category_info =
       GetManifestDataForKey<const wgt::parse::CategoryInfoList>(
              app_keys::kTizenCategoryKey);
@@ -291,6 +304,14 @@ 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
@@ -303,11 +324,16 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   auto settings_info =
       GetManifestDataForKey<const wgt::parse::SettingInfo>(
              wgt::application_widget_keys::kTizenSettingKey);
+
   bool no_display = settings_info ? settings_info->no_display() : false;
-  application->nodisplay = (has_watch_category || has_ime || no_display) ?
+  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_watch_category || has_ime) ? strdup("false") :
+  application->taskmanage = has_no_display_category ? strdup("false") :
       strdup("true");
+
   SetApplicationXDefaults(application);
   if (has_watch_category)
     application->ambient_support =
@@ -433,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;