Move utility files into newly created directory 86/219286/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 4 Dec 2019 04:52:13 +0000 (13:52 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 14 Jan 2020 06:10:07 +0000 (15:10 +0900)
Move it to reduce module circular dependency.

Change-Id: Iffed47db7a38950afe961ea4ebdc9b5fd643e57f
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
28 files changed:
src/hybrid/hybrid_backend_data.h
src/unit_tests/manifest_test.cc
src/unit_tests/smoke_test_helper.cc
src/unit_tests/smoke_utils.h
src/wgt/CMakeLists.txt
src/wgt/extension_config_parser.cc [deleted file]
src/wgt/extension_config_parser.h [deleted file]
src/wgt/shared_dirs.h [deleted file]
src/wgt/step/configuration/step_check_start_files.cc
src/wgt/step/configuration/step_check_start_files.h
src/wgt/step/configuration/step_parse.cc
src/wgt/step/encryption/step_encrypt_resources.h
src/wgt/step/filesystem/step_copy_preview_icons.cc
src/wgt/step/pkgmgr/step_generate_xml.cc
src/wgt/step/security/step_check_extension_privileges.cc
src/wgt/step/security/step_check_settings_level.cc
src/wgt/step/security/step_check_wgt_background_category.cc
src/wgt/utils/extension_config_parser.cc [new file with mode: 0644]
src/wgt/utils/extension_config_parser.h [new file with mode: 0644]
src/wgt/utils/shared_dirs.h [new file with mode: 0644]
src/wgt/utils/wgt_app_query_interface.cc [new file with mode: 0644]
src/wgt/utils/wgt_app_query_interface.h [new file with mode: 0644]
src/wgt/utils/wgt_backend_data.h [new file with mode: 0644]
src/wgt/wgt_app_query_interface.cc [deleted file]
src/wgt/wgt_app_query_interface.h [deleted file]
src/wgt/wgt_backend_data.h [deleted file]
src/wgt/wgt_installer.cc
src/wgt_backend/wgt_backend.cc

index 9cc98c9846094876851b33bfbc0fd5ac2f193f3a..de0e9a03b1adf420d17ef4d96f375b55c2c51314 100644 (file)
@@ -13,7 +13,7 @@
 #include <string>
 #include <vector>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace hybrid {
 
index 051d2f3fdcaa0e40839e740fec51d9091d1c2ff2..e195ff0ddee6ce820020aa6f5c5ccb1de0a8b2ea 100644 (file)
@@ -19,7 +19,7 @@
 #include <vector>
 
 #include "wgt/step/configuration/step_parse.h"
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 #define ASSERT_CSTR_EQ(STR1, STR2)                                             \
   ASSERT_EQ(strcmp(STR1, STR2), 0)                                             \
index 3549d847e304c18d82b1286168035097ccd03b78..9d666b2547746dcbd6a40a10e9399e7f5d0a9a73 100644 (file)
@@ -5,7 +5,7 @@
 #include <common/pkgmgr_interface.h>
 #include <cerrno>
 
-#include "wgt/wgt_app_query_interface.h"
+#include "wgt/utils/wgt_app_query_interface.h"
 #include "wgt/wgt_installer.h"
 
 namespace ci = common_installer;
index 7b22263a302834fc52728c770afbcad518cc8f92..14e099477f9e45836d9b84484ff4c6692675e059 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "hybrid/hybrid_installer.h"
 #include "wgt/wgt_installer.h"
-#include "wgt/wgt_app_query_interface.h"
+#include "wgt/utils/wgt_app_query_interface.h"
 
 namespace smoke_test {
 
index a9baf9b5ecd034f9ef72b56b9ad5ccff094b851b..e2456c754514bc65550086bbb3fd493c392ab1db 100755 (executable)
@@ -5,6 +5,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/encryption WGT_STEP_ENCRYP
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/filesystem WGT_STEP_FILESYSTEM_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/pkgmgr WGT_STEP_PKGMGR_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/security WGT_STEP_SECURITY_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils WGT_UTILS_SRCS)
 
 # Target - definition
 ADD_LIBRARY(${TARGET_LIBNAME_WGT} STATIC
@@ -13,7 +14,8 @@ ADD_LIBRARY(${TARGET_LIBNAME_WGT} STATIC
   ${WGT_STEP_ENCRYPTION_SRCS}
   ${WGT_STEP_FILESYSTEM_SRCS}
   ${WGT_STEP_PKGMGR_SRCS}
-  ${WGT_STEP_SECURITY_SRCS})
+  ${WGT_STEP_SECURITY_SRCS}
+  ${WGT_UTILS_SRCS})
 # Target - includes
 TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_WGT} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
 # Target - deps
