Add light user element parsing logic 05/274005/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 20 Apr 2022 02:31:15 +0000 (11:31 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 21 Apr 2022 08:50:17 +0000 (17:50 +0900)
Change-Id: I1c69cec450030212d1126897823e39becefb40ea
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/wgt_manifest_handlers/CMakeLists.txt
src/wgt_manifest_handlers/application_manifest_constants.cc
src/wgt_manifest_handlers/application_manifest_constants.h
src/wgt_manifest_handlers/lightuser_handler.cc [new file with mode: 0644]
src/wgt_manifest_handlers/lightuser_handler.h [new file with mode: 0644]

index 3b19fbc1dbc62c957e8d3f28624bd2266ee97b47..36659699de53e9020c2055c27aa1139a92a9df6d 100644 (file)
@@ -11,6 +11,7 @@ SET(SRCS
   content_handler.cc
   csp_handler.cc
   ime_handler.cc
+  lightuser_handler.cc
   metadata_handler.cc
   navigation_handler.cc
   permissions_handler.cc
index 22d7de7bf6bcdc9c9f1edc469be417c7d453dd17..5ed036fd762303789d9c86fd230eb8555c646b5d 100644 (file)
@@ -79,6 +79,8 @@ const char kTizenContentKey[] = "widget.content";
 const char kTizenCategoryKey[] = "widget.category";
 // Service
 const char kTizenServiceKey[] = "widget.service";
+// Lightuser
+const char kTizenLightUserKey[] = "widget.lightuser";
 
 // launch_screen
 const char kLaunchScreenKey[] = "widget.launch_screen";
index b0d574bbd9313abb699637630e494e313dfa3533..0eefe4e29f4af88b1fe026df5c3f84442c13d1e3 100644 (file)
@@ -50,6 +50,7 @@ extern const char kWidgetKey[];
 extern const char kLaunchScreenKey[];
 extern const char kTizenTrustAnchorKey[];
 extern const char kVideoSplashScreenKey[];
+extern const char kTizenLightUserKey[];
 }  // namespace application_widget_keys
 
 const std::vector<std::string> GetElementsWithDifferentAttributeLength();
diff --git a/src/wgt_manifest_handlers/lightuser_handler.cc b/src/wgt_manifest_handlers/lightuser_handler.cc
new file mode 100644 (file)
index 0000000..86ba749
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt_manifest_handlers/lightuser_handler.h"
+
+#include "manifest_parser/values.h"
+
+namespace wgt {
+namespace parse {
+
+namespace {
+
+const char kLightUserKey[] = "manifest.lightuser";
+const char kLightUserSwitchModeKey[] = "@switch-mode";
+
+void ParseLightUserAndStore(
+    const parser::DictionaryValue& lightuser_dict,
+    LightUserInfo* lightuser) {
+  std::string switch_mode;
+  lightuser_dict.GetString(kLightUserSwitchModeKey, &switch_mode);
+  lightuser->set_switch_mode(switch_mode);
+}
+
+}  // namespace
+
+bool LightUserHandler::Parse(
+    const parser::Manifest& manifest,
+    std::shared_ptr<parser::ManifestData>* output,
+    std::string* /*error*/) {
+  std::shared_ptr<LightUserInfo> lightuser(new LightUserInfo());
+
+  auto items = parser::GetOneOrMany(manifest.value(), kLightUserKey, "");
+  if (items.empty())
+    return true;
+
+  ParseLightUserAndStore(*items[0], lightuser.get());
+
+  *output = std::static_pointer_cast<parser::ManifestData>(lightuser);
+  return true;
+}
+
+std::string LightUserInfo::Key() {
+  return kLightUserKey;
+}
+
+std::string LightUserHandler::Key() const {
+  return kLightUserKey;
+}
+
+}  // namespace parse
+}  // namespace wgt
diff --git a/src/wgt_manifest_handlers/lightuser_handler.h b/src/wgt_manifest_handlers/lightuser_handler.h
new file mode 100644 (file)
index 0000000..acc12bb
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_MANIFEST_HANDLERS_LIGHTUSER_HANDLER_H_
+#define WGT_MANIFEST_HANDLERS_LIGHTUSER_HANDLER_H_
+
+#include <memory>
+#include <string>
+
+#include "manifest_parser/manifest_handler.h"
+
+namespace wgt {
+namespace parse {
+
+class LightUserInfo : public parser::ManifestData {
+ public:
+  /**
+   * @brief key
+   * @param key string
+   */
+  static std::string Key();
+  /**
+   * @brief set_switch_mode sets switch_mode
+   * @param switch_mode
+   */
+  void set_switch_mode(std::string switch_mode) {
+    switch_mode_ = std::move(switch_mode);
+  }
+  /**
+   * @brief switch_mode
+   * @return switch_mode string
+   */
+  const std::string& switch_mode() const {
+    return switch_mode_;
+  }
+
+ private:
+  std::string switch_mode_;
+};
+
+/**
+ * @brief The LightUserHandler class
+ *
+ * Handler of tizen-manifest.xml for xml elements:
+ *  <lightuser>
+ */
+class LightUserHandler : public parser::ManifestHandler {
+ public:
+  bool Parse(
+      const parser::Manifest& manifest,
+      std::shared_ptr<parser::ManifestData>* output,
+      std::string* error) override;
+  std::string Key() const override;
+};
+
+}  // namespace parse
+}  // namespace wgt
+
+#endif  // WGT_MANIFEST_HANDLERS_LIGHTUSER_HANDLER_H_