Move it to reduce module circular dependency.
Change-Id: Iffed47db7a38950afe961ea4ebdc9b5fd643e57f
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
#include <string>
#include <vector>
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
namespace hybrid {
#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) \
#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;
#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 {
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
${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
+++ /dev/null
-// 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
+++ /dev/null
-// 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_
+++ /dev/null
-// 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_
#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>
#include <manifest_parser/utils/logging.h>
-#include <wgt/wgt_backend_data.h>
+#include <wgt/utils/wgt_backend_data.h>
#include <type_traits>
#include <cassert>
#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;
#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 {
#include <string>
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
namespace bf = boost::filesystem;
namespace ci = common_installer;
#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;
#include <string>
#include <memory>
-#include "wgt/extension_config_parser.h"
+#include "wgt/utils/extension_config_parser.h"
namespace {
#include <map>
-#include "wgt/wgt_backend_data.h"
+#include "wgt/utils/wgt_backend_data.h"
namespace wgt {
namespace security {
#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 {
--- /dev/null
+// 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
--- /dev/null
+// 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_
--- /dev/null
+// 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_
--- /dev/null
+// 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
--- /dev/null
+// 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_
--- /dev/null
+// 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_
+++ /dev/null
-// 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
+++ /dev/null
-// 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_
+++ /dev/null
-// 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_
#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"
#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;