diff --git a/src/wgt/extension_config_parser.cc b/src/wgt/extension_config_parser.cc
deleted file mode 100755 (executable)
index 2409389..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#include "wgt/extension_config_parser.h"
-#include <manifest_parser/utils/string_util.h>
-#include <manifest_parser/manifest_handler.h>
-
-#include <cassert>
-#include <utility>
-
-namespace wgt {
-
-namespace {
-
-const xmlChar kExtensionNodeKey[] = "extension";
-const xmlChar kNamePrivilegeKey[] = "privilege";
-const xmlChar kPrivigeNameAttributeKey[] = "name";
-const char kAttributePrefix[] = "@";
-const xmlChar kDirAttributeKey[] = "dir";
-const char kXmlTextKey[] = "#text";
-const char kNamespaceKey[] = "@namespace";
-const char kExtensionPath[] = "extension.privilege";
-const char kExtensionNameKey[] = "@name";
-
-}  // namespace
-
-ExtensionConfigParser::ExtensionConfigParser(std::string config_xml)
-    : config_xml_(config_xml) {}
-
-std::unique_ptr<parser::DictionaryValue>
-    ExtensionConfigParser::LoadExtensionConfig(const std::string& config_xml) {
-  xmlDoc *doc = nullptr;
-  xmlNode* root_node = nullptr;
-  doc = xmlReadFile(config_xml.c_str(), nullptr, XML_PARSE_NOENT);
-  if (!doc) {
-    LOG(ERROR) << "Failed to read xml document model from" << config_xml;
-    return nullptr;
-  }
-  root_node = xmlDocGetRootElement(doc);
-  std::unique_ptr<parser::DictionaryValue> dv = LoadXMLNode(root_node);
-  std::unique_ptr<parser::DictionaryValue> result(new parser::DictionaryValue);
-  if (dv)
-    result->Set(reinterpret_cast<const char*>(root_node->name), dv.release());
-  return result;
-}
-
-std::string ExtensionConfigParser::GetNodeDir(
-    xmlNode* node, const std::string& inherit_dir) {
-  std::string dir(inherit_dir);
-  for (xmlAttr* prop = node->properties; prop; prop = prop->next) {
-    if (xmlStrEqual(prop->name, kDirAttributeKey)) {
-      char* prop_value = reinterpret_cast<char*>(xmlNodeListGetString(
-          node->doc, prop->children, 1));
-      dir = prop_value;
-      xmlFree(prop_value);
-      break;
-    }
-  }
-  return dir;
-}
-std::string ExtensionConfigParser::GetNodeText(
-    xmlNode* root, const std::string& inherit_dir) {
-  if (root->type != XML_ELEMENT_NODE)
-    return std::string();
-  std::string current_dir(GetNodeDir(root, inherit_dir));
-  std::string text;
-  if (!current_dir.empty())
-    text += parser::utils::GetDirUTF8Start(current_dir);
-  for (xmlNode* node = root->children; node; node = node->next) {
-    if (node->type == XML_TEXT_NODE || node->type == XML_CDATA_SECTION_NODE)
-      text = text + std::string(reinterpret_cast<char*>(node->content));
-    else
-      text += GetNodeText(node, current_dir);
-  }
-  if (!current_dir.empty())
-    text += parser::utils::GetDirUTF8End();
-  return text;
-}
-bool ExtensionConfigParser::IsPropSupportDir(xmlNode* root, xmlAttr* prop) {
-  if (xmlStrEqual(root->name, kNamePrivilegeKey)
-      && xmlStrEqual(prop->name, kPrivigeNameAttributeKey)) {
-    return true;
-  }
-  return false;
-}
-bool ExtensionConfigParser::IsTrimRequiredForElement(xmlNode* root) {
-  if (xmlStrEqual(root->name, kNamePrivilegeKey)) {
-    return true;
-  }
-  return false;
-}
-bool ExtensionConfigParser::IsTrimRequiredForProp(
-    xmlNode* root, xmlAttr* prop) {
-  if (xmlStrEqual(root->name, kNamePrivilegeKey) &&
-      xmlStrEqual(prop->name, kPrivigeNameAttributeKey)) {
-    return true;
-  }
-  return false;
-}
-std::unique_ptr<parser::DictionaryValue>
-    ExtensionConfigParser::LoadXMLNode(
-    xmlNode* root, const std::string& inherit_dir) {
-  std::unique_ptr<parser::DictionaryValue> value(new parser::DictionaryValue());
-  if (root->type != XML_ELEMENT_NODE)
-    return nullptr;
-
-  std::string current_dir(GetNodeDir(root, inherit_dir));
-
-  xmlAttr* prop = nullptr;
-  for (prop = root->properties; prop; prop = prop->next) {
-    xmlChar* value_ptr = xmlNodeListGetString(root->doc, prop->children, 1);
-    std::string prop_value(reinterpret_cast<char*>(value_ptr));
-    xmlFree(value_ptr);
-    if (IsPropSupportDir(root, prop))
-      prop_value = parser::utils::GetDirTextUTF8(prop_value, current_dir);
-
-    if (IsTrimRequiredForProp(root, prop))
-      prop_value = parser::utils::CollapseWhitespaceUTF8(prop_value);
-
-    value->SetString(
-        std::string(kAttributePrefix)
-        + reinterpret_cast<const char*>(prop->name),
-        prop_value);
-  }
-
-  if (root->ns)
-    value->SetString(kNamespaceKey,
-        reinterpret_cast<const char*>(root->ns->href));
-
-  for (xmlNode* node = root->children; node; node = node->next) {
-    std::string sub_node_name(reinterpret_cast<const char*>(node->name));
-    std::unique_ptr<parser::DictionaryValue> sub_value =
-        LoadXMLNode(node, current_dir);
-
-    if (!sub_value) {
-      continue;
-    }
-    if (!value->HasKey(sub_node_name)) {
-      value->Set(sub_node_name, sub_value.release());
-      continue;
-    }
-
-    parser::Value* temp;
-    value->Get(sub_node_name, &temp);
-
-    if (temp->IsType(parser::Value::TYPE_LIST)) {
-      parser::ListValue* list;
-      temp->GetAsList(&list);
-      list->Append(sub_value.release());
-    } else {
-      assert(temp->IsType(parser::Value::TYPE_DICTIONARY));
-      parser::DictionaryValue* dict;
-      temp->GetAsDictionary(&dict);
-      parser::DictionaryValue* prev_value = dict->DeepCopy();
-
-      parser::ListValue* list = new parser::ListValue();
-      list->Append(prev_value);
-      list->Append(sub_value.release());
-      value->Set(sub_node_name, list);
-    }
-  }
-
-  std::string text;
-  xmlChar* text_ptr = xmlNodeListGetString(root->doc, root->children, 1);
-  if (text_ptr) {
-    text = reinterpret_cast<char*>(text_ptr);
-    xmlFree(text_ptr);
-  }
-  if (IsTrimRequiredForElement(root))
-    text = parser::utils::CollapseWhitespaceUTF8(text);
-  if (!text.empty())
-    value->SetString(kXmlTextKey, text);
-
-  return value;
-}
-std::vector<std::string> ExtensionConfigParser::GetExtensionPrivilegeList() {
-  std::unique_ptr<parser::DictionaryValue> dic
-    = LoadExtensionConfig(config_xml_);
-  std::vector<std::string> privilege_list;
-
-  for (auto& item : parser::GetOneOrMany(dic.get(), kExtensionPath, "")) {
-    std::string privilege;
-    if (item->GetString(kExtensionNameKey, &privilege)) {
-      LOG(DEBUG) << "User defined extra privilege: " << privilege;
-      privilege_list.push_back(privilege);
-    }
-  }
-  return privilege_list;
-}
-
-}  // namespace wgt
diff --git a/src/wgt/extension_config_parser.h b/src/wgt/extension_config_parser.h
deleted file mode 100755 (executable)
index 915497e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef WGT_EXTENSION_CONFIG_PARSER_H_
-#define WGT_EXTENSION_CONFIG_PARSER_H_
-
-#include <libxml2/libxml/tree.h>
-#include <manifest_parser/utils/logging.h>
-#include <manifest_parser/values.h>
-#include <manifest_parser/manifest_util.h>
-
-#include <memory>
-#include <string>
-#include <map>
-#include <vector>
-
-namespace wgt {
-class ExtensionConfigParser {
- public:
-  explicit ExtensionConfigParser(std::string config_xml);
-  std::vector<std::string> GetExtensionPrivilegeList();
- private:
-  std::unique_ptr<parser::DictionaryValue> LoadExtensionConfig(
-      const std::string& config_xml);
-  std::string GetNodeDir(xmlNode* node, const std::string& inherit_dir);
-  std::string GetNodeText(xmlNode* root, const std::string& inherit_dir);
-  bool IsPropSupportDir(xmlNode* root, xmlAttr* prop);
-  bool IsTrimRequiredForElement(xmlNode* root);
-  bool IsTrimRequiredForProp(xmlNode* root, xmlAttr* prop);
-  std::unique_ptr<parser::DictionaryValue> LoadXMLNode(
-      xmlNode* root, const std::string& inherit_dir = "");
-  std::string config_xml_;
-};
-
-}  // namespace wgt
-
-#endif  // WGT_EXTENSION_CONFIG_PARSER_H_
diff --git a/src/wgt/shared_dirs.h b/src/wgt/shared_dirs.h
deleted file mode 100644 (file)
index 61bb319..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2016 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_SHARED_DIRS_H_
-#define WGT_SHARED_DIRS_H_
-
-#include <vector>
-
-namespace wgt {
-namespace filesystem {
-
-const std::vector<const char*> WgtAdditionalSharedDirs = {
-  {"tmp"},
-};
-
-}  // namespace filesystem
-}  // namespace wgt
-
-#endif  // WGT_SHARED_DIRS_H_
index 6db5b8ec3f8995d92f8c2e561c1753acf9d198f3..c39474b3bfbbcdf76377f4d5a74a0e9c4d3a09ed 100644 (file)
@@ -10,7 +10,7 @@
 #include <common/installer_context.h>
 #include <common/step/step.h>
 
