Addition of main attribute for widget-application 66/101266/6
authorPiotr Ganicz <p.ganicz@samsung.com>
Wed, 30 Nov 2016 11:54:22 +0000 (12:54 +0100)
committerHwanKyu Jhun <h.jhun@samsung.com>
Wed, 7 Dec 2016 04:03:45 +0000 (20:03 -0800)
This commit repairs the issue with generating proper main attribute
for widget-application element in manifest. Only one attribute can
be set to "true" for list of apps (widget-application).

Submit together:
  - https://review.tizen.org/gerrit/#/c/101269/
  - https://review.tizen.org/gerrit/#/c/101267/
  - https://review.tizen.org/gerrit/#/c/101266/

Change-Id: I8d4688f0fcd779e3c3fab6751290ce051c8c4845

src/common/step/configuration/step_parse_manifest.cc

index 02867346733d6326a47842e673420a8acd2f5330..c08927d475e372fe09ee12b2ec221c9d50d7aa3c 100644 (file)
@@ -363,6 +363,13 @@ bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
           parser_->GetManifestData(app_keys::kWidgetApplicationKey));
   if (!widget_application_list)
     return true;
+  int mainapps = std::count_if(widget_application_list->items.begin(),
+          widget_application_list->items.end(),
+          [](const tpk::parse::WidgetApplicationSingleEntry& app) {
+            return app.app_info.main() == "true";
+          });
+  if (mainapps > 1)  // only one main app is permitted
+      return false;
 
   for (const auto& application : widget_application_list->items) {
     // if there is no app yet, set this app as mainapp
@@ -390,7 +397,11 @@ bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
         strdup(application.app_info.hwacceleration().c_str());
     widget_app->onboot = strdup("false");
     widget_app->autorestart = strdup("false");
-    widget_app->mainapp = main_app ? strdup("true") : strdup("false");
+    if (mainapps == 1) {
+        widget_app->mainapp = strdup(application.app_info.main().c_str());
+    } else {
+        widget_app->mainapp = main_app ? strdup("true") : strdup("false");
+    }
     widget_app->enabled = strdup("true");
     widget_app->screenreader = strdup("use-system-setting");
     widget_app->recentimage = strdup("false");