Unify TV profile 60/238760/8
authorDongHyun Song <dh81.song@samsung.com>
Fri, 17 Jul 2020 05:47:00 +0000 (14:47 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Fri, 17 Jul 2020 09:47:34 +0000 (18:47 +0900)
TV profile has forked wgt-manifest-handlers separately in github.
Thus, there are migration or maintenance issues sometimes.
Because the code difference is not large, it is better to use it
as one branch.

Change-Id: Ibb18fb5cfe79343b77a98205da443428b62349ca
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
packaging/wgt-manifest-handlers.spec
src/wgt_manifest_handlers/CMakeLists.txt
src/wgt_manifest_handlers/application_manifest_constants.cc [changed mode: 0755->0644]
src/wgt_manifest_handlers/application_manifest_constants.h
src/wgt_manifest_handlers/launch_screen_handler.h
src/wgt_manifest_handlers/setting_handler.cc [changed mode: 0755->0644]
src/wgt_manifest_handlers/setting_handler.h [changed mode: 0755->0644]
src/wgt_manifest_handlers/video_splash_screen_handler.cc [new file with mode: 0644]
src/wgt_manifest_handlers/video_splash_screen_handler.h [new file with mode: 0644]
src/wgt_manifest_handlers/w3c_pc_utils.cc
src/wgt_manifest_handlers/widget_config_parser.cc

index 858fea0a9cedba37cb37f58786a0fed9584c48d2..65aa0b68f03a6f53c39c6bc73f318d1958c183e1 100644 (file)
@@ -1,6 +1,6 @@
 Name:           wgt-manifest-handlers
 Summary:        wgt-manifest-handlers
-Version:        1.9.0
+Version:        1.9.1
 Release:        1
 Group:          Application Framework/Package Management
 License:        Apache-2.0 and BSD-3-Clause
index b9bfde25c0efff73a8ed483eac537ec6a9a5144c..3b19fbc1dbc62c957e8d3f28624bd2266ee97b47 100644 (file)
@@ -22,6 +22,7 @@ SET(SRCS
   launch_screen_handler.cc
   splash_screen_handler.cc
   tizen_application_handler.cc
+  video_splash_screen_handler.cc
   warp_handler.cc
   widget_config_parser.cc
   widget_handler.cc
old mode 100755 (executable)
new mode 100644 (file)
index cd59d66..22d7de7
@@ -82,6 +82,8 @@ const char kTizenServiceKey[] = "widget.service";
 
 // launch_screen
 const char kLaunchScreenKey[] = "widget.launch_screen";
+// video_splash_screen
+const char kVideoSplashScreenKey[] = "widget.video_splash_screen";
 
 }  // namespace application_widget_keys
 
index db5ea97fedd16214461f6d456b899e5565f10ed3..b0d574bbd9313abb699637630e494e313dfa3533 100644 (file)
@@ -49,6 +49,7 @@ extern const char kVersionKey[];
 extern const char kWidgetKey[];
 extern const char kLaunchScreenKey[];
 extern const char kTizenTrustAnchorKey[];
+extern const char kVideoSplashScreenKey[];
 }  // namespace application_widget_keys
 
 const std::vector<std::string> GetElementsWithDifferentAttributeLength();