-#include <wgt/wgt_backend_data.h>
+#include <wgt/utils/wgt_backend_data.h>
 
 #include <wgt_manifest_handlers/w3c_pc_utils.h>
 #include <wgt_manifest_handlers/content_handler.h>
index 7fc7025c830d8f40cca6e695caa2afa6906cdcfa..31f42d591a8be79027db81bf31567ccd562d6c4d 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <manifest_parser/utils/logging.h>
 
-#include <wgt/wgt_backend_data.h>
+#include <wgt/utils/wgt_backend_data.h>
 
 #include <type_traits>
 #include <cassert>
index 9cbf0fbe6b9a127f87586a80d03954a8d0367742..be1e09c0b952feb6a2b9a2e097b9a54fbae7543b 100644 (file)
@@ -47,7 +47,7 @@
 #include <vector>
 #include <utility>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace bf = boost::filesystem;
 namespace ci = common_installer;
index 6b420fdd94df757786ee647638d5319266322773..b66db685be1f6a2d2974b9d96a6518c83abee4cf 100644 (file)
@@ -10,7 +10,7 @@
 #include <common/step/step.h>
 #include <manifest_parser/utils/logging.h>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace wgt {
 namespace encryption {
index 2cdf5cc6c76e640b62eba586f7a01aa8f1e63a72..b706345c51a811a1c18e5223902a336888c80afa 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <string>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace bf = boost::filesystem;
 namespace ci = common_installer;
index f6537f9f50e4311520919f592b5718248c56a871..7294e17e1d470fa56ba71e2a40d1a8c27b9598f6 100644 (file)
@@ -23,7 +23,7 @@
 #include <cstring>
 #include <string>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace bs = boost::system;
 namespace bf = boost::filesystem;
index b5330bdc9a6d3e07a3831617bd1af81c1f4c32ea..affeb473b8693f5da1b52b715e218bc66fff59b2 100755 (executable)
@@ -22,7 +22,7 @@
 #include <string>
 #include <memory>
 
-#include "wgt/extension_config_parser.h"
+#include "wgt/utils/extension_config_parser.h"
 
 namespace {
 
index b26f7ede296b82975d2f8a6ce0d45135dd41d3fe..2ea5a8555274a21f0ae4e6783f8090c8c1e82cd6 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <map>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace wgt {
 namespace security {
index b3d6a2c98b1628b055c519c4da299d2ff36c9b02..a245545371ee79349efc4849337d213270b460a5 100644 (file)
@@ -7,7 +7,7 @@
 #include <common/installer_context.h>
 #include <wgt_manifest_handlers/setting_handler.h>
 
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
 
 namespace {
 
diff --git a/src/wgt/utils/extension_config_parser.cc b/src/wgt/utils/extension_config_parser.cc
new file mode 100644 (file)
index 0000000..7a448a4
--- /dev/null
@@ -0,0 +1,192 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/utils/extension_config_parser.h"
+#include <manifest_parser/utils/string_util.h>
+#include <manifest_parser/manifest_handler.h>
+
+#include <cassert>
+#include <utility>
+
+namespace wgt {
+
+namespace {
+
+const xmlChar kExtensionNodeKey[] = "extension";
+const xmlChar kNamePrivilegeKey[] = "privilege";
+const xmlChar kPrivigeNameAttributeKey[] = "name";
+const char kAttributePrefix[] = "@";
+const xmlChar kDirAttributeKey[] = "dir";
+const char kXmlTextKey[] = "#text";
+const char kNamespaceKey[] = "@namespace";
+const char kExtensionPath[] = "extension.privilege";
+const char kExtensionNameKey[] = "@name";
+
+}  // namespace
+
+ExtensionConfigParser::ExtensionConfigParser(std::string config_xml)
+    : config_xml_(config_xml) {}
+
+std::unique_ptr<parser::DictionaryValue>
+    ExtensionConfigParser::LoadExtensionConfig(const std::string& config_xml) {
+  xmlDoc *doc = nullptr;
+  xmlNode* root_node = nullptr;
+  doc = xmlReadFile(config_xml.c_str(), nullptr, XML_PARSE_NOENT);
+  if (!doc) {
+    LOG(ERROR) << "Failed to read xml document model from" << config_xml;
+    return nullptr;
+  }
+  root_node = xmlDocGetRootElement(doc);
+  std::unique_ptr<parser::DictionaryValue> dv = LoadXMLNode(root_node);
+  std::unique_ptr<parser::DictionaryValue> result(new parser::DictionaryValue);
+  if (dv)
+    result->Set(reinterpret_cast<const char*>(root_node->name), dv.release());
+  return result;
+}
+
+std::string ExtensionConfigParser::GetNodeDir(
+    xmlNode* node, const std::string& inherit_dir) {
+  std::string dir(inherit_dir);
+  for (xmlAttr* prop = node->properties; prop; prop = prop->next) {
+    if (xmlStrEqual(prop->name, kDirAttributeKey)) {
+      char* prop_value = reinterpret_cast<char*>(xmlNodeListGetString(
+          node->doc, prop->children, 1));
+      dir = prop_value;
+      xmlFree(prop_value);
+      break;
+    }
+  }
+  return dir;
+}
+std::string ExtensionConfigParser::GetNodeText(
+    xmlNode* root, const std::string& inherit_dir) {
+  if (root->type != XML_ELEMENT_NODE)
+    return std::string();
+  std::string current_dir(GetNodeDir(root, inherit_dir));
+  std::string text;
+  if (!current_dir.empty())
+    text += parser::utils::GetDirUTF8Start(current_dir);
+  for (xmlNode* node = root->children; node; node = node->next) {
+    if (node->type == XML_TEXT_NODE || node->type == XML_CDATA_SECTION_NODE)
+      text = text + std::string(reinterpret_cast<char*>(node->content));
+    else
+      text += GetNodeText(node, current_dir);
+  }
+  if (!current_dir.empty())
+    text += parser::utils::GetDirUTF8End();
+  return text;
+}
+bool ExtensionConfigParser::IsPropSupportDir(xmlNode* root, xmlAttr* prop) {
+  if (xmlStrEqual(root->name, kNamePrivilegeKey)
+      && xmlStrEqual(prop->name, kPrivigeNameAttributeKey)) {
+    return true;
+  }
+  return false;
+}
+bool ExtensionConfigParser::IsTrimRequiredForElement(xmlNode* root) {
+  if (xmlStrEqual(root->name, kNamePrivilegeKey)) {
+    return true;
+  }
+  return false;
+}
+bool ExtensionConfigParser::IsTrimRequiredForProp(
+    xmlNode* root, xmlAttr* prop) {
+  if (xmlStrEqual(root->name, kNamePrivilegeKey) &&
+      xmlStrEqual(prop->name, kPrivigeNameAttributeKey)) {
+    return true;
+  }
+  return false;
+}
+std::unique_ptr<parser::DictionaryValue>
+    ExtensionConfigParser::LoadXMLNode(
+    xmlNode* root, const std::string& inherit_dir) {
+  std::unique_ptr<parser::DictionaryValue> value(new parser::DictionaryValue());
+  if (root->type != XML_ELEMENT_NODE)
+    return nullptr;
+
+  std::string current_dir(GetNodeDir(root, inherit_dir));
+
+  xmlAttr* prop = nullptr;
+  for (prop = root->properties; prop; prop = prop->next) {
+    xmlChar* value_ptr = xmlNodeListGetString(root->doc, prop->children, 1);
+    std::string prop_value(reinterpret_cast<char*>(value_ptr));
+    xmlFree(value_ptr);
+    if (IsPropSupportDir(root, prop))
+      prop_value = parser::utils::GetDirTextUTF8(prop_value, current_dir);
+
+    if (IsTrimRequiredForProp(root, prop))
+      prop_value = parser::utils::CollapseWhitespaceUTF8(prop_value);
+
+    value->SetString(
+        std::string(kAttributePrefix)
+        + reinterpret_cast<const char*>(prop->name),
+        prop_value);
+  }
+
+  if (root->ns)
+    value->SetString(kNamespaceKey,
+        reinterpret_cast<const char*>(root->ns->href));
+
+  for (xmlNode* node = root->children; node; node = node->next) {
+    std::string sub_node_name(reinterpret_cast<const char*>(node->name));
+    std::unique_ptr<parser::DictionaryValue> sub_value =
+        LoadXMLNode(node, current_dir);
+
+    if (!sub_value) {
+      continue;
+    }
+    if (!value->HasKey(sub_node_name)) {
+      value->Set(sub_node_name, sub_value.release());
+      continue;
+    }
+
+    parser::Value* temp;
+    value->Get(sub_node_name, &temp);
+
+    if (temp->IsType(parser::Value::TYPE_LIST)) {
+      parser::ListValue* list;
+      temp->GetAsList(&list);
+      list->Append(sub_value.release());
+    } else {
+      assert(temp->IsType(parser::Value::TYPE_DICTIONARY));
+      parser::DictionaryValue* dict;
+      temp->GetAsDictionary(&dict);
+      parser::DictionaryValue* prev_value = dict->DeepCopy();
+
+      parser::ListValue* list = new parser::ListValue();
+      list->Append(prev_value);
+      list->Append(sub_value.release());
+      value->Set(sub_node_name, list);
+    }
+  }
+
+  std::string text;
+  xmlChar* text_ptr = xmlNodeListGetString(root->doc, root->children, 1);
+  if (text_ptr) {
+    text = reinterpret_cast<char*>(text_ptr);
+    xmlFree(text_ptr);
+  }
+  if (IsTrimRequiredForElement(root))
+    text = parser::utils::CollapseWhitespaceUTF8(text);
+  if (!text.empty())
+    value->SetString(kXmlTextKey, text);
+
+  return value;
+}
+std::vector<std::string> ExtensionConfigParser::GetExtensionPrivilegeList() {
+  std::unique_ptr<parser::DictionaryValue> dic
+    = LoadExtensionConfig(config_xml_);
+  std::vector<std::string> privilege_list;
+
+  for (auto& item : parser::GetOneOrMany(dic.get(), kExtensionPath, "")) {
+    std::string privilege;
+    if (item->GetString(kExtensionNameKey, &privilege)) {
+      LOG(DEBUG) << "User defined extra privilege: " << privilege;
+      privilege_list.push_back(privilege);
+    }
+  }
+  return privilege_list;
+}
+
+}  // namespace wgt
diff --git a/src/wgt/utils/extension_config_parser.h b/src/wgt/utils/extension_config_parser.h
new file mode 100644 (file)
index 0000000..915497e
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_EXTENSION_CONFIG_PARSER_H_
+#define WGT_EXTENSION_CONFIG_PARSER_H_
+
+#include <libxml2/libxml/tree.h>
+#include <manifest_parser/utils/logging.h>
+#include <manifest_parser/values.h>
+#include <manifest_parser/manifest_util.h>
+
+#include <memory>
+#include <string>
+#include <map>
+#include <vector>
+
+namespace wgt {
+class ExtensionConfigParser {
+ public:
+  explicit ExtensionConfigParser(std::string config_xml);
+  std::vector<std::string> GetExtensionPrivilegeList();
+ private:
+  std::unique_ptr<parser::DictionaryValue> LoadExtensionConfig(
+      const std::string& config_xml);
+  std::string GetNodeDir(xmlNode* node, const std::string& inherit_dir);
+  std::string GetNodeText(xmlNode* root, const std::string& inherit_dir);
+  bool IsPropSupportDir(xmlNode* root, xmlAttr* prop);
+  bool IsTrimRequiredForElement(xmlNode* root);
+  bool IsTrimRequiredForProp(xmlNode* root, xmlAttr* prop);
+  std::unique_ptr<parser::DictionaryValue> LoadXMLNode(
+      xmlNode* root, const std::string& inherit_dir = "");
+  std::string config_xml_;
+};
+
+}  // namespace wgt
+
+#endif  // WGT_EXTENSION_CONFIG_PARSER_H_
diff --git a/src/wgt/utils/shared_dirs.h b/src/wgt/utils/shared_dirs.h
new file mode 100644 (file)
index 0000000..61bb319
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2016 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_SHARED_DIRS_H_
+#define WGT_SHARED_DIRS_H_
+
+#include <vector>
+
+namespace wgt {
+namespace filesystem {
+
+const std::vector<const char*> WgtAdditionalSharedDirs = {
+  {"tmp"},
+};
+
+}  // namespace filesystem
+}  // namespace wgt
+
+#endif  // WGT_SHARED_DIRS_H_
diff --git a/src/wgt/utils/wgt_app_query_interface.cc b/src/wgt/utils/wgt_app_query_interface.cc
new file mode 100644 (file)
index 0000000..3c9131e
--- /dev/null
@@ -0,0 +1,127 @@
+// Copyright (c) 2015 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/utils/wgt_app_query_interface.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/system/error_code.hpp>
+
+#include <common/pkgmgr_interface.h>
+#include <common/pkgmgr_query.h>
+#include <common/recovery_file.h>
+#include <common/request.h>
+#include <common/utils/file_util.h>
+
+#include <manifest_parser/manifest_parser.h>
+#include <manifest_parser/utils/logging.h>
+#include <wgt_manifest_handlers/application_manifest_constants.h>
+#include <wgt_manifest_handlers/tizen_application_handler.h>
+#include <wgt_manifest_handlers/addon_handler.h>
+#include <wgt_manifest_handlers/widget_handler.h>
+
+#include <tzplatform_config.h>
+
+#include <memory>
+#include <utility>
+#include <string>
+#include <vector>
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+namespace ci = common_installer;
+
+namespace {
+
+const char kHybridConfigLocation[] = "res/wgt/config.xml";
+const char kTizenManifestLocation[] = "tizen-manifest.xml";
+
+std::string ReadPkgidFromRecovery(const std::string& recovery_path) {
+  std::unique_ptr<ci::recovery::RecoveryFile> recovery_file =
+      ci::recovery::RecoveryFile::OpenRecoveryFile(recovery_path);
+  recovery_file->Detach();
+  return recovery_file->pkgid();
+}
+
+}  // namespace
+
+namespace wgt {
+
+std::string WgtAppQueryInterface::GetManifestFileName() const {
+  return "config.xml";
+}
+
+std::string WgtAppQueryInterface::GetPkgIdFromPath(
+    const std::string& path) const {
+  bf::path tmp_path = ExtractManifest(path);
+  if (tmp_path.empty())
+    return {};
+  std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
+    std::make_shared<wgt::parse::WidgetHandler>(),
+    std::make_shared<wgt::parse::TizenApplicationHandler>(),
+    std::make_shared<wgt::parse::AddonHandler>()
+  };
+  std::unique_ptr<parser::ManifestHandlerRegistry> registry(
+      new parser::ManifestHandlerRegistry(handlers));
+  std::unique_ptr<parser::ManifestParser> parser(
+      new parser::ManifestParser(std::move(registry)));
+  bf::path config_path = tmp_path / GetManifestFileName();
+  if (!parser->ParseManifest(config_path)) {
+    ci::RemoveAll(tmp_path);
+    return {};
+  }
+  auto info = std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
+      parser->GetManifestData(
+          wgt::application_widget_keys::kTizenApplicationKey));
+
+  auto info_addon = std::static_pointer_cast<const wgt::parse::AddonInfo>(
+      parser->GetManifestData(
+          wgt::application_widget_keys::kTizenAddonKey));
+
+  if (!info && !info_addon) {
+    ci::RemoveAll(tmp_path);
+    return {};
+  }
+  std::string pkg_id = !info ? info_addon->package() : info->package();
+
+  ci::RemoveAll(tmp_path);
+  return pkg_id;
+}
+
+bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg,
+    uid_t uid) const {
+  std::string info;
+  bool is_recovery = arg.find("wgt-recovery-") != std::string::npos;
+  if (is_recovery)
+    info = ReadPkgidFromRecovery(arg);
+  else
+    info = arg;
+  bf::path rw_package_directory(ci::GetRootAppPath(false, uid));
+  bf::path ro_package_directory;
+  if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) || uid == 0)
+    ro_package_directory = ci::GetRootAppPath(true, uid);
+  if ((bf::exists(rw_package_directory / info / kTizenManifestLocation) &&
+        bf::exists(rw_package_directory / info / kHybridConfigLocation)) ||
+       (bf::exists(ro_package_directory / info / kTizenManifestLocation) &&
+        bf::exists(ro_package_directory / info / kHybridConfigLocation))) {
+      return true;
+  } else if (!is_recovery) {
+    bool tizen_manifest_found = false;
+    bool config_xml_found = false;
+    if (!ci::CheckPathInZipArchive(info.c_str(), kTizenManifestLocation,
+                                   &tizen_manifest_found))
+      return false;
+    if (!ci::CheckPathInZipArchive(info.c_str(), kHybridConfigLocation,
+                                   &config_xml_found))
+      return false;
+    if (tizen_manifest_found && config_xml_found)
+      return true;
+  }
+  return false;
+}
+
+}  // namespace wgt
diff --git a/src/wgt/utils/wgt_app_query_interface.h b/src/wgt/utils/wgt_app_query_interface.h
new file mode 100644 (file)
index 0000000..c19d46a
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (c) 2015 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_WGT_APP_QUERY_INTERFACE_H_
+#define WGT_WGT_APP_QUERY_INTERFACE_H_
+
+#include <common/app_query_interface.h>
+
+#include <sys/types.h>
+
+#include <string>
+
+namespace wgt {
+
+/**
+ * \brief Helper functionalities used before
+ *        configuring app-installer steps.
+ *        Eg. it is used to check, if package is to be installed or updated
+ */
+class WgtAppQueryInterface : public common_installer::AppQueryInterface {
+ public:
+  /**
+   * \brief This method is workaround for detecting installation of hybrid
+   *        application.
+   *
+   * \return true if package is hybrid
+   */
+  bool IsHybridApplication(const std::string& arg, uid_t uid) const;
+
+ private:
+  std::string GetPkgIdFromPath(const std::string& path) const override;
+  std::string GetManifestFileName() const override;
+};
+
+}  // namespace wgt
+
+#endif  // WGT_WGT_APP_QUERY_INTERFACE_H_
diff --git a/src/wgt/utils/wgt_backend_data.h b/src/wgt/utils/wgt_backend_data.h
new file mode 100644 (file)
index 0000000..cd7651a
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_WGT_BACKEND_DATA_H_
+#define WGT_WGT_BACKEND_DATA_H_
+
+#include <common/installer_context.h>
+#include <common/utils/property.h>
+
+#include <wgt_manifest_handlers/appwidget_handler.h>
+#include <wgt_manifest_handlers/content_handler.h>
+#include <wgt_manifest_handlers/service_handler.h>
+#include <wgt_manifest_handlers/setting_handler.h>
+#include <wgt_manifest_handlers/trust_anchor_handler.h>
+
+#include <string>
+#include <vector>
+
+namespace wgt {
+
+/**
+ * \brief Class that is used within specific backends to keep additional
+ *        information regarding package
+ */
+class WgtBackendData : public common_installer::BackendData {
+ public:
+  /**
+   * \brief Property of SettingInfo
+   */
+  Property<parse::SettingInfo> settings;
+
+  Property<parse::AppWidgetInfo> appwidgets;
+  Property<parse::ContentInfo> content;
+  Property<parse::ServiceList> service_list;
+  Property<parse::TrustAnchorInfo> trust_anchor;
+};
+
+}  // namespace wgt
+
+#endif  // WGT_WGT_BACKEND_DATA_H_
diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc
deleted file mode 100644 (file)
index 736982c..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) 2015 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/wgt_app_query_interface.h"
-
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <common/pkgmgr_interface.h>
-#include <common/pkgmgr_query.h>
-#include <common/recovery_file.h>
-#include <common/request.h>
-#include <common/utils/file_util.h>
-
-#include <manifest_parser/manifest_parser.h>
-#include <manifest_parser/utils/logging.h>
-#include <wgt_manifest_handlers/application_manifest_constants.h>
-#include <wgt_manifest_handlers/tizen_application_handler.h>
-#include <wgt_manifest_handlers/addon_handler.h>
-#include <wgt_manifest_handlers/widget_handler.h>
-
-#include <tzplatform_config.h>
-
-#include <memory>
-#include <utility>
-#include <string>
-#include <vector>
-
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-namespace ci = common_installer;
-
-namespace {
-
-const char kHybridConfigLocation[] = "res/wgt/config.xml";
-const char kTizenManifestLocation[] = "tizen-manifest.xml";
-
-std::string ReadPkgidFromRecovery(const std::string& recovery_path) {
-  std::unique_ptr<ci::recovery::RecoveryFile> recovery_file =
-      ci::recovery::RecoveryFile::OpenRecoveryFile(recovery_path);
-  recovery_file->Detach();
-  return recovery_file->pkgid();
-}
-
-}  // namespace
-
-namespace wgt {
-
-std::string WgtAppQueryInterface::GetManifestFileName() const {
-  return "config.xml";
-}
-
-std::string WgtAppQueryInterface::GetPkgIdFromPath(
-    const std::string& path) const {
-  bf::path tmp_path = ExtractManifest(path);
-  if (tmp_path.empty())
-    return {};
-  std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
-    std::make_shared<wgt::parse::WidgetHandler>(),
-    std::make_shared<wgt::parse::TizenApplicationHandler>(),
-    std::make_shared<wgt::parse::AddonHandler>()
-  };
-  std::unique_ptr<parser::ManifestHandlerRegistry> registry(
-      new parser::ManifestHandlerRegistry(handlers));
-  std::unique_ptr<parser::ManifestParser> parser(
-      new parser::ManifestParser(std::move(registry)));
-  bf::path config_path = tmp_path / GetManifestFileName();
-  if (!parser->ParseManifest(config_path)) {
-    ci::RemoveAll(tmp_path);
-    return {};
-  }
-  auto info = std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
-      parser->GetManifestData(
-          wgt::application_widget_keys::kTizenApplicationKey));
-
-  auto info_addon = std::static_pointer_cast<const wgt::parse::AddonInfo>(
-      parser->GetManifestData(
-          wgt::application_widget_keys::kTizenAddonKey));
-
-  if (!info && !info_addon) {
-    ci::RemoveAll(tmp_path);
-    return {};
-  }
-  std::string pkg_id = !info ? info_addon->package() : info->package();
-
-  ci::RemoveAll(tmp_path);
-  return pkg_id;
-}
-
-bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg,
-    uid_t uid) const {
-  std::string info;
-  bool is_recovery = arg.find("wgt-recovery-") != std::string::npos;
-  if (is_recovery)
-    info = ReadPkgidFromRecovery(arg);
-  else
-    info = arg;
-  bf::path rw_package_directory(ci::GetRootAppPath(false, uid));
-  bf::path ro_package_directory;
-  if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) || uid == 0)
-    ro_package_directory = ci::GetRootAppPath(true, uid);
-  if ((bf::exists(rw_package_directory / info / kTizenManifestLocation) &&
-        bf::exists(rw_package_directory / info / kHybridConfigLocation)) ||
-       (bf::exists(ro_package_directory / info / kTizenManifestLocation) &&
-        bf::exists(ro_package_directory / info / kHybridConfigLocation))) {
-      return true;
-  } else if (!is_recovery) {
-    bool tizen_manifest_found = false;
-    bool config_xml_found = false;
-    if (!ci::CheckPathInZipArchive(info.c_str(), kTizenManifestLocation,
-                                   &tizen_manifest_found))
-      return false;
-    if (!ci::CheckPathInZipArchive(info.c_str(), kHybridConfigLocation,
-                                   &config_xml_found))
-      return false;
-    if (tizen_manifest_found && config_xml_found)
-      return true;
-  }
-  return false;
-}
-
-}  // namespace wgt
diff --git a/src/wgt/wgt_app_query_interface.h b/src/wgt/wgt_app_query_interface.h
deleted file mode 100644 (file)
index c19d46a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2015 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_WGT_APP_QUERY_INTERFACE_H_
-#define WGT_WGT_APP_QUERY_INTERFACE_H_
-
-#include <common/app_query_interface.h>
-
-#include <sys/types.h>
-
-#include <string>
-
-namespace wgt {
-
-/**
- * \brief Helper functionalities used before
- *        configuring app-installer steps.
- *        Eg. it is used to check, if package is to be installed or updated
- */
-class WgtAppQueryInterface : public common_installer::AppQueryInterface {
- public:
-  /**
-   * \brief This method is workaround for detecting installation of hybrid
-   *        application.
-   *
-   * \return true if package is hybrid
-   */
-  bool IsHybridApplication(const std::string& arg, uid_t uid) const;
-
- private:
-  std::string GetPkgIdFromPath(const std::string& path) const override;
-  std::string GetManifestFileName() const override;
-};
-
-}  // namespace wgt
-
-#endif  // WGT_WGT_APP_QUERY_INTERFACE_H_
diff --git a/src/wgt/wgt_backend_data.h b/src/wgt/wgt_backend_data.h
deleted file mode 100644 (file)
index cd7651a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef WGT_WGT_BACKEND_DATA_H_
-#define WGT_WGT_BACKEND_DATA_H_
-
-#include <common/installer_context.h>
-#include <common/utils/property.h>
-
-#include <wgt_manifest_handlers/appwidget_handler.h>
-#include <wgt_manifest_handlers/content_handler.h>
-#include <wgt_manifest_handlers/service_handler.h>
-#include <wgt_manifest_handlers/setting_handler.h>
-#include <wgt_manifest_handlers/trust_anchor_handler.h>
-
-#include <string>
-#include <vector>
-
-namespace wgt {
-
-/**
- * \brief Class that is used within specific backends to keep additional
- *        information regarding package
- */
-class WgtBackendData : public common_installer::BackendData {
- public:
-  /**
-   * \brief Property of SettingInfo
-   */
-  Property<parse::SettingInfo> settings;
-
-  Property<parse::AppWidgetInfo> appwidgets;
-  Property<parse::ContentInfo> content;
-  Property<parse::ServiceList> service_list;
-  Property<parse::TrustAnchorInfo> trust_anchor;
-};
-
-}  // namespace wgt
-
-#endif  // WGT_WGT_BACKEND_DATA_H_
index f74e37abdaf994a73e28ffd5298fc01a72f8a6d4..76d0a009687a06b19591482039653402d6aa279d 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <wgt_manifest_handlers/widget_config_parser.h>
 
-#include "wgt/shared_dirs.h"
+#include "wgt/utils/shared_dirs.h"
 #include "wgt/step/configuration/step_check_rds_manifest.h"
 #include "wgt/step/configuration/step_check_start_files.h"
 #include "wgt/step/configuration/step_parse.h"
index f0633b471d132a33739c69a734cd93469db334ba..9f003e37731153fd41a7f512deb7290b925443de 100644 (file)
@@ -7,7 +7,7 @@
 #include <cerrno>
 
 #include "hybrid/hybrid_installer.h"
-#include "wgt/wgt_app_query_interface.h"
+#include "wgt/utils/wgt_app_query_interface.h"
 #include "wgt/wgt_installer.h"
 
 namespace ci = common_installer;