Fix service-application validation 63/61063/2
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 3 Mar 2016 15:18:54 +0000 (16:18 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Mon, 7 Mar 2016 09:13:13 +0000 (10:13 +0100)
 - add 'multiple' attribute for service application,
 - add 'taskmanage' attribute for service application,
 - validation for value of 'on-boot' and 'auto-restart'.

Change-Id: I8d509a1217036c2a1f36c2fd2dd59da366cc7663

src/tpk_manifest_handlers/service_application_handler.cc
src/tpk_manifest_handlers/service_application_handler.h

index 611e38b9c7552b20d4f024ec801dc47c80c582fc..01d6eb8654de93d7c249de6f42321f816e4af18c 100644 (file)
@@ -29,8 +29,13 @@ const char kServiceApplicationExecKey[] = "@exec";
 const char kServiceApplicationOnBootKey[] = "@on-boot";
 const char kServiceApplicationTypeKey[] = "@type";
 const char kServiceApplicationProcessPoolKey[] = "@process-pool";
+const char kServiceApplicationMultipleKey[] = "@multiple";
+const char kServiceApplicationTaskManageKey[] = "@taskmanage";
 const char kServiceApplicationKeyText[] = "#text";
 
+const char kTrue[] = "true";
+const char kFalse[] = "false";
+
 bool ServiceAppValidation(
     const ServiceApplicationSingleEntry& item,
     std::string* error) {
@@ -57,6 +62,27 @@ bool ServiceAppValidation(
         "The type child element of service application element is obligatory";
     return false;
   }
+  const std::string& multiple = item.app_info.multiple();
+  if (multiple != kTrue && multiple != kFalse) {
+    *error = "multiple attribute should have 'true' or 'false' value";
+    return false;
+  }
+  const std::string& taskmanage = item.app_info.taskmanage();
+  if (taskmanage != kTrue && taskmanage != kFalse) {
+    *error = "taskmanage attribute should have 'true' or 'false' value";
+    return false;
+  }
+  const std::string& on_boot = item.app_info.on_boot();
+  if (on_boot != kTrue && on_boot != kFalse) {
+    *error = "on-boot attribute should have 'true' or 'false' value";
+    return false;
+  }
+  const std::string& auto_restart = item.app_info.auto_restart();
+  if (auto_restart != kTrue && auto_restart != kFalse) {
+    *error = "auto-restart attribute should have 'true' or 'false' value";
+    return false;
+  }
+
   return true;
 }
 
@@ -74,12 +100,18 @@ bool ParseServiceApplicationAndStore(
   app_dict.GetString(kServiceApplicationOnBootKey, &on_boot);
   std::string type;
   app_dict.GetString(kServiceApplicationTypeKey, &type);
+  std::string multiple("false");
+  app_dict.GetString(kServiceApplicationMultipleKey, &multiple);
+  std::string taskmanage("true");
+  app_dict.GetString(kServiceApplicationTaskManageKey, &taskmanage);
 
   serviceapplicationinfo->app_info.set_appid(appid);
   serviceapplicationinfo->app_info.set_exec(exec);
   serviceapplicationinfo->app_info.set_auto_restart(auto_restart);
   serviceapplicationinfo->app_info.set_on_boot(on_boot);
   serviceapplicationinfo->app_info.set_type(type);
+  serviceapplicationinfo->app_info.set_multiple(multiple);
+  serviceapplicationinfo->app_info.set_taskmanage(taskmanage);
 
   std::string process_pool;
   if (app_dict.GetString(kServiceApplicationProcessPoolKey, &process_pool)) {
index eaa2fd49289d7c497c389d8fa37d3961b82a5465..196fab5df3c7405a983fa18ba75a7050e2816be1 100644 (file)
@@ -44,6 +44,14 @@ class ServiceApplicationInfo : public ApplicationInfo {
     on_boot_ = on_boot;
   }
 
+  void set_multiple(const std::string& multiple) {
+    multiple_ = multiple;
+  }
+
+  void set_taskmanage(const std::string& taskmanage) {
+    taskmanage_ = taskmanage;
+  }
+
   const std::string& type() const {
     return type_;
   }
@@ -65,11 +73,21 @@ class ServiceApplicationInfo : public ApplicationInfo {
     return on_boot_;
   }
 
+  const std::string& multiple() const {
+    return multiple_;
+  }
+
+  const std::string& taskmanage() const {
+    return taskmanage_;
+  }
+
  private:
   std::string type_;
   std::string process_pool_;
   std::string auto_restart_;
   std::string on_boot_;
+  std::string multiple_;
+  std::string taskmanage_;
 };
 
 struct ServiceApplicationSingleEntry :