index 7cba6daab8057055824328187c7d7c6a417f2eac..c088c2c05e4a915f01657ea60e09c04bc3589115 100644 (file)
@@ -19,7 +19,7 @@
 namespace wgt {
 namespace parse {
 
-enum class ReadyWhen { FIRSTPAINT, COMPLETE, CUSTOM };
+enum class ReadyWhen { FIRSTPAINT, COMPLETE, CUSTOM, VIDEOFINISHED };
 
 enum class ScreenOrientation { AUTO, PORTRAIT, LANDSCAPE, NONE };
 
@@ -35,6 +35,7 @@ struct LaunchScreenData {
   std::vector<std::string> image_border;
   std::vector<std::pair<std::string, boost::optional<int>>> images;
   std::vector<std::pair<std::string, boost::optional<int>>> background_images;
+  std::string video;
 };
 
 class LaunchScreenInfo : public parser::ManifestData {
@@ -78,10 +79,7 @@ class LaunchScreenHandler : public parser::ManifestHandler {
              std::string* error) override;
   std::string Key() const override;
 
- private:
-  bool ParseSingleOrientation(const parser::Manifest& manifest,
-                              ScreenOrientation orientation,
-                              LaunchScreenInfo* ls_info);
+ protected:
   bool ParseElement(const parser::DictionaryValue* dict,
                     std::vector<std::string>* to_be_saved,
                     const char* keyToParse);
@@ -89,10 +87,15 @@ class LaunchScreenHandler : public parser::ManifestHandler {
                    std::vector<std::pair<std::string,
                    boost::optional<int>>>* to_be_saved,
                    const char* keyToParse);
-  bool ParseReadyWhen(const parser::Manifest& manifest,
-                      LaunchScreenInfo* ls_info);
   bool ParseColor(const parser::DictionaryValue* dict,
                   LaunchScreenData* launch_screen);
+
+ private:
+  bool ParseSingleOrientation(const parser::Manifest& manifest,
+                              ScreenOrientation orientation,
+                              LaunchScreenInfo* ls_info);
+  bool ParseReadyWhen(const parser::Manifest& manifest,
+                      LaunchScreenInfo* ls_info);
 };
 
 }  // namespace parse
old mode 100755 (executable)
new mode 100644 (file)
index 6608d6a..5045d06
@@ -38,6 +38,8 @@ const char kTizenBackgroundVibrationKey[] = "@background-vibration";
 const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
 const char kTizenSettingKey[] = "widget.setting";
 const char kTizenLongPollingKey[] = "@long-polling";
+const char kTizenPointingDeviceSupport[] = "@pointing-device-support";
+
 const utils::VersionNumber kDefaultAutoOrientationVersion("3.0");
 
 bool ForAllFindKey(const parser::Value* value, const std::string& key,
@@ -178,6 +180,10 @@ bool SettingHandler::Parse(const parser::Manifest& manifest,
       *error = "Long polling value is out of range";
       return false;
     }
+
+    std::string pointing_device_option;
+    ForAllFindKey(value, kTizenPointingDeviceSupport, &pointing_device_option);
+    app_info->set_pointing_device_option(pointing_device_option);
   }
 
   *output = std::static_pointer_cast<parser::ManifestData>(app_info);
old mode 100755 (executable)
new mode 100644 (file)
index 2b49ffc..a1a3d74
@@ -219,6 +219,20 @@ class SettingInfo : public parser::ManifestData {
    */
   boost::optional<unsigned int> long_polling() const { return long_polling_; }
 
+  /**
+   * @brief set_pointing_device_option
+   * @param pointing device option
+   */
+  void set_pointing_device_option(std::string& option) {
+    pointing_device_option_ = option;
+  }
+
+  /**
+   * @brief pointing_device_option
+   * @return pointing device option value
+   */
+  std::string pointing_device_option() const { return pointing_device_option_; }
+
  private:
   bool hwkey_enabled_;
   ScreenOrientation screen_orientation_;
@@ -235,6 +249,7 @@ class SettingInfo : public parser::ManifestData {
   bool background_vibration_;
   bool orientation_defaulted_;
   boost::optional<unsigned int> long_polling_;
+  std::string pointing_device_option_;
 };
 
 /**
diff --git a/src/wgt_manifest_handlers/video_splash_screen_handler.cc b/src/wgt_manifest_handlers/video_splash_screen_handler.cc
new file mode 100644 (file)
index 0000000..387794a
--- /dev/null
@@ -0,0 +1,183 @@
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#include <cassert>
+#include <cstdlib>
+#include <map>
+#include <string>
+#include <utility>
+
+#include "manifest_parser/utils/logging.h"
+#include "wgt_manifest_handlers/application_manifest_constants.h"
+#include "wgt_manifest_handlers/video_splash_screen_handler.h"
+
+namespace keys = wgt::application_widget_keys;
+namespace wgt_parse = wgt::parse;
+
+namespace {
+
+const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
+const char kTagDelimiter[] = " ";
+const char kImageDelimiter[] = ",";
+const char kFirstPaint[] = "first-paint";
+const char kComplete[] = "complete";
+const char kCustom[] = "custom";
+const char kVideoFinished[] = "video-finished";
+const char kVideoSplashScreenDefault[] =
+  "widget.video_splash_screen.vss_default";
+const char kVideoSplashScreenPortrait[] =
+  "widget.video_splash_screen.vss_portrait";
+const char kVideoSplashScreenLandscape[] =
+  "widget.video_splash_screen.vss_landscape";
+const char kVideoSplashScreenKey[] = "widget.video_splash_screen";
+const char kVideoSplashScreenReadyWhen[] = "@ready_when";
+const char kVideoSplashScreenBgColor[] = "@background_color";
+const char kVideoSplashScreenBgImage[] = "@background_image";
+const char kVideoSplashScreenImage[] = "@image";
+const char kVideoSplashScreenImageBorder[] = "@image_border";
+const char kVideoSplashScreenVideo[] = "@video";
+const std::map<wgt_parse::ScreenOrientation, const char*> kOrientationMap = {
+    {wgt_parse::ScreenOrientation::AUTO, kVideoSplashScreenDefault},
+    {wgt_parse::ScreenOrientation::LANDSCAPE, kVideoSplashScreenLandscape},
+    {wgt_parse::ScreenOrientation::PORTRAIT, kVideoSplashScreenPortrait}};
+
+}  // namespace
+
+namespace wgt {
+namespace parse {
+
+std::string VideoSplashScreenInfo::Key() {
+  return kVideoSplashScreenKey;
+}
+
+bool VideoSplashScreenHandler::ParseSingleOrientation(
+    const parser::Manifest& manifest, ScreenOrientation orientation,
+    VideoSplashScreenInfo* vss_info) {
+  auto dict_element_parser =
+  [this](LaunchScreenData& video_splash_screen,
+         const parser::DictionaryValue* dict) -> bool {
+    if (!parser::VerifyElementNamespace(*dict, kTizenNamespacePrefix))
+      return false;
+    bool result = ParseColor(dict, &video_splash_screen);
+    if (!result)
+      return false;
+
+    result = ParseImages(dict, &video_splash_screen.background_images,
+                         kVideoSplashScreenBgImage);
+    if (!result)
+      return false;
+
+    result = ParseImages(dict, &video_splash_screen.images,
+                         kVideoSplashScreenImage);
+    if (!result)
+      return false;
+
+    result = ParseVideo(dict, video_splash_screen.video);
+    if (!result)
+        return false;
+
+    result = ParseElement(dict, &video_splash_screen.image_border,
+                          kVideoSplashScreenImageBorder);
+    if (!result)
+      return false;
+
+    return !!video_splash_screen.background_color
+            || !video_splash_screen.background_images.empty()
+            || !video_splash_screen.images.empty();
+  };
+
+  auto orientation_chosen = kOrientationMap.at(orientation);
+
+
+  auto& dict_element =
+      parser::GetOneOrMany(manifest.value(),
+                           orientation_chosen,
+                           kTizenNamespacePrefix);
+  if (dict_element.empty())
+    return true;
+
+  if (dict_element.size() > 1)
+    return false;
+
+  LaunchScreenData video_splash_screen;
+  if (!dict_element_parser(video_splash_screen, dict_element[0]))
+    return false;
+
+  vss_info->set_launch_screen_data(std::make_pair(orientation, video_splash_screen));
+  return true;
+}
+
+
+bool VideoSplashScreenHandler::ParseReadyWhen(const parser::Manifest& manifest,
+                                         VideoSplashScreenInfo* vss_info) {
+  auto dict_values = parser::GetOneOrMany(manifest.value(),
+                                          kVideoSplashScreenKey,
+                                          kTizenNamespacePrefix);
+  if (dict_values.empty())
+    return false;
+
+  std::string ready_when;
+  dict_values[0]->GetString(kVideoSplashScreenReadyWhen, &ready_when);
+
+  if (ready_when.empty()) {
+    ready_when = kFirstPaint;
+  }
+  if (ready_when != kFirstPaint && ready_when != kComplete &&
+      ready_when != kCustom && ready_when != kVideoFinished)
+    return false;
+
+  if (ready_when == kFirstPaint) {
+    vss_info->set_ready_when(ReadyWhen::FIRSTPAINT);
+  } else  if (ready_when == kComplete) {
+    vss_info->set_ready_when(ReadyWhen::COMPLETE);
+  } else  if (ready_when == kCustom) {
+    vss_info->set_ready_when(ReadyWhen::CUSTOM);
+  } else  if (ready_when == kVideoFinished) {
+    vss_info->set_ready_when(ReadyWhen::VIDEOFINISHED);
+  }
+  return true;
+}
+
+bool VideoSplashScreenHandler::ParseVideo(const parser::DictionaryValue* dict,
+                                          std::string& to_be_saved) {
+  std::string element;
+  if (!dict->GetString(kVideoSplashScreenVideo, &element))
+    return false;
+  to_be_saved = element;
+  return true;
+}
+
+
+bool VideoSplashScreenHandler::Parse(const parser::Manifest& manifest,
+                                std::shared_ptr<parser::ManifestData>* output,
+                                std::string* error) {
+  auto vss_info = std::make_shared<VideoSplashScreenInfo>();
+  if (!ParseReadyWhen(manifest, vss_info.get())) return false;
+
+  if (!ParseSingleOrientation(manifest, ScreenOrientation::AUTO,
+      vss_info.get())) {
+    *error = "Failed to parse video splash screen default orientation";
+    return false;
+  }
+  if (!ParseSingleOrientation(manifest, ScreenOrientation::LANDSCAPE,
+      vss_info.get())) {
+    *error = "Failed to parse video splash screen landscape orientation";
+    return false;
+  }
+  if (!ParseSingleOrientation(manifest, ScreenOrientation::PORTRAIT,
+        vss_info.get())) {
+    *error = "Failed to parse video splash screen portrait orientation";
+    return false;
+  }
+  *output = std::static_pointer_cast<parser::ManifestData>(vss_info);
+  return true;
+}
+
+
+std::string VideoSplashScreenHandler::Key() const {
+  return kVideoSplashScreenKey;
+}
+
+}  // namespace parse
+}  // namespace wgt
diff --git a/src/wgt_manifest_handlers/video_splash_screen_handler.h b/src/wgt_manifest_handlers/video_splash_screen_handler.h
new file mode 100644 (file)
index 0000000..558a5b2
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE-xwalk file.
+
+#ifndef WGT_MANIFEST_HANDLERS_VIDEO_SPLASH_SCREEN_HANDLER_H_
+#define WGT_MANIFEST_HANDLERS_VIDEO_SPLASH_SCREEN_HANDLER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "manifest_parser/manifest_handler.h"
+#include "manifest_parser/values.h"
+#include "wgt_manifest_handlers/launch_screen_handler.h"
+#include "wgt_manifest_handlers/setting_handler.h"
+
+namespace wgt {
+namespace parse {
+
+class VideoSplashScreenInfo : public LaunchScreenInfo {
+ public:
+  VideoSplashScreenInfo() = default;
+  virtual ~VideoSplashScreenInfo() = default;
+  static std::string Key();
+};
+
+/**
+ * @brief The VideoSplashScreenHandler class
+ *
+ * Handler of config.xml for xml elements:
+ *  - <tizen:video_splash_screen>.
+ */
+class VideoSplashScreenHandler : public LaunchScreenHandler {
+ public:
+  VideoSplashScreenHandler() = default;
+  virtual ~VideoSplashScreenHandler() = default;
+  bool Parse(const parser::Manifest& manifest,
+            std::shared_ptr<parser::ManifestData>* output,
+            std::string* error) override;
+  std::string Key() const override;
+
+ private:
+  bool ParseSingleOrientation(const parser::Manifest& manifest,
+                              ScreenOrientation orientation,
+                              VideoSplashScreenInfo* vss_info);
+  bool ParseReadyWhen(const parser::Manifest& manifest,
+                      VideoSplashScreenInfo* vss_info);
+  bool ParseVideo(const parser::DictionaryValue* dict,
+                  std::string& to_be_saved);
+};
+
+}  // namespace parse
+}  // namespace wgt
+
+
+#endif  // WGT_MANIFEST_HANDLERS_VIDEO_SPLASH_SCREEN_HANDLER_H_
index 5bdf80c80664b6c217a5ec99232d4c84834f2995..a5cae59a8a351df6d6a4116690196f3fd76332bb 100644 (file)
@@ -179,7 +179,9 @@ namespace parse {
 bool CheckW3CContentSrcExists(const bf::path& widget_path,
                              const std::string& content) {
   if (!content.empty()) {
-    if (FindFilesWithinWidget(widget_path, content) == FindResult::OK) {
+    auto tmg_content = std::string(content).append(".spm");
+    if (FindFilesWithinWidget(widget_path, content) == FindResult::OK ||
+        FindFilesWithinWidget(widget_path, tmg_content) == FindResult::OK) {
       return true;
     }
   }
@@ -189,7 +191,9 @@ bool CheckW3CContentSrcExists(const bf::path& widget_path,
 // http://www.w3.org/TR/widgets/#step-8-locate-the-start-file
 bool CheckStartFileInWidget(const bf::path& widget_path) {
   for (auto& file : kDefaultStartFiles) {
-    if (FindFilesWithinWidget(widget_path, file) == FindResult::OK) {
+    auto tmg_file = std::string(file).append(".spm");
+    if (FindFilesWithinWidget(widget_path, file) == FindResult::OK ||
+        FindFilesWithinWidget(widget_path, tmg_file) == FindResult::OK) {
       LOG(INFO) << "Start file is: " << file;
       return true;
     }
@@ -277,7 +281,8 @@ bool CheckServicesStartFiles(
 
   for (auto& service_info : service_list.services) {
     bf::path start_file = widget_path / service_info.content();
-    if (!bf::exists(start_file)) {
+    bf::path start_file_tmg = widget_path / (service_info.content() + ".spm");
+    if (!bf::exists(start_file) && !bf::exists(start_file_tmg)) {
       *error = std::string("Could not find valid service start file: ")
           + start_file.string();
       return false;
index 2081f5b7999adda46196f4544f98f26afa257e9b..9a799fce2aee1d872891c9d0606567f983ed814a 100644 (file)
@@ -37,6 +37,7 @@
 #include "wgt_manifest_handlers/launch_screen_handler.h"
 #include "wgt_manifest_handlers/splash_screen_handler.h"
 #include "wgt_manifest_handlers/tizen_application_handler.h"
+#include "wgt_manifest_handlers/video_splash_screen_handler.h"
 #include "wgt_manifest_handlers/warp_handler.h"
 #include "wgt_manifest_handlers/widget_handler.h"
 #include "wgt_manifest_handlers/w3c_pc_utils.h"
@@ -75,7 +76,8 @@ WidgetConfigParser::WidgetConfigParser() {
     std::make_shared<AppDefinedPrivilegeHandler>(),
     std::make_shared<ProvidesAppDefinedPrivilegeHandler>(),
     std::make_shared<TrustAnchorHandler>(),
-    std::make_shared<AddonHandler>()
+    std::make_shared<AddonHandler>(),
+    std::make_shared<VideoSplashScreenHandler>()
   };
 
   std::unique_ptr<parser::ManifestHandlerRegistry> registry(
@@ -111,9 +113,11 @@ void WidgetConfigParser::ContentTypeSetIfEmpty() {
 }
 
 bool WidgetConfigParser::CheckSplashAndLaunchScreenOccurences() {
-    return parser_->GetManifestData(SplashScreenInfo::Key()) &&
-        parser_->GetManifestData(LaunchScreenInfo::Key());
+  return parser_->GetManifestData(SplashScreenInfo::Key()) &&
+         (parser_->GetManifestData(LaunchScreenInfo::Key()) ||
+          parser_->GetManifestData(VideoSplashScreenInfo::Key()));
 }
+
 bool WidgetConfigParser::ParseManifest(const boost::filesystem::path& path) {
   widget_path_ = path.parent_path();
   std::shared_ptr<parser::ManifestConstraints> constraints(