SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++11 -g --coverage")
# Targets
-SET(TARGET_LIBNAME_WGT_MANIFEST_HANDLERS "wgt-manifest-handlers")
-SET(TARGET_LIBNAME_TPK_MANIFEST_HANDLERS "tpk-manifest-handlers")
SET(TARGET_LIBNAME_DELTA_MANIFEST_HANDLERS "delta-manifest-handlers")
SET(TARGET_LIBNAME_PARSER "manifest-parser")
SET(TARGET_LIBNAME_UTILS "manifest-parser-utils")
%{_datarootdir}/manifest-parser/languages-only.txt
%{_libdir}/libmanifest-parser.so*
%{_libdir}/libmanifest-parser-utils.so*
-%{_libdir}/libtpk-manifest-handlers.so*
-%{_libdir}/libwgt-manifest-handlers.so*
%{_libdir}/libdelta-manifest-handlers.so*
%license LICENSE LICENSE-xwalk
%{_libdir}/pkgconfig/*.pc
%{_includedir}/manifest_parser/*.h
%{_includedir}/manifest_parser/utils/*.h
-%{_includedir}/tpk_manifest_handlers/*.h
-%{_includedir}/tpk_manifest_handlers/common/*.h
-%{_includedir}/wgt_manifest_handlers/*.h
%{_includedir}/delta/*.h
%files tests
ADD_SUBDIRECTORY(manifest_parser)
-ADD_SUBDIRECTORY(tpk_manifest_handlers)
ADD_SUBDIRECTORY(unit_tests)
-ADD_SUBDIRECTORY(wgt_manifest_handlers)
ADD_SUBDIRECTORY(examples)
-ADD_SUBDIRECTORY(delta)
+ADD_SUBDIRECTORY(delta)
\ No newline at end of file
Boost
)
-TARGET_LINK_LIBRARIES(${TARGET_EXAMPLES} PUBLIC ${TARGET_LIBNAME_PARSER} ${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS})
+TARGET_LINK_LIBRARIES(${TARGET_EXAMPLES} PUBLIC ${TARGET_LIBNAME_PARSER})
INSTALL(FILES config.xml DESTINATION ${SHAREDIR}/manifest-parser)
// Include manifest parser
#include <manifest_parser/manifest_parser.h>
// Include manifest handler, which is packaged with manifest parser
-#include <wgt_manifest_handlers/tizen_application_handler.h>
#include <boost/filesystem/path.hpp>
#include <cassert>
std::unique_ptr<parser::ManifestHandlerRegistry> registry(
new parser::ManifestHandlerRegistry());
// Add some manifest handlers
- registry->RegisterManifestHandler(new wgt::parse::TizenApplicationHandler);
registry->RegisterManifestHandler(new example::ItemListHandler);
registry->RegisterManifestHandler(new example::ItemHandler);
std::shared_ptr<const example::ItemListInfo> item_info_list =
std::static_pointer_cast<const example::ItemListInfo>(
m_parser->GetManifestData(example::keys::item_handler_list_key));
- std::shared_ptr<const wgt::parse::TizenApplicationInfo> tizen_app_info =
- std::static_pointer_cast<const wgt::parse::TizenApplicationInfo>(
- m_parser->GetManifestData(wgt::parse::TizenApplicationInfo::Key()));
// Check parsed ItemInfo data
assert(!strcmp("additional", item_info->type().c_str()));
assert(!strcmp("text", item_info_list->get_item(2)->type().c_str()));
assert(!strcmp("third", item_info_list->get_item(2)->value().c_str()));
- // Check parsed TizenApplicationInfo data
- assert(!strcmp("nNBDOItqjN.sample", tizen_app_info->id().c_str()));
- assert(!strcmp("nNBDOItqjN", tizen_app_info->package().c_str()));
- assert(!strcmp("2.2", tizen_app_info->required_version().c_str()));
-
return 0;
}
${CMAKE_CURRENT_SOURCE_DIR}/manifest.h
${CMAKE_CURRENT_SOURCE_DIR}/manifest_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/manifest_parser.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/manifest_util.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/manifest_parser_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/permission_types.h
${CMAKE_CURRENT_SOURCE_DIR}/values.h
)
Name: manifest-parser-utils
Description: Universal manifest parser utils
Version: @VERSION@
-Requires: libiri
+Requires: libiri dlog
Libs: -L${libdir} -lmanifest-parser-utils
Cflags: -I${includedir}
\ No newline at end of file
+++ /dev/null
-# Target - sources
-SET(SRCS
- account_handler.cc
- application_manifest_constants.cc
- author_handler.cc
- common/application_handler.cc
- description_handler.cc
- package_handler.cc
- privileges_handler.cc
- profile_handler.cc
- service_application_handler.cc
- shortcut_handler.cc
- tpk_config_parser.cc
- ui_application_handler.cc
- watch_application_handler.cc
- widget_application_handler.cc
-)
-
-# Target - definition
-ADD_LIBRARY(${TARGET_LIBNAME_TPK_MANIFEST_HANDLERS} SHARED ${SRCS})
-
-# Target - includes
-TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_TPK_MANIFEST_HANDLERS} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
-
-# Target - deps
-APPLY_PKG_CONFIG(${TARGET_LIBNAME_TPK_MANIFEST_HANDLERS} PUBLIC
- Boost
-)
-
-# Extra
-SET_TARGET_PROPERTIES(${TARGET_LIBNAME_TPK_MANIFEST_HANDLERS} PROPERTIES VERSION ${VERSION})
-SET_TARGET_PROPERTIES(${TARGET_LIBNAME_TPK_MANIFEST_HANDLERS} PROPERTIES SOVERSION ${VERSION_MAJOR})
-
-# Install
-INSTALL(TARGETS ${TARGET_LIBNAME_TPK_MANIFEST_HANDLERS} DESTINATION ${LIB_INSTALL_DIR})
-
-# Install includes
-INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDEDIR}
- FILES_MATCHING PATTERN "*.h")
-
-# Configure and install pkgconfig file
-SET(PKG_FILE tpk-manifest-handlers.pc)
-CONFIGURE_FILE(${PKG_FILE}.in ${PKG_FILE} @ONLY)
-INSTALL(FILES ${PKG_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+++ /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.
-
-#include "tpk_manifest_handlers/account_handler.h"
-
-#include "manifest_parser/utils/language_tag_validator.h"
-#include "manifest_parser/utils/logging.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-const char kTrueValueString[] = "true";
-const char kFalseValueString[] = "false";
-}
-
-namespace tpk {
-namespace parse {
-
-namespace keys = tpk::application_keys;
-
-namespace {
-const char kAccountKey[] = "manifest.account";
-const char kAccountProviderKey[] = "account-provider";
-const char kAccountProviderIDKey[] = "@providerid";
-const char kAccountAppIDKey[] = "@appid";
-const char kAccountMASKey[] = "@multiple-accounts-support";
-const char kAccountIconKey[] = "icon";
-const char kAccountSectionKey[] = "@section";
-const char kAccountTextKey[] = "#text";
-const char kAccountLabelKey[] = "label";
-const char kAccountCapabilityKey[] = "capability";
-const char kAccountLangKey[] = "@lang";
-const char kAccountIconNormalKey[] = "account";
-const char kAccountIconSmallKey[] = "account-small";
-} // namespace
-
-bool AccountHandler::Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- std::shared_ptr<AccountInfo> info(new AccountInfo);
-
- if (manifest.Get(kAccountKey, &val)) {
- if (val->GetAsDictionary(&dict)) {
- if (!ParseSingleAccountElement(dict, info, error))
- return false;
- } else if (val->GetAsList(&list)) {
- *error = "<account> may be declared only once";
- return false;
- }
- }
- *output = std::static_pointer_cast<AccountInfo>(info);
- return true;
-}
-
-std::string AccountInfo::key() {
- return kAccountKey;
-}
-
-std::string AccountHandler::Key() const {
- return kAccountKey;
-}
-
-bool AccountHandler::ParseSingleAccountElement(
- const parser::DictionaryValue* item_dict,
- std::shared_ptr<AccountInfo> info,
- std::string* error) {
- for (auto& item : parser::GetOneOrMany(item_dict, kAccountProviderKey, "")) {
- if (!ParseAccountProvider(item, info, error))
- return false;
- }
- return true;
-}
-
-bool AccountHandler::ParseAccountProvider(
- const parser::DictionaryValue* dict,
- std::shared_ptr<AccountInfo> info,
- std::string* error) {
- SingleAccountInfo single_account;
- std::string app_id;
- if (!dict->GetString(kAccountAppIDKey, &app_id)) {
- *error = "Error while parsing app id in account";
- return false;
- }
-
- single_account.app_id = app_id;
-
- std::string multiple_apps_support;
- if (!dict->GetString(kAccountMASKey, &multiple_apps_support)) {
- *error = "Error while parsing multiple accounts support in account";
- return false;
- }
-
- std::string provider_id;
- dict->GetString(kAccountProviderIDKey, &provider_id);
- single_account.provider_id = provider_id;
-
- bool mas_bool = false;
- if (multiple_apps_support == kFalseValueString) {
- mas_bool = false;
- } else if (multiple_apps_support == kTrueValueString) {
- mas_bool = true;
- } else {
- *error = "Multiple accounts support in "
- "account has invalid (not boolean) value";
- return false;
- }
-
- single_account.multiple_account_support = mas_bool;
- if (!ParseAccountIcons(dict, &single_account)) {
- *error = "Error while parsing account icons";
- return false;
- }
- if (!ParseLabels(dict, &single_account)) {
- *error = "Error while parsing account lables";
- return false;
- }
- if (!ParseCapabilities(dict, &single_account)) {
- *error = "Error while parsing account capabilities";
- return false;
- }
- info->set_account(single_account);
- return true;
-}
-
-bool AccountHandler::ParseAccountIcons(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- auto& icons = parser::GetOneOrMany(item_dict, kAccountIconKey, "");
- if (icons.empty())
- return false;
- for (auto& item : icons) {
- if (!ParseSingleAccountIcon(item, info))
- return false;
- }
- return true;
-}
-
-bool AccountHandler::ParseSingleAccountIcon(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- std::string section;
- item_dict->GetString(kAccountSectionKey, §ion);
- if (section != kAccountIconNormalKey &&
- section != kAccountIconSmallKey)
- return false;
- std::string icon_path;
- item_dict->GetString(kAccountTextKey, &icon_path);
- info->icon_paths.push_back(std::make_pair(section, icon_path));
- return true;
-}
-
-bool AccountHandler::ParseLabels(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- for (auto& item : parser::GetOneOrMany(item_dict, kAccountLabelKey, "")) {
- std::string lang;
- std::string label;
- item->GetString(kAccountLangKey, &lang);
- item->GetString(kAccountTextKey, &label);
- info->labels.push_back(std::make_pair(label, lang));
- }
- return true;
-}
-
-bool AccountHandler::ParseCapabilities(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- for (auto& item : parser::GetOneOrMany(item_dict, kAccountCapabilityKey,
- "")) {
- std::string capability;
- item->GetString(kAccountTextKey, &capability);
- info->capabilities.push_back(capability);
- }
- return true;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_ACCOUNT_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_ACCOUNT_HANDLER_H_
-
-#include <utility>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace tpk {
-namespace parse {
-
-struct SingleAccountInfo {
- bool multiple_account_support;
- std::string app_id;
- std::string provider_id;
- std::vector<std::pair<std::string, std::string>> icon_paths;
- std::vector<std::string> capabilities;
- std::vector<std::pair<std::string, std::string>> labels;
-};
-
-class AccountInfo : public parser::ManifestData {
- public:
- static std::string key();
-
- const std::vector<SingleAccountInfo>& accounts() const {
- return accounts_;
- }
-
- void set_account(SingleAccountInfo single_account) {
- accounts_.push_back(std::move(single_account));
- }
-
- private:
- std::vector<SingleAccountInfo> accounts_;
-};
-
-/**
- * @brief The AccountHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <account>
- * \_ <account-provider>
- * \_ <icon>
- * \_ <label>
- * \_ <capability>
- */
-class AccountHandler : 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;
-
- private:
- /**
- * @brief ParseSingleAccountElement parses single account element
- * @param item_dict
- * @param info
- * @param error
- * @return true everything okay
- */
- bool ParseSingleAccountElement(const parser::DictionaryValue* item_dict,
- std::shared_ptr<AccountInfo> info,
- std::string* error);
- /**
- * @brief ParseAccountIcons parse account icons
- * @param item_dict
- * @param singel_account
- * @return true if everything is okay
- */
- bool ParseAccountIcons(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- /**
- * @brief ParseAccountProvider parses account provider
- * @param item_dict
- * @param info
- * @param error
- * @return if everything is fine
- */
- bool ParseAccountProvider(const parser::DictionaryValue* item_dict,
- std::shared_ptr<AccountInfo> info,
- std::string* error);
- /**
- * @brief ParseSingleAccountIcon parses single account icon
- * @param item_dict
- * @param singel_account
- * @return
- */
- bool ParseSingleAccountIcon(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- /**
- * @brief ParseLabels parses single account label
- * @param item_dict
- * @param singel_account
- * @return true if everything is fine
- */
- bool ParseLabels(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- /**
- * @brief ParseCapabilities pa
- * @param item_dict
- * @param singel_account
- * @return true if everything is fine
- */
- bool ParseCapabilities(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_ACCOUNT_HANDLER_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 "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace application_keys {
-
-// manifest
-const char kManifestKey[] = "manifest";
-
-// privileges
-const char kPrivilegesKey[] = "manifest.privileges";
-
-// service-application
-const char kServiceApplicationKey[] = "manifest.service-application";
-
-// ui-application
-const char kUIApplicationKey[] = "manifest.ui-application";
-
-// widget-application
-const char kWidgetApplicationKey[] = "manifest.widget-application";
-
-// watch-application
-const char kWatchApplicationKey[] = "manifest.watch-application";
-
-// account
-const char kAccountKey[] = "manifest.account";
-
-// shortcuts
-const char kShortcutListKey[] = "manifest.shortcut-list";
-const char kShortcutKey[] = "shortcut";
-const char kShortcutAppidKey[] = "@appid";
-const char kShortcutExtraDataKey[] = "@extra_data";
-const char kShortcutExtraKeyKey[] = "@extra_key";
-const char kShortcutIconKey[] = "icon";
-const char kShortcutIconTextKey[] = "#text";
-const char kShortcutLabelKey[] = "label";
-const char kShortcutLabelTextKey[] = "#text";
-const char kShortcutLabelLangKey[] = "@lang";
-
-// profile
-const char kProfileKey[] = "manifest.profile";
-
-} // namespace application_keys
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_APPLICATION_MANIFEST_CONSTANTS_H_
-#define TPK_MANIFEST_HANDLERS_APPLICATION_MANIFEST_CONSTANTS_H_
-
-// Keys used in JSON representation of applications.
-namespace tpk {
-namespace application_keys {
-
-// manifest
-extern const char kManifestKey[];
-
-// privileges
-extern const char kPrivilegesKey[];
-
-// service-application
-extern const char kServiceApplicationKey[];
-
-// ui-application
-extern const char kUIApplicationKey[];
-
-// widget-application
-extern const char kWidgetApplicationKey[];
-
-// watch-application
-extern const char kWatchApplicationKey[];
-
-// account
-extern const char kAccountKey[];
-
-// shortcuts
-extern const char kShortcutListKey[];
-extern const char kShortcutKey[];
-extern const char kShortcutAppidKey[];
-extern const char kShortcutExtraDataKey[];
-extern const char kShortcutExtraKeyKey[];
-extern const char kShortcutIconKey[];
-extern const char kShortcutIconTextKey[];
-extern const char kShortcutLabelKey[];
-extern const char kShortcutLabelTextKey[];
-extern const char kShortcutLabelLangKey[];
-
-// profile
-extern const char kProfileKey[];
-
-} // namespace application_keys
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_APPLICATION_MANIFEST_CONSTANTS_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 "tpk_manifest_handlers/author_handler.h"
-
-#include <cassert>
-#include <map>
-#include <regex>
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-namespace keys = tpk::application_keys;
-
-namespace {
-
-const char kAuthorKey[] = "manifest.author";
-const char kAuthorKeyText[] = "#text";
-const char kAuthorEmailKey[] = "@email";
-const char kAuthorHrefKey[] = "@href";
-
-void ParseAuthorAndStore(
- const parser::DictionaryValue& author_dict,
- AuthorInfo* author) {
- std::string email;
- author_dict.GetString(kAuthorEmailKey, &email);
- author->set_email(email);
-
- std::string href;
- author_dict.GetString(kAuthorHrefKey, &href);
- author->set_href(href);
-
- std::string name;
- author_dict.GetString(kAuthorKeyText, &name);
- author->set_name(name);
-}
-
-} // namespace
-
-bool AuthorHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- std::shared_ptr<AuthorInfo> author(new AuthorInfo());
-
- auto items = parser::GetOneOrMany(manifest.value(), kAuthorKey, "");
- // TODO(t.iwanek): handle multiple authors
- if (items.empty())
- return true;
-
- ParseAuthorAndStore(*items[0], author.get());
-
- *output = std::static_pointer_cast<parser::ManifestData>(author);
- return true;
-}
-
-std::string AuthorInfo::Key() {
- return kAuthorKey;
-}
-
-std::string AuthorHandler::Key() const {
- return kAuthorKey;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_AUTHOR_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_AUTHOR_HANDLER_H_
-
-#include <memory>
-#include <string>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-class AuthorInfo : public parser::ManifestData {
- public:
- /**
- * @brief key
- * @param key string
- */
- static std::string Key();
- /**
- * @brief set_email sets email
- * @param email
- */
- void set_email(std::string email) {
- email_ = std::move(email);
- }
- /**
- * @brief set_href sets href
- * @param href
- */
- void set_href(std::string href) {
- href_ = std::move(href);
- }
- /**
- * @brief set_name sets name
- * @param name
- */
- void set_name(std::string name) {
- name_ = std::move(name);
- }
- /**
- * @brief email
- * @return email string
- */
- const std::string& email() const {
- return email_;
- }
- /**
- * @brief href
- * @return href string
- */
- const std::string& href() const {
- return href_;
- }
- /**
- * @brief name
- * @return name string
- */
- const std::string& name() const {
- return name_;
- }
-
- private:
- std::string email_;
- std::string href_;
- std::string name_;
-};
-
-/**
- * @brief The AuthorHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <author>
- */
-class AuthorHandler : 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 tpk
-
-#endif // TPK_MANIFEST_HANDLERS_AUTHOR_HANDLER_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 "tpk_manifest_handlers/common/application_handler.h"
-
-namespace tpk {
-namespace parse {
-namespace tpk_app_keys {
-// app-control
-const char kAppControlKey[] = "app-control";
-const char kAppControlOperationKey[] = "operation";
-const char kAppControlURIKey[] = "uri";
-const char kAppControlMimeKey[] = "mime";
-const char kAppControlNameKey[] = "@name";
-
-// background-category
-const char kBackgroundCategoryKey[] = "background-category";
-const char kBackgroundCategoryValueKey[] = "@value";
-
-// datacontrol
-const char kDataControlKey[] = "datacontrol";
-const char kDataControlAccessKey[] = "@access";
-const char kDataControlProviderIDKey[] = "@providerid";
-const char kDataControlTypeKey[] = "@type";
-
-// icon
-const char kIconKey[] = "icon";
-const char kIconTextKey[] = "#text";
-const char kIconLangKey[] = "@lang";
-const char kIconDpiKey[] = "@dpi";
-
-// image
-const char kImageKey[] = "image";
-const char kImageNameKey[] = "@name";
-const char kImageSectionKey[] = "@section";
-const char kImageLangKey[] = "@lang";
-
-// label
-const char kLabelKey[] = "label";
-const char kLabelTextKey[] = "#text";
-const char kLabelLangKey[] = "@lang";
-
-// metadata
-const char kMetaDataKey[] = "metadata";
-const char kMetaDataKeyKey[] = "@key";
-const char kMetaDataValueKey[] = "@value";
-
-// category
-const char kCategoryKey[] = "category";
-const char kCategoryNameKey[] = "@name";
-
-// splash-screen
-const char kSplashScreensKey[] = "splash-screens";
-const char kSplashScreenKey[] = "splash-screen";
-const char kSplashScreenSrcKey[] = "@src";
-const char kSplashScreenTypeKey[] = "@type";
-const char kSplashScreenDpiKey[] = "@dpi";
-const char kSplashScreenOrientationKey[] = "@orientation";
-const char kSplashScreenIndicatorDisplayKey[] = "@indicator-display";
-const char kSplashScreenAppControlOperationKey[] = "@app-control-operation";
-const char kSplashScreenColorDepthKey[] = "@color-depth";
-
-} // namespace tpk_app_keys
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_COMMON_APPLICATION_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_COMMON_APPLICATION_HANDLER_H_
-
-#include <algorithm>
-#include <functional>
-#include <string>
-#include <vector>
-#include <utility>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/ui_and_service_application_infos.h"
-
-namespace tpk {
-namespace parse {
-namespace tpk_app_keys {
-// app-control
-extern const char kAppControlKey[];
-extern const char kAppControlOperationKey[];
-extern const char kAppControlURIKey[];
-extern const char kAppControlMimeKey[];
-extern const char kAppControlNameKey[];
-
-// background-category
-extern const char kBackgroundCategoryKey[];
-extern const char kBackgroundCategoryValueKey[];
-
-// datacontrol
-extern const char kDataControlKey[];
-extern const char kDataControlAccessKey[];
-extern const char kDataControlProviderIDKey[];
-extern const char kDataControlTypeKey[];
-
-// icon
-extern const char kIconKey[];
-extern const char kIconTextKey[];
-extern const char kIconLangKey[];
-extern const char kIconDpiKey[];
-
-// image
-extern const char kImageKey[];
-extern const char kImageNameKey[];
-extern const char kImageSectionKey[];
-extern const char kImageLangKey[];
-
-// label
-extern const char kLabelKey[];
-extern const char kLabelTextKey[];
-extern const char kLabelLangKey[];
-
-// metadata
-extern const char kMetaDataKey[];
-extern const char kMetaDataKeyKey[];
-extern const char kMetaDataValueKey[];
-
-// category
-extern const char kCategoryKey[];
-extern const char kCategoryNameKey[];
-
-// splash-screen
-extern const char kSplashScreensKey[];
-extern const char kSplashScreenKey[];
-extern const char kSplashScreenSrcKey[];
-extern const char kSplashScreenTypeKey[];
-extern const char kSplashScreenDpiKey[];
-extern const char kSplashScreenOrientationKey[];
-extern const char kSplashScreenIndicatorDisplayKey[];
-extern const char kSplashScreenOperationKey[];
-extern const char kSplashScreenAppControlOperationKey[];
-extern const char kSplashScreenColorDepthKey[];
-
-} // namespace tpk_app_keys
-
-class ApplicationInfo : public parser::ManifestData {
- public:
- void set_appid(std::string appid) {
- appid_ = std::move(appid);
- }
-
- void set_exec(std::string exec) {
- exec_ = std::move(exec);
- }
-
- const std::string& appid() const {
- return appid_;
- }
-
- const std::string& exec() const {
- return exec_;
- }
-
- private:
- std::string appid_;
- std::string exec_;
-};
-
-template<typename T>
-struct ApplicationSingleEntry : public parser::ManifestData {
- T app_info;
- std::vector<MetaDataInfo> meta_data;
- ApplicationIconsInfo app_icons;
- std::vector<LabelInfo> label;
- std::vector<std::string> categories;
- ApplicationSplashScreenInfo app_splashscreens;
-};
-
-template<typename T>
-struct ApplicationInfoList : public parser::ManifestData {
- std::vector<T> items;
-};
-
-template<typename T>
-bool ParseAppControl(const parser::DictionaryValue& dict,
- T* info, std::string* error) {
- for (const auto& item_operation : parser::GetOneOrMany(&dict,
- tpk_app_keys::kAppControlOperationKey, "")) {
- std::string operation;
- if (!item_operation->GetString(
- tpk_app_keys::kAppControlNameKey, &operation)) {
- *error = "appcontrol operation is missing name attribute";
- return false;
- }
-
- std::vector<std::string> uris;
- for (auto& uri_item : parser::GetOneOrMany(&dict,
- tpk_app_keys::kAppControlURIKey, "")) {
- std::string uri;
- if (!uri_item->GetString(tpk_app_keys::kAppControlNameKey, &uri)) {
- *error = "appcontrol uri is missing name attribute";
- return false;
- }
- uris.push_back(uri);
- }
-
- std::vector<std::string> mimes;
- for (auto& mime_item : parser::GetOneOrMany(
- &dict, tpk_app_keys::kAppControlMimeKey, "")) {
- std::string mime;
- if (!mime_item->GetString(tpk_app_keys::kAppControlNameKey,
- &mime)) {
- *error = "appcontrol mime is missing name attribute";
- return false;
- }
- mimes.push_back(mime);
- }
-
- if (uris.empty())
- uris.push_back("");
- if (mimes.empty())
- mimes.push_back("");
-
- for (const auto& uri : uris) {
- for (const auto& mime : mimes) {
- info->app_control.emplace_back(operation, uri, mime);
- }
- }
- }
-
- return true;
-}
-
-template<typename T>
-bool ParseBackgroundCategoryElement(const parser::DictionaryValue& dict,
- T* info, std::string* error) {
- std::string value;
-
- if (!dict.GetString(tpk_app_keys::kBackgroundCategoryValueKey, &value)) {
- *error = "Parsing background-category element failed";
- return false;
- }
-
- info->background_category.emplace_back(std::move(value));
-
- return true;
-}
-
-template<typename T>
-bool ParseDataControl(const parser::DictionaryValue& dict,
- T* info, std::string*) {
- std::string access;
- dict.GetString(tpk_app_keys::kDataControlAccessKey, &access);
- std::string providerid;
- dict.GetString(tpk_app_keys::kDataControlProviderIDKey, &providerid);
- std::string type;
- dict.GetString(tpk_app_keys::kDataControlTypeKey, &type);
- info->data_control.emplace_back(access, providerid, type);
- return true;
-}
-
-template<typename T>
-bool ParseAppIcon(const parser::DictionaryValue& dict,
- T* info, std::string* /*error*/) {
- std::string icon_path;
-
- if (!dict.GetString(tpk_app_keys::kIconTextKey, &icon_path))
- return true;
- std::string xml_lang;
- dict.GetString(tpk_app_keys::kIconLangKey, &xml_lang);
-
- std::string dpi;
- dict.GetString(tpk_app_keys::kIconDpiKey, &dpi);
-
- info->app_icons.AddIcon(ApplicationIcon(icon_path, xml_lang, dpi));
-
- return true;
-}
-
-template<typename T>
-bool ParseAppImage(const parser::DictionaryValue& dict, T* info,
- std::string*) {
- std::string image_name;
- dict.GetString(tpk_app_keys::kImageNameKey, &image_name);
- std::string image_section;
- dict.GetString(tpk_app_keys::kImageSectionKey, &image_section);
- std::string image_lang;
- dict.GetString(tpk_app_keys::kImageLangKey, &image_lang);
- info->app_images.images.emplace_back(image_name, image_section, image_lang);
- return true;
-}
-
-template<typename T>
-bool ParseLabel(const parser::DictionaryValue& dict,
- T* info, std::string*) {
- std::string text;
- dict.GetString(tpk_app_keys::kLabelTextKey, &text);
- std::string xml_lang;
- dict.GetString(tpk_app_keys::kLabelLangKey, &xml_lang);
- info->label.emplace_back(text, text, xml_lang);
- return true;
-}
-
-template<typename T>
-bool ParseMetaData(const parser::DictionaryValue& dict,
- T* info, std::string*) {
- std::string key;
- dict.GetString(tpk_app_keys::kMetaDataKeyKey, &key);
- std::string val;
- dict.GetString(tpk_app_keys::kMetaDataValueKey, &val);
-
- if (key.find(tpk_app_keys::kBackgroundCategoryKey) == std::string::npos) {
- info->meta_data.emplace_back(key, val);
- } else {
- val = key.substr(key.find_last_of("/") + 1);
- info->background_category.emplace_back(std::move(val));
- }
-
- return true;
-}
-
-template<typename T>
-bool ParseCategory(const parser::DictionaryValue& dict,
- T* info, std::string*) {
- std::string name;
- dict.GetString(tpk_app_keys::kCategoryNameKey, &name);
- if (!name.empty())
- info->categories.push_back(name);
- return true;
-}
-
-template<typename T>
-bool ParseSplashScreen(const parser::DictionaryValue& dict,
- T* info, std::string*) {
- for (const auto& item_splashscreen : parser::GetOneOrMany(&dict,
- tpk_app_keys::kSplashScreenKey, "")) {
- std::string src;
- if (!item_splashscreen->GetString(tpk_app_keys::kSplashScreenSrcKey, &src))
- return true;
- std::string type;
- if (!item_splashscreen->GetString(tpk_app_keys::kSplashScreenTypeKey,
- &type))
- return true;
- std::string dpi;
- item_splashscreen->GetString(tpk_app_keys::kSplashScreenDpiKey, &dpi);
- std::string orientation;
- if (!item_splashscreen->GetString(tpk_app_keys::kSplashScreenOrientationKey,
- &orientation))
- return true;
- std::string indicatordisplay;
- item_splashscreen->GetString(tpk_app_keys::kSplashScreenIndicatorDisplayKey,
- &indicatordisplay);
- std::string operation;
- item_splashscreen->GetString(
- tpk_app_keys::kSplashScreenAppControlOperationKey, &operation);
- std::string colordepth;
- item_splashscreen->GetString(
- tpk_app_keys::kSplashScreenColorDepthKey, &colordepth);
- info->app_splashscreens.AddSplashScreen(ApplicationSplashScreen(src, type,
- dpi, orientation, indicatordisplay, operation, colordepth));
- }
-
- return true;
-}
-
-template<typename T>
-using ParsingFuncPtr =
- std::function<bool(const parser::DictionaryValue&, T*, std::string*)>;
-
-template<typename T>
-bool InitializeParsingElement(
- const parser::DictionaryValue& app_dict,
- const std::string& key,
- ParsingFuncPtr<T> ParsingFunc,
- T* applicationinfo, std::string* error) {
- for (const auto& item : parser::GetOneOrMany(&app_dict, key, "")) {
- if (!ParsingFunc(*item, applicationinfo, error)) {
- return false;
- }
- }
- return true;
-}
-
-template<typename T>
-bool AppControlValidation(const T& it, std::string* error) {
- for (const auto& item : it.app_control) {
- if (item.operation().empty()) {
- *error =
- "The operation child element of app-control element is obligatory";
- return false;
- } else if (!parser::utils::IsValidIRI(item.operation())) {
- *error =
- "The operation child element of app-control element is not valid url";
- return false;
- }
- }
- return true;
-}
-
-template<typename T>
-bool DataControlValidation(const T& it, std::string* error) {
- for (const auto& item : it.data_control) {
- if (item.access().empty()) {
- *error =
- "The access child element of datacontrol element is obligatory";
- return false;
- }
-
- if (item.providerid().empty()) {
- *error =
- "The providerid child element of datacontrol element is obligatory";
- return false;
- }
-
- if (item.type().empty()) {
- *error =
- "The type child element of datacontrol element is obligatory";
- return false;
- }
- }
- return true;
-}
-
-template<typename T>
-bool LabelValidation(const T& it, std::string* error) {
- if (std::any_of(it.label.begin(), it.label.end(),
- [](const LabelInfo& item) { return item.text().empty(); })) {
- *error = "The text child element of label element is obligatory";
- return false;
- }
-
- for (auto& label : it.label) {
- if (label.name().empty()) {
- *error = "The name child element of label element is obligatory";
- return false;
- }
- }
-
- return true;
-}
-
-template<typename T>
-bool MetadataValidation(const T& it, std::string* error) {
- if (std::any_of(it.meta_data.begin(), it.meta_data.end(),
- [](const MetaDataInfo& item) { return item.key().empty(); })) {
- *error = "The key child element of metadata element is obligatory";
- return false;
- }
-
- return true;
-}
-
-template<typename T>
-bool SplashScreenValidation(const T& it, std::string* error) {
- for (const auto& item : it.app_splashscreens.splashscreens()) {
- if (item.src().empty()) {
- *error =
- "The source child element of splash-screen element is obligatory";
- return false;
- }
-
- if (item.type().empty()) {
- *error =
- "The type child element of splash-screen element is obligatory";
- return false;
- }
-
- if (item.orientation().empty()) {
- *error =
- "The orientation element of splash-screen element is obligatory";
- return false;
- }
- }
- return true;
-}
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_COMMON_APPLICATION_HANDLER_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 "tpk_manifest_handlers/description_handler.h"
-
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace keys = tpk::application_keys;
-
-namespace {
-
-const char kDescriptionKey[] = "manifest.description";
-const char kDescriptionTextKey[] = "#text";
-const char kDescriptionLangKey[] = "@lang";
-
-void ParseDescriptionAndStore(
- const parser::DictionaryValue& description_dict,
- tpk::parse::DescriptionInfoList* descriptioninfo) {
- std::string description;
- description_dict.GetString(kDescriptionTextKey, &description);
- std::string xml_lang;
- description_dict.GetString(kDescriptionLangKey, &xml_lang);
-
- // TODO(t.iwanek): do not skip it when preloaded apps will be fixed.
- if (description.empty())
- return;
-
- descriptioninfo->descriptions.emplace_back(description, xml_lang);
-}
-
-} // namespace
-
-namespace tpk {
-namespace parse {
-
-DescriptionInfo::DescriptionInfo(
- const std::string& description, const std::string& xml_lang)
- : description_(description),
- xml_lang_(xml_lang) {
-}
-
-bool DescriptionHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- std::shared_ptr<DescriptionInfoList>
- descriptioninfo(new DescriptionInfoList());
-
- for (auto dict : parser::GetOneOrMany(manifest.value(), kDescriptionKey,
- {})) {
- ParseDescriptionAndStore(*dict, descriptioninfo.get());
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(descriptioninfo);
- return true;
-}
-
-std::string DescriptionInfoList::Key() {
- return kDescriptionKey;
-}
-
-std::string DescriptionHandler::Key() const {
- return DescriptionInfoList::Key();
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_DESCRIPTION_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_DESCRIPTION_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-class DescriptionInfo {
- public:
- DescriptionInfo(const std::string& description, const std::string& xml_lang);
-
- /**
- * @brief set_description sets description
- * @param description
- */
- void set_description(std::string description) {
- description_ = std::move(description);
- }
- /**
- * @brief set_xml_lang sets xml lang
- * @param xml_lang
- */
- void set_xml_lang(std::string xml_lang) {
- xml_lang_ = std::move(xml_lang);
- }
- /**
- * @brief description
- * @return description string
- */
- const std::string& description() const {
- return description_;
- }
- // NOTE: not in spec
- const std::string& xml_lang() const {
- return xml_lang_;
- }
-
- private:
- std::string description_;
- std::string xml_lang_;
-};
-
-class DescriptionInfoList : public parser::ManifestData {
- public:
- /**
- * @brief key
- * @param key string
- */
- static std::string Key();
-
- std::vector<DescriptionInfo> descriptions;
-};
-
-/**
- * @brief The DescriptionHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <description>
- */
-class DescriptionHandler : 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 tpk
-
-#endif // TPK_MANIFEST_HANDLERS_DESCRIPTION_HANDLER_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 "tpk_manifest_handlers/package_handler.h"
-
-#include <cassert>
-#include <map>
-#include <set>
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-namespace {
-const char kNamespace[] = "@namespace";
-const char kAPI[] = "@api-version";
-const char kPackage[] = "@package";
-const char kVersion[] = "@version";
-const char kType[] = "@type";
-const char kInstallLocation[] = "@install-location";
-const char kNodisplaySetting[] = "@nodisplay-setting";
-const char kAutoInstallLocation[] = "auto";
-const char kManifestKey[] = "manifest";
-const char kLabelKey[] = "label";
-const char kLabelLangKey[] = "@lang";
-const char kLabelTextKey[] = "#text";
-const char kPreload[] = "@preload";
-const std::set<std::string> kInstallLocationAllowedValues =
- {"auto", "internal-only", "prefer-external"};
-const std::set<std::string> kPackageTypeAllowedValues =
- {"tpk", "wgt", "rpm"};
-
-bool ParsePackageAndStore(
- const parser::DictionaryValue& manifest_dict,
- PackageInfo* pkg_info) {
- std::string xmlns;
- manifest_dict.GetString(kNamespace, &xmlns);
- std::string api_version;
- manifest_dict.GetString(kAPI, &api_version);
- std::string package;
- manifest_dict.GetString(kPackage, &package);
- std::string version;
- manifest_dict.GetString(kVersion, &version);
- std::string type;
- manifest_dict.GetString(kType, &type);
- std::string install_location;
- manifest_dict.GetString(kInstallLocation, &install_location);
- std::string nodisplay_setting("false");
- manifest_dict.GetString(kNodisplaySetting, &nodisplay_setting);
- std::string preload;
- manifest_dict.GetString(kPreload, &preload);
-
- pkg_info->set_xmlns(xmlns);
- pkg_info->set_api_version(api_version);
- pkg_info->set_package(package);
- pkg_info->set_version(version);
- pkg_info->set_type(type);
- pkg_info->set_nodisplay_setting(nodisplay_setting);
- pkg_info->set_preload(preload);
-
- if (install_location.empty()) {
- pkg_info->set_install_location(kAutoInstallLocation);
- } else {
- if (kInstallLocationAllowedValues.find(install_location) ==
- kInstallLocationAllowedValues.end())
- return false;
- pkg_info->set_install_location(install_location);
- }
-
- for (auto label_dict : parser::GetOneOrMany(&manifest_dict, kLabelKey, "")) {
- std::string lang;
- std::string text;
- label_dict->GetString(kLabelLangKey, &lang);
- label_dict->GetString(kLabelTextKey, &text);
- pkg_info->AddLabel(lang, text);
- }
- return true;
-}
-
-} // namespace
-
-
-std::string PackageInfo::key() {
- return kManifestKey;
-}
-
-bool PackageHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- std::shared_ptr<PackageInfo> pkg_info(new PackageInfo());
- parser::Value* value = nullptr;
- if (!manifest.Get(kManifestKey, &value)) {
- *error = "Manifest element not found";
- return false;
- }
-
- if (value->GetType() == parser::Value::TYPE_DICTIONARY) {
- const parser::DictionaryValue* dict = nullptr;
- value->GetAsDictionary(&dict);
- if (!ParsePackageAndStore(*dict, pkg_info.get())) {
- *error = "Cannot parse manifest element";
- return false;
- }
- } else {
- *error = "Cannot parse manifest element";
- return false;
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(pkg_info);
- return true;
-}
-
-bool PackageHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const PackageInfo& app_info =
- static_cast<const PackageInfo&>(data);
-
- if (app_info.xmlns().empty()) {
- *error = "The xmlns child element of manifest element is obligatory";
- return false;
- }
-
- const std::string& api_version = app_info.api_version();
- if (api_version.empty()) {
- *error =
- "The api-version child element of manifest element is obligatory";
- return false;
- }
- if (!utils::VersionNumber(api_version).IsValid()) {
- *error =
- "The api-version child element of manifest element is invalid";
- return false;
- }
-
- const std::string& package = app_info.package();
- if (package.empty()) {
- *error =
- "The package child element of manifest element is obligatory";
- return false;
- }
- if (!parser::ValidateTizenNativeId(package)) {
- *error = "The package name should be composed of alphanumeric characters "
- "optionally separate with dots.";
- return false;
- }
-
- if (!app_info.type().empty() &&
- kPackageTypeAllowedValues.find(app_info.type()) ==
- kPackageTypeAllowedValues.end()) {
- *error = "Invalid package type";
- return false;
- }
-
- const std::string& version = app_info.version();
- if (version.empty()) {
- *error =
- "The version child element of manifest element is obligatory";
- return false;
- }
- // TODO(t.iwanek): use IsValidTizenPackageVersion() for version number if
- // preloaded apps will be fixed.
-
- return true;
-}
-
-std::string PackageHandler::Key() const {
- return kManifestKey;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_PACKAGE_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_PACKAGE_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-using LangTextPair = std::pair<std::string, std::string>;
-
-class PackageInfo : public parser::ManifestData {
- public:
- /**
- * @brief key
- * @param key string
- */
- static std::string key();
- /**
- * @brief set_xmlns xmlns
- * @param xmlns
- */
- void set_xmlns(std::string xmlns) {
- xmlns_ = std::move(xmlns);
- }
- /**
- * @brief set_api_version set api version
- * @param api_version
- */
- void set_api_version(std::string api_version) {
- api_version_ = std::move(api_version);
- }
- /**
- * @brief set_package set package
- * @param package
- */
- void set_package(std::string package) {
- package_ = std::move(package);
- }
- /**
- * @brief set_version sets version
- * @param version
- */
- void set_version(std::string version) {
- version_ = std::move(version);
- }
- void set_type(std::string type) {
- type_ = std::move(type);
- }
- /**
- * @brief set_install_location sets install location
- * @param install_location
- */
- void set_install_location(std::string install_location) {
- install_location_ = std::move(install_location);
- }
-
- void set_nodisplay_setting(std::string nodisplay_setting) {
- nodisplay_setting_ = std::move(nodisplay_setting);
- }
-
- void set_preload(std::string preload) {
- preload_ = std::move(preload);
- }
-
- void AddLabel(const std::string& lang, const std::string& text) {
- labels_.emplace_back(lang, text);
- }
-
- /**
- * @brief xmlns
- * @return xmlns string
- */
- const std::string& xmlns() const {
- return xmlns_;
- }
- /**
- * @brief api_version
- * @return api_version string
- */
- const std::string& api_version() const {
- return api_version_;
- }
- /**
- * @brief package
- * @return package string
- */
- const std::string& package() const {
- return package_;
- }
- /**
- * @brief version
- * @return version string
- */
- const std::string& version() const {
- return version_;
- }
- const std::string& type() const {
- return type_;
- }
- const std::string& install_location() const {
- return install_location_;
- }
- const std::string& nodisplay_setting() const {
- return nodisplay_setting_;
- }
- const std::string& preload() const {
- return preload_;
- }
- const std::vector<LangTextPair>& labels() const {
- return labels_;
- }
-
- private:
- std::string xmlns_;
- std::string api_version_;
- std::string package_;
- std::string version_;
- std::string type_;
- std::string install_location_;
- std::string nodisplay_setting_;
- std::string preload_;
-
- std::vector<LangTextPair> labels_;
-};
-
-/**
- * @brief The PackageHandler class
- *
- * Handler of tizen-manifest.xml for root xml element <manifest>
- * Child elements are parsed in other handlers.
- */
-class PackageHandler : public parser::ManifestHandler {
- public:
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
- bool AlwaysParseForKey() const override { return true; }
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_PACKAGE_HANDLER_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 "tpk_manifest_handlers/privileges_handler.h"
-
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-namespace keys = tpk::application_keys;
-
-namespace {
-const char kPrivilegesKey[] = "manifest.privileges";
-const char kPrivilegeKey[] = "privilege";
-const char kPrivilegeTextKey[] = "#text";
-}
-
-bool PrivilegesHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- std::shared_ptr<PrivilegesInfo> privileges_info(new PrivilegesInfo());
- parser::Value* privileges_value = nullptr;
- if (!manifest.Get(kPrivilegesKey, &privileges_value))
- return true;
- parser::DictionaryValue* privileges_dict = nullptr;
- if (!privileges_value->GetAsDictionary(&privileges_dict)) {
- *error = "Failed to parse <privileges> tag";
- return false;
- }
- for (auto& item : parser::GetOneOrMany(privileges_dict, kPrivilegeKey, "")) {
- std::string privilege;
- if (!item->GetString(kPrivilegeTextKey, &privilege) ||
- privilege.empty())
- continue;
- privileges_info->AddPrivilege(privilege);
- }
- *output = std::static_pointer_cast<parser::ManifestData>(privileges_info);
- return true;
-}
-
-std::string PrivilegesInfo::key() {
- return kPrivilegesKey;
-}
-
-std::string PrivilegesHandler::Key() const {
- return kPrivilegesKey;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_PRIVILEGES_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_PRIVILEGES_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/permission_types.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-class PrivilegesInfo : public parser::ManifestData {
- public:
- /**
- * @brief key
- * @param key string
- */
- static std::string key();
- /**
- * @brief GetPrivileges
- * @return PrivilegesSet
- */
- const parser::PrivilegesSet& GetPrivileges() const {
- return privileges_;
- }
- /**
- * @brief AddPrivilege add privilege
- * @param privilege
- */
- void AddPrivilege(const std::string& privilege) {
- privileges_.insert(privilege);
- }
-
- private:
- parser::PrivilegesSet privileges_;
-};
-
-/**
- * @brief The PrivilegesHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <privileges>
- * \_ <privilege>
- */
-class PrivilegesHandler : 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 tpk
-
-#endif // TPK_MANIFEST_HANDLERS_PRIVILEGES_HANDLER_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 "tpk_manifest_handlers/profile_handler.h"
-
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-
-const char kProfileNameKey[] = "@name";
-const char kProfileKey[] = "manifest.profile";
-} // namespace
-
-namespace tpk {
-namespace parse {
-
-namespace keys = tpk::application_keys;
-
-std::string ProfileInfo::Key() {
- return kProfileKey;
-}
-
-bool ProfileHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kProfileKey))
- return true;
-
- std::shared_ptr<ProfileInfo> profile_info(new ProfileInfo());
- for (auto& item : parser::GetOneOrMany(manifest.value(), kProfileKey,
- "")) {
- std::string name;
- if (!item->GetString(kProfileNameKey, &name)) {
- *error = "Missing 'name' attribute in profile tag";
- return false;
- }
- profile_info->AddProfile(name);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(profile_info);
- return true;
-}
-
-std::string ProfileHandler::Key() const {
- return kProfileKey;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_PROFILE_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_PROFILE_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-class ProfileInfo : public parser::ManifestData {
- public:
- static std::string Key();
-
- void AddProfile(const std::string& profile) {
- profiles_.push_back(profile);
- }
-
- const std::vector<std::string>& profiles() const {
- return profiles_;
- }
-
- private:
- std::vector<std::string> profiles_;
-};
-
-/**
- * @brief The ProfileHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <profile>
- */
-class ProfileHandler : 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 tpk
-
-#endif // TPK_MANIFEST_HANDLERS_PROFILE_HANDLER_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 "tpk_manifest_handlers/service_application_handler.h"
-
-#include <boost/algorithm/string/predicate.hpp>
-
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace tpk {
-namespace parse {
-
-namespace ba = boost::algorithm;
-namespace keys = tpk::application_keys;
-
-namespace {
-const char kServiceApplicationKey[] = "manifest.service-application";
-
-// service-application
-const char kServiceApplicationAppIDKey[] = "@appid";
-const char kServiceApplicationAutoRestartKey[] = "@auto-restart";
-const char kServiceApplicationExecKey[] = "@exec";
-const char kServiceApplicationOnBootKey[] = "@on-boot";
-const char kServiceApplicationTypeKey[] = "@type";
-const char kServiceApplicationProcessPoolKey[] = "@process-pool";
-const char kServiceApplicationMultipleKey[] = "@multiple";
-const char kServiceApplicationTaskManageKey[] = "@taskmanage";
-const char kServiceApplicationKeyText[] = "#text";
-
-const char kTrue[] = "true";
-const char kFalse[] = "false";
-
-bool ServiceAppValidation(
- const ServiceApplicationSingleEntry& item,
- std::string* error) {
- if (item.app_info.appid().empty()) {
- *error = "The appid child element of "
- "service application element is obligatory";
- return false;
- }
- if (!parser::ValidateTizenNativeId(item.app_info.appid())) {
- *error = "The application id should be composed of alphanumerics "
- "optionally separate with dots.";
- return false;
- }
-
- const std::string& exec = item.app_info.exec();
- if (exec.empty()) {
- *error =
- "The exec child element of service application element is obligatory";
- return false;
- }
- const std::string& type = item.app_info.type();
- if (type.empty()) {
- *error =
- "The type child element of service application element is obligatory";
- return false;
- }
- const std::string& multiple = item.app_info.multiple();
- if (multiple != kTrue && multiple != kFalse) {
- *error = "multiple attribute should have 'true' or 'false' value";
- return false;
- }
- const std::string& taskmanage = item.app_info.taskmanage();
- if (taskmanage != kTrue && taskmanage != kFalse) {
- *error = "taskmanage attribute should have 'true' or 'false' value";
- return false;
- }
- const std::string& on_boot = item.app_info.on_boot();
- if (on_boot != kTrue && on_boot != kFalse) {
- *error = "on-boot attribute should have 'true' or 'false' value";
- return false;
- }
- const std::string& auto_restart = item.app_info.auto_restart();
- if (auto_restart != kTrue && auto_restart != kFalse) {
- *error = "auto-restart attribute should have 'true' or 'false' value";
- return false;
- }
-
- return true;
-}
-
-bool ParseServiceApplicationAndStore(
- const parser::DictionaryValue& app_dict,
- ServiceApplicationSingleEntry* serviceapplicationinfo,
- std::string* error) {
- std::string appid;
- app_dict.GetString(kServiceApplicationAppIDKey, &appid);
- std::string exec;
- app_dict.GetString(kServiceApplicationExecKey, &exec);
- std::string auto_restart("false");
- app_dict.GetString(kServiceApplicationAutoRestartKey, &auto_restart);
- std::string on_boot("false");
- app_dict.GetString(kServiceApplicationOnBootKey, &on_boot);
- std::string type;
- app_dict.GetString(kServiceApplicationTypeKey, &type);
- std::string multiple("false");
- app_dict.GetString(kServiceApplicationMultipleKey, &multiple);
- std::string taskmanage("true");
- app_dict.GetString(kServiceApplicationTaskManageKey, &taskmanage);
-
- serviceapplicationinfo->app_info.set_appid(appid);
- serviceapplicationinfo->app_info.set_exec(exec);
- serviceapplicationinfo->app_info.set_auto_restart(auto_restart);
- serviceapplicationinfo->app_info.set_on_boot(on_boot);
- serviceapplicationinfo->app_info.set_type(type);
- serviceapplicationinfo->app_info.set_multiple(multiple);
- serviceapplicationinfo->app_info.set_taskmanage(taskmanage);
-
- std::string process_pool;
- if (app_dict.GetString(kServiceApplicationProcessPoolKey, &process_pool)) {
- if (!ba::iequals(process_pool, "true") &&
- !ba::iequals(process_pool, "false")) {
- *error = "process_pool must be 'true' or 'false'";
- return false;
- }
- serviceapplicationinfo->app_info.set_process_pool(process_pool);
- }
-
- ParsingFuncPtr<ServiceApplicationSingleEntry> parsingFunc =
- ParseAppControl<ServiceApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kAppControlKey,
- parsingFunc, serviceapplicationinfo, error))
- return false;
- parsingFunc = ParseDataControl<ServiceApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kDataControlKey,
- parsingFunc, serviceapplicationinfo, error))
- return false;
- parsingFunc = ParseMetaData<ServiceApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kMetaDataKey,
- parsingFunc, serviceapplicationinfo, error))
- return false;
- parsingFunc = ParseAppIcon<ServiceApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kIconKey,
- parsingFunc, serviceapplicationinfo, error))
- return false;
- parsingFunc = ParseLabel<ServiceApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kLabelKey,
- parsingFunc, serviceapplicationinfo, error))
- return false;
- parsingFunc = ParseBackgroundCategoryElement<ServiceApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kBackgroundCategoryKey,
- parsingFunc, serviceapplicationinfo, error))
- return false;
-
- return true;
-}
-
-} // namespace
-
-bool ServiceApplicationHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kServiceApplicationKey))
- return true;
- std::shared_ptr<ServiceApplicationInfoList>
- serviceapplicationinfo(new ServiceApplicationInfoList());
- for (auto& item : parser::GetOneOrMany(manifest.value(),
- kServiceApplicationKey, "")) {
- ServiceApplicationSingleEntry serviceappentry;
- if (!ParseServiceApplicationAndStore(*item,
- &serviceappentry,
- error))
- return false;
- serviceapplicationinfo->items.push_back(serviceappentry);
- }
- *output = std::static_pointer_cast
- <parser::ManifestData>(serviceapplicationinfo);
- return true;
-}
-
-bool ServiceApplicationHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const ServiceApplicationInfoList& elements =
- static_cast<const ServiceApplicationInfoList&>(data);
-
- for (auto& item : elements.items) {
- if (!ServiceAppValidation(item, error) ||
- !AppControlValidation(item, error) ||
- !DataControlValidation(item, error) ||
- !MetadataValidation(item, error) ||
- !LabelValidation(item, error)) {
- return false;
- }
- }
- return true;
-}
-
-
-std::string ServiceApplicationInfo::key() {
- return kServiceApplicationKey;
-}
-
-std::string ServiceApplicationHandler::Key() const {
- return kServiceApplicationKey;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_SERVICE_APPLICATION_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_SERVICE_APPLICATION_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/common/application_handler.h"
-
-namespace tpk {
-namespace parse {
-
-class ServiceApplicationInfo : public ApplicationInfo {
- public:
- /**
- * @brief key
- * @param key string
- */
- static std::string key();
- void set_type(std::string type) {
- type_ = std::move(type);
- }
- void set_process_pool(std::string process_pool) {
- process_pool_ = std::move(process_pool);
- }
- /**
- * @brief set_auto_restart sets auto restart
- * @param auto_restart
- */
- void set_auto_restart(std::string auto_restart) {
- auto_restart_ = std::move(auto_restart);
- }
- /**
- * @brief set_on_boot sets on boot
- * @param on_boot
- */
- void set_on_boot(std::string on_boot) {
- on_boot_ = std::move(on_boot);
- }
-
- void set_multiple(std::string multiple) {
- multiple_ = std::move(multiple);
- }
-
- void set_taskmanage(std::string taskmanage) {
- taskmanage_ = std::move(taskmanage);
- }
-
- const std::string& type() const {
- return type_;
- }
- const std::string& process_pool() const {
- return process_pool_;
- }
- /**
- * @brief auto_restart
- * @return auto_restart string
- */
- const std::string& auto_restart() const {
- return auto_restart_;
- }
- /**
- * @brief on_boot
- * @return on_boot string
- */
- const std::string& on_boot() const {
- return on_boot_;
- }
-
- const std::string& multiple() const {
- return multiple_;
- }
-
- const std::string& taskmanage() const {
- return taskmanage_;
- }
-
- private:
- std::string type_;
- std::string process_pool_;
- std::string auto_restart_;
- std::string on_boot_;
- std::string multiple_;
- std::string taskmanage_;
-};
-
-struct ServiceApplicationSingleEntry :
- public ApplicationSingleEntry<ServiceApplicationInfo> {
- std::vector<AppControlInfo> app_control;
- std::vector<BackgroundCategoryInfo> background_category;
- std::vector<DataControlInfo> data_control;
-};
-
-using ServiceApplicationInfoList =
- ApplicationInfoList<ServiceApplicationSingleEntry>;
-
-/**
- * @brief The ServiceApplicationHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <service-application>
- * \_ <label>
- * \_ <icon>
- * \_ <app-control>
- * | \_ <mime>
- * | \_ <operation>
- * | \_ <uri>
- * \_ <metadata>
- * \_ <datacontrol>
- */
-class ServiceApplicationHandler : public parser::ManifestHandler {
- public:
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_SERVICE_APPLICATION_HANDLER_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 "tpk_manifest_handlers/shortcut_handler.h"
-
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-
-namespace keys = tpk::application_keys;
-
-namespace {
-
-const char kShortcutListKey[] = "manifest.shortcut-list";
-const char kShortcutKey[] = "shortcut";
-const char kShortcutAppidKey[] = "@appid";
-const char kShortcutExtraDataKey[] = "@extra_data";
-const char kShortcutExtraKeyKey[] = "@extra_key";
-const char kShortcutIconKey[] = "icon";
-const char kShortcutIconTextKey[] = "#text";
-const char kShortcutLabelKey[] = "label";
-const char kShortcutLabelTextKey[] = "#text";
-const char kShortcutLabelLangKey[] = "@lang";
-
-bool ParseShortcutLabel(const parser::DictionaryValue* dict,
- std::string* error,
- std::pair<std::string, std::string>* label) {
- std::string lang;
- dict->GetString(kShortcutLabelLangKey, &lang);
- label->first = lang;
- dict->GetString(kShortcutLabelTextKey, &label->second);
- return true;
-}
-
-bool ParseShortcut(const parser::DictionaryValue* dict, std::string* error,
- tpk::parse::ShortcutListInfo* list) {
- tpk::parse::ShortcutInfo shortcut;
- dict->GetString(kShortcutAppidKey, &shortcut.app_id);
- dict->GetString(kShortcutExtraDataKey, &shortcut.extra_data);
- dict->GetString(kShortcutExtraKeyKey, &shortcut.extra_key);
-
- for (auto& item : parser::GetOneOrMany(dict, kShortcutLabelKey, "")) {
- std::pair<std::string, std::string> label;
- if (!ParseShortcutLabel(item, error, &label))
- return false;
- shortcut.labels.push_back(label);
- }
-
- const parser::Value* icon_value = nullptr;
- if (dict->Get(kShortcutIconKey, &icon_value)) {
- const parser::DictionaryValue* icon_dict = nullptr;
- if (!icon_value->GetAsDictionary(&icon_dict)) {
- *error = "Invalid shortcut icon. Parser is expecting single <icon> tag";
- return false;
- }
- icon_dict->GetString(kShortcutIconTextKey, &shortcut.icon);
- }
-
- list->shortcuts.push_back(shortcut);
- return true;
-}
-
-} // namespace
-
-namespace tpk {
-namespace parse {
-
-bool ShortcutHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- const parser::Value* listvalue = nullptr;
- if (!manifest.Get(kShortcutListKey, &listvalue))
- return true;
- const parser::DictionaryValue* listdict = nullptr;
- if (!listvalue->GetAsDictionary(&listdict)) {
- *error = "Cannot parse shortcut-list element. Single element is expected";
- return false;
- }
- std::shared_ptr<ShortcutListInfo> shortcuts(new ShortcutListInfo());
- for (auto& item : parser::GetOneOrMany(listdict, kShortcutKey, "")) {
- if (!ParseShortcut(item, error, shortcuts.get()))
- return false;
- }
- *output = std::static_pointer_cast<parser::ManifestData>(shortcuts);
- return true;
-}
-
-std::string ShortcutListInfo::key() {
- return kShortcutListKey;
-}
-
-std::string ShortcutHandler::Key() const {
- return kShortcutListKey;
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_SHORTCUT_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_SHORTCUT_HANDLER_H_
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace tpk {
-namespace parse {
-
-struct ShortcutInfo {
- std::string app_id;
- std::string extra_data;
- std::string extra_key;
- std::string icon;
- std::vector<std::pair<std::string, std::string>> labels;
-};
-
-class ShortcutListInfo : public parser::ManifestData {
- public:
- static std::string key();
- std::vector<ShortcutInfo> shortcuts;
-};
-
-class ShortcutHandler : 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 tpk
-
-#endif // TPK_MANIFEST_HANDLERS_SHORTCUT_HANDLER_H_
+++ /dev/null
-prefix=@PREFIX@
-exec_prefix=@PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: tpk-manifest-handlers
-Description: Manifest handlers for tpk manifest file parser
-Version: @VERSION@
-Requires: manifest-parser
-Libs: -L${libdir} -ltpk-manifest-handlers
-Cflags: -I${includedir}
\ No newline at end of file
+++ /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 "tpk_manifest_handlers/tpk_config_parser.h"
-
-#include <boost/filesystem/path.hpp>
-
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "tpk_manifest_handlers/account_handler.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/author_handler.h"
-#include "tpk_manifest_handlers/description_handler.h"
-#include "tpk_manifest_handlers/package_handler.h"
-#include "tpk_manifest_handlers/privileges_handler.h"
-#include "tpk_manifest_handlers/profile_handler.h"
-#include "tpk_manifest_handlers/service_application_handler.h"
-#include "tpk_manifest_handlers/shortcut_handler.h"
-#include "tpk_manifest_handlers/ui_application_handler.h"
-#include "tpk_manifest_handlers/widget_application_handler.h"
-#include "tpk_manifest_handlers/watch_application_handler.h"
-
-namespace bf = boost::filesystem;
-
-namespace {
-
-const char kLocaleDirectory[] = "locales";
-
-} // namespace
-
-namespace tpk {
-namespace parse {
-
-TPKConfigParser::TPKConfigParser() {
- std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
- std::make_shared<AccountHandler>(),
- std::make_shared<AuthorHandler>(),
- std::make_shared<DescriptionHandler>(),
- std::make_shared<PackageHandler>(),
- std::make_shared<PrivilegesHandler>(),
- std::make_shared<ProfileHandler>(),
- std::make_shared<WidgetApplicationHandler>(),
- std::make_shared<WatchApplicationHandler>(),
- std::make_shared<ServiceApplicationHandler>(),
- std::make_shared<UIApplicationHandler>(),
- std::make_shared<ShortcutHandler>()
- };
-
- std::unique_ptr<parser::ManifestHandlerRegistry> registry(
- new parser::ManifestHandlerRegistry(handlers));
-
- parser_.reset(new parser::ManifestParser(std::move(registry)));
-}
-
-std::shared_ptr<const parser::ManifestData> TPKConfigParser::GetManifestData(
- const std::string& key) {
- return parser_->GetManifestData(key);
-}
-
-const std::string& TPKConfigParser::GetErrorMessage() const {
- if (!error_.empty())
- return error_;
- return parser_->GetErrorMessage();
-}
-
-bool TPKConfigParser::ParseManifest(const boost::filesystem::path& path) {
- if (!parser_->ParseManifest(path))
- return false;
-
- return true;
-}
-
-void ApplicationIconsInfo::AddIcon(const ApplicationIcon& new_icon) {
- // Eliminate duplicates, keep order
- if (std::find_if(icons_.begin(), icons_.end(),
- [&new_icon](const ApplicationIcon& icon) {
- return icon.path() == new_icon.path();
- })
- != icons_.end()) {
- return;
- }
- icons_.push_back(new_icon);
-}
-
-void ApplicationSplashScreenInfo::AddSplashScreen(
- const ApplicationSplashScreen& new_splashscreen) {
- // Eliminate duplicates, keep order
- if (std::find_if(splashscreens_.begin(), splashscreens_.end(),
- [&new_splashscreen](const ApplicationSplashScreen& splashscreen) {
- return splashscreen.src() == new_splashscreen.src();
- })
- != splashscreens_.end()) {
- return;
- }
- splashscreens_.push_back(new_splashscreen);
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_TPK_CONFIG_PARSER_H_
-#define TPK_MANIFEST_HANDLERS_TPK_CONFIG_PARSER_H_
-
-#include <boost/filesystem/path.hpp>
-
-#include <memory>
-#include <string>
-
-#include "manifest_parser/manifest_parser.h"
-
-namespace tpk {
-namespace parse {
-
-/**
- * @brief The TPKConfigParser class
- * Parser class of tpk package tizen-manifest.xml manifest file.
- *
- * Instance of this class may be used to parse single configuration file.
- * Depending on boolean result of @ref ParseManifest method, client code may
- * call:
- * - on success -> @ref GetManifestData(), passing the key of ManifestData
- * instance that it is interested in.
- * - on failure -> @ref GetErrorMessage(), to get value of error which was set
- * during the processing of config.xml
- *
- * To investigate which key do you need to get certain parsed piece of data,
- * check the key reported by handler's @ref ManifestHandler::Key() method.
- * Key returned by this method is the key to access data set by handler.
- */
-class TPKConfigParser {
- public:
- TPKConfigParser();
-
- std::shared_ptr<const parser::ManifestData> GetManifestData(
- const std::string& key);
- const std::string& GetErrorMessage() const;
- bool ParseManifest(const boost::filesystem::path& path);
-
- private:
- std::unique_ptr<parser::ManifestParser> parser_;
- std::string error_;
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_TPK_CONFIG_PARSER_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.
-
-#ifndef TPK_MANIFEST_HANDLERS_UI_AND_SERVICE_APPLICATION_INFOS_H_
-#define TPK_MANIFEST_HANDLERS_UI_AND_SERVICE_APPLICATION_INFOS_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-
-namespace tpk {
-namespace parse {
-
-// AppControl
-class AppControlInfo : public parser::ManifestData {
- public:
- AppControlInfo(const std::string& operation,
- const std::string& uri,
- const std::string& mime)
- : operation_(operation),
- uri_(uri),
- mime_(mime) {}
-
- const std::string& operation() const {
- return operation_;
- }
-
- const std::string& uri() const {
- return uri_;
- }
-
- const std::string& mime() const {
- return mime_;
- }
-
- private:
- std::string operation_;
- std::string uri_;
- std::string mime_;
-};
-
-// Background-category
-class BackgroundCategoryInfo : public parser::ManifestData {
- public:
- explicit BackgroundCategoryInfo(const std::string& value) : value_(value) {}
- virtual ~BackgroundCategoryInfo() {}
-
- const std::string& value() const { return value_; }
-
- private:
- std::string value_;
-};
-
-// DataControl
-class DataControlInfo : public parser::ManifestData {
- public:
- DataControlInfo(const std::string& access,
- const std::string& providerid,
- const std::string& type)
- : access_(access),
- providerid_(providerid),
- type_(type) {}
-
- const std::string& access() const {
- return access_;
- }
- const std::string& providerid() const {
- return providerid_;
- }
- const std::string& type() const {
- return type_;
- }
-
- private:
- std::string access_;
- std::string providerid_;
- std::string type_;
-};
-
-// MetaData
-class MetaDataInfo : public parser::ManifestData {
- public:
- MetaDataInfo(const std::string& key,
- const std::string& val)
- : key_(key),
- value_(val) {}
-
- const std::string& key() const {
- return key_;
- }
- const std::string& val() const {
- return value_;
- }
-
- private:
- std::string key_;
- std::string value_;
-};
-
-// Icon
-class ApplicationIcon {
- public:
- explicit ApplicationIcon(const std::string& path, const std::string& lang,
- const std::string& dpi)
- : path_(path), lang_(lang), dpi_(dpi) {}
-
- const std::string& path() const {
- return path_;
- }
-
- const std::string& lang() const {
- return lang_;
- }
-
- const std::string& dpi() const {
- return dpi_;
- }
-
- private:
- std::string path_;
- std::string lang_;
- std::string dpi_;
-};
-
-class ApplicationImage {
- public:
- ApplicationImage(const std::string& name, const std::string& section,
- const std::string& lang)
- : name_(name), section_(section), lang_(lang) {
- }
-
- const std::string& name() const {
- return name_;
- }
-
- const std::string& section() const {
- return section_;
- }
-
- const std::string& lang() const {
- return lang_;
- }
-
- private:
- std::string name_;
- std::string section_;
- std::string lang_;
-};
-
-// SplashScreen
-class ApplicationSplashScreen {
- public:
- explicit ApplicationSplashScreen(const std::string& src,
- const std::string& type,
- const std::string& dpi,
- const std::string& orientation,
- const std::string& indicatordisplay,
- const std::string& operation,
- const std::string& colordepth)
- : src_(src),
- type_(type),
- dpi_(dpi),
- orientation_(orientation),
- indicatordisplay_(indicatordisplay),
- operation_(operation),
- colordepth_(colordepth) {
- }
-
- const std::string& src() const {
- return src_;
- }
- const std::string& type() const {
- return type_;
- }
- const std::string& dpi() const {
- return dpi_;
- }
- const std::string& orientation() const {
- return orientation_;
- }
- const std::string& indicatordisplay() const {
- return indicatordisplay_;
- }
- const std::string& operation() const {
- return operation_;
- }
- const std::string& colordepth() const {
- return colordepth_;
- }
-
- private:
- std::string src_;
- std::string type_;
- std::string dpi_;
- std::string orientation_;
- std::string indicatordisplay_;
- std::string operation_;
- std::string colordepth_;
-};
-
-class ApplicationSplashScreenInfo : public parser::ManifestData {
- public:
- const std::vector<ApplicationSplashScreen>& splashscreens() const {
- return splashscreens_;
- }
-
- void AddSplashScreen(const ApplicationSplashScreen& splash_src);
-
- private:
- std::vector<ApplicationSplashScreen> splashscreens_;
-};
-
-class ApplicationIconsInfo : public parser::ManifestData {
- public:
- const std::vector<ApplicationIcon>& icons() const {
- return icons_;
- }
-
- void AddIcon(const ApplicationIcon& icon_path);
-
- private:
- std::vector<ApplicationIcon> icons_;
-};
-
-class ApplicationImagesInfo {
- public:
- std::vector<ApplicationImage> images;
-};
-
-// Label
-class LabelInfo : public parser::ManifestData {
- public:
- LabelInfo(const std::string& text,
- const std::string& name,
- const std::string& xml_lang)
- : text_(text),
- name_(name),
- xml_lang_(xml_lang) {}
-
- const std::string& text() const {
- return text_;
- }
- const std::string& name() const {
- return name_;
- }
- const std::string& xml_lang() const {
- return xml_lang_;
- }
-
- private:
- std::string text_;
- std::string name_;
- std::string xml_lang_;
-};
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_UI_AND_SERVICE_APPLICATION_INFOS_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 "tpk_manifest_handlers/ui_application_handler.h"
-
-#include <boost/algorithm/string/predicate.hpp>
-
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/package_handler.h"
-
-namespace tpk {
-namespace parse {
-
-namespace ba = boost::algorithm;
-namespace keys = tpk::application_keys;
-
-namespace {
-
-// ui-application
-const char kUIApplicationAppIDKey[] = "@appid";
-const char kUIApplicationExecKey[] = "@exec";
-const char kUIApplicationLaunchModeKey[] = "@launch_mode";
-const char kUIApplicationMultipleKey[] = "@multiple";
-const char kUIApplicationNoDisplayKey[] = "@nodisplay";
-const char kUIApplicationTaskManageKey[] = "@taskmanage";
-const char kUIApplicationTypeKey[] = "@type";
-const char kUIApplicationUIGadgetKey[] = "@ui-gadget";
-const char kUIApplicationProcessPoolKey[] = "@process-pool";
-const char kUIApplicationSubmodeKey[] = "@submode";
-const char kUIApplicationSubmodeMainIDKey[] = "@submode-mainid";
-const char kUIApplicationIndicatorDisplayKey[] = "@indicatordisplay";
-const char kUIApplicationPortraitEffectImageKey[] = "@portrait-effectimage";
-const char kUIApplicationLandscapeEffectImageKey[] = "@landscape-effectimage";
-const char kUIApplicationEffectImageTypeKey[] = "@effectimage-type";
-const char kUIApplicationHwAccelerationKey[] = "@hw-acceleration";
-const char kUIApplicationSplashScreenDisplayKey[] = "@splash-screen-display";
-const char kUIApplicationKey[] = "manifest.ui-application";
-
-const char kTrue[] = "true";
-const char kFalse[] = "false";
-
-// manifest
-const char kManifestKey[] = "manifest";
-
-bool IsBooleanString(const std::string& value) {
- return ba::iequals(value, "true") || ba::iequals(value, "false");
-}
-
-} // namespace
-
-bool InitializeParsing(const parser::DictionaryValue& app_dict,
- UIApplicationSingleEntry* uiapplicationinfo,
- std::string* error) {
- ParsingFuncPtr<UIApplicationSingleEntry> parsingFunc =
- ParseAppControl<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kAppControlKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseDataControl<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kDataControlKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseMetaData<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kMetaDataKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseAppIcon<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kIconKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseLabel<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kLabelKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseAppImage<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kImageKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseCategory<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kCategoryKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseBackgroundCategoryElement<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kBackgroundCategoryKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
- parsingFunc = ParseSplashScreen<UIApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kSplashScreensKey,
- parsingFunc, uiapplicationinfo, error))
- return false;
-
- return true;
-}
-
-bool UIAppValidation(const UIApplicationSingleEntry& item,
- const std::string&, std::string* error) {
- if (item.app_info.appid().empty()) {
- *error = "The appid child element of ui-application element is obligatory";
- return false;
- }
-
- if (!parser::ValidateTizenNativeId(item.app_info.appid())) {
- *error = "The application id should be composed of alphanumerics "
- "optionally separate with dots.";
- return false;
- }
-
- const std::string& exec = item.app_info.exec();
- if (exec.empty()) {
- *error = "The exec child element of ui-application element is obligatory";
- return false;
- }
-
- const std::string& launch_mode = item.app_info.launch_mode();
- if (!launch_mode.empty()) {
- if (launch_mode != "group" &&
- launch_mode != "caller" &&
- launch_mode != "single") {
- *error = "The improper value was given for ui-application launch_mode";
- return false;
- }
- } else {
- // FIXME currently const_cast used, but it is not the best way.
- UIApplicationInfo &tmp = const_cast<UIApplicationInfo &>(item.app_info);
- tmp.set_launch_mode("single");
- }
-
- const std::string& multiple = item.app_info.multiple();
- if (multiple.empty()) {
- *error =
- "The multiple child element of ui-application element is obligatory";
- return false;
- }
- if (multiple != kTrue && multiple != kFalse) {
- *error = "multiple attribute should have 'true' or 'false' value";
- return false;
- }
-
- const std::string& nodisplay = item.app_info.nodisplay();
- if (nodisplay.empty()) {
- *error =
- "The nodisplay child element of ui-application element is obligatory";
- return false;
- }
-
- if (nodisplay != kTrue && nodisplay != kFalse) {
- *error = "nodisplay attribute should have 'true' or 'false' value";
- return false;
- }
-
- const std::string& taskmanage = item.app_info.taskmanage();
- if (taskmanage.empty()) {
- *error =
- "The taskmanage child element of "
- "ui-application element is obligatory";
- return false;
- }
-
- if (taskmanage != kTrue && taskmanage != kFalse) {
- *error = "taskmanage attribute should have 'true' or 'false' value";
- return false;
- }
-
- const std::string& type = item.app_info.type();
- if (type.empty()) {
- *error =
- "The type child element of "
- "ui-application element is obligatory";
- return false;
- }
- return true;
-}
-
-bool ParseUIApplicationAndStore(
- const parser::DictionaryValue& app_dict,
- UIApplicationSingleEntry* uiapplicationinfo,
- std::string* error) {
- std::string appid;
- if (app_dict.GetString(kUIApplicationAppIDKey, &appid))
- uiapplicationinfo->app_info.set_appid(appid);
- std::string exec;
- if (app_dict.GetString(kUIApplicationExecKey, &exec))
- uiapplicationinfo->app_info.set_exec(exec);
- std::string multiple;
- if (app_dict.GetString(kUIApplicationMultipleKey, &multiple))
- uiapplicationinfo->app_info.set_multiple(multiple);
- std::string nodisplay;
- if (app_dict.GetString(kUIApplicationNoDisplayKey, &nodisplay))
- uiapplicationinfo->app_info.set_nodisplay(nodisplay);
- std::string taskmanage;
- if (app_dict.GetString(kUIApplicationTaskManageKey, &taskmanage))
- uiapplicationinfo->app_info.set_taskmanage(taskmanage);
- std::string type;
- if (app_dict.GetString(kUIApplicationTypeKey, &type))
- uiapplicationinfo->app_info.set_type(type);
- std::string uigadget;
- if (app_dict.GetString(kUIApplicationUIGadgetKey, &uigadget))
- uiapplicationinfo->app_info.set_uigadget(uigadget);
- std::string process_pool;
- if (app_dict.GetString(kUIApplicationProcessPoolKey, &process_pool)) {
- if (!IsBooleanString(process_pool)) {
- *error = "process_pool must be 'true' or 'false'";
- return false;
- }
- uiapplicationinfo->app_info.set_process_pool(process_pool);
- }
- std::string submode;
- if (app_dict.GetString(kUIApplicationSubmodeKey, &submode)) {
- if (!IsBooleanString(submode)) {
- *error = "submode must be 'true' or 'false'";
- return false;
- }
- uiapplicationinfo->app_info.set_submode(submode);
- }
- std::string submode_mainid;
- if (app_dict.GetString(kUIApplicationSubmodeMainIDKey, &submode_mainid))
- uiapplicationinfo->app_info.set_submode_mainid(submode_mainid);
- std::string indicator_display;
- if (app_dict.GetString(kUIApplicationIndicatorDisplayKey,
- &indicator_display)) {
- if (!IsBooleanString(indicator_display)) {
- *error = "indicatordisplay must be 'true' or 'false'";
- return false;
- }
- uiapplicationinfo->app_info.set_indicator_display(indicator_display);
- }
- std::string portrait_effectimage;
- if (app_dict.GetString(kUIApplicationPortraitEffectImageKey,
- &portrait_effectimage))
- uiapplicationinfo->app_info.set_portrait_image(portrait_effectimage);
- std::string landscape_effectimage;
- if (app_dict.GetString(kUIApplicationLandscapeEffectImageKey,
- &landscape_effectimage))
- uiapplicationinfo->app_info.set_landscape_image(landscape_effectimage);
- std::string effectimage_type;
- if (app_dict.GetString(kUIApplicationEffectImageTypeKey, &effectimage_type))
- uiapplicationinfo->app_info.set_effectimage_type(effectimage_type);
-
- std::string launch_mode;
- if (app_dict.GetString(kUIApplicationLaunchModeKey, &launch_mode)) {
- if (launch_mode.empty()) {
- *error = "launch_mode attribute is empty";
- return false;
- }
- uiapplicationinfo->app_info.set_launch_mode(launch_mode);
- }
-
- std::string hwacceleration;
- if (app_dict.GetString(kUIApplicationHwAccelerationKey, &hwacceleration)) {
- if (hwacceleration == "use-GL")
- hwacceleration = "on";
- else if (hwacceleration == "not-use-GL")
- hwacceleration = "off";
- else if (hwacceleration == "use-system-setting")
- hwacceleration = "default";
- uiapplicationinfo->app_info.set_hwacceleration(hwacceleration);
- }
-
- std::string splash_screen_display;
- if (app_dict.GetString(kUIApplicationSplashScreenDisplayKey,
- &splash_screen_display)) {
- if (!IsBooleanString(splash_screen_display)) {
- *error = "splash-screen-display must be 'true' or 'false'";
- return false;
- }
- uiapplicationinfo->app_info.set_splash_screen_display(
- splash_screen_display);
- }
-
- return InitializeParsing(app_dict, uiapplicationinfo, error);
-}
-
-UIApplicationInfo::UIApplicationInfo()
- : process_pool_("false"),
- multiple_("false"),
- nodisplay_("false"),
- taskmanage_("true"),
- submode_("false"),
- indicator_display_("true"),
- effectimage_type_("image"),
- hwacceleration_("default"),
- splash_screen_display_("true") {
-}
-
-bool UIApplicationHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kUIApplicationKey))
- return true;
-
- auto uiapplicationinfo = std::make_shared<UIApplicationInfoList>();
-
- for (const auto& ui_dict : parser::GetOneOrMany(
- manifest.value(), kUIApplicationKey, "")) {
- UIApplicationSingleEntry uiappentry;
- if (!ParseUIApplicationAndStore(*ui_dict, &uiappentry, error))
- return false;
- uiapplicationinfo->items.push_back(uiappentry);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(uiapplicationinfo);
- return true;
-}
-
-bool UIApplicationHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const {
- const UIApplicationInfoList& elements =
- static_cast<const UIApplicationInfoList&>(data);
-
- std::shared_ptr<const PackageInfo> package_info =
- std::static_pointer_cast<const PackageInfo>(
- handlers_output.find(kManifestKey)->second);
-
- for (const auto& item : elements.items) {
- if (!UIAppValidation(item, package_info->api_version(), error) ||
- !AppControlValidation(item, error) ||
- !DataControlValidation(item, error) ||
- !MetadataValidation(item, error) ||
- !LabelValidation(item, error) ||
- !SplashScreenValidation(item, error)) {
- return false;
- }
- }
- return true;
-}
-
-std::string UIApplicationInfo::key() {
- return kUIApplicationKey;
-}
-
-std::string UIApplicationHandler::Key() const {
- return kUIApplicationKey;
-}
-
-std::vector<std::string> UIApplicationHandler::PrerequisiteKeys() const {
- return { kManifestKey };
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_UI_APPLICATION_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_UI_APPLICATION_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/common/application_handler.h"
-
-namespace tpk {
-namespace parse {
-
-class UIApplicationInfo : public ApplicationInfo {
- public:
- UIApplicationInfo();
- /**
- * @brief key
- * @param key string
- */
- static std::string key();
- /**
- * @brief set_launch_mode sets launch mdoe
- * @param launch_mode
- */
- void set_type(std::string type) {
- type_ = std::move(type);
- }
- void set_process_pool(std::string process_pool) {
- process_pool_ = std::move(process_pool);
- }
- void set_launch_mode(std::string launch_mode) {
- launch_mode_ = std::move(launch_mode);
- }
- /**
- * @brief set_multiple sets multiple
- * @param multiple
- */
- void set_multiple(std::string multiple) {
- multiple_ = std::move(multiple);
- }
- /**
- * @brief set_nodisplay sets no display
- * @param nodisplay
- */
- void set_nodisplay(std::string nodisplay) {
- nodisplay_ = std::move(nodisplay);
- }
- /**
- * @brief set_taskmanage set task manage
- * @param taskmanage
- */
- void set_taskmanage(std::string taskmanage) {
- taskmanage_ = std::move(taskmanage);
- }
- void set_uigadget(std::string uigadget) {
- uigadget_ = std::move(uigadget);
- }
- void set_submode(std::string submode) {
- submode_ = std::move(submode);
- }
- void set_submode_mainid(std::string submode_mainid) {
- submode_mainid_ = std::move(submode_mainid);
- }
- void set_indicator_display(std::string indicator_display) {
- indicator_display_ = std::move(indicator_display);
- }
- void set_portrait_image(std::string portrait_image) {
- portrait_image_ = std::move(portrait_image);
- }
- void set_landscape_image(std::string landscape_image) {
- landscape_image_ = std::move(landscape_image);
- }
- void set_effectimage_type(std::string effectimage_type) {
- effectimage_type_ = std::move(effectimage_type);
- }
- void set_hwacceleration(std::string hwacceleration) {
- hwacceleration_ = std::move(hwacceleration);
- }
- void set_splash_screen_display(std::string splash_screen_display) {
- splash_screen_display_ = std::move(splash_screen_display);
- }
-
- const std::string& type() const {
- return type_;
- }
- const std::string& process_pool() const {
- return process_pool_;
- }
- /**
- * @brief launch_mode
- * @return launch mode string
- */
- const std::string& launch_mode() const {
- return launch_mode_;
- }
- /**
- * @brief multiple
- * @return multiple string
- */
- const std::string& multiple() const {
- return multiple_;
- }
- /**
- * @brief nodisplay
- * @return nodisplay string
- */
- const std::string& nodisplay() const {
- return nodisplay_;
- }
- /**
- * @brief taskmanage
- * @return taskmanage
- */
- const std::string& taskmanage() const {
- return taskmanage_;
- }
-
- const std::string& uigadget() const {
- return uigadget_;
- }
-
- const std::string& submode() const {
- return submode_;
- }
-
- const std::string& submode_mainid() const {
- return submode_mainid_;
- }
-
- const std::string& indicator_display() const {
- return indicator_display_;
- }
-
- const std::string& portrait_image() const {
- return portrait_image_;
- }
-
- const std::string& landscape_image() const {
- return landscape_image_;
- }
-
- const std::string& effectimage_type() const {
- return effectimage_type_;
- }
-
- const std::string& hwacceleration() const {
- return hwacceleration_;
- }
-
- const std::string& splash_screen_display() const {
- return splash_screen_display_;
- }
-
- private:
- std::string type_;
- std::string process_pool_;
- std::string launch_mode_;
- std::string multiple_;
- std::string nodisplay_;
- std::string taskmanage_;
- std::string uigadget_;
- std::string submode_;
- std::string submode_mainid_;
- std::string indicator_display_;
- std::string portrait_image_;
- std::string landscape_image_;
- std::string effectimage_type_;
- std::string hwacceleration_;
- std::string splash_screen_display_;
-};
-
-struct UIApplicationSingleEntry :
- public ApplicationSingleEntry<UIApplicationInfo> {
- ApplicationImagesInfo app_images;
- std::vector<AppControlInfo> app_control;
- std::vector<BackgroundCategoryInfo> background_category;
- std::vector<DataControlInfo> data_control;
- ApplicationSplashScreenInfo app_splashscreens;
-};
-
-using UIApplicationInfoList = ApplicationInfoList<UIApplicationSingleEntry>;
-
-/**
- * @brief The UIApplicationHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <ui-application>
- * \_ <label>
- * \_ <icon>
- * \_ <image>
- * \_ <app-control>
- * | \_ <mime>
- * | \_ <operation>
- * | \_ <uri>
- * \_ <metadata>
- * \_ <datacontrol>
- * \_ <splash-screens>
- * \_ <splash-screen>
- */
-class UIApplicationHandler : public parser::ManifestHandler {
- public:
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
- std::vector<std::string> PrerequisiteKeys() const override;
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_UI_APPLICATION_HANDLER_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.
-
-#include "tpk_manifest_handlers/watch_application_handler.h"
-
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/package_handler.h"
-
-namespace tpk {
-namespace parse {
-
-namespace keys = tpk::application_keys;
-
-namespace {
-
-// watch-application
-const char kWatchApplicationAppIDKey[] = "@appid";
-const char kWatchApplicationExecKey[] = "@exec";
-const char kWatchApplicationLabelKey[] = "label";
-const char kWatchApplicationTypeKey[] = "@type";
-const char kWatchApplicationIconKey[] = "icon";
-const char kWatchApplicationAmbientSupport[] = "@ambient-support";
-const char kWatchApplicationKey[] = "manifest.watch-application";
-
-const char kTrue[] = "true";
-const char kFalse[] = "false";
-
-// manifest
-const char kManifestKey[] = "manifest";
-
-} // namespace
-
-bool WatchAppValidation(const WatchApplicationSingleEntry& watch_app_info,
- std::string* error) {
- if (watch_app_info.app_info.appid().empty()) {
- *error = "The appid attribute of watch-application element is obligatory";
- return false;
- }
- if (!parser::ValidateTizenNativeId(watch_app_info.app_info.appid())) {
- *error = "The application id should be composed of alphanumerics "
- "optionally separate with dots.";
- return false;
- }
-
- if (watch_app_info.app_info.exec().empty()) {
- *error = "The exec attribute of watch-application element is obligatory";
- return false;
- }
- const auto& ambient_support = watch_app_info.app_info.ambient_support();
- if (ambient_support != kTrue && ambient_support != kFalse) {
- *error = "ambient-support attribute should have 'true' or 'false' value";
- return false;
- }
-
- return true;
-}
-
-bool InitializeParsing(const parser::DictionaryValue& app_dict,
- WatchApplicationSingleEntry* widgetapplicationinfo,
- std::string* error) {
- ParsingFuncPtr<WatchApplicationSingleEntry> parsingFunc =
- ParseLabel<WatchApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kLabelKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseAppIcon<WatchApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kIconKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseAppImage<WatchApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kImageKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseMetaData<WatchApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kMetaDataKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseCategory<WatchApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kCategoryKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseBackgroundCategoryElement<WatchApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kBackgroundCategoryKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- return true;
-}
-
-bool ParseWatchApplication(
- const parser::DictionaryValue& app_dict,
- WatchApplicationSingleEntry* watch_app_info,
- std::string* error) {
-
- std::string appid;
- if (app_dict.GetString(kWatchApplicationAppIDKey, &appid))
- watch_app_info->app_info.set_appid(appid);
-
- std::string exec;
- if (app_dict.GetString(kWatchApplicationExecKey, &exec))
- watch_app_info->app_info.set_exec(exec);
-
- std::string ambient_support;
- if (app_dict.GetString(kWatchApplicationAmbientSupport, &ambient_support))
- watch_app_info->app_info.set_ambient_support(ambient_support);
-
- std::string icon;
- if (app_dict.GetString(kWatchApplicationIconKey, &icon))
- watch_app_info->app_info.set_icon(icon);
-
- std::string label;
- if (app_dict.GetString(kWatchApplicationLabelKey, &label))
- watch_app_info->app_info.set_label(label);
-
- std::string type;
- if (app_dict.GetString(kWatchApplicationTypeKey, &type))
- watch_app_info->app_info.set_type(type);
-
- return InitializeParsing(app_dict, watch_app_info, error);
-}
-
-WatchApplicationInfo::WatchApplicationInfo()
- : type_(""), ambient_support_(kFalse), icon_(""), label_("") {
-}
-
-bool WatchApplicationHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kWatchApplicationKey))
- return true;
-
-
- auto watchapplicationinfo = std::make_shared<WatchApplicationInfoList>();
-
- for (const auto& watch_dict : parser::GetOneOrMany(
- manifest.value(), kWatchApplicationKey, "")) {
- WatchApplicationSingleEntry watchappentry;
- if (!ParseWatchApplication(*watch_dict, &watchappentry, error))
- return false;
- watchapplicationinfo->items.push_back(watchappentry);
- }
-
- if (watchapplicationinfo->items.size() > 1) {
- *error = "Multiple watch-application tags not supported.";
- return false;
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(
- watchapplicationinfo);
- return true;
-}
-
-bool WatchApplicationHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const {
- const WatchApplicationInfoList& watch_app_info =
- static_cast<const WatchApplicationInfoList&>(data);
-
- std::shared_ptr<const PackageInfo> package_info =
- std::static_pointer_cast<const PackageInfo>(
- handlers_output.find(kManifestKey)->second);
-
- for (const auto& item : watch_app_info.items) {
- if (!WatchAppValidation(item, error)) {
- return false;
- }
- }
-
- return true;
-}
-
-std::string WatchApplicationInfo::key() {
- return kWatchApplicationKey;
-}
-
-std::string WatchApplicationHandler::Key() const {
- return kWatchApplicationKey;
-}
-
-std::vector<std::string> WatchApplicationHandler::PrerequisiteKeys() const {
- return { kManifestKey };
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_WATCH_APPLICATION_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_WATCH_APPLICATION_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/common/application_handler.h"
-
-namespace tpk {
-namespace parse {
-
-class WatchApplicationInfo : public ApplicationInfo {
- public:
- WatchApplicationInfo();
-
- /**
- * @brief Key indicating element name in tizen-manifest.xml file.
- * @param key string
- */
- static std::string key();
-
- /**
- * @brief Indicates whether the application draws the ambient mode UI itself.
- * @return ambient_support_ string
- */
- const std::string& ambient_support() const {
- return ambient_support_;
- }
-
- /**
- * @brief Watch application icon image.
- * @return icon string
- */
- const std::string& icon() const {
- return icon_;
- }
-
- /**
- * @brief Watch application text.
- * @return label string
- */
- const std::string& label() const {
- return label_;
- }
-
- /**
- * @brief Watch application type.
- * @return type string
- */
- const std::string& type() const {
- return type_;
- }
-
- void set_ambient_support(std::string ambient_support) {
- ambient_support_ = std::move(ambient_support);
- }
-
- void set_icon(std::string icon) {
- icon_ = std::move(icon);
- }
-
- void set_label(std::string label) {
- label_ = std::move(label);
- }
- void set_type(std::string type) {
- type_ = std::move(type);
- }
-
- private:
- std::string type_;
- std::string ambient_support_;
- std::string icon_;
- std::string label_;
-};
-
-struct WatchApplicationSingleEntry :
- public ApplicationSingleEntry<WatchApplicationInfo> {
- ApplicationImagesInfo app_images;
- std::vector<BackgroundCategoryInfo> background_category;
-};
-
-using WatchApplicationInfoList =
- ApplicationInfoList<WatchApplicationSingleEntry>;
-
-/**
- * @brief The WatchApplicationHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <watch-application>
- * \_ <label>
- * \_ <icon>
- */
-class WatchApplicationHandler : public parser::ManifestHandler {
- public:
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
- std::vector<std::string> PrerequisiteKeys() const override;
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_WATCH_APPLICATION_HANDLER_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 "tpk_manifest_handlers/widget_application_handler.h"
-
-#include <boost/algorithm/string/predicate.hpp>
-
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/package_handler.h"
-
-namespace tpk {
-namespace parse {
-
-namespace ba = boost::algorithm;
-namespace keys = tpk::application_keys;
-
-namespace {
-// image
-const char kImageKey[] = "image";
-const char kImageNameKey[] = "@name";
-const char kImageSectionKey[] = "@section";
-const char kImageLangKey[] = "@lang";
-
-// widget-application
-const char kWidgetApplicationAppIDKey[] = "@appid";
-const char kWidgetApplicationExecKey[] = "@exec";
-const char kWidgetApplicationLaunchModeKey[] = "@launch_mode";
-const char kWidgetApplicationMultipleKey[] = "@multiple";
-const char kWidgetApplicationNoDisplayKey[] = "@nodisplay";
-const char kWidgetApplicationHwAccelerationKey[] = "@hwacceleration";
-const char kWidgetApplicationKey[] = "manifest.widget-application";
-
-const char kTrue[] = "true";
-const char kFalse[] = "false";
-
-// manifest
-const char kManifestKey[] = "manifest";
-
-} // namespace
-
-template<>
-bool ParseMetaData(const parser::DictionaryValue& dict,
- WidgetApplicationSingleEntry* info, std::string*) {
- std::string key;
- dict.GetString(tpk_app_keys::kMetaDataKeyKey, &key);
- std::string val;
- dict.GetString(tpk_app_keys::kMetaDataValueKey, &val);
- info->meta_data.emplace_back(key, val);
-
- return true;
-}
-
-bool InitializeParsing(const parser::DictionaryValue& app_dict,
- WidgetApplicationSingleEntry* widgetapplicationinfo,
- std::string* error) {
- ParsingFuncPtr<WidgetApplicationSingleEntry> parsingFunc =
- ParseMetaData<WidgetApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kMetaDataKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseAppIcon<WidgetApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kIconKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseLabel<WidgetApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kLabelKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseAppImage<WidgetApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kImageKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
- parsingFunc = ParseCategory<WidgetApplicationSingleEntry>;
- if (!InitializeParsingElement(app_dict, tpk_app_keys::kCategoryKey,
- parsingFunc, widgetapplicationinfo, error))
- return false;
-
- return true;
-}
-
-bool WidgetAppValidation(const WidgetApplicationSingleEntry& item,
- const std::string&, std::string* error) {
- if (item.app_info.appid().empty()) {
- *error = "The appid child element of widget-application element "
- "is obligatory";
- return false;
- }
-
- if (!parser::ValidateTizenNativeId(item.app_info.appid())) {
- *error = "The application id should be composed of alphanumerics "
- "optionally separate with dots.";
- return false;
- }
-
- const std::string& exec = item.app_info.exec();
- if (exec.empty()) {
- *error = "The exec child element of widget-application element "
- "is obligatory";
- return false;
- }
-
- const std::string& launch_mode = item.app_info.launch_mode();
- if (!launch_mode.empty()) {
- if (launch_mode != "group" &&
- launch_mode != "caller" &&
- launch_mode != "single") {
- *error = "The improper value was given for widget-application "
- "launch_mode";
- return false;
- }
- } else {
- // FIXME currently const_cast used, but it is not the best way.
- WidgetApplicationInfo &tmp = const_cast<WidgetApplicationInfo &>(
- item.app_info);
- tmp.set_launch_mode("single");
- }
-
- const std::string& multiple = item.app_info.multiple();
- if (multiple.empty()) {
- *error = "The multiple child element of widget-application element "
- "is obligatory";
- return false;
- }
-
- if (multiple != kTrue && multiple != kFalse) {
- *error = "multiple attribute should have 'true' or 'false' value";
- return false;
- }
-
- const std::string& nodisplay = item.app_info.nodisplay();
- if (nodisplay.empty()) {
- *error = "The nodisplay child element of widget-application element "
- "is obligatory";
- return false;
- }
-
- if (nodisplay != kTrue && nodisplay != kFalse) {
- *error = "nodisplay attribute should have 'true' or 'false' value";
- return false;
- }
-
- return true;
-}
-
-bool ParseWidgetApplicationAndStore(
- const parser::DictionaryValue& app_dict,
- WidgetApplicationSingleEntry* widgetapplicationinfo,
- std::string* error) {
- std::string appid;
- if (app_dict.GetString(kWidgetApplicationAppIDKey, &appid))
- widgetapplicationinfo->app_info.set_appid(appid);
- std::string exec;
- if (app_dict.GetString(kWidgetApplicationExecKey, &exec))
- widgetapplicationinfo->app_info.set_exec(exec);
- std::string multiple;
- if (app_dict.GetString(kWidgetApplicationMultipleKey, &multiple))
- widgetapplicationinfo->app_info.set_multiple(multiple);
- std::string nodisplay;
- if (app_dict.GetString(kWidgetApplicationNoDisplayKey, &nodisplay))
- widgetapplicationinfo->app_info.set_nodisplay(nodisplay);
-
- std::string launch_mode;
- if (app_dict.GetString(kWidgetApplicationLaunchModeKey, &launch_mode)) {
- if (launch_mode.empty()) {
- *error = "launch_mode attribute is empty";
- return false;
- }
- widgetapplicationinfo->app_info.set_launch_mode(launch_mode);
- }
-
- std::string hwacceleration;
- if (app_dict.GetString(kWidgetApplicationHwAccelerationKey,
- &hwacceleration)) {
- if (hwacceleration == "use-GL")
- hwacceleration = "on";
- else if (hwacceleration == "not-use-GL")
- hwacceleration = "off";
- else if (hwacceleration == "use-system-setting")
- hwacceleration = "default";
- widgetapplicationinfo->app_info.set_hwacceleration(hwacceleration);
- }
-
- return InitializeParsing(app_dict, widgetapplicationinfo, error);
-}
-
-WidgetApplicationInfo::WidgetApplicationInfo()
- : multiple_("false"),
- nodisplay_("false"),
- hwacceleration_("default") {
-}
-
-bool WidgetApplicationHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kWidgetApplicationKey))
- return true;
-
- auto widgetapplicationinfo = std::make_shared<WidgetApplicationInfoList>();
-
- for (const auto& ui_dict : parser::GetOneOrMany(
- manifest.value(), kWidgetApplicationKey, "")) {
- WidgetApplicationSingleEntry widgetappentry;
- if (!ParseWidgetApplicationAndStore(*ui_dict, &widgetappentry, error))
- return false;
- widgetapplicationinfo->items.push_back(widgetappentry);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(
- widgetapplicationinfo);
- return true;
-}
-
-bool WidgetApplicationHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const {
- const WidgetApplicationInfoList& elements =
- static_cast<const WidgetApplicationInfoList&>(data);
-
-
- std::shared_ptr<const PackageInfo> package_info =
- std::static_pointer_cast<const PackageInfo>(
- handlers_output.find(kManifestKey)->second);
-
- for (const auto& item : elements.items) {
- if (!WidgetAppValidation(item, package_info->api_version(), error) ||
- !MetadataValidation(item, error) ||
- !LabelValidation(item, error)) {
- return false;
- }
- }
- return true;
-}
-
-std::string WidgetApplicationHandler::Key() const {
- return kWidgetApplicationKey;
-}
-
-std::vector<std::string> WidgetApplicationHandler::PrerequisiteKeys() const {
- return { kManifestKey };
-}
-
-} // namespace parse
-} // namespace tpk
+++ /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 TPK_MANIFEST_HANDLERS_WIDGET_APPLICATION_HANDLER_H_
-#define TPK_MANIFEST_HANDLERS_WIDGET_APPLICATION_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "tpk_manifest_handlers/application_manifest_constants.h"
-#include "tpk_manifest_handlers/common/application_handler.h"
-
-namespace tpk {
-namespace parse {
-
-class WidgetApplicationInfo : public ApplicationInfo {
- public:
- WidgetApplicationInfo();
- /**
- * @brief key
- * @param key string
- */
- static std::string key();
- /**
- * @brief set_launch_mode sets launch mdoe
- * @param launch_mode
- */
- void set_launch_mode(std::string launch_mode) {
- launch_mode_ = std::move(launch_mode);
- }
- /**
- * @brief set_multiple sets multiple
- * @param multiple
- */
- void set_multiple(std::string multiple) {
- multiple_ = std::move(multiple);
- }
- /**
- * @brief set_nodisplay sets no display
- * @param nodisplay
- */
- void set_nodisplay(std::string nodisplay) {
- nodisplay_ = std::move(nodisplay);
- }
- void set_hwacceleration(std::string hwacceleration) {
- hwacceleration_ = std::move(hwacceleration);
- }
-
- /**
- * @brief launch_mode
- * @return launch mode string
- */
- const std::string& launch_mode() const {
- return launch_mode_;
- }
- /**
- * @brief multiple
- * @return multiple string
- */
- const std::string& multiple() const {
- return multiple_;
- }
- /**
- * @brief nodisplay
- * @return nodisplay string
- */
- const std::string& nodisplay() const {
- return nodisplay_;
- }
-
- const std::string& hwacceleration() const {
- return hwacceleration_;
- }
-
- private:
- std::string launch_mode_;
- std::string multiple_;
- std::string nodisplay_;
- std::string hwacceleration_;
-};
-
-struct WidgetApplicationSingleEntry :
- public ApplicationSingleEntry<WidgetApplicationInfo> {
- ApplicationImagesInfo app_images;
-};
-
-using WidgetApplicationInfoList =
- ApplicationInfoList<WidgetApplicationSingleEntry>;
-
-/**
- * @brief The WidgetApplicationHandler class
- *
- * Handler of tizen-manifest.xml for xml elements:
- * <widget-application>
- * \_ <label>
- * \_ <icon>
- * \_ <image>
- * \_ <metadata>
- */
-class WidgetApplicationHandler : public parser::ManifestHandler {
- public:
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
- std::vector<std::string> PrerequisiteKeys() const override;
-};
-
-} // namespace parse
-} // namespace tpk
-
-#endif // TPK_MANIFEST_HANDLERS_WIDGET_APPLICATION_HANDLER_H_
values_unittest
manifest_unittest
manifest_handler_unittest
- manifest_util_unittest
parser_unittest
- service_handler_unittest
- content_handler_unittest
string_util_unittest
version_number_unittest
)
parser_manifest_unittest.cc)
ADD_EXECUTABLE(manifest_handler_unittest
parser_manifest_handler_unittest.cc)
-ADD_EXECUTABLE(manifest_util_unittest
- parser_manifest_util_unittest.cc)
-ADD_EXECUTABLE(service_handler_unittest
- service_handler_unittest.cc)
-ADD_EXECUTABLE(content_handler_unittest
- content_handler_unittest.cc)
ADD_EXECUTABLE(parser_unittest
parser_unittest.cc)
ADD_EXECUTABLE(string_util_unittest string_util_unittest.cc)
target_link_libraries(values_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(manifest_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(manifest_handler_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${GTEST_MAIN_LIBRARIES})
-target_link_libraries(manifest_util_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(parser_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${GTEST_MAIN_LIBRARIES})
-target_link_libraries(service_handler_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} ${GTEST_MAIN_LIBRARIES})
-target_link_libraries(content_handler_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(string_util_unittest PUBLIC ${TARGET_LIBNAME_UTILS} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(version_number_unittest PUBLIC ${TARGET_LIBNAME_UTILS} ${GTEST_MAIN_LIBRARIES})
+++ /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.
-
-#include <boost/filesystem/path.hpp>
-
-#include <gtest/gtest.h>
-
-#include <memory>
-#include <vector>
-
-#include "manifest_parser/manifest.h"
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/manifest_parser_impl.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-#include "wgt_manifest_handlers/content_handler.h"
-
-namespace bf = boost::filesystem;
-
-namespace {
-const char kWidgetKey[] = "widget";
-const char kNamespaceKey[] = "@namespace";
-const char kTizenContentTagKey[] = "content";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kTizenContentEncodingKey[] = "@encoding";
-const char kTizenContentTypeKey[] = "@type";
-const char kTizenContentKey[] = "widget.content";
-const char kMimeMainComponent[] = "";
-const char kMimeCharsetComponent[] = "charset";
-const char kDefaultMimeType[] = "text/html";
-const char kDefaultEncoding[] = "UTF-8";
-const char kTizenContentSrcKey[] = "@src";
-
-
-std::unique_ptr<parser::ManifestHandlerRegistry> GetRegistryForTest() {
- std::unique_ptr<parser::ManifestHandlerRegistry> registry;
- registry.reset(new parser::ManifestHandlerRegistry());
- registry->RegisterManifestHandler(new wgt::parse::ContentHandler());
- return registry;
-}
-
-} // namespace
-
-namespace parser {
-
-/**
- * @brief The ContentHandlerTest class
- *
- * Those tests are using ManifestParserImpl so they are testing all behaviour
- * beside file existance verification which is done in WidgetConfigParser.
- * It works as if all valid content positions exist in widget package.
- */
-class ContentHandlerTest : public testing::Test {
- public:
- void SetUp() override {
- parser_.reset(new ManifestParserImpl((GetRegistryForTest())));
- }
- void TearDown() override { parser_.reset(); }
- void SetManifest(std::shared_ptr<Manifest> manifest) {
- parser_->manifest_ = manifest;
- }
- bool ParseAppManifest() {
- std::string error;
- return parser_->ParseAppManifest(&error);
- }
- bool ValidateAppManifest() {
- std::string error;
- return parser_->ValidateAppManifest(&error);
- }
- std::shared_ptr<const ManifestData> GetManifestData(const std::string& key) {
- return parser_->GetManifestData(key);
- }
-
- private:
- std::unique_ptr<ManifestParserImpl> parser_;
-};
-
-TEST_F(ContentHandlerTest, NoContentEntry) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!GetManifestData(kTizenContentKey));
-}
-
-TEST_F(ContentHandlerTest, SingleContentEntry) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenContentSrcKey, "my_index.html");
- widget->Set(kTizenContentTagKey, content.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), false);
- ASSERT_EQ(content_info->src(), "my_index.html");
-}
-
-TEST_F(ContentHandlerTest, SingleContentEntrySrcEmpty) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenContentSrcKey, "");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kTizenContentTagKey, content.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check empty
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_FALSE(!!content_info);
-}
-
-TEST_F(ContentHandlerTest, SingleTizenContentEntry) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenContentSrcKey, "http://www.tizen.app/my_index.html");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kTizenContentTagKey, content.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), true);
- ASSERT_EQ(content_info->src(), "http://www.tizen.app/my_index.html");
-}
-
-TEST_F(ContentHandlerTest, SingleTizenContentEntryNotURL) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenContentSrcKey, "relative_NOT_url");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kTizenContentTagKey, content.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check error
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), true);
- ASSERT_EQ(content_info->src(), "relative_NOT_url");
-}
-
-TEST_F(ContentHandlerTest, MultipleContentEntryW3CTakeFirst) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content1->SetString(kTizenContentSrcKey, "w3c_1_index.html");
- content2->SetString(kTizenContentSrcKey, "w3c_2_index.html");
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), false);
- ASSERT_EQ(content_info->src(), "w3c_1_index.html");
-}
-
-TEST_F(ContentHandlerTest, MultipleContentEntryTizenTakeFirst) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content1->SetString(kTizenContentSrcKey,
- "http://www.tizen.app/tizen_1_index.html");
- content1->SetString(kNamespaceKey, kTizenNamespacePrefix);
- content2->SetString(kTizenContentSrcKey,
- "http://www.tizen.app/tizen_2_index.html");
- content2->SetString(kNamespaceKey, kTizenNamespacePrefix);
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), true);
- ASSERT_EQ(content_info->src(), "http://www.tizen.app/tizen_1_index.html");
-}
-
-TEST_F(ContentHandlerTest, MultipleContentEntryTizenPrioritizedAsFirst) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content1->SetString(kTizenContentSrcKey,
- "http://www.tizen.app/tizen_index.html");
- content1->SetString(kNamespaceKey, kTizenNamespacePrefix);
- content2->SetString(kTizenContentSrcKey, "my_index.html");
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), true);
- ASSERT_EQ(content_info->src(), "http://www.tizen.app/tizen_index.html");
-}
-
-TEST_F(ContentHandlerTest, MultipleContentEntryTizenPrioritizedAsSecond) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content1->SetString(kTizenContentSrcKey, "my_index.html");
- content2->SetString(kTizenContentSrcKey,
- "http://www.tizen.app/tizen_index.html");
- content2->SetString(kNamespaceKey, kTizenNamespacePrefix);
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), true);
- ASSERT_EQ(content_info->src(), "http://www.tizen.app/tizen_index.html");
-}
-
-TEST_F(ContentHandlerTest, MultipleContentEntryW3CIgnoreIfNotFirst) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content2->SetString(kTizenContentSrcKey, "w3c_2_index.html");
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check empty
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_FALSE(!!content_info);
-}
-
-TEST_F(ContentHandlerTest, MultipleContentEntryW3CIgnoreIfFirstEmpty) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content1->SetString(kTizenContentSrcKey, "");
- content2->SetString(kTizenContentSrcKey, "w3c_2_index.html");
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check empty
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_FALSE(!!content_info);
-}
-
-TEST_F(ContentHandlerTest, MultipleContentBackToW3CWhenTizenEntryBroken) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- content1->SetString(kNamespaceKey, kTizenNamespacePrefix);
- content2->SetString(kTizenContentSrcKey, "w3c_1_index.html");
- list->Append(content1.release());
- list->Append(content2.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check w3c when tizen:content broken
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), false);
- ASSERT_EQ(content_info->src(), "w3c_1_index.html");
-}
-
-TEST_F(ContentHandlerTest, MultipleMoreContentEntry) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> content1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content2(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content3(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content4(new DictionaryValue());
- content1->SetString(kTizenContentSrcKey, "w3c_1_index.html");
- content2->SetString(kTizenContentSrcKey, "w3c_2_index.html");
- content3->SetString(kTizenContentSrcKey,
- "http://www.tizen.app/tizen_3_index.html");
- content3->SetString(kNamespaceKey, kTizenNamespacePrefix);
- content4->SetString(kTizenContentSrcKey,
- "http://www.tizen.app/tizen_4_index.html");
- content4->SetString(kNamespaceKey, kTizenNamespacePrefix);
- list->Append(content1.release());
- list->Append(content2.release());
- list->Append(content3.release());
- list->Append(content4.release());
- widget->Set(kTizenContentTagKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- std::shared_ptr<const wgt::parse::ContentInfo> content_info =
- std::dynamic_pointer_cast<const wgt::parse::ContentInfo>(
- GetManifestData(kTizenContentKey));
- ASSERT_TRUE(!!content_info);
- ASSERT_EQ(content_info->is_tizen_content(), true);
- ASSERT_EQ(content_info->src(), "http://www.tizen.app/tizen_3_index.html");
-}
-
-} // namespace parser
+++ /dev/null
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Copyright (c) 2015 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 <boost/filesystem/fstream.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <gtest/gtest.h>
-
-#include "manifest_parser/manifest.h"
-#include "manifest_parser/manifest_util.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace bf = boost::filesystem;
-
-namespace parser {
-
-class ManifestUtilTest : public testing::Test {
-};
-
-TEST_F(ManifestUtilTest, LoadApplicationWithValidPath) {
- boost::filesystem::path install_dir("/usr/share/manifest-parser-ut");
- ASSERT_TRUE(&install_dir);
- install_dir /= "test_samples";
- install_dir /= "good_manifest.xml";
-
- std::string error;
- std::shared_ptr<Manifest> manifest(
- LoadManifest(install_dir.string(), &error));
- ASSERT_TRUE(error.empty());
- EXPECT_TRUE(manifest.get());
-
- std::string app_id;
- manifest->GetString("widget.application.@id", &app_id);
- EXPECT_STREQ("nNBDOItqjN.WebSettingSample", app_id.c_str());
-}
-
-TEST_F(ManifestUtilTest,
- LoadApplicationGivesHelpfullErrorOnMissingManifest) {
- boost::filesystem::path install_dir("/usr/share/manifest-parser-ut");
- ASSERT_TRUE(&install_dir);
- install_dir /= "test_samples";
- install_dir /= "bad_manifest.xml";
- std::string error;
- std::shared_ptr<Manifest> manifest(
- LoadManifest(install_dir.string(), &error));
- ASSERT_FALSE(error.empty());
- ASSERT_STREQ("Manifest file is missing or unreadable.", error.c_str());
- EXPECT_FALSE(manifest.get());
-}
-
-// Tests IsPropSupportDir method
-TEST_F(ManifestUtilTest, IsPropSupportDirTest) {
- xmlChar kWidgetNodeKey[] = "widget";
- xmlChar kNameNodeKey[] = "name";
- xmlChar kVersionAttributeKey[] = "version";
- xmlChar kShortAttributeKey[] = "short";
- xmlNode node, sec_node;
- node.name = kWidgetNodeKey;
- sec_node.name = kNameNodeKey;
- xmlAttr attr, sec_attr;
- attr.name = kVersionAttributeKey;
- sec_attr.name = kShortAttributeKey;
- ASSERT_TRUE(IsPropSupportDir(&node, &attr));
- ASSERT_TRUE(IsPropSupportDir(&sec_node, &sec_attr));
- ASSERT_TRUE(!IsPropSupportDir(&node, &sec_attr));
- ASSERT_TRUE(!IsPropSupportDir(&sec_node, &attr));
- ASSERT_TRUE(!IsPropSupportDir(&node, &sec_attr));
-}
-
-// Tests IsElementSupportSpanAndDir method
-TEST_F(ManifestUtilTest, IsElementSupportSpanAndDirTest) {
- std::map <const char*, bool> nodeNames = {
- { "name", true },
- { "description", true },
- { "author", true },
- { "license", true },
- { "badlicense", false }
- };
- xmlNode node;
- for (const auto& p : nodeNames) {
- node.name = reinterpret_cast<xmlChar*>(const_cast<char*>(p.first));
- EXPECT_TRUE(IsElementSupportSpanAndDir(&node) == p.second);
- }
-}
-
-// Tests IsTrimRequiredForElement
-TEST_F(ManifestUtilTest, IsTrimRequiredForElementTest) {
- std::map<const char*, bool> elements {
- { "name", true },
- { "author", true },
- { "badname", false },
- { "badauthor", false }
- };
- xmlNode node;
- for (const auto& p : elements) {
- node.name = reinterpret_cast<xmlChar*>(const_cast<char*>(p.first));
- EXPECT_TRUE(IsTrimRequiredForElement(&node) == p.second);
- }
-}
-
-// Tests IsTrimRequiredForProp method
-TEST_F(ManifestUtilTest, IsTrimRequiredForPropTest) {
- struct node{
- bool operator <(const node& rhs) const {
- return node_name_ < rhs.node_name_;
- }
- const char* node_name_;
- const char* attr_name_;
- };
-
- std::map<node, bool> nodes = {
- { {"widget", "id"}, true },
- { {"widget", "version"}, true },
- { {"widget", "defaultlocale"}, true },
- { {"name", "short"}, true },
- { {"author", "email"}, true },
- { {"author", "href"}, true },
- { {"license", "href"}, true },
- { {"icon", "path"}, true },
- { {"widget", "email"}, false },
- { {"name", "path"}, false },
- { {"author", "id"}, false }
- };
-
- xmlNode node;
- xmlAttr attr;
- for (const auto& p : nodes) {
- node.name =
- reinterpret_cast<xmlChar*>(const_cast<char*>(p.first.node_name_));
- attr.name =
- reinterpret_cast<xmlChar*>(const_cast<char*>(p.first.attr_name_));
- EXPECT_TRUE(IsTrimRequiredForProp(&node, &attr) == p.second);
- }
-}
-
-// Tests GetNodeDir method with proper values
-TEST_F(ManifestUtilTest, GetNodeDirTestProperValues) {
- const char* xml = "<widget dir=\"rtl\">"
- "<name>ppa emoS</name>"
- "</widget>";
- xmlDoc* doc = xmlParseMemory(xml, strlen(xml));
- ASSERT_TRUE(doc);
- xmlNode* root = doc->children;
- ASSERT_TRUE(root);
- std::string inherit_dir("ltr");
- EXPECT_STREQ("rtl", GetNodeDir(root, inherit_dir).c_str());
-}
-
-// Tests GetNodeDir method with default dir
-TEST_F(ManifestUtilTest, GetNodeDirTestDefaultValues) {
- const char* xml = "<widget>"
- "<name>Some app</name>"
- "</widget>";
- xmlDoc* doc = xmlParseMemory(xml, strlen(xml));
- ASSERT_TRUE(doc);
- xmlNode* root = doc->children;
- ASSERT_TRUE(root);
- std::string inherit_dir("ltr");
- EXPECT_STREQ("ltr", GetNodeDir(root, inherit_dir).c_str());
-}
-
-// Tests GetNodeText method with rtl text direction
-TEST_F(ManifestUtilTest, GetNodeTextTestXmlElementNode) {
- const char* xml = "<widget dir=\"rtl\">"
- "<name>ppa emoS</name>"
- "</widget>";
- std::map<int, char> control_chars = {
- { 0, '\xe2' }, { 1, '\x80' }, { 2, '\xab' },
- { 14, '\xe2' }, { 15, '\x80' }, { 16, '\xac' },
- };
- xmlDoc* doc = xmlParseMemory(xml, strlen(xml));
- ASSERT_TRUE(doc);
- xmlNode* root = doc->children;
- ASSERT_TRUE(root);
- std::string inherit_dir("ltr");
- std::string s = GetNodeText(root, inherit_dir);
- for (const auto& p : control_chars)
- EXPECT_EQ(p.second, s[p.first]);
-}
-
-// Tests GetNodeText method with rtl and ltr text direction
-TEST_F(ManifestUtilTest, GetNodeTextTestTwoXmlElementNodes) {
- const char* xml = "<widget dir=\"rtl\">"
- "<name>ppa emoS</name>"
- "<description dir=\"ltr\">Desc</description>"
- "</widget>";
- std::map<int, char> control_chars = {
- { 0, '\xe2' }, { 1, '\x80' }, { 2, '\xab' },
- { 14, '\xe2' }, { 15, '\x80' }, { 16, '\xac' },
- { 17, '\xe2' }, { 18, '\x80' }, { 19, '\xaa' },
- { 24, '\xe2' }, { 25, '\x80' }, { 26, '\xac' }
- };
- xmlDoc* doc = xmlParseMemory(xml, strlen(xml));
- ASSERT_TRUE(doc);
- xmlNode* root = doc->children;
- ASSERT_TRUE(root);
- std::string inherit_dir("ltr");
- std::string s = GetNodeText(root, inherit_dir);
- for (const auto& p : control_chars)
- EXPECT_EQ(p.second, s[p.first]);
-}
-
-// Tests LoadXMLNode method with proper xml tree
-TEST_F(ManifestUtilTest, LoadXMLNodeTestProperXMLTree) {
- const char* xml = "<root>"
- "<widget dir=\"ltr\">"
- "<name short=\"SA\">Some app</name>"
- "<description>Desc</description>"
- "<author dir=\"rtl\">enoemoS</author>"
- "</widget>"
- "</root>";
- std::map<std::string, std::string> expected_vals = {
- { "widget.@dir", "ltr" },
- { "widget.name.@short",
- std::string("\xE2\x80\xAA") + "SA" + "\xE2\x80\xAC" },
- { "widget.name.#text",
- std::string("\xE2\x80\xAA") + "Some app" + "\xE2\x80\xAC" },
- { "widget.description.#text",
- std::string("\xE2\x80\xAA") + "Desc" + "\xE2\x80\xAC" },
- { "widget.author.@dir", "rtl" },
- { "widget.author.#text",
- std::string("\xE2\x80\xAB") + "enoemoS" + "\xE2\x80\xAC" }
- };
-
- xmlDoc* doc = xmlParseMemory(xml, strlen(xml));
- ASSERT_TRUE(doc);
- xmlNode* root = doc->children;
- std::unique_ptr<DictionaryValue> val = LoadXMLNode(root);
-
- std::string test_str;
- for (const auto& p : expected_vals) {
- ASSERT_TRUE(val->GetString(p.first, &test_str));
- EXPECT_STREQ(p.second.c_str(), test_str.c_str());
- }
-}
-
-} // namespace parser
+++ /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.
-
-#include <boost/filesystem/path.hpp>
-
-#include <gtest/gtest.h>
-
-#include <initializer_list>
-#include <vector>
-
-#include "manifest_parser/manifest.h"
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/manifest_parser_impl.h"
-#include "manifest_parser/manifest_parser.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-#include "wgt_manifest_handlers/service_handler.h"
-
-namespace bf = boost::filesystem;
-
-namespace {
-const char kWidgetKey[] = "widget";
-const char kTizenServiceKey[] = "widget.service";
-const char kTizenServiceContentKey[] = "content";
-const char kTizenServiceContentSrcKey[] = "@src";
-const char kTizenServiceIdKey[] = "@id";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kTizenServiceOnBootKey[] = "@on-boot";
-const char kTizenServiceNameKey[] = "name";
-const char kTizenServiceCategoryNameKey[] = "@name";
-const char kTizenServiceCategoryKey[] = "category";
-const char kTizenServiceIconKey[] = "icon";
-const char kNamespaceKey[] = "@namespace";
-const char kServiceKey[] = "service";
-const char kTizenServiceAutoRestartKey[] = "@auto-restart";
-const char kTizenServiceIconSrcKey[] = "@src";
-const char kTizenServiceDescriptionKey[] = "description";
-const char kTizenServiceMetadataKeyKey[] = "@key";
-const char kTizenServiceMetadataValueKey[] = "@value";
-const char kTizenServiceMetadataKey[] = "metadata";
-const char kXmlLangKey[] = "@lang";
-const char kXmlTextKey[] = "#text";
-std::unique_ptr<parser::ManifestHandlerRegistry> GetRegistryForTest() {
- std::unique_ptr<parser::ManifestHandlerRegistry> registry;
- registry.reset(new parser::ManifestHandlerRegistry());
- registry->RegisterManifestHandler(new wgt::parse::ServiceHandler());
- return registry;
-}
-
-} // namespace
-
-namespace parser {
-
-class ServiceHandlerTest : public testing::Test {
- public:
- void SetUp() override {
- parser_.reset(new ManifestParserImpl((GetRegistryForTest())));
- }
- void TearDown() override { parser_.reset(); }
- void SetManifest(std::shared_ptr<Manifest> manifest) {
- parser_->manifest_ = manifest;
- }
- bool ParseAppManifest() {
- std::string error;
- return parser_->ParseAppManifest(&error);
- }
- bool ValidateAppManifest() {
- std::string error;
- return parser_->ValidateAppManifest(&error);
- }
- std::shared_ptr<const ManifestData> GetManifestData(const std::string& key) {
- return parser_->GetManifestData(key);
- }
-
- private:
- std::unique_ptr<ManifestParserImpl> parser_;
-};
-
-TEST_F(ServiceHandlerTest, NoServiceEntry) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryDefault) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].categories().size(), 0);
- ASSERT_EQ(service_list->services[0].metadata_set().size(), 0);
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryOnBootOn) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(::kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct002.appId");
- service->SetString(kTizenServiceOnBootKey, "true");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct002.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), true);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryAutoRestartOn) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct003.appId");
- service->SetString(kTizenServiceOnBootKey, "false");
- service->SetString(kTizenServiceAutoRestartKey, "true");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct003.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), true);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryWrongId) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "wrongid.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_FALSE(ValidateAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryIdTypeMismatch) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetInteger(kTizenServiceIdKey, 1410);
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryNameMissing) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- service->Set(kTizenServiceContentKey, content.release());
- service->SetInteger(kTizenServiceIdKey, 1410);
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryIdSingleNameNotInTizen) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->SetInteger(kTizenServiceIdKey, 1410);
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleNames) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
-
- std::unique_ptr<ListValue> name_list(new ListValue());
- for (auto& pair : {std::make_pair(std::string(), "first"),
- std::make_pair(std::string("en"), "second"),
- std::make_pair(std::string("de"), "third")}) {
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- if (!pair.first.empty()) name->SetString(kXmlLangKey, pair.first);
- name->SetString(kXmlTextKey, pair.second);
- name_list->Append(name.release());
- }
- service->Set(kTizenServiceNameKey, name_list.release());
-
- service->Set(kTizenServiceContentKey, content.release());
- service->SetString(kTizenServiceIdKey, "correct003.appId");
- service->SetString(kTizenServiceOnBootKey, "false");
- service->SetString(kTizenServiceAutoRestartKey, "true");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct003.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), true);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 3);
- ASSERT_EQ(service_list->services[0].names()[0].first, "");
- ASSERT_EQ(service_list->services[0].names()[0].second, "first");
- ASSERT_EQ(service_list->services[0].names()[1].first, "en");
- ASSERT_EQ(service_list->services[0].names()[1].second, "second");
- ASSERT_EQ(service_list->services[0].names()[2].first, "de");
- ASSERT_EQ(service_list->services[0].names()[2].second, "third");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryIdSingleContentNotInTizen) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceNameKey, name.release());
- service->SetInteger(kTizenServiceIdKey, 1410);
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryContentMissing) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceNameKey, name.release());
- service->SetInteger(kTizenServiceIdKey, 1410);
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleContents) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
-
- std::unique_ptr<ListValue> content_list(new ListValue());
- for (auto& start_file : {"content1.js", "content2.js"}) {
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, start_file);
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- content_list->Append(content.release());
- }
- service->Set(kTizenServiceContentKey, content_list.release());
-
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceNameKey, name.release());
- service->SetInteger(kTizenServiceIdKey, 1410);
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleIcon) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> icon(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- icon->SetString(kNamespaceKey, kTizenNamespacePrefix);
- icon->SetString(kTizenServiceIconSrcKey, "my_icon.png");
- service->Set(kTizenServiceIconKey, icon.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].icon(), "my_icon.png");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleIconNotInTizen) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> icon(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- icon->SetString(kTizenServiceIconSrcKey, "my_icon.png");
- service->Set(kTizenServiceIconKey, icon.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].icon(), "");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleIcon) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
-
- std::unique_ptr<ListValue> icon_list(new ListValue());
- for (auto& icon_value : {"icon1.png", "icon2.png"}) {
- std::unique_ptr<DictionaryValue> icon(new DictionaryValue());
- icon->SetString(kNamespaceKey, kTizenNamespacePrefix);
- icon->SetString(kTizenServiceIconSrcKey, icon_value);
- icon_list->Append(icon.release());
- }
-
- service->Set(kTizenServiceIconKey, icon_list.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleDescription) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> description(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- description->SetString(kNamespaceKey, kTizenNamespacePrefix);
- description->SetString(kXmlTextKey, "my description");
- service->Set(kTizenServiceDescriptionKey, description.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].description(), "my description");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleDescriptionNotInTizen) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> description(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- description->SetString(kXmlTextKey, "my description");
- service->Set(kTizenServiceDescriptionKey, description.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].description(), "");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleDescription) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
-
- std::unique_ptr<ListValue> description_list(new ListValue());
- for (auto& desc_value : {"1", "2"}) {
- std::unique_ptr<DictionaryValue> description(new DictionaryValue());
- description->SetString(kNamespaceKey, kTizenNamespacePrefix);
- description->SetString(kXmlTextKey, desc_value);
- description_list->Append(description.release());
- }
- service->Set(kTizenServiceDescriptionKey, description_list.release());
-
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_FALSE(ParseAppManifest());
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleMetadata) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> metadata(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- metadata->SetString(kNamespaceKey, kTizenNamespacePrefix);
- metadata->SetString(kTizenServiceMetadataKeyKey, "unique key");
- metadata->SetString(kTizenServiceMetadataValueKey, "some value");
- service->Set(kTizenServiceMetadataKey, metadata.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].metadata_set().size(), 1);
- ASSERT_EQ(service_list->services[0].metadata_set()[0].first, "unique key");
- ASSERT_EQ(service_list->services[0].metadata_set()[0].second, "some value");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleMetadataNotInTizen) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> metadata(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- metadata->SetString(kTizenServiceMetadataKeyKey, "unique key");
- metadata->SetString(kTizenServiceMetadataValueKey, "some value");
- service->Set(kTizenServiceMetadataKey, metadata.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].metadata_set().size(), 0);
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleMetadata) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
-
- std::unique_ptr<ListValue> metadata_list(new ListValue());
- std::unique_ptr<DictionaryValue> metadata(new DictionaryValue());
- metadata->SetString(kNamespaceKey, kTizenNamespacePrefix);
- metadata->SetString(kTizenServiceMetadataKeyKey, "unique key");
- metadata->SetString(kTizenServiceMetadataValueKey, "some value");
- metadata_list->Append(metadata.release());
- std::unique_ptr<DictionaryValue> metadata2(new DictionaryValue());
- metadata2->SetString(kNamespaceKey, kTizenNamespacePrefix);
- metadata2->SetString(kTizenServiceMetadataKeyKey, "unique key 2");
- metadata_list->Append(metadata2.release());
- service->Set(kTizenServiceMetadataKey, metadata_list.release());
-
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].metadata_set().size(), 2);
- ASSERT_EQ(service_list->services[0].metadata_set()[0].first, "unique key");
- ASSERT_EQ(service_list->services[0].metadata_set()[0].second, "some value");
- ASSERT_EQ(service_list->services[0].metadata_set()[1].first, "unique key 2");
- ASSERT_EQ(service_list->services[0].metadata_set()[1].second, "");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleMetadataMixedNamespaces) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
-
- std::unique_ptr<ListValue> metadata_list(new ListValue());
-
- std::unique_ptr<DictionaryValue> metadata(new DictionaryValue());
- metadata->SetString(kNamespaceKey, kTizenNamespacePrefix);
- metadata->SetString(kTizenServiceMetadataKeyKey, "unique key");
- metadata->SetString(kTizenServiceMetadataValueKey, "some value");
- metadata_list->Append(metadata.release());
-
- std::unique_ptr<DictionaryValue> metadata2(new DictionaryValue());
- metadata2->SetString(kNamespaceKey, kTizenNamespacePrefix);
- metadata2->SetString(kTizenServiceMetadataKeyKey, "unique key 2");
- metadata_list->Append(metadata2.release());
-
- std::unique_ptr<DictionaryValue> metadata3(new DictionaryValue());
- metadata3->SetString(kTizenServiceMetadataKeyKey, "unique key 3");
- metadata_list->Append(metadata3.release());
-
- service->Set(kTizenServiceMetadataKey, metadata_list.release());
-
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].metadata_set().size(), 2);
- ASSERT_EQ(service_list->services[0].metadata_set()[0].first, "unique key");
- ASSERT_EQ(service_list->services[0].metadata_set()[0].second, "some value");
- ASSERT_EQ(service_list->services[0].metadata_set()[1].first, "unique key 2");
- ASSERT_EQ(service_list->services[0].metadata_set()[1].second, "");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleCategory) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> category(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- category->SetString(kNamespaceKey, kTizenNamespacePrefix);
- category->SetString(kTizenServiceCategoryNameKey, "category name");
- service->Set(kTizenServiceCategoryKey, category.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].categories().size(), 1);
- ASSERT_EQ(service_list->services[0].categories()[0], "category name");
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntrySingleCategoryNotInTizen) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- std::unique_ptr<DictionaryValue> category(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- category->SetString(kTizenServiceCategoryNameKey, "category name");
- service->Set(kTizenServiceCategoryKey, category.release());
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].categories().size(), 0);
-}
-
-TEST_F(ServiceHandlerTest, SingleServiceEntryMultipleCategory) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service(new DictionaryValue());
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
-
- std::unique_ptr<ListValue> catogory_list(new ListValue());
- for (auto& name : {"category name 1", "category name 2", "category name 3"}) {
- std::unique_ptr<DictionaryValue> category(new DictionaryValue());
- category->SetString(kNamespaceKey, kTizenNamespacePrefix);
- category->SetString(kTizenServiceCategoryNameKey, name);
- catogory_list->Append(category.release());
- }
- service->Set(kTizenServiceCategoryKey, catogory_list.release());
-
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- service->SetString(kTizenServiceIdKey, "correct001.appId");
- service->SetString(kNamespaceKey, kTizenNamespacePrefix);
- widget->Set(kServiceKey, service.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(kTizenServiceKey));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 1);
- ASSERT_EQ(service_list->services[0].id(), "correct001.appId");
- ASSERT_EQ(service_list->services[0].auto_restart(), false);
- ASSERT_EQ(service_list->services[0].on_boot(), false);
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[0].categories().size(), 3);
- ASSERT_EQ(service_list->services[0].categories()[0], "category name 1");
- ASSERT_EQ(service_list->services[0].categories()[1], "category name 2");
- ASSERT_EQ(service_list->services[0].categories()[2], "category name 3");
-}
-
-TEST_F(ServiceHandlerTest, MultipleServiceEntry) {
- // Set test values
- std::unique_ptr<DictionaryValue> value(new DictionaryValue());
- std::unique_ptr<DictionaryValue> widget(new DictionaryValue());
- std::unique_ptr<ListValue> list(new ListValue());
- std::unique_ptr<DictionaryValue> service1(new DictionaryValue());
- std::unique_ptr<DictionaryValue> service2(new DictionaryValue());
- service1->SetString(kTizenServiceIdKey, "correct004.appId");
- service1->SetString(kNamespaceKey, kTizenNamespacePrefix);
- service2->SetString(kTizenServiceIdKey, "correct005.appId");
- service2->SetString(kNamespaceKey, kTizenNamespacePrefix);
- for (auto& service : {service1.get(), service2.get()}) {
- std::unique_ptr<DictionaryValue> content(new DictionaryValue());
- std::unique_ptr<DictionaryValue> name(new DictionaryValue());
- content->SetString(kTizenServiceContentSrcKey, "service.js");
- content->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kNamespaceKey, kTizenNamespacePrefix);
- name->SetString(kXmlTextKey, "name");
- service->Set(kTizenServiceContentKey, content.release());
- service->Set(kTizenServiceNameKey, name.release());
- }
- list->Append(service1.release());
- list->Append(service2.release());
- widget->Set(kServiceKey, list.release());
- value->Set(kWidgetKey, widget.release());
- std::shared_ptr<Manifest> manifest(new Manifest(std::move(value)));
- SetManifest(manifest);
- // Check correctness
- ASSERT_TRUE(ParseAppManifest());
- ASSERT_TRUE(ValidateAppManifest());
- ASSERT_TRUE(!!GetManifestData(kTizenServiceKey));
- std::shared_ptr<const wgt::parse::ServiceList> service_list =
- std::dynamic_pointer_cast<const wgt::parse::ServiceList>(
- GetManifestData(wgt::parse::ServiceInfo::Key()));
- ASSERT_TRUE(!!service_list);
- ASSERT_EQ(service_list->services.size(), 2);
- ASSERT_EQ(service_list->services[0].id(), "correct004.appId");
- ASSERT_EQ(service_list->services[1].id(), "correct005.appId");
- ASSERT_EQ(service_list->services[0].content(), "service.js");
- ASSERT_EQ(service_list->services[0].names().size(), 1);
- ASSERT_EQ(service_list->services[0].names()[0].second, "name");
- ASSERT_EQ(service_list->services[1].content(), "service.js");
- ASSERT_EQ(service_list->services[1].names().size(), 1);
- ASSERT_EQ(service_list->services[1].names()[0].second, "name");
-}
-
-} // namespace parser
+++ /dev/null
-# Target - sources
-SET(SRCS
- account_handler.cc
- app_control_handler.cc
- application_manifest_constants.cc
- application_icons_handler.cc
- appwidget_handler.cc
- background_category_handler.cc
- category_handler.cc
- content_handler.cc
- csp_handler.cc
- ime_handler.cc
- metadata_handler.cc
- navigation_handler.cc
- permissions_handler.cc
- platform_version.cc
- setting_handler.cc
- service_handler.cc
- splash_screen_handler.cc
- tizen_application_handler.cc
- warp_handler.cc
- widget_config_parser.cc
- widget_handler.cc
-)
-
-# Target - definition
-ADD_LIBRARY(${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} SHARED ${SRCS})
-# Target - includes
-TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} PUBLIC
- "${CMAKE_CURRENT_SOURCE_DIR}/../")
-APPLY_PKG_CONFIG(${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} PUBLIC
- XGDMIME_DEPS
-)
-
-# Extra
-SET_TARGET_PROPERTIES(${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} PROPERTIES VERSION ${VERSION})
-SET_TARGET_PROPERTIES(${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} PROPERTIES SOVERSION ${VERSION_MAJOR})
-
-# Install
-INSTALL(TARGETS ${TARGET_LIBNAME_WGT_MANIFEST_HANDLERS} DESTINATION ${LIB_INSTALL_DIR})
-
-# Install includes
-INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDEDIR}
- FILES_MATCHING PATTERN "*.h")
-
-# Configure and install pkgconfig file
-SET(PKG_FILE wgt-manifest-handlers.pc)
-CONFIGURE_FILE(${PKG_FILE}.in ${PKG_FILE} @ONLY)
-INSTALL(FILES ${PKG_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+++ /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.
-
-#include "wgt_manifest_handlers/account_handler.h"
-
-#include "manifest_parser/utils/language_tag_validator.h"
-#include "manifest_parser/utils/logging.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kAccountKey[] = "widget.account";
-
-const char kSectionIconAccount[] = "Account";
-const char kSectionIconAccountSmall[] = "AccountSmall";
-const char kTrueValueString[] = "true";
-const char kFalseValueString[] = "false";
-const char kAccountMASKey[] = "@multiple-account-support";
-const char kAccountSectionKey[] = "@section";
-const char kAccountTextKey[] = "#text";
-const char kAccountNameKey[] = "display-name";
-const char kAccountLangKey[] = "@lang";
-const char kAccountIconKey[] = "icon";
-const char kAccountCapabilityKey[] = "capability";
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-bool AccountHandler::Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kAccountKey))
- return true;
-
- auto info = std::make_shared<AccountInfo>();
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kAccountKey, kTizenNamespacePrefix)) {
- if (!ParseSingleAccountElement(dict, info, error))
- return false;
- }
-
- *output = std::static_pointer_cast<AccountInfo>(info);
- return true;
-}
-
-std::string AccountHandler::Key() const {
- return kAccountKey;
-}
-
-std::string AccountInfo::Key() {
- return kAccountKey;
-}
-
-bool AccountHandler::ParseSingleAccountElement(
- const parser::DictionaryValue* item_dict,
- std::shared_ptr<AccountInfo> info,
- std::string* error) {
- std::string multiple_apps_support;
- SingleAccountInfo single_account;
- if (!item_dict->GetString(kAccountMASKey, &multiple_apps_support)) {
- *error = "Error while parsing multiple apps support in account";
- return false;
- }
- bool mas_bool = false;
- if (multiple_apps_support == kFalseValueString) {
- mas_bool = false;
- } else if (multiple_apps_support == kTrueValueString) {
- mas_bool = true;
- } else {
- *error = "Multiple apps support in account has invalid (not boolean) value";
- return false;
- }
- single_account.multiple_account_support = mas_bool;
- if (!ParseAccountNames(item_dict, &single_account)) {
- *error = "Error while parsing account names";
- return false;
- }
- if (!ParseAccountIcons(item_dict, &single_account)) {
- *error = "Error while parsing account icons";
- return false;
- }
- if (!ParseCapabilities(item_dict, &single_account)) {
- *error = "Error while parsing account capabilities";
- return false;
- }
- info->set_account(single_account);
- return true;
-}
-
-bool AccountHandler::ParseAccountIcons(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- if (item_dict->Get(kAccountIconKey, &val)) {
- if (val->GetAsDictionary(&dict)) {
- if (!ParseSingleAccountIcon(dict, info))
- return false;
- } else if (val->GetAsList(&list)) {
- for (auto& item : *list)
- if (item->GetAsDictionary(&dict) &&
- !ParseSingleAccountIcon(dict, info))
- return false;
- }
- return true;
- }
- return false;
-}
-
-bool AccountHandler::ParseSingleAccountIcon(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- std::string section;
- item_dict->GetString(kAccountSectionKey, §ion);
- if (section.compare(kSectionIconAccount) != 0 &&
- section.compare(kSectionIconAccountSmall) != 0)
- return false;
- std::string icon_path;
- item_dict->GetString(kAccountTextKey, &icon_path);
- info->icon_paths.push_back(std::make_pair(section, icon_path));
- return true;
-}
-
-bool AccountHandler::ParseAccountNames(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- if (item_dict->Get(kAccountNameKey, &val)) {
- if (val->GetAsDictionary(&dict)) {
- if (!ParseSingleAccountName(dict, info))
- return false;
- } else if (val->GetAsList(&list)) {
- for (auto& item : *list)
- if (item->GetAsDictionary(&dict) &&
- !ParseSingleAccountName(dict, info))
- return false;
- }
- return true;
- }
- return false;
-}
-
-bool AccountHandler::ParseSingleAccountName(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- std::string lang;
- if (item_dict->GetString(kAccountLangKey, &lang) &&
- !utils::w3c_languages::ValidateLanguageTag(lang)) {
- return false;
- }
- std::string name;
- item_dict->GetString(kAccountTextKey, &name);
- info->names.push_back(std::make_pair(name, lang));
- return true;
-}
-
-
-bool AccountHandler::ParseCapabilities(
- const parser::DictionaryValue* item_dict,
- SingleAccountInfo* info) {
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- if (item_dict->Get(kAccountCapabilityKey, &val)) {
- std::string capability;
- if (val->GetAsDictionary(&dict)) {
- dict->GetString(kAccountTextKey, &capability);
- info->capabilities.push_back(capability);
- } else if (val->GetAsList(&list)) {
- for (auto& item : *list)
- if (item->GetAsDictionary(&dict)) {
- dict->GetString(kAccountTextKey, &capability);
- info->capabilities.push_back(capability);
- }
- }
- }
- return true;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /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_MANIFEST_HANDLERS_ACCOUNT_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_ACCOUNT_HANDLER_H_
-
-#include <utility>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-struct SingleAccountInfo {
- bool multiple_account_support;
- std::vector<std::pair<std::string, std::string>> names;
- std::vector<std::pair<std::string, std::string>> icon_paths;
- std::vector<std::string> capabilities;
-};
-
-class AccountInfo : public parser::ManifestData {
- public:
- AccountInfo() {}
- ~AccountInfo() override {}
- static std::string Key();
-
- /**
- * @brief This method returns all the accounts successfully parsed
- */
- const std::vector<SingleAccountInfo>& accounts() const {
- return accounts_;
- }
-
- /**
- * @brief Method add to the vector successfully created account
- */
- void set_account(SingleAccountInfo single_account) {
- accounts_.push_back(std::move(single_account));
- }
-
- private:
- std::vector<SingleAccountInfo> accounts_;
-};
-
-/**
- * @brief The AccountHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:account>.
- */
-class AccountHandler : 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;
-
- private:
- /**
- * @brief ParseSingleAccountElement everything between <account> </account>
- * @param item_dict dictionary to be parsed
- * @param info ptr for entity that stores successfully parsed results
- * @param error information about error that happened
- * @return true if operation of parsing was successful
- */
- bool ParseSingleAccountElement(const parser::DictionaryValue* item_dict,
- std::shared_ptr<AccountInfo> info,
- std::string* error);
- /**
- * @brief ParseAccountIcons icons of account
- * @param item_dict dictionary to be parsed
- * @param singel_account the single account entity
- * @return true parsed successfully
- */
- bool ParseAccountIcons(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- bool ParseSingleAccountIcon(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- /**
- * @brief ParseAccountNames parse and validates account name
- * @param item_dict dictionary to be parsed
- * @param singel_account the single account entity
- * @return true if parsed successfully
- */
- bool ParseAccountNames(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- bool ParseSingleAccountName(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
- /**
- * @brief ParseCapabilities parses capabilities and validates them
- * @param item_dict dictionary to be parsed
- * @param singel_account the single account entity
- * @return true if parsed successfully
- */
- bool ParseCapabilities(const parser::DictionaryValue* item_dict,
- SingleAccountInfo* singel_account);
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_ACCOUNT_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/app_control_handler.h"
-
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-#include "wgt_manifest_handlers/tizen_application_handler.h"
-
-namespace {
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-
-const char kEnabledValue[] = "enable";
-const char kDisabledValue[] = "disable";
-
-const utils::VersionNumber kReloadRequiredVersion("2.4");
-const char kTizenApplicationKey[] = "widget.application";
-const char kTizenApplicationAppControlSrcKey[] = "src";
-const char kTizenApplicationAppControlOperationKey[] = "operation";
-const char kTizenApplicationAppControlUriKey[] = "uri";
-const char kTizenApplicationAppControlMimeKey[] = "mime";
-const char kTizenApplicationAppControlReloadKey[] = "@reload";
-const char kTizenApplicationAppControlChildNameAttrKey[] = "@name";
-const char kTizenApplicationAppControlsKey[] = "widget.app-control";
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-namespace {
-
-void ParseAppControlEntryAndStore(
- const parser::DictionaryValue& control_dict,
- AppControlInfoList* aplist) {
- std::string src;
- std::string reload;
- const parser::DictionaryValue* src_dict;
- if (control_dict.GetDictionary(kTizenApplicationAppControlSrcKey,
- &src_dict)) {
- src_dict->GetString(
- kTizenApplicationAppControlChildNameAttrKey, &src);
- src_dict->GetString(kTizenApplicationAppControlReloadKey, &reload);
- }
-
- std::string operation;
- const parser::DictionaryValue* operation_dict;
- if (control_dict.GetDictionary(
- kTizenApplicationAppControlOperationKey,
- &operation_dict)) {
- operation_dict->GetString(
- kTizenApplicationAppControlChildNameAttrKey, &operation);
- }
-
- std::string uri;
- const parser::DictionaryValue* uri_dict;
- if (control_dict.GetDictionary(kTizenApplicationAppControlUriKey,
- &uri_dict)) {
- uri_dict->GetString(
- kTizenApplicationAppControlChildNameAttrKey, &uri);
- }
-
- std::string mime;
- const parser::DictionaryValue* mime_dict;
- if (control_dict.GetDictionary(kTizenApplicationAppControlMimeKey,
- &mime_dict)) {
- mime_dict->GetString(
- kTizenApplicationAppControlChildNameAttrKey, &mime);
- }
-
- aplist->controls.emplace_back(src, operation, uri, mime, reload);
-}
-
-} // namespace
-
-AppControlHandler::AppControlHandler() {
-}
-
-AppControlHandler::~AppControlHandler() {
-}
-
-bool AppControlHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
-
- if (!manifest.HasPath(kTizenApplicationAppControlsKey))
- return true;
-
- auto aplist = std::make_shared<AppControlInfoList>();
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kTizenApplicationAppControlsKey, kTizenNamespacePrefix)) {
- ParseAppControlEntryAndStore(*dict, aplist.get());
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(aplist);
- return true;
-}
-
-bool AppControlHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const {
- const AppControlInfoList& app_controls =
- static_cast<const AppControlInfoList&>(data);
-
- for (const auto& item : app_controls.controls) {
- if (item.src().empty()) {
- *error = "The src child element of app-control element is obligatory";
- return false;
- }
-
- const std::string& operation = item.operation();
- if (operation.empty()) {
- *error =
- "The operation child element of app-control element is obligatory";
- return false;
- }
-
- if (!parser::utils::IsValidIRI(operation)) {
- *error =
- "The operation child element of app-control element is not valid url";
- return false;
- }
-
- const TizenApplicationInfo& app_info =
- static_cast<const TizenApplicationInfo&>(
- *handlers_output.find(kTizenApplicationKey)->second);
- utils::VersionNumber required_version(app_info.required_version());
- if (!required_version.IsValid()) {
- *error = "Cannot retrieve required API version from widget";
- return false;
- }
-
- if (required_version >= kReloadRequiredVersion) {
- if (item.reload().empty()) {
- // FIXME for now, this const_cast is used, but it is not the best way.
- AppControlInfo &tmp = const_cast<AppControlInfo &>(item);
- tmp.set_reload(kEnabledValue); // default parameter
- } else if (item.reload() != kEnabledValue &&
- item.reload() != kDisabledValue) {
- *error = "The improper value was given for appcontrol reload";
- return false;
- }
- } else if (!item.reload().empty()) {
- *error = "reload attribute cannot be used for api version lower "
- "than 2.4";
- return false;
- }
- }
- return true;
-}
-
-std::vector<std::string> AppControlHandler::PrerequisiteKeys() const {
- return { kTizenApplicationKey };
-}
-
-std::string AppControlInfo::Key() {
- return kTizenApplicationAppControlsKey;
-}
-
-std::string AppControlHandler::Key() const {
- return kTizenApplicationAppControlsKey;
-}
-
-AppControlInfo::AppControlInfo(
- const std::string& src,
- const std::string& operation,
- const std::string& uri,
- const std::string& mime,
- const std::string& reload)
- : src_(src),
- operation_(operation),
- uri_(uri),
- mime_(mime),
- reload_(reload) {}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_APP_CONTROL_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_APP_CONTROL_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest.h"
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-/**
- * @brief The AppControlHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:app-control>.
- */
-class AppControlHandler : public parser::ManifestHandler {
- public:
- AppControlHandler();
- ~AppControlHandler() override;
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
- std::vector<std::string> PrerequisiteKeys() const override;
-};
-
-class AppControlInfo {
- public:
- AppControlInfo(const std::string& src, const std::string& operation,
- const std::string& uri, const std::string& mime,
- const std::string& reload);
-
- static std::string Key();
- /**
- * @brief src return the source attribute
- * @return the value of source attribute
- */
- const std::string& src() const {
- return src_;
- }
- /**
- * @brief
- * @return the value of operation attribute
- */
- const std::string& operation() const {
- return operation_;
- }
- /**
- * @brief uri
- * @return the value of the uri attribute
- */
- const std::string& uri() const {
- return uri_;
- }
- /**
- * @brief mime
- * @return the value of the mime attribute
- */
- const std::string& mime() const {
- return mime_;
- }
- /**
- * @brief reload
- * @return the value of reload attribute
- */
- const std::string& reload() const {
- return reload_;
- }
- void set_reload(std::string rel) {
- reload_ = std::move(rel);
- }
-
- private:
- std::string src_;
- std::string operation_;
- std::string uri_;
- std::string mime_;
- std::string reload_;
-};
-
-struct AppControlInfoList : public parser::ManifestData {
- std::vector<AppControlInfo> controls;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_APP_CONTROL_HANDLER_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_manifest_handlers/application_icons_handler.h"
-
-#include <algorithm>
-#include <string>
-
-#include "manifest_parser/utils/logging.h"
-
-namespace {
-
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kWidgetIconKey[] = "widget.icon";
-const char kWidgetIconSrcKey[] = "@src";
-const char kWidgetIconWidthKey[] = "@width";
-const char kWidgetIconHeightKey[] = "@height";
-const char kIconsKey[] = "icons";
-
-bool ExtractIconSrc(const parser::Value& dict, std::string* value,
- std::string* /*error*/) {
- const parser::DictionaryValue* inner_dict;
- if (!dict.GetAsDictionary(&inner_dict)) {
- LOG(INFO) << "Cannot get key value as a dictionary. Key name: widget.icon";
- return true;
- }
- std::string src;
- if (!inner_dict->GetString(kWidgetIconSrcKey, &src)) {
- LOG(INFO) << "Cannot find mandatory key. Key name: .@src";
- return true;
- }
- *value = src;
- return true;
-}
-
-/**
- * @brief ExtractIconDimensions
- *
- * Parses and sets icon dimensions. If value cannot be received it is set to -1.
- *
- * @param dict dictionary value of icon
- * @param height output parameter of height of icon
- * @param width output parameter of width of icon
- */
-void ExtractIconDimensions(const parser::Value& dict, int* height, int* width) {
- *width = -1;
- *height = -1;
- const parser::DictionaryValue* inner_dict;
- if (!dict.GetAsDictionary(&inner_dict)) {
- return;
- }
-
- std::string width_str;
- if (inner_dict->GetString(kWidgetIconWidthKey, &width_str)) {
- try {
- *width = std::stoi(width_str);
- } catch (const std::logic_error&) {
- // ignore, width is set to -1
- }
- }
-
- std::string height_str;
- if (inner_dict->GetString(kWidgetIconHeightKey, &height_str)) {
- try {
- *height = std::stoi(height_str);
- } catch (const std::logic_error&) {
- // ignore, height is set to -1
- }
- }
-}
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-ApplicationIcon::ApplicationIcon(const std::string& path, int height, int width)
- : path_(path),
- height_((height >= 0) ? height : -1),
- width_((width >= 0) ? width : -1) {
-}
-
-bool ApplicationIcon::GetWidth(int* width) const {
- if (!width || width_ < 0)
- return false;
- *width = width_;
- return true;
-}
-
-bool ApplicationIcon::GetHeight(int* height) const {
- if (!height || height_ < 0)
- return false;
- *height = height_;
- return true;
-}
-
-const std::string& ApplicationIcon::path() const {
- return path_;
-}
-
-std::string ApplicationIconsInfo::Key() {
- return kIconsKey;
-}
-
-
-const std::vector<ApplicationIcon>& ApplicationIconsInfo::icons() const {
- return icons_;
-}
-
-void ApplicationIconsInfo::AddIcon(const ApplicationIcon& new_icon) {
- // Eliminate duplicates, keep order
- if (std::find_if(icons_.begin(), icons_.end(),
- [&new_icon](const ApplicationIcon& icon) {
- return icon.path() == new_icon.path();
- })
- != icons_.end()) {
- return;
- }
- icons_.push_back(new_icon);
-}
-
-ApplicationIconsHandler::ApplicationIconsHandler() {
-}
-
-ApplicationIconsHandler::~ApplicationIconsHandler() {
-}
-
-bool ApplicationIconsHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- std::shared_ptr<ApplicationIconsInfo> app_icons_info =
- std::make_shared<ApplicationIconsInfo>();
-
- if (!manifest.HasPath(kWidgetIconKey)) {
- *output = std::static_pointer_cast<parser::ManifestData>(app_icons_info);
- return true;
- }
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kWidgetIconKey, kWidgetNamespacePrefix)) {
- std::string icon_path;
-
- if (!ExtractIconSrc(*dict, &icon_path, error)) {
- *error = "Cannot get key value as a dictionary. Key name: widget.icon";
- return false;
- }
-
- int width;
- int height;
-
- ExtractIconDimensions(*dict, &height, &width);
- app_icons_info->AddIcon(ApplicationIcon(icon_path, height, width));
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(app_icons_info);
- return true;
-}
-
-bool ApplicationIconsHandler::AlwaysParseForKey() const {
- return true;
-}
-
-std::string ApplicationIconsHandler::Key() const {
- return wgt::application_widget_keys::kIconsKey;
-}
-
-} // namespace parse
-} // 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_MANIFEST_HANDLERS_APPLICATION_ICONS_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_APPLICATION_ICONS_HANDLER_H_
-
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-class ApplicationIcon {
- public:
- explicit ApplicationIcon(const std::string& path, int height = -1,
- int width = -1);
- /**
- * @brief GetWidth
- * @param width
- * @return true if successful
- */
- bool GetWidth(int* width) const;
- /**
- * @brief GetHeight
- * @param height
- * @return true if successful
- */
- bool GetHeight(int* height) const;
- /**
- * @brief path
- * @return string to the path
- */
- const std::string& path() const;
-
- private:
- std::string path_;
- int height_;
- int width_;
-};
-
-class ApplicationIconsInfo : public parser::ManifestData {
- public:
- static std::string Key();
-
- const std::vector<ApplicationIcon>& icons() const;
- /**
- * @brief AddIcon adds icon
- * @param icon_path
- */
- void AddIcon(const ApplicationIcon& icon_path);
- private:
- std::vector<ApplicationIcon> icons_;
-};
-
-/**
- * @brief The ApplicationIconsHandler class
- *
- * Handler of config.xml for xml elements:
- * - <w3c:icon>.
- */
-class ApplicationIconsHandler : public parser::ManifestHandler {
- public:
- ApplicationIconsHandler();
- ~ApplicationIconsHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool AlwaysParseForKey() const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_APPLICATION_ICONS_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-
-// manifest keys for widget applications.
-namespace application_widget_keys {
-
-const char kCSPKey[] = "widget.content-security-policy";
-const char kCSPReportOnlyKey[] = "widget.content-security-policy-report-only";
-const char kIconsKey[] = "icons";
-const char kAccountKey[] = "widget.account";
-const char kDefaultLocaleKey[] = "widget.@defaultlocale";
-const char kViewModesKey[] = "widget.@viewmodes";
-const char kWidgetKey[] = "widget";
-const char kAuthorKey[] = "widget.author";
-const char kDescriptionKey[] = "widget.description";
-const char kShortKey[] = "@short";
-const char kIDKey[] = "widget.@id";
-const char kHeightKey[] = "widget.@height";
-const char kWidthKey[] = "widget.@width";
-const char kPreferencesKey[] = "widget.preference";
-const char kAccessKey[] = "widget.access";
-const char kLicenseKey[] = "widget.license";
-
-const char kTizenWidgetKey[] = "widget";
-// Child keys inside 'kPreferencesKey'.
-const char kPreferencesNameKey[] = "@name";
-
-const char kWidgetLangKey[] = "widget.@lang";
-
-const char kTizenApplicationKey[] = "widget.application";
-const char kTizenAppWidgetFullKey[] = "widget.app-widget";
-// Child keys inside 'kTizenApplicationKey'
-
-const char kTizenApplicationLaunchModeKey[] = "@launch_mode";
-const char kTizenApplicationPackageKey[] = "@package";
-
-const char kAllowNavigationKey[] = "widget.allow-navigation";
-const char kTizenBackgroundCategoryKey[] = "widget.background-category";
-const char kTizenSettingKey[] = "widget.setting";
-const char kTizenInstallLocationKey[] = "@install-location";
-
-const char kTizenNoDisplayKey[] = "@nodisplay";
-const char kTizenIndicatorPresenceKey[] = "@indicator-presence";
-const char kTizenBackbuttonPresenceKey[] = "@backbutton-presence";
-const char kTizenUserAgentKey[] = "@user-agent";
-const char kTizenSoundModeKey[] = "@sound-mode";
-const char kTizenBackgroundVibrationKey[] = "@background-vibration";
-const char kTizenMetaDataKey[] = "widget.metadata";
-const char kTizenSplashScreenKey[] = "widget.splash-screen";
-// Child keys inside 'kTizenMetaDataKey'
-const char kTizenPermissionsKey[] = "widget.privilege";
-
-// App control
-const char kTizenApplicationAppControlsKey[] = "widget.app-control";
-// IME
-const char kTizenImeKey[] = "widget.ime";
-// Content
-const char kTizenContentKey[] = "widget.content";
-// Category
-const char kTizenCategoryKey[] = "widget.category";
-// Service
-const char kTizenServiceKey[] = "widget.service";
-
-// launch_screen
-const char kSplashScreenKey[] = "widget.launch_screen";
-
-} // namespace application_widget_keys
-
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Copyright (c) 2015 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_APPLICATION_MANIFEST_CONSTANTS_H_
-#define WGT_MANIFEST_HANDLERS_APPLICATION_MANIFEST_CONSTANTS_H_
-
-#include "manifest_parser/manifest.h"
-
-// Keys used in JSON representation of applications.
-namespace wgt {
-
-namespace application_widget_keys {
-
-extern const char kAccessKey[];
-extern const char kAccountKey[];
-extern const char kAllowNavigationKey[];
-extern const char kAuthorKey[];
-extern const char kCSPKey[];
-extern const char kCSPReportOnlyKey[];
-extern const char kDescriptionKey[];
-extern const char kIconsKey[];
-extern const char kTizenApplicationAppControlsKey[];
-extern const char kTizenApplicationKey[];
-extern const char kTizenAppWidgetFullKey[];
-extern const char kTizenBackgroundCategoryKey[];
-extern const char kTizenCategoryKey[];
-extern const char kTizenContentKey[];
-extern const char kTizenImeKey[];
-extern const char kTizenMetaDataKey[];
-extern const char kTizenPermissionsKey[];
-extern const char kTizenServiceKey[];
-extern const char kTizenSettingKey[];
-extern const char kTizenSplashScreenKey[];
-extern const char kTizenWidgetKey[];
-extern const char kVersionKey[];
-extern const char kWidgetKey[];
-extern const char kSplashScreenKey[];
-
-} // namespace application_widget_keys
-
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_APPLICATION_MANIFEST_CONSTANTS_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/appwidget_handler.h"
-
-#include <cassert>
-#include <cstdlib>
-#include <limits>
-#include <regex>
-#include <set>
-
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-#include "wgt_manifest_handlers/tizen_application_handler.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-
-const char kTizenAppWidgetFullKey[] = "widget.app-widget";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kNamespaceKey[] = "@namespace";
-const char kTizenWidgetKey[] = "widget";
-const char kTizenAppWidgetKey[] = "app-widget";
-const char kTizenAppWidgetBoxLabelLangKey[] = "@lang";
-const char kTizenAppWidgetBoxIconSrcKey[] = "@src";
-const char kTizenAppWidgetBoxContentSizePreviewKey[] = "@preview";
-const char kTizenAppWidgetBoxContentSizeUseDecorationKey[] = "@use-decoration";
-const char kTizenAppWidgetBoxContentDropViewSrcKey[] = "@src";
-const char kTizenAppWidgetBoxContentDropViewWidthKey[] = "@width";
-const char kTizenAppWidgetBoxContentDropViewHeightKey[] = "@height";
-const char kTizenAppWidgetBoxContentSrcKey[] = "@src";
-const char kTizenAppWidgetBoxContentMouseEventKey[] = "@mouse-event";
-const char kTizenAppWidgetBoxContentTouchEffectKey[] = "@touch-effect";
-const char kTizenAppWidgetBoxContentSizeKey[] = "box-size";
-const char kTizenAppWidgetBoxContentDropViewKey[] = "pd";
-const char kTizenAppWidgetAutoLaunchKey[] = "@auto-launch";
-const char kTizenAppWidgetBoxLabelKey[] = "box-label";
-const char kTizenAppWidgetBoxIconKey[] = "box-icon";
-const char kTizenAppWidgetBoxContentKey[] = "box-content";
-const char kTizenAppWidgetIdKey[] = "@id";
-const char kTizenAppWidgetPrimaryKey[] = "@primary";
-const char kTizenAppWidgetUpdatePeriodKey[] = "@update-period";
-const char kTizenAppWidgetBoxLabelTextKey[] = "#text";
-const char kTizenAppWidgetBoxContentSizeTextKey[] = "#text";
-
-const char kErrMsgInvalidDictionary[] =
- "Cannot get key value as a dictionary. Key name: ";
-const char kErrMsgInvalidList[] = "Cannot get key value as a list. Key name: ";
-const char kErrMsgNoMandatoryKey[] = "Cannot find mandatory key. Key name: ";
-const char kErrMsgInvalidKeyValue[] = "Invalid key value. Key name: ";
-const char kErrMsgMultipleKeys[] = "Too many keys found. Key name: ";
-const char kErrMsgNoNamespace[] =
- "Element pointed by key has no namespace specified. Key name: ";
-const char kErrMsgInvalidNamespace[] =
- "Invalid namespace of element pointed by key. Key name: ";
-const char kErrMsgUpdatePeriodOutOfDomain[] =
- "Value of an update-period attribute in app-widget element out of domain."
- " The value: ";
-const char kErrMsgNoLabel[] =
- "No box-label element in app-widget element.";
-const char kErrMsgInvalidContentSrc[] =
- "Invalid path or url in a src attribute of box-content element."
- " The value: ";
-const char kErrMsgNoMandatoryContentSize1x1[] =
- "No mandatory box-size element (1x1) in box-content element.";
-const char kErrMsgInvalidContentDropViewSrc[] =
- "Invalid path or url in a src attribute of pd element. The value: ";
-const char kErrMsgContentDropViewHeightOutOfDomain[] =
- "Value of a height attribute in box-content element out of domain."
- " The value: ";
-
-const std::regex kStringRegex("[.][0-9a-zA-Z]+");
-
-// If the error parameter is specified, it is filled with the given message
-// otherwise it does nothing.
-void SetError(const std::string& message, std::string* error) {
- if (error) *error = message;
-}
-
-// If the error parameter is specified, it is filled with concatenation
-// of message and arg parameters otherwise it does nothing.
-void SetError(const std::string& message, const std::string& arg,
- std::string* error) {
- if (error) *error = message + arg;
-}
-
-// Converts given text value to a value of specific type. Returns true
-// if convertion is successful or false otherwise.
-template <typename ValueType>
-bool ConvertValue(const std::string& /*str_value*/, ValueType* /*value*/) {
- assert(false &&
- "Use one of already defined template specializations"
- " or define a new one.");
- return false;
-}
-
-// Converts given text value to a string value. Returns true
-// if convertion is successful or false otherwise.
-template <>
-bool ConvertValue(const std::string& str_value, std::string* value) {
- assert(value);
- *value = str_value;
- return true;
-}
-
-// Converts given text value to a boolean value. Returns true
-// if convertion is successful or false otherwise.
-template <>
-bool ConvertValue(const std::string& str_value, bool* value) {
- assert(value);
- if (str_value == "true") {
- *value = true;
- return true;
- }
- if (str_value == "false") {
- *value = false;
- return true;
- }
- return false;
-}
-
-// Converts given text value to an integer value. Returns true
-// if convertion is successful or false otherwise.
-template <>
-bool ConvertValue(const std::string& str_value, int* value) {
- assert(value);
- char* end = nullptr;
- *value = strtol(str_value.c_str(), &end, 10);
- return end == &*str_value.end();
-}
-
-// Converts given text value to a floating point value. Returns true
-// if convertion is successful or false otherwise.
-template <>
-bool ConvertValue(const std::string& str_value, double* value) {
- assert(value);
- char* end = nullptr;
- *value = strtod(str_value.c_str(), &end);
- return end == &*str_value.end();
-}
-
-// Retrieves a mandatory value from specified dictionary and specified key.
-// Returns true, if the value is found or false otherwise. If the error
-// parameter is specified, it is also filled with proper message.
-template <typename ValueType>
-bool GetMandatoryValue(const parser::DictionaryValue& dict,
- const std::string& key, ValueType* value,
- std::string* error) {
- assert(value);
- std::string tmp;
- if (!dict.GetString(key, &tmp)) {
- SetError(kErrMsgNoMandatoryKey, key, error);
- return false;
- }
- bool result = ConvertValue(tmp, value);
- if (!result) SetError(kErrMsgInvalidKeyValue, key, error);
- return result;
-}
-
-// Retrieves an optional value from specified dictionary and specified key.
-// If the value is found, the function returns true and fills value
-// parameter. If the value is not found, the function returns true and fills
-// value parameter with default value. If an error occurs, it returns false
-// and fills error parameter if it is set.
-template <typename ValueType>
-bool GetOptionalValue(const parser::DictionaryValue& dict,
- const std::string& key, ValueType default_value,
- ValueType* value, std::string* error) {
- assert(value);
- std::string tmp;
- if (!dict.GetString(key, &tmp)) {
- *value = default_value;
- return true;
- }
- bool result = ConvertValue(tmp, value);
- if (!result) SetError(kErrMsgInvalidKeyValue, key, error);
- return result;
-}
-
-// Verifies whether specified dictionary represents an element in specified
-// namespace. Returns true, if the namespace is set and equal to the specified
-// one or false otherwise. If the error parameter is specified, it is also
-// filled with proper message.
-bool VerifyElementNamespace(const parser::DictionaryValue& dict,
- const std::string& key,
- const std::string& desired_namespace_value,
- std::string* error) {
- std::string namespace_value;
- if (!GetMandatoryValue(dict, kNamespaceKey, &namespace_value, nullptr)) {
- SetError(kErrMsgNoNamespace, key, error);
- return false;
- }
- if (namespace_value != desired_namespace_value) {
- SetError(kErrMsgInvalidNamespace, key, error);
- return false;
- }
- return true;
-}
-
-// Parses box-label part
-bool ParseLabel(const parser::DictionaryValue& dict, const std::string& key,
- AppWidget* app_widget, std::string* error) {
- assert(app_widget);
-
- if (!VerifyElementNamespace(dict, key, kTizenNamespacePrefix, error))
- return false;
-
- std::string lang;
- if (!GetOptionalValue(dict, kTizenAppWidgetBoxLabelLangKey, std::string(),
- &lang, error))
- return false;
-
- std::string text;
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxLabelTextKey, &text, error))
- return false;
-
- if (lang.empty()) {
- // Note: Tizen 2.2 WRT Core Spec does not determine how many times the value
- // without lang attribute can appear in one app-widget, so overwrite.
- app_widget->label.default_value = text;
- } else {
- // Note: Tizen 2.2 WRT Core Spec does not determine how many times the value
- // with specific lang attribute can appear in one app-widget, so overwrite.
- app_widget->label.lang_value_map[lang] = text;
- }
-
- return true;
-}
-
-// Parses box-icon part
-bool ParseIcon(const parser::DictionaryValue& dict, const std::string& key,
- AppWidget* app_widget, std::string* error) {
- assert(app_widget);
-
- if (!VerifyElementNamespace(dict, key, kTizenNamespacePrefix, error))
- return false;
-
- if (!app_widget->icon_src.empty()) {
- SetError(kErrMsgMultipleKeys, key, error);
- return false;
- }
-
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxIconSrcKey,
- &app_widget->icon_src, error))
- return false;
-
- return true;
-}
-
-// Converts size type from text to enum representation
-bool StringToSizeType(const std::string& str_type,
- AppWidgetSizeType* enum_type) {
- assert(enum_type);
- if (str_type == "1x1") {
- *enum_type = AppWidgetSizeType::k1x1;
- return true;
- }
- if (str_type == "2x1") {
- *enum_type = AppWidgetSizeType::k2x1;
- return true;
- }
- if (str_type == "2x2") {
- *enum_type = AppWidgetSizeType::k2x2;
- return true;
- }
- return false;
-}
-
-// Parses box-size part
-bool ParseContentSizes(const parser::DictionaryValue& dict,
- const std::string& key, AppWidget* app_widget,
- std::string* error) {
- assert(app_widget);
-
- if (!VerifyElementNamespace(dict, key, kTizenNamespacePrefix, error))
- return false;
-
- AppWidgetSize size;
-
- std::string str_type;
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxContentSizeTextKey, &str_type,
- error))
- return false;
-
- AppWidgetSizeType type;
- if (!StringToSizeType(str_type, &type)) {
- SetError(kErrMsgInvalidKeyValue, kTizenAppWidgetBoxContentSizeTextKey,
- error);
- return false;
- }
- size.type = type;
-
- if (!GetOptionalValue(dict, kTizenAppWidgetBoxContentSizePreviewKey,
- std::string(), &size.preview, error))
- return false;
-
- if (!GetOptionalValue(dict, kTizenAppWidgetBoxContentSizeUseDecorationKey,
- true, &size.use_decoration, error))
- return false;
-
- app_widget->content_size.push_back(size);
-
- return true;
-}
-
-// Parses pd part
-bool ParseContentDropView(const parser::DictionaryValue& dict,
- const std::string& key, AppWidget* app_widget,
- std::string* error) {
- assert(app_widget);
-
- if (!VerifyElementNamespace(dict, key, kTizenNamespacePrefix, error))
- return false;
-
- if (!app_widget->content_drop_view.empty()) {
- SetError(kErrMsgMultipleKeys, key, error);
- return false;
- }
-
- AppWidgetDropView drop_view;
-
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxContentDropViewSrcKey,
- &drop_view.src, error))
- return false;
-
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxContentDropViewWidthKey,
- &drop_view.width, error))
- return false;
-
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxContentDropViewHeightKey,
- &drop_view.height, error))
- return false;
-
- app_widget->content_drop_view.push_back(drop_view);
-
- return true;
-}
-
-// Parses box-content part
-bool ParseContent(const parser::DictionaryValue& dict, const std::string& key,
- AppWidget* app_widget, std::string* error) {
- assert(app_widget);
-
- if (!VerifyElementNamespace(dict, key, kTizenNamespacePrefix, error))
- return false;
-
- if (!app_widget->content_src.empty()) {
- SetError(kErrMsgMultipleKeys, key, error);
- return false;
- }
- if (!GetMandatoryValue(dict, kTizenAppWidgetBoxContentSrcKey,
- &app_widget->content_src, error))
- return false;
-
- if (!GetOptionalValue(dict, kTizenAppWidgetBoxContentMouseEventKey, false,
- &app_widget->content_mouse_event, error))
- return false;
-
- if (!GetOptionalValue(dict, kTizenAppWidgetBoxContentTouchEffectKey, true,
- &app_widget->content_touch_effect, error))
- return false;
-
- if (!dict.HasKey(kTizenAppWidgetBoxContentSizeKey))
- return false;
-
- for (const auto& dict_cs : parser::GetOneOrMany(&dict,
- kTizenAppWidgetBoxContentSizeKey, "")) {
- if (!ParseContentSizes(*dict_cs, kTizenAppWidgetBoxContentSizeKey,
- app_widget, error))
- return false;
- }
-
- for (const auto& dict_dv : parser::GetOneOrMany(&dict,
- kTizenAppWidgetBoxContentDropViewKey, "")) {
- if (!ParseContentDropView(*dict_dv,
- kTizenAppWidgetBoxContentDropViewKey, app_widget, error))
- return false;
- }
-
- return true;
-}
-
-// Parses app-widget part
-bool ParseAppWidget(const parser::DictionaryValue& dict, const std::string& key,
- AppWidgetVector* app_widgets, std::string* error) {
- assert(app_widgets);
-
- if (!VerifyElementNamespace(dict, key, kTizenNamespacePrefix, error))
- return false;
-
- AppWidget app_widget;
-
- if (!GetMandatoryValue(dict, kTizenAppWidgetIdKey, &app_widget.id, error))
- return false;
-
- if (!GetMandatoryValue(dict, kTizenAppWidgetPrimaryKey, &app_widget.primary,
- error))
- return false;
-
- double update_period;
- double no_update_period = std::numeric_limits<double>::min();
- if (!GetOptionalValue(dict, kTizenAppWidgetUpdatePeriodKey, no_update_period,
- &update_period, error))
- return false;
- if (update_period != no_update_period)
- app_widget.update_period.push_back(update_period);
-
- if (!GetOptionalValue(dict, kTizenAppWidgetAutoLaunchKey, false,
- &app_widget.auto_launch, error))
- return false;
-
- if (!dict.HasKey(kTizenAppWidgetBoxLabelKey))
- return false;
-
- for (const auto& dict_l : parser::GetOneOrMany(&dict,
- kTizenAppWidgetBoxLabelKey, kTizenNamespacePrefix)) {
- if (!ParseLabel(*dict_l, kTizenAppWidgetBoxLabelKey,
- &app_widget, error))
- return false;
- }
-
- for (const auto& dict_i : parser::GetOneOrMany(&dict,
- kTizenAppWidgetBoxIconKey, kTizenNamespacePrefix)) {
- if (!ParseIcon(*dict_i, kTizenAppWidgetBoxIconKey,
- &app_widget, error))
- return false;
- }
-
- if (!dict.HasKey(kTizenAppWidgetBoxContentKey))
- return false;
-
- for (const auto& dict_c : parser::GetOneOrMany(&dict,
- kTizenAppWidgetBoxContentKey, kTizenNamespacePrefix)) {
- if (!ParseContent(*dict_c, kTizenAppWidgetBoxContentKey,
- &app_widget, error))
- return false;
- }
-
- app_widgets->push_back(app_widget);
-
- return true;
-}
-
-// Validates all content sizes in an app-widget
-bool ValidateContentSize(const AppWidgetSizeVector& content_size,
- std::string* error) {
- bool mandatory_1x1_found = false;
-
- for (const AppWidgetSize& size : content_size) {
- mandatory_1x1_found |= size.type == AppWidgetSizeType::k1x1;
- }
-
- if (!mandatory_1x1_found) {
- SetError(kErrMsgNoMandatoryContentSize1x1, error);
- return false;
- }
-
- return true;
-}
-
-} // namespace
-
-AppWidgetInfo::AppWidgetInfo(const AppWidgetVector& app_widgets)
- : app_widgets_(app_widgets) {}
-
-AppWidgetInfo::~AppWidgetInfo() {}
-
-AppWidgetHandler::AppWidgetHandler() {}
-
-AppWidgetHandler::~AppWidgetHandler() {}
-
-
-bool AppWidgetHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kTizenAppWidgetFullKey))
- return false;
-
- AppWidgetVector app_widgets;
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kTizenAppWidgetFullKey, kTizenNamespacePrefix)) {
- if (!ParseAppWidget(*dict, kTizenAppWidgetKey, &app_widgets, error))
- return false;
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(
- std::make_shared<AppWidgetInfo>(app_widgets));
- return true;
-}
-
-bool AppWidgetHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const AppWidgetInfo& app_widget_info =
- static_cast<const AppWidgetInfo&>(data);
- const AppWidgetVector& app_widgets = app_widget_info.app_widgets();
-
- for (const AppWidget& app_widget : app_widgets) {
- if (!app_widget.update_period.empty() &&
- app_widget.update_period.front() < 1800) {
- SetError(kErrMsgUpdatePeriodOutOfDomain,
- std::to_string(app_widget.update_period.front()), error);
- return false;
- }
-
- if (app_widget.label.default_value.empty() &&
- app_widget.label.lang_value_map.empty()) {
- SetError(kErrMsgNoLabel, error);
- return false;
- }
-
- if (!ValidateContentSize(app_widget.content_size, error))
- return false;
-
- if (!app_widget.content_drop_view.empty()) {
- const AppWidgetDropView& drop_view = app_widget.content_drop_view.front();
-
- if (drop_view.height < 1 || drop_view.height > 380) {
- SetError(kErrMsgContentDropViewHeightOutOfDomain,
- std::to_string(drop_view.height), error);
- return false;
- }
- }
- }
-
- return true;
-}
-
-std::string AppWidgetHandler::Key() const {
- return kTizenAppWidgetFullKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_APPWIDGET_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_APPWIDGET_HANDLER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-typedef std::map<std::string, std::string> AppWidgetLabelLangValueMap;
-
-struct AppWidgetLabel {
- // may be empty
- std::string default_value;
-
- // may be empty if default is set
- AppWidgetLabelLangValueMap lang_value_map;
-};
-
-enum AppWidgetSizeType {
- k1x1, k2x1, k2x2
-};
-
-struct AppWidgetSize {
- // mandatory
- AppWidgetSizeType type;
-
- // optional, relative to web app directory
- std::string preview;
-
- // optional, default: true
- bool use_decoration;
-};
-
-typedef std::vector<AppWidgetSize> AppWidgetSizeVector;
-
-struct AppWidgetDropView {
- // mandatory, relative to web app directory or remote URL
- std::string src;
-
- // mandatory
- int width;
-
- // mandatory, <1, 380>
- int height;
-};
-
-typedef std::vector<AppWidgetDropView> AppWidgetDropViewVector;
-
-struct AppWidget {
- // mandatory, unique, must start with application id and end with label
- // separated with dot, the label can contain only 0-9, a-z, A-Z
- std::string id;
-
- // mandatory, if 2 or more app widgets have the primary attribute set to true,
- // the default icon and title of the parent web app can be used
- bool primary;
-
- // optional(0-1), min: 1800.0, default: no update
- std::vector<double> update_period;
-
- // optional, default: false
- bool auto_launch;
-
- // box label, multiple(1+)
- AppWidgetLabel label;
-
- // box icon, optional(0-1), src, mandatory, relative to web app directory
- std::string icon_src;
-
- // box content, mandatory(1) -[
-
- // mandatory, relative to web app directory or remote URL
- std::string content_src;
-
- // optional, default: false
- bool content_mouse_event;
-
- // optional, default: true
- bool content_touch_effect;
-
- // box size, mandatory(1-3), 1x1 must exist
- AppWidgetSizeVector content_size;
-
- // drop view, optional(0-1)
- AppWidgetDropViewVector content_drop_view;
-
- // ]- box content
-};
-
-typedef std::vector<AppWidget> AppWidgetVector;
-
-class AppWidgetInfo : public parser::ManifestData {
- public:
- explicit AppWidgetInfo(const AppWidgetVector& app_widgets);
- virtual ~AppWidgetInfo();
-
- const AppWidgetVector& app_widgets() const {
- return app_widgets_;
- }
-
- private:
- // multiple(0+)
- AppWidgetVector app_widgets_;
-};
-
-/**
- * @brief The AppWidgetHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:app-widget>.
- */
-class AppWidgetHandler : public parser::ManifestHandler {
- public:
- AppWidgetHandler();
- virtual ~AppWidgetHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_APPWIDGET_HANDLER_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-xwalk file.
-
-#include "wgt_manifest_handlers/background_category_handler.h"
-
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kTizenBackgroundCategoryValueKey[] = "@value";
-const char kErrMsgElementParse[] = "Parsing background-category element failed";
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-namespace keys = wgt::application_widget_keys;
-
-bool BackgroundCategoryHandler::ParseBackgroundCategoryElement(
- const parser::DictionaryValue& element_dict,
- BackgroundCategoryInfoList* bclist) {
- std::string value;
-
- if (!element_dict.GetString(kTizenBackgroundCategoryValueKey, &value))
- return false;
-
- bclist->background_categories.emplace_back(value);
-
- return true;
-}
-
-bool BackgroundCategoryHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(keys::kTizenBackgroundCategoryKey))
- return true;
-
- std::shared_ptr<BackgroundCategoryInfoList> bclist(
- new BackgroundCategoryInfoList());
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- keys::kTizenBackgroundCategoryKey, kTizenNamespacePrefix)) {
- if (!ParseBackgroundCategoryElement(*dict, bclist.get())) {
- *error = kErrMsgElementParse;
- return false;
- }
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(bclist);
- return true;
-}
-
-std::string BackgroundCategoryHandler::Key() const {
- return keys::kTizenBackgroundCategoryKey;
-}
-
-BackgroundCategoryInfo::BackgroundCategoryInfo(const std::string& value) :
- value_(value) {}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2015 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_BACKGROUND_CATEGORY_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_BACKGROUND_CATEGORY_HANDLER_H_
-
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-/**
- * \brief Holds details about background-category element
- *
- * Purpose of this class is to hold information declared in background-category
- * element in manifest xml document
- */
-class BackgroundCategoryInfo : public parser::ManifestData {
- public:
- explicit BackgroundCategoryInfo(const std::string& value);
- virtual ~BackgroundCategoryInfo() {}
-
- const std::string& value() const { return value_; }
-
- private:
- std::string value_;
-};
-
-/**
- * \brief Container for detailed information of each declaration of
- * background-category element
- */
-struct BackgroundCategoryInfoList : public parser::ManifestData {
- std::vector<BackgroundCategoryInfo> background_categories;
-};
-
-/**
- * \brief The BackgroundCategoryHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:background-category>.
- */
-class BackgroundCategoryHandler : 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;
-
- private:
- bool ParseBackgroundCategoryElement(
- const parser::DictionaryValue& element_dict,
- BackgroundCategoryInfoList* bclist);
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_BACKGROUND_CATEGORY_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/category_handler.h"
-
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kTizenCategoryNameKey[] = "@name";
-const char kErrMsgCategory[] = "Parsing category element failed";
-const char kTizenCategoryKey[] = "widget.category";
-const char kErrMsgCategoryName[] =
- "The name element inside category element is obligatory";
-
-bool ParseCategoryEntryAndStore(const parser::DictionaryValue& control_dict,
- CategoryInfoList* aplist) {
- std::string name;
- if (!control_dict.GetString(kTizenCategoryNameKey, &name)) return false;
- aplist->categories.push_back(name);
- return true;
-}
-
-} // namespace
-
-CategoryHandler::CategoryHandler() {}
-
-CategoryHandler::~CategoryHandler() {}
-
-
-bool CategoryHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- if (!manifest.HasPath(kTizenCategoryKey))
- return true;
-
- auto aplist = std::make_shared<CategoryInfoList>();
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kTizenCategoryKey, kTizenNamespacePrefix)) {
- if (!ParseCategoryEntryAndStore(*dict, aplist.get()))
- return false;
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(aplist);
- return true;
-}
-
-bool CategoryHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const CategoryInfoList& categories_list =
- static_cast<const CategoryInfoList&>(data);
-
- for (const auto& item : categories_list.categories) {
- if (item.empty()) {
- *error = kErrMsgCategoryName;
- return false;
- }
- }
- return true;
-}
-
-std::string CategoryHandler::Key() const {
- return kTizenCategoryKey;
-}
-
-
-std::string CategoryInfoList::Key() {
- return kTizenCategoryKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_CATEGORY_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_CATEGORY_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-struct CategoryInfoList : public parser::ManifestData {
- static std::string Key();
- std::vector<std::string> categories;
-};
-
-/**
- * @brief The CategoryHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:category>.
- */
-class CategoryHandler : public parser::ManifestHandler {
- public:
- CategoryHandler();
- virtual ~CategoryHandler();
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_CATEGORY_HANDLER_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-xwalk file.
-
-#include "wgt_manifest_handlers/content_handler.h"
-
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/trim.hpp>
-
-#include <map>
-#include <set>
-
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/utils/string_util.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace ba = boost::algorithm;
-
-namespace {
-
-const char kNamespaceKey[] = "@namespace";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kTizenContentEncodingKey[] = "@encoding";
-const char kTizenContentTypeKey[] = "@type";
-const char kTizenContentKey[] = "widget.content";
-const char kMimeMainComponent[] = "";
-const char kMimeCharsetComponent[] = "charset";
-const char kDefaultMimeType[] = "text/html";
-const char kDefaultEncoding[] = "UTF-8";
-const char kTizenContentSrcKey[] = "@src";
-
-const std::set<std::string> ValidMimeTypeStartFile = {
- "text/html", "application/xhtml+xml", "image/svg+xml"};
-
-std::map<std::string, std::string> ParseMimeComponents(
- const std::string& type) {
- std::map<std::string, std::string> mime_components;
- std::vector<std::string> components;
-
- ba::split(components, type, ba::is_any_of(";"));
- for (auto& component : components) {
- auto split = component.find("=");
- std::string key;
- std::string value;
- if (split != std::string::npos) {
- key = component.substr(0, split);
- value = component.substr(split + 1);
- } else {
- key = kMimeMainComponent;
- value = component;
- }
- ba::trim(key);
- ba::trim(value);
- mime_components.insert(std::make_pair(key, value));
- }
- return mime_components;
-}
-
-bool ValidateMimeTypeStartFile(const std::string& type) {
- return ValidMimeTypeStartFile.find(parser::utils::CollapseWhitespaceUTF8(
- type)) != ValidMimeTypeStartFile.end();
-}
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-ContentHandler::ContentHandler()
- : w3c_content_found_(false), tizen_content_found_(false) {}
-
-ContentHandler::~ContentHandler() {}
-
-/**
- * @brief ParseAndSetContentValue
- *
- * This function should return parse result and set output parameter content
- * to valid content if returning OK
- *
- * @param dict input dictionary for content element
- * @param content content element to be set if valid one found
- * @param error parser error to be set if parsing failed with error
- * @return enum value describing result of parsing
- */
-ContentHandler::ParseResult ContentHandler::ParseAndSetContentValue(
- const parser::DictionaryValue& dict,
- std::shared_ptr<wgt::parse::ContentInfo>* content, std::string* error) {
- std::string element_namespace;
- dict.GetString(kNamespaceKey, &element_namespace);
-
- if (element_namespace == kTizenNamespacePrefix) {
- if (tizen_content_found_) {
- // tizen:content already found
- return ParseResult::IGNORE;
- }
- tizen_content_found_ = true;
- } else {
- if (w3c_content_found_) {
- // ignore all content element that are not first
- return ParseResult::IGNORE;
- }
- w3c_content_found_ = true;
- }
-
- std::string src;
- if (!dict.GetString(kTizenContentSrcKey, &src)) {
- return ParseResult::IGNORE;
- }
-
- // error if empty
- if (src.empty()) {
- // ignore this element
- return ParseResult::IGNORE;
- }
-
- std::string type = kDefaultMimeType;
- dict.GetString(kTizenContentTypeKey, &type);
- // TODO(t.iwanek): this will fail for "quoted-string"
- // use/implement proper mime parsing...
- std::map<std::string, std::string> mime_components =
- ParseMimeComponents(type);
-
- auto mime_iter = mime_components.find(kMimeMainComponent);
- if (mime_iter != mime_components.end()) {
- if (!ValidateMimeTypeStartFile(mime_iter->second)) {
- *error = "Not proper type of starting file";
- return ParseResult::IGNORE;
- }
- }
-
- std::string encoding = kDefaultEncoding;
- if (!dict.GetString(kTizenContentEncodingKey, &encoding)) {
- auto charset_iter = mime_components.find(kMimeCharsetComponent);
- if (charset_iter != mime_components.end()) {
- encoding = charset_iter->second;
- }
- }
- ba::trim(encoding);
-
- if (*content && (*content)->is_tizen_content()) {
- // Prefer tizen:content if both are correct
- return ParseResult::IGNORE;
- }
-
- content->reset(new wgt::parse::ContentInfo());
- (*content)->set_src(src);
- (*content)->set_type(type);
- (*content)->set_encoding(encoding);
- (*content)->set_is_tizen_content(element_namespace == kTizenNamespacePrefix);
- return ParseResult::OK;
-}
-
-bool ContentHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kTizenContentKey))
- return true;
-
- std::shared_ptr<ContentInfo> content_info;
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kTizenContentKey, "")) {
- if (ParseAndSetContentValue(*dict, &content_info, error)
- == ParseResult::ERROR) {
- return false;
- }
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(content_info);
-
- return true;
-}
-
-std::string ContentHandler::Key() const {
- return kTizenContentKey;
-}
-
-std::string ContentInfo::Key() {
- return kTizenContentKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /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-xwalk file.
-
-#ifndef WGT_MANIFEST_HANDLERS_CONTENT_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_CONTENT_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-class ContentInfo : public parser::ManifestData {
- public:
- ContentInfo()
- : is_tizen_content_(false) { }
-
- virtual ~ContentInfo() { }
-
- static std::string Key();
-
- const std::string& src() const {
- return src_;
- }
- const std::string& type() const {
- return type_;
- }
- const std::string& encoding() const {
- return encoding_;
- }
- /**
- * @brief set_src sets source
- * @param src
- */
- void set_src(std::string src) { src_ = std::move(src); }
- /**
- * @brief set_type sets type
- * @param type
- */
- void set_type(std::string type) { type_ = std::move(type); }
- /**
- * @brief set_encoding sets encoding
- * @param encoding
- */
- void set_encoding(std::string encoding) { encoding_ = std::move(encoding); }
- /**
- * @brief is_tizen_content
- * @return if is tizen content
- */
- bool is_tizen_content() const {
- return is_tizen_content_;
- }
- /**
- * @brief set_is_tizen_content
- * @param is_tizen_content
- */
- void set_is_tizen_content(bool is_tizen_content) {
- is_tizen_content_ = is_tizen_content;
- }
-
- private:
- std::string src_;
- std::string type_;
- std::string encoding_;
- bool is_tizen_content_;
-};
-
-/**
- * @brief The ContentHandler class
- *
- * Handler of config.xml for xml elements:
- * - <w3c:content>,
- * - <tizen:content>.
- */
-class ContentHandler : public parser::ManifestHandler {
- public:
- enum class ParseResult {
- OK,
- IGNORE,
- ERROR,
- };
-
- ContentHandler();
- virtual ~ContentHandler();
-
- ParseResult ParseAndSetContentValue(
- const parser::DictionaryValue& dict,
- std::shared_ptr<wgt::parse::ContentInfo>* content,
- std::string* error);
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- std::string Key() const override;
-
- private:
- bool w3c_content_found_;
- bool tizen_content_found_;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_CONTENT_HANDLER_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-xwalk file.
-
-#include "wgt_manifest_handlers/csp_handler.h"
-
-#include <string.h>
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kXmlTextKey[] = "#text";
-const char kCSPKey[] = "widget.content-security-policy";
-const char kCSPReportOnlyKey[] = "widget.content-security-policy-report-only";
-}
-
-namespace wgt {
-namespace parse {
-
-std::string CSPInfo::Key() {
- return kCSPKey;
-}
-
-std::string CSPInfo::Report_only_key() {
- return kCSPReportOnlyKey;
-}
-
-bool CSPHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- std::string security_key = (security_type_ == SecurityType::CSP) ?
- kCSPKey : kCSPReportOnlyKey;
-
- if (!manifest.HasPath(security_key))
- return true;
-
- std::shared_ptr<CSPInfo> info(new CSPInfo);
-
- const auto& dict = parser::GetOneOrMany(manifest.value()
- , security_key, kTizenNamespacePrefix);
- std::string security_rules;
-
- if (dict.front()->GetString(kXmlTextKey, &security_rules)) {
- info->set_security_rules(security_rules);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(info);
-
- return true;
-}
-
-std::string CSPHandler::Key() const {
- return security_type_ == SecurityType::CSP ? kCSPKey
- : kCSPReportOnlyKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /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-xwalk file.
-
-#ifndef WGT_MANIFEST_HANDLERS_CSP_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_CSP_HANDLER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "manifest_parser/values.h"
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-class CSPInfo : public parser::ManifestData {
- public:
- CSPInfo() {}
- ~CSPInfo() override {}
-
- static std::string Key();
- static std::string Report_only_key();
- /**
- * @brief set_security_rules sets up string with security rules
- * @param security_rules
- */
- void set_security_rules(std::string security_rules) {
- security_rules_ = std::move(security_rules);
- }
- /**
- * @brief security_rules
- * @return string with security_rules
- */
- const std::string security_rules() const {
- return security_rules_;
- }
-
- private:
- std::string security_rules_;
-};
-
-/**
- * @brief The CSPHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:content-security-policy>,
- * - <tizen:content-security-policy-report-only>.
- */
-class CSPHandler : public parser::ManifestHandler {
- public:
- enum class SecurityType {
- CSP,
- CSP_REPORT_ONLY
- };
- explicit CSPHandler(SecurityType securityType)
- : security_type_(securityType) {}
- ~CSPHandler() override {}
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- std::string Key() const override;
- private:
- SecurityType security_type_;
-};
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_CSP_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/ime_handler.h"
-
-#include <cassert>
-#include <memory>
-#include <regex>
-
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kTizenImeUuidKey[] = "uuid";
-const char kTizenImeUuidTextKey[] = "#text";
-const char kTizenImeLanguagesKey[] = "languages";
-const char kTizenImeLanguageKey[] = "language";
-const char kTizenImeLanguageTextKey[] = "#text";
-const char kTizenImeKey[] = "widget.ime";
-
-const char kErrMsgLanguages[] =
- "At least and only ONE tizen:languages tag should be specified";
-const char kErrMsgEmptyLanguage[] = "Language cannot be empty";
-const char kErrMsgParsingIme[] = "Only one ime tag should be specified";
-const char kErrMsgParsingUuid[] = "Only one uuid tag should be specified";
-const char kErrMsgValidatingUuidEmpty[] =
- "The UUID of ime element is obligatory";
-const char kErrMsgUuidFormat[] = "Uuid should be in proper format (8-4-4-4-12)";
-const char kErrMsgNoLanguages[] =
- "At least one language of ime element should be specified";
-
-const std::regex kUuidRegex(
- "^[0-9a-zA-Z]{8}([-][0-9a-zA-Z]{4}){3}[-][0-9a-zA-Z]{12}$");
-
-bool GetLanguage(const parser::Value* item, ImeInfo* ime_info,
- std::string* error) {
- const parser::DictionaryValue* language_dict;
- if (item->GetAsDictionary(&language_dict)) {
- std::string language;
- if (!language_dict->GetString(kTizenImeLanguageTextKey, &language) ||
- language.empty()) {
- *error = kErrMsgEmptyLanguage;
- return false;
- }
- ime_info->AddLanguage(language);
- }
- return true;
-}
-
-bool ParseImeEntryAndStore(const parser::DictionaryValue& control_dict,
- ImeInfo* ime_info, std::string* error) {
- // parsing uuid element
- const parser::DictionaryValue* uuid_dict;
- std::string uuid;
- if (control_dict.GetDictionary(kTizenImeUuidKey, &uuid_dict) &&
- uuid_dict->GetString(kTizenImeUuidTextKey, &uuid)) {
- ime_info->set_uuid(uuid);
- } else {
- *error = kErrMsgParsingUuid;
- return false;
- }
-
- const parser::DictionaryValue* languages_dict;
- if (!control_dict.GetDictionary(kTizenImeLanguagesKey, &languages_dict)) {
- *error = kErrMsgLanguages;
- return false;
- }
-
- const parser::Value* languages;
- if (!languages_dict->Get(kTizenImeLanguageKey, &languages)) {
- *error = kErrMsgNoLanguages;
- return false;
- }
-
- if (languages->GetType() == parser::Value::TYPE_LIST) {
- // many languages
- const parser::ListValue* list;
- languages->GetAsList(&list);
- for (const auto& item : *list) {
- if (!GetLanguage(item, ime_info, error)) return false;
- }
- } else if (languages->GetType() == parser::Value::TYPE_DICTIONARY) {
- if (!GetLanguage(languages, ime_info, error)) return false;
- }
-
- return true;
-}
-
-// UUID is string of 36 characters in form 8-4-4-4-12
-bool IsValidUuid(const std::string& uuid) {
- return std::regex_match(uuid, kUuidRegex);
-}
-
-} // namespace
-
-ImeInfo::ImeInfo() {}
-
-ImeInfo::~ImeInfo() {}
-
-ImeHandler::ImeHandler() {}
-
-ImeHandler::~ImeHandler() {}
-
-void ImeInfo::AddLanguage(const std::string& language) {
- languages_.push_back(language);
-}
-
-
-bool ImeHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kTizenImeKey))
- return true;
-
- auto ime_info = std::make_shared<ImeInfo>();
-
- const auto dict = parser::GetOneOrMany(manifest.value(),
- kTizenImeKey, kTizenNamespacePrefix).front();
-
- if (!ParseImeEntryAndStore(*dict, ime_info.get(), error)) {
- return false;
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(ime_info);
-
- return true;
-}
-
-bool ImeHandler::Validate(const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const ImeInfo& ime_info = static_cast<const ImeInfo&>(data);
-
- if (!ime_info.exists()) return true;
-
- if (ime_info.uuid().empty()) {
- *error = kErrMsgValidatingUuidEmpty;
- return false;
- }
-
- if (!IsValidUuid(ime_info.uuid())) {
- *error = kErrMsgUuidFormat;
- return false;
- }
-
- if (ime_info.languages().empty()) {
- *error = kErrMsgNoLanguages;
- return false;
- }
-
- return true;
-}
-
-std::string ImeHandler::Key() const { return kTizenImeKey; }
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_IME_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_IME_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-class ImeInfo : public parser::ManifestData {
- public:
- ImeInfo();
- virtual ~ImeInfo();
- /**
- * @brief uuid
- * @return uuid string
- */
- const std::string& uuid() const {
- return uuid_;
- }
- /**
- * @brief set_uuid sets uuid string
- * @param uuid
- */
- void set_uuid(std::string uuid) { uuid_ = std::move(uuid); }
- const std::vector<std::string>& languages() const {
- return languages_;
- }
- /**
- * @brief AddLanguage adds language
- * @param language
- */
- void AddLanguage(const std::string& language);
-
- private:
- std::string uuid_;
- std::vector<std::string> languages_;
-};
-
-/**
- * @brief The ImeHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:ime>.
- */
-class ImeHandler : public parser::ManifestHandler {
- public:
- ImeHandler();
- virtual ~ImeHandler();
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& application,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_IME_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/metadata_handler.h"
-
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-typedef std::pair<std::string, std::string> MetaDataPair;
-typedef std::map<std::string, std::string> MetaDataMap;
-typedef std::map<std::string, std::string>::const_iterator MetaDataIter;
-
-namespace {
-
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kTizenMetaDataNameKey[] = "@key";
-const char kTizenMetaDataValueKey[] = "@value";
-const char kTizenMetaDataKey[] = "widget.metadata";
-
-MetaDataPair ParseMetaDataItem(const parser::DictionaryValue* dict,
- std::string* error) {
- assert(dict && dict->IsType(parser::Value::TYPE_DICTIONARY));
- MetaDataPair result;
- if (!dict->GetString(kTizenMetaDataNameKey, &result.first)) {
- *error = "Invalid key of tizen metaData.";
- } else {
- if (!dict->GetString(kTizenMetaDataValueKey, &result.second)) {
- result.second = "";
- }
- }
-
- return result;
-}
-
-} // namespace
-
-MetaDataInfo::MetaDataInfo() {}
-
-MetaDataInfo::~MetaDataInfo() {}
-
-bool MetaDataInfo::HasKey(const std::string& key) const {
- return metadata_.find(key) != metadata_.end();
-}
-
-std::string MetaDataInfo::GetValue(const std::string& key) const {
- MetaDataIter it = metadata_.find(key);
- if (it != metadata_.end()) return it->second;
- return std::string("");
-}
-
-void MetaDataInfo::SetValue(const std::string& key, const std::string& value) {
- metadata_.insert(MetaDataPair(key, value));
-}
-
-MetaDataHandler::MetaDataHandler() {}
-
-MetaDataHandler::~MetaDataHandler() {}
-
-
-bool MetaDataHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kTizenMetaDataKey))
- return true;
-
- auto metadata_info = std::make_shared<MetaDataInfo>();
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kTizenMetaDataKey, kTizenNamespacePrefix)) {
- MetaDataPair metadata_item;
-
- metadata_item = ParseMetaDataItem(dict, error);
- metadata_info->SetValue(metadata_item.first, metadata_item.second);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(metadata_info);
-
- return true;
-}
-
-bool MetaDataHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* /*error*/) const {
- const MetaDataInfo& mdata_info = static_cast<const MetaDataInfo&>(data);
- // TODO(j.izydorczyk):
- // Here should be performed *info class members validity check
- (void)mdata_info;
- return true;
-}
-
-std::string MetaDataHandler::Key() const {
- return kTizenMetaDataKey;
-}
-
-std::string MetaDataInfo::Key() {
- return kTizenMetaDataKey;
-}
-
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_METADATA_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_METADATA_HANDLER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-
-namespace wgt {
-namespace parse {
-
-class MetaDataInfo : public parser::ManifestData {
- public:
- MetaDataInfo();
- virtual ~MetaDataInfo();
-
- static std::string Key();
- /**
- * @brief HasKey
- * @param key
- * @return true if has key
- */
- bool HasKey(const std::string& key) const;
- /**
- * @brief GetValue gets value
- * @param key
- * @return
- */
- std::string GetValue(const std::string& key) const;
- /**
- * @brief SetValue sets value
- * @param key
- * @param value
- */
- void SetValue(const std::string& key, const std::string& value);
- /**
- * @brief metadata
- * @return map of metadata
- */
- const std::map<std::string, std::string>& metadata() const {
- return metadata_;
- }
-
- private:
- std::map<std::string, std::string> metadata_;
-};
-
-/**
- * @brief The MetaDataHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:metadata>.
- */
-class MetaDataHandler : public parser::ManifestHandler {
- public:
- MetaDataHandler();
- virtual ~MetaDataHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_METADATA_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/navigation_handler.h"
-
-#include <boost/tokenizer.hpp>
-
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kAllowNavigationKey[] = "widget.allow-navigation";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kXmlTextKey[] = "#text";
-const boost::char_separator<char> navigation_separator(" ");
-
-} // namespace
-
-AllowedNavigationInfo::AllowedNavigationInfo(
- const std::string& allowed_domains) {
- boost::tokenizer<boost::char_separator<char>> tokens(allowed_domains,
- navigation_separator);
- for (auto& item : tokens) {
- allowed_domains_.push_back(item);
- }
-}
-
-AllowedNavigationInfo::~AllowedNavigationInfo() {}
-
-std::string AllowedNavigationInfo::Key() {
- return kAllowNavigationKey;
-}
-
-NavigationHandler::NavigationHandler() {}
-
-NavigationHandler::~NavigationHandler() {}
-
-
-bool NavigationHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- if (!manifest.HasPath(kAllowNavigationKey))
- return true;
-
- std::string allowed_domains;
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kAllowNavigationKey, kTizenNamespacePrefix)) {
- if (!dict->GetString(kXmlTextKey, &allowed_domains))
- return true;
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(
- std::make_shared<AllowedNavigationInfo>(allowed_domains));
- return true;
-}
-
-bool NavigationHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* /*error*/) const {
- const AllowedNavigationInfo& navi_info =
- static_cast<const AllowedNavigationInfo&>(data);
- // TODO(j.izydorczyk): There should be done 'navi_info' validity check.
- (void)navi_info;
- return true;
-}
-
-std::string NavigationHandler::Key() const {
- return kAllowNavigationKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_NAVIGATION_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_NAVIGATION_HANDLER_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-class AllowedNavigationInfo : public parser::ManifestData {
- public:
- explicit AllowedNavigationInfo(const std::string& allowed_domains);
- virtual ~AllowedNavigationInfo();
-
- static std::string Key();
- /**
- * @brief GetAllowedDomains
- * @return vector with allowed domains
- */
- const std::vector<std::string>& GetAllowedDomains() const {
- return allowed_domains_;
- }
-
- private:
- std::vector<std::string> allowed_domains_;
-};
-
-/**
- * @brief The NavigationHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:allow-navigation>.
- */
-class NavigationHandler : public parser::ManifestHandler {
- public:
- NavigationHandler();
- virtual ~NavigationHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
-
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_NAVIGATION_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/permissions_handler.h"
-
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-const char kTizenPermissionsKey[] = "widget.privilege";
-}
-
-namespace wgt {
-namespace parse {
-
-namespace {
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kTizenPermissionsNameKey[] = "@name";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-}
-
-PermissionsInfo::PermissionsInfo() {}
-
-PermissionsInfo::~PermissionsInfo() {}
-
-PermissionsHandler::PermissionsHandler() {}
-
-PermissionsHandler::~PermissionsHandler() {}
-
-bool PermissionsHandler::Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kTizenPermissionsKey)) {
- return true;
- }
-
- parser::Value* value;
- if (!manifest.Get(kTizenPermissionsKey, &value)) {
- *error = "Invalid value of tizen permissions.";
- return false;
- }
-
- auto permissions_info = std::make_shared<PermissionsInfo>();
- parser::PermissionSet api_permissions;
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kTizenPermissionsKey, kTizenNamespacePrefix)) {
- std::string permission;
-
- if (!dict->GetString(kTizenPermissionsNameKey, &permission) ||
- permission.empty())
- continue;
-
- if (api_permissions.find(permission) != api_permissions.end())
- LOG(WARNING) << "Duplicated permission names found: " << permission;
-
- api_permissions.insert(permission);
- }
-
- permissions_info->SetAPIPermissions(api_permissions);
-
- *output = std::static_pointer_cast<parser::ManifestData>(permissions_info);
- return true;
-}
-
-bool PermissionsHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* /*error*/) const {
- const PermissionsInfo& perm_info = static_cast<const PermissionsInfo&>(data);
- // TODO(j.izydorczyk): there should be done 'perm_info' members validation
- (void)perm_info;
- return true;
-}
-
-std::string PermissionsInfo::Key() {
- return kTizenPermissionsKey;
-}
-
-std::string PermissionsHandler::Key() const {
- return kTizenPermissionsKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_PERMISSIONS_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_PERMISSIONS_HANDLER_H_
-
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/permission_types.h"
-
-namespace wgt {
-namespace parse {
-
-class PermissionsInfo: public parser::ManifestData {
- public:
- PermissionsInfo();
- virtual ~PermissionsInfo();
-
- static std::string Key();
- /**
- * @brief GetAPIPermissions
- * @return permission set
- */
- const parser::PermissionSet& GetAPIPermissions() const {
- return api_permissions_;
- }
- /**
- * @brief SetAPIPermissions sets api permissions
- * @param api_permissions
- */
- void SetAPIPermissions(const parser::PermissionSet& api_permissions) {
- api_permissions_ = api_permissions;
- }
-
- private:
- parser::PermissionSet api_permissions_;
-};
-
-/**
- * @brief The PermissionsHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:privilege>.
- */
-class PermissionsHandler: public parser::ManifestHandler {
- public:
- PermissionsHandler();
- virtual ~PermissionsHandler();
-
- bool Parse(
- const parser::Manifest& data,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_PERMISSIONS_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2015 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 "wgt_manifest_handlers/platform_version.h"
-
-namespace parser {
-
-utils::VersionNumber GetCurrentPlatformVersion() {
- return utils::VersionNumber(TIZEN_VERSION);
-}
-
-utils::VersionNumber GetMinimumPlatformVersion() {
-#ifdef TIZEN_TV
- return utils::VersionNumber("2.3");
-#elif TIZEN_WEARABLE
- return utils::VersionNumber("2.3");
-#else
- return utils::VersionNumber("2.2.1");
-#endif
-}
-
-} // namespace parser
+++ /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_MANIFEST_HANDLERS_PLATFORM_VERSION_H_
-#define WGT_MANIFEST_HANDLERS_PLATFORM_VERSION_H_
-
-#include <string>
-
-#include "manifest_parser/utils/version_number.h"
-
-namespace parser {
-/**
- * @brief GetCurrentPlatformVersion
- * @return number version of the platform currently used
- */
-utils::VersionNumber GetCurrentPlatformVersion();
-
-/**
- * @brief GetMinimumPlatformVersion
- * @return number version of the minimum platform for current profile
- */
-utils::VersionNumber GetMinimumPlatformVersion();
-
-} // namespace parser
-
-#endif // WGT_MANIFEST_HANDLERS_PLATFORM_VERSION_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/service_handler.h"
-
-#include <cassert>
-#include <map>
-#include <utility>
-#include <set>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-const char kTizenServiceKey[] = "widget.service";
-const char kTizenServiceIdKey[] = "@id";
-const char kTizenServiceAutoRestartKey[] = "@auto-restart";
-const char kTizenServiceOnBootKey[] = "@on-boot";
-const char kTizenServiceCategoryKey[] = "category";
-const char kTizenServiceCategoryNameKey[] = "@name";
-const char kTizenServiceContentKey[] = "content";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kTizenServiceNameKey[] = "name";
-const char kTizenServiceContentSrcKey[] = "@src";
-const char kTizenServiceIconKey[] = "icon";
-const char kTizenServiceIconSrcKey[] = "@src";
-const char kTizenServiceDescriptionKey[] = "description";
-const char kTizenServiceMetadataKey[] = "metadata";
-const char kTizenServiceMetadataKeyKey[] = "@key";
-const char kTizenServiceMetadataValueKey[] = "@value";
-const char kXmlLangKey[] = "@lang";
-const char kXmlTextKey[] = "#text";
-
-bool ParseServiceContent(const parser::DictionaryValue* dict,
- wgt::parse::ServiceInfo* service_info,
- std::string* error) {
- std::string content;
- bool found = false;
- for (auto& item : parser::GetOneOrMany(dict, kTizenServiceContentKey,
- kTizenNamespacePrefix)) {
- if (found) {
- *error = "tizen:content element of tizen:service "
- "should be declared only once";
- return false;
- }
- found = true;
- if (!item->GetString(kTizenServiceContentSrcKey, &content)) {
- *error =
- "Missing 'src' attribute in tizen:content tag in tizen:service";
- return false;
- }
- }
- if (!found) {
- *error = "Missing tizen:content tag in tizen:service";
- return false;
- }
- service_info->set_content(content);
- return true;
-}
-
-bool ParseServiceIcon(const parser::DictionaryValue* dict,
- wgt::parse::ServiceInfo* service_info,
- std::string* error) {
- std::string icon;
- const auto& items = parser::GetOneOrMany(dict, kTizenServiceIconKey,
- kTizenNamespacePrefix);
- if (!items.empty()) {
- if (items.size() > 1) {
- *error = "tizen:icon element of tizen:service "
- "should be declared only once";
- return false;
- }
- if (!items[0]->GetString(kTizenServiceIconSrcKey, &icon)) {
- *error = "Missing 'src' attribute in tizen:icon tag in tizen:service";
- return false;
- }
- service_info->set_icon(icon);
- }
- return true;
-}
-
-bool ParseServiceDescription(const parser::DictionaryValue* dict,
- wgt::parse::ServiceInfo* service_info,
- std::string* error) {
- const parser::Value* value = nullptr;
- if (!dict->Get(kTizenServiceDescriptionKey, &value)) return true;
- std::string description;
-
- const auto& items = parser::GetOneOrMany(dict,
- kTizenServiceDescriptionKey,
- kTizenNamespacePrefix);
- if (!items.empty()) {
- if (items.size() > 1) {
- *error = "tizen:description element of tizen:service "
- "should be declared only once";
- return false;
- }
- items[0]->GetString(kXmlTextKey, &description);
- service_info->set_description(description);
- }
- return true;
-}
-
-bool ParseServiceCategory(const parser::DictionaryValue* dict,
- wgt::parse::ServiceInfo* service_info,
- std::string* error) {
- std::vector<std::string> categories;
- for (auto& item : parser::GetOneOrMany(dict, kTizenServiceCategoryKey,
- kTizenNamespacePrefix)) {
- std::string category;
- if (!item->GetString(kTizenServiceCategoryNameKey, &category)) {
- *error =
- "Missing 'name' attribute of tizen:category tag in tizen:service";
- return false;
- }
- categories.push_back(category);
- }
- service_info->set_categories(categories);
- return true;
-}
-
-bool ParseServiceName(const parser::DictionaryValue* dict,
- wgt::parse::ServiceInfo* service_info,
- std::string* error) {
- wgt::parse::LangNameVector names;
- for (auto& item : parser::GetOneOrMany(dict, kTizenServiceNameKey,
- kTizenNamespacePrefix)) {
- std::string lang;
- std::string name;
- item->GetString(kXmlLangKey, &lang);
- item->GetString(kXmlTextKey, &name);
- names.emplace_back(lang, name);
- }
- if (names.empty()) {
- *error = "Cannot find tizen:name element for tizen:service. "
- "At least one must be provided.";
- return false;
- }
- service_info->set_names(names);
- return true;
-}
-
-bool ParseServiceMetadata(const parser::DictionaryValue* dict,
- wgt::parse::ServiceInfo* service_info,
- std::string* error) {
- wgt::parse::KeyValueVector metadata_set;
- for (auto& item : parser::GetOneOrMany(dict, kTizenServiceMetadataKey,
- kTizenNamespacePrefix)) {
- std::string key;
- std::string value;
- if (!item->GetString(kTizenServiceMetadataKeyKey, &key)) {
- *error = "'key' attribute of metadata is obligatory";
- return false;
- }
- item->GetString(kTizenServiceMetadataValueKey, &value);
- metadata_set.emplace_back(key, value);
- }
- service_info->set_metadata_set(metadata_set);
- return true;
-}
-
-std::unique_ptr<wgt::parse::ServiceInfo> ParseService(
- const parser::DictionaryValue* dict, std::string* error) {
- std::string id;
- if (!dict->GetString(kTizenServiceIdKey, &id)) {
- *error = "Cannot get appid for tizen:service";
- return nullptr;
- }
-
- std::unique_ptr<wgt::parse::ServiceInfo> service(
- new wgt::parse::ServiceInfo(id));
-
- std::string auto_restart = "false";
- if (dict->GetString(kTizenServiceAutoRestartKey, &auto_restart))
- service->set_auto_restart(auto_restart == "true");
-
- std::string on_boot = "false";
- if (dict->GetString(kTizenServiceOnBootKey, &on_boot))
- service->set_on_boot(on_boot == "true");
-
- if (!ParseServiceContent(dict, service.get(), error)) return nullptr;
-
- if (!ParseServiceIcon(dict, service.get(), error)) return nullptr;
-
- if (!ParseServiceDescription(dict, service.get(), error)) return nullptr;
-
- if (!ParseServiceCategory(dict, service.get(), error)) return nullptr;
-
- if (!ParseServiceName(dict, service.get(), error)) return nullptr;
-
- if (!ParseServiceMetadata(dict, service.get(), error)) return nullptr;
-
- return service;
-}
-
-} // namespace
-
-namespace wgt {
-
-namespace parse {
-
-ServiceInfo::ServiceInfo(const std::string& id, bool auto_restart, bool on_boot)
- : id_(id), auto_restart_(auto_restart), on_boot_(on_boot) {}
-
-ServiceInfo::~ServiceInfo() {}
-
-ServiceHandler::ServiceHandler() {}
-
-ServiceHandler::~ServiceHandler() {}
-
-
-bool ServiceHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- if (!manifest.HasPath(kTizenServiceKey)) {
- return true;
- }
- std::shared_ptr<ServiceList> services_data(new ServiceList());
-
- for (auto& item : parser::GetOneOrMany(manifest.value(),
- kTizenServiceKey, kTizenNamespacePrefix)) {
- auto service = ParseService(item, error);
- if (!service)
- return false;
- services_data->services.push_back(*service);
- }
- *output = std::static_pointer_cast<parser::ManifestData>(services_data);
- return true;
-}
-
-bool ServiceHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const auto services = static_cast<const wgt::parse::ServiceList&>(data);
-
- for (auto& service : services.services) {
- if (!parser::ValidateTizenApplicationId(service.id())) {
- *error =
- "The id property of application element "
- "does not match the format\n";
- return false;
- }
- }
-
- return true;
-}
-
-std::string ServiceInfo::Key() {
- return kTizenServiceKey;
-}
-
-std::string ServiceHandler::Key() const {
- return kTizenServiceKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_SERVICE_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_SERVICE_HANDLER_H_
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-
-namespace wgt {
-namespace parse {
-
-using LangNameVector = std::vector<std::pair<std::string, std::string>>;
-using KeyValueVector = std::vector<std::pair<std::string, std::string>>;
-
-class ServiceInfo {
- public:
- explicit ServiceInfo(const std::string& id, bool auto_restart = false,
- bool on_boot = false);
- virtual ~ServiceInfo();
-
- static std::string Key();
- /**
- * @brief id
- * @return string id
- */
- const std::string& id() const { return id_; }
- void set_id(std::string id) {
- id_ = std::move(id);
- }
- /**
- * @brief auto_restart
- * @return true is auto-restart is set
- */
- bool auto_restart() const { return auto_restart_; }
- /**
- * @brief set_auto_restart sets auto restart
- * @param auto_restart
- */
- void set_auto_restart(bool auto_restart) {
- auto_restart_ = auto_restart;
- }
- /**
- * @brief on_boot
- * @return if is on boot
- */
- bool on_boot() const { return on_boot_; }
- void set_on_boot(bool on_boot) {
- on_boot_ = on_boot;
- }
- /**
- * @brief names
- * @return lang names vector
- */
- const LangNameVector& names() const {
- return names_;
- }
- /**
- * @brief set_names sets name lang vector
- * @param names
- */
- void set_names(LangNameVector names) {
- names_ = std::move(names);
- }
- /**
- * @brief icon
- * @return string to the icon
- */
- const std::string& icon() const {
- return icon_;
- }
- /**
- * @brief set_icon set string to the icon
- * @param icon
- */
- void set_icon(std::string icon) {
- icon_ = std::move(icon);
- }
- /**
- * @brief content
- * @return content string
- */
-
- const std::string& content() const {
- return content_;
- }
- /**
- * @brief set_content sets content string
- * @param content
- */
- void set_content(std::string content) {
- content_ = std::move(content);
- }
- /**
- * @brief description
- * @return description string
- */
- const std::string& description() const {
- return description_;
- }
- /**
- * @brief set_description sets description
- * @param description
- */
- void set_description(std::string description) {
- description_ = std::move(description);
- }
- /**
- * @brief categories
- * @return categories vector
- */
-
- const std::vector<std::string>& categories() const {
- return categories_;
- }
- /**
- * @brief set_categories sets categories
- * @param categories
- */
- void set_categories(std::vector<std::string> categories) {
- categories_ = std::move(categories);
- }
- /**
- * @brief metadata_set
- * @return key value vector
- */
- const KeyValueVector& metadata_set() const {
- return metadata_set_;
- }
- /**
- * @brief set_metadata_set sets metadata
- * @param metadata_set
- */
- void set_metadata_set(KeyValueVector metadata_set) {
- metadata_set_ = std::move(metadata_set);
- }
-
- private:
- std::string id_;
- bool auto_restart_;
- bool on_boot_;
- LangNameVector names_;
- std::string icon_;
- std::string content_;
- std::string description_;
- std::vector<std::string> categories_;
- KeyValueVector metadata_set_;
-};
-
-struct ServiceList : public parser::ManifestData {
- std::vector<ServiceInfo> services;
-};
-
-/**
- * @brief The ServiceHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:service>.
- */
-class ServiceHandler : public parser::ManifestHandler {
- public:
- ServiceHandler();
- virtual ~ServiceHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_SERVICE_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/setting_handler.h"
-
-#include <boost/algorithm/string.hpp>
-#include <string.h>
-
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace {
-
-const char kTrueValue[] = "true";
-const char kFalseValue[] = "false";
-
-const char kTizenHardwareKey[] = "@hwkey-event";
-const char kTizenScreenOrientationKey[] = "@screen-orientation";
-const char kTizenEncryptionKey[] = "@encryption";
-const char kTizenContextMenuKey[] = "@context-menu";
-const char kTizenBackgroundSupportKey[] = "@background-support";
-const char kTizenNoDisplayKey[] = "@nodisplay";
-const char kTizenIndicatorPresenceKey[] = "@indicator-presence";
-const char kTizenBackbuttonPresenceKey[] = "@backbutton-presence";
-const char kTizenInstallLocationKey[] = "@install-location";
-const char kTizenUserAgentKey[] = "@user-agent";
-const char kTizenSoundModeKey[] = "@sound-mode";
-const char kTizenBackgroundVibrationKey[] = "@background-vibration";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kTizenSettingKey[] = "widget.setting";
-
-bool ForAllFindKey(const parser::Value* value, const std::string& key,
- std::string* result) {
- if (value->GetType() == parser::Value::TYPE_DICTIONARY) {
- const parser::DictionaryValue* dict = nullptr;
- value->GetAsDictionary(&dict);
- if (!parser::VerifyElementNamespace(*dict, kTizenNamespacePrefix))
- return false;
- if (dict->GetString(key, result)) return true;
- } else if (value->GetType() == parser::Value::TYPE_LIST) {
- const parser::ListValue* list = nullptr;
- value->GetAsList(&list);
- for (auto& item : *list) {
- const parser::DictionaryValue* dict = nullptr;
- if (item->GetAsDictionary(&dict)) {
- if (!parser::VerifyElementNamespace(*dict, kTizenNamespacePrefix))
- continue;
- if (dict->GetString(key, result)) return true;
- }
- }
- }
- return false;
-}
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-SettingInfo::SettingInfo()
- : hwkey_enabled_(true),
- screen_orientation_(ScreenOrientation::AUTO),
- encryption_enabled_(false),
- context_menu_enabled_(true),
- background_support_enabled_(false),
- install_location_(InstallLocation::AUTO),
- no_display_(false),
- indicator_presence_(true),
- backbutton_presence_(false),
- sound_mode_(SoundMode::SHARED),
- background_vibration_(false) {}
-
-SettingInfo::~SettingInfo() {}
-
-SettingHandler::SettingHandler() {}
-
-SettingHandler::~SettingHandler() {}
-
-bool SettingHandler::Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- const parser::Value* value = nullptr;
- manifest.Get(kTizenSettingKey, &value);
-
- std::shared_ptr<SettingInfo> app_info(new SettingInfo);
- std::string hwkey;
- ForAllFindKey(value, kTizenHardwareKey, &hwkey);
- app_info->set_hwkey_enabled(hwkey != "disable");
-
- std::string screen_orientation;
- ForAllFindKey(value, kTizenScreenOrientationKey, &screen_orientation);
- if (strcasecmp("portrait", screen_orientation.c_str()) == 0)
- app_info->set_screen_orientation(SettingInfo::ScreenOrientation::PORTRAIT);
- else if (strcasecmp("landscape", screen_orientation.c_str()) == 0)
- app_info->set_screen_orientation(SettingInfo::ScreenOrientation::LANDSCAPE);
- else
- app_info->set_screen_orientation(SettingInfo::ScreenOrientation::AUTO);
-
- std::string encryption;
- ForAllFindKey(value, kTizenEncryptionKey, &encryption);
- app_info->set_encryption_enabled(encryption == "enable");
-
- std::string context_menu;
- ForAllFindKey(value, kTizenContextMenuKey, &context_menu);
- app_info->set_context_menu_enabled(context_menu != "disable");
-
- std::string background_support;
- ForAllFindKey(value, kTizenBackgroundSupportKey, &background_support);
- app_info->set_background_support_enabled(background_support == "enable");
-
- std::string install_location;
- ForAllFindKey(value, kTizenInstallLocationKey, &install_location);
- if (strcasecmp("internal-only", install_location.c_str()) == 0)
- app_info->set_install_location(SettingInfo::InstallLocation::INTERNAL);
- else if (strcasecmp("prefer-external", install_location.c_str()) == 0)
- app_info->set_install_location(SettingInfo::InstallLocation::EXTERNAL);
-
- std::string no_display;
- ForAllFindKey(value, kTizenNoDisplayKey, &no_display);
- app_info->set_no_display(boost::iequals(no_display, kTrueValue));
-
- std::string indicator_presence;
- ForAllFindKey(value, kTizenIndicatorPresenceKey, &indicator_presence);
- app_info->set_indicator_presence(indicator_presence == "enable");
-
- std::string backbutton_presence;
- ForAllFindKey(value, kTizenBackbuttonPresenceKey, &backbutton_presence);
- app_info->set_backbutton_presence(backbutton_presence == "enable");
-
- std::string user_agent;
- ForAllFindKey(value, kTizenUserAgentKey, &user_agent);
- app_info->set_user_agent(user_agent);
-
- std::string background_vibration;
- ForAllFindKey(value, kTizenBackgroundVibrationKey, &background_vibration);
- app_info->set_background_vibration(background_vibration == "enable");
-
- std::string sound_mode;
- ForAllFindKey(value, kTizenSoundModeKey, &sound_mode);
- if (strcasecmp("exclusive", sound_mode.c_str()) == 0)
- app_info->set_sound_mode(SettingInfo::SoundMode::EXCLUSIVE);
-
- *output = std::static_pointer_cast<parser::ManifestData>(app_info);
- return true;
-}
-
-bool SettingHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const SettingInfo& setting_info = static_cast<const SettingInfo&>(data);
- if (setting_info.screen_orientation() !=
- SettingInfo::ScreenOrientation::AUTO &&
- setting_info.screen_orientation() !=
- SettingInfo::ScreenOrientation::PORTRAIT &&
- setting_info.screen_orientation() !=
- SettingInfo::ScreenOrientation::LANDSCAPE) {
- *error = "Wrong value of screen orientation";
- return false;
- }
-
- if (setting_info.install_location() != SettingInfo::InstallLocation::AUTO &&
- setting_info.install_location() !=
- SettingInfo::InstallLocation::INTERNAL &&
- setting_info.install_location() !=
- SettingInfo::InstallLocation::EXTERNAL) {
- *error = "Wrong value of install location";
- return false;
- }
-
- if (setting_info.sound_mode() != SettingInfo::SoundMode::SHARED &&
- setting_info.sound_mode() != SettingInfo::SoundMode::EXCLUSIVE) {
- *error = "Wrong value of screen sound mode";
- return false;
- }
-
- return true;
-}
-
-
-std::string SettingHandler::Key() const {
- return kTizenSettingKey;
-}
-
-std::string SettingInfo::Key() {
- return kTizenSettingKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_SETTING_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_SETTING_HANDLER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/values.h"
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-class SettingInfo : public parser::ManifestData {
- public:
- enum class ScreenOrientation {
- PORTRAIT,
- LANDSCAPE,
- AUTO
- };
-
- enum class InstallLocation {
- INTERNAL,
- EXTERNAL,
- AUTO
- };
-
- enum class SoundMode {
- SHARED,
- EXCLUSIVE
- };
-
- SettingInfo();
- virtual ~SettingInfo();
-
- static std::string Key();
- /**
- * @brief set_hwkey_enabled sets value of hw_key to true or false
- * @param enabled
- */
- void set_hwkey_enabled(bool enabled) { hwkey_enabled_ = enabled; }
- /**
- * @brief hwkey_enabled
- * @return current value of hw_key
- */
- bool hwkey_enabled() const { return hwkey_enabled_; }
- /**
- * @brief set_screen_orientation sets screen_orientation
- * @param orientation
- */
- void set_screen_orientation(ScreenOrientation orientation) {
- screen_orientation_ = orientation;
- }
- /**
- * @brief screen_orientation
- * @return currently selected screen orientation
- */
-
- ScreenOrientation screen_orientation() const { return screen_orientation_; }
- /**
- * @brief set_encryption_enabled sets if encryption is enabled or disabled
- * @param enabled
- */
- void set_encryption_enabled(bool enabled) { encryption_enabled_ = enabled; }
- /**
- * @brief encryption_enabled
- * @return true if encryption is enable
- */
- bool encryption_enabled() const { return encryption_enabled_; }
- /**
- * @brief set_context_menu_enabled sets context menu enabled
- * @param enabled
- */
- void set_context_menu_enabled(bool enabled) {
- context_menu_enabled_ = enabled;
- }
- /**
- * @brief context_menu_enabled
- * @return true if context menu is enabled
- */
- bool context_menu_enabled() const { return context_menu_enabled_; }
- /**
- * @brief set_background_support_enabled whether it is enabled
- * @param enabled
- */
- void set_background_support_enabled(bool enabled) {
- background_support_enabled_ = enabled;
- }
- /**
- * @brief background_support_enabled
- * @return true if background support is enabled
- */
- bool background_support_enabled() const {
- return background_support_enabled_;
- }
- /**
- * @brief set_install_location sets install location
- * @param installLocation
- */
- void set_install_location(InstallLocation installLocation) {
- install_location_ = installLocation;
- }
- /**
- * @brief install_location
- * @return what InstallLocation is chosen
- */
- InstallLocation install_location() const { return install_location_; }
- /**
- * @brief set_no_display sets is there is no display
- * @param enabled
- */
- void set_no_display(bool enabled) { no_display_ = enabled; }
- /**
- * @brief no_display
- * @return if there is no supoort for display
- */
- bool no_display() const { return no_display_; }
- /**
- * @brief set_indicator_presence sets indicator presence
- * @param enabled
- */
- void set_indicator_presence(bool enabled) { indicator_presence_ = enabled; }
- /**
- * @brief indicator_presence
- * @return if the indicator is present
- */
- bool indicator_presence() const { return indicator_presence_; }
- /**
- * @brief set_backbutton_presence sets if backbutton is present
- * @param enabled
- */
- void set_backbutton_presence(bool enabled) { backbutton_presence_ = enabled; }
- /**
- * @brief backbutton_presence
- * @return true if backbutton is present
- */
- bool backbutton_presence() const { return backbutton_presence_; }
- /**
- * @brief set_user_agent sets user_agent()
- * @param user_agent
- */
- void set_user_agent(std::string user_agent) { user_agent_ = std::move(user_agent); }
- /**
- * @brief user_agent
- * @return actual user agent
- */
- std::string user_agent() const { return user_agent_; }
- /**
- * @brief set_sound_mode sets sound mode
- * @param soundMode
- */
- void set_sound_mode(SoundMode soundMode) { sound_mode_ = soundMode; }
- /**
- * @brief sound_mode
- * @return current sound mode
- */
- SoundMode sound_mode() const { return sound_mode_; }
- /**
- * @brief set_background_vibration set background vibration
- * @param enabled
- */
- void set_background_vibration(bool enabled) {
- background_vibration_ = enabled;
- }
- /**
- * @brief background_vibration
- * @return background vibration
- */
- bool background_vibration() const { return background_vibration_; }
-
- private:
- bool hwkey_enabled_;
- ScreenOrientation screen_orientation_;
- bool encryption_enabled_;
- bool context_menu_enabled_;
- bool background_support_enabled_;
- InstallLocation install_location_;
- bool no_display_;
- bool indicator_presence_;
- bool backbutton_presence_;
- std::string user_agent_;
- SoundMode sound_mode_;
- bool background_vibration_;
-};
-
-/**
- * @brief The SettingHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:setting>.
- */
-class SettingHandler : public parser::ManifestHandler {
- public:
- SettingHandler();
- virtual ~SettingHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& application,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-};
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_SETTING_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/splash_screen_handler.h"
-
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <algorithm>
-#include <cassert>
-#include <cstdlib>
-#include <map>
-#include <utility>
-
-#include "manifest_parser/utils/logging.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace bf = boost::filesystem;
-namespace keys = wgt::application_widget_keys;
-namespace wgt_parse = wgt::parse;
-
-namespace {
-const char kTizenSplashScreenSrcKey[] = "@src";
-const char kTizenSplashScreenKey[] = "widget.splash-screen";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kTagDelimiter[] = " ";
-const char kFirstPaint[] = "first-paint";
-const char kComplete[] = "complete";
-const char kCustom[] = "custom";
-const char kSplashScreenDefault[] = "widget.launch_screen.ls_default";
-const char kSplashScreenPortrait[] = "widget.launch_screen.ls_portrait";
-const char kSplashScreenLandscape[] = "widget.launch_screen.ls_landscape";
-const char kSplashScreenKey[] = "widget.launch_screen";
-const char kSplashScreenReadyWhen[] = "@ready_when";
-const char kSplashScreenBgColor[] = "@background_color";
-const char kSplashScreenBgImage[] = "@background_image";
-const char kSplashScreenImage[] = "@image";
-const char kSplashScreenImageBorder[] = "@image_border";
-const std::map<wgt_parse::ScreenOrientation, const char*> kOrientationMap = {
- {wgt_parse::ScreenOrientation::AUTO, kSplashScreenDefault},
- {wgt_parse::ScreenOrientation::LANDSCAPE, kSplashScreenLandscape},
- {wgt_parse::ScreenOrientation::PORTRAIT, kSplashScreenPortrait}};
-
-std::shared_ptr< wgt_parse::Color>
-ConvertStringToColor(const std::string& color_str) {
- auto to_long = [&color_str](unsigned int start, unsigned int end) -> int {
- return std::strtoul(color_str.substr(start, end).c_str(), 0, 16);
- };
- std::shared_ptr<wgt_parse::Color> color(new wgt_parse::Color);
- switch (color_str.size()) {
- case 3:
- color->red = to_long(0, 0);
- color->green = to_long(1, 1);
- color->blue = to_long(2, 1);
- break;
- case 6:
- color->red = to_long(0, 2);
- color->green = to_long(2, 2);
- color->blue = to_long(4, 2);
- }
- return color;
-}
-
-bool IsStringToColorConvertable(const std::string& string_color) {
- return string_color[0] == '#' &&
- (string_color.size() == 4 || string_color.size() == 7);
-}
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-std::string SplashScreenInfo::Key() {
- return kTizenSplashScreenKey;
-}
-
-bool SplashScreenHandler::ParseSingleOrientation(
- const parser::Manifest& manifest, ScreenOrientation orientation,
- SplashScreenInfo* ss_info) {
- auto dict_element_parser =
- [this](SplashScreenData& splash_screen,
- const parser::DictionaryValue* dict) -> bool {
- if (!parser::VerifyElementNamespace(*dict, kTizenNamespacePrefix))
- return false;
-
- bool parsed_color = ParseColor(dict, &splash_screen);
- ParseElement(dict, &splash_screen.background_image, kSplashScreenBgImage);
- ParseElement(dict, &splash_screen.image, kSplashScreenImage);
- ParseElement(dict, &splash_screen.image_border, kSplashScreenImageBorder);
-
- return parsed_color || !splash_screen.background_image.empty() ||
- !splash_screen.image.empty();
- };
-
- auto orientation_chosen = kOrientationMap.at(orientation);
- SplashScreenData splash_screen;
-
- bool valid_element = false;
- for (auto& dict_element :
- parser::GetOneOrMany(manifest.value(),
- orientation_chosen,
- kTizenNamespacePrefix)) {
- if (dict_element_parser(splash_screen, dict_element))
- valid_element = true;
- }
- if (!valid_element) return false;
-
- ss_info->set_splash_screen_data(std::make_pair(orientation, splash_screen));
- return true;
-}
-
-bool SplashScreenHandler::ParseElement(const parser::DictionaryValue* dict,
- std::vector<std::string>* to_be_saved,
- const char* keyToParse) {
- // TODO(w.kosowicz) check which elements not declared should cause fail
- std::string element;
- dict->GetString(keyToParse, &element);
- boost::split(*to_be_saved, element, boost::is_any_of(kTagDelimiter));
- return true;
-}
-
-bool SplashScreenHandler::ParseColor(const parser::DictionaryValue* dict,
- SplashScreenData* splash_screen) {
- std::string background_color;
- if (!dict->GetString(kSplashScreenBgColor, &background_color) ||
- !IsStringToColorConvertable(background_color))
- return false;
-
- std::string only_hex = background_color.substr(1);
- if (!std::all_of(only_hex.begin(), only_hex.end(), isxdigit)) return false;
-
- splash_screen->background_color = ConvertStringToColor(only_hex);
- return true;
-}
-
-bool SplashScreenHandler::ParseReadyWhen(const parser::Manifest& manifest,
- SplashScreenInfo* ss_info) {
- auto dict_values = parser::GetOneOrMany(manifest.value(),
- kSplashScreenKey,
- kTizenNamespacePrefix);
- if (dict_values.empty())
- return false;
-
- std::string ready_when;
- dict_values[0]->GetAsString(&ready_when);
-
- if (ready_when.empty()) return false;
- if (ready_when != kFirstPaint && ready_when != kComplete &&
- ready_when != kCustom)
- return false;
-
- std::map<std::string, std::function<void()>> ready_when_functors;
- ready_when_functors[kFirstPaint] = std::bind(
- &SplashScreenInfo::set_ready_when, ss_info, ReadyWhen::FIRSTPAINT);
- ready_when_functors[kComplete] = std::bind(&SplashScreenInfo::set_ready_when,
- ss_info, ReadyWhen::COMPLETE);
- ready_when_functors[kCustom] =
- std::bind(&SplashScreenInfo::set_ready_when, ss_info, ReadyWhen::CUSTOM);
- ready_when_functors[ready_when]();
-
- return true;
-}
-
-bool SplashScreenHandler::Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- auto ss_info = std::make_shared<SplashScreenInfo>();
- if (!ParseReadyWhen(manifest, ss_info.get())) return false;
-
- ParseSingleOrientation(manifest, ScreenOrientation::AUTO, ss_info.get());
- ParseSingleOrientation(manifest, ScreenOrientation::LANDSCAPE, ss_info.get());
- ParseSingleOrientation(manifest, ScreenOrientation::PORTRAIT, ss_info.get());
-
- *output = std::static_pointer_cast<parser::ManifestData>(ss_info);
-
- return true;
-}
-
-bool SplashScreenHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const SplashScreenInfo& splash_data =
- static_cast<const SplashScreenInfo&>(data);
- std::string src = splash_data.src();
- // According to w3c specification splash screen image should be of one of
- // below types.
- if (src.compare(src.size() - 3, 3, "png") &&
- src.compare(src.size() - 3, 3, "svg") &&
- src.compare(src.size() - 3, 3, "gif") &&
- src.compare(src.size() - 3, 3, "jpg")) {
- *error = "Not supported file extension of splash image";
- return false;
- }
- return true;
-}
-
-std::string SplashScreenHandler::Key() const {
- return kTizenSplashScreenKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_SPLASH_SCREEN_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_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/setting_handler.h"
-
-namespace wgt {
-namespace parse {
-
-enum class ReadyWhen { FIRSTPAINT, COMPLETE, CUSTOM };
-
-enum class ScreenOrientation { AUTO, PORTRAIT, LANDSCAPE, NONE };
-
-struct Color {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
-};
-
-struct SplashScreenData {
- ScreenOrientation orientation;
- std::shared_ptr<Color> background_color;
- std::vector<std::string> background_image;
- std::vector<std::string> image;
- std::vector<std::string> image_border;
-};
-
-class SplashScreenInfo : public parser::ManifestData {
- public:
- SplashScreenInfo() { }
- virtual ~SplashScreenInfo() { }
-
- static std::string Key();
-
- void set_src(std::string src) { src_ = std::move(src); }
- const std::string& src() const { return src_; }
- void set_splash_screen_data(
- std::pair<ScreenOrientation, SplashScreenData> splash_screen_data) {
- splash_screen_data_.insert(std::move(splash_screen_data));
- }
- const std::map<ScreenOrientation, SplashScreenData>& splash_screen_data()
- const {
- return splash_screen_data_;
- }
- void set_ready_when(ReadyWhen ready_when) { ready_when_ = ready_when; }
- ReadyWhen ready_when() const { return ready_when_; }
-
- private:
- std::string src_;
- std::map<ScreenOrientation, SplashScreenData> splash_screen_data_;
- ReadyWhen ready_when_;
-};
-
-/**
- * @brief The SplashScreenHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:splash-screen>.
- */
-class SplashScreenHandler : public parser::ManifestHandler {
- public:
- SplashScreenHandler() {}
- virtual ~SplashScreenHandler() {}
- bool Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- std::string Key() const override;
-
- private:
- bool ParseSingleOrientation(const parser::Manifest& manifest,
- ScreenOrientation orientation,
- SplashScreenInfo* ss_info);
- bool ParseElement(const parser::DictionaryValue* dict,
- std::vector<std::string>* to_be_saved,
- const char* keyToParse);
- bool ParseReadyWhen(const parser::Manifest& manifest,
- SplashScreenInfo* ss_info);
- bool ParseColor(const parser::DictionaryValue* dict,
- SplashScreenData* splash_screen);
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_SPLASH_SCREEN_HANDLER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/tizen_application_handler.h"
-
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "manifest_parser/manifest_util.h"
-#include "manifest_parser/utils/version_number.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-#include "wgt_manifest_handlers/platform_version.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-
-const char kTizenApplicationKey[] = "widget.application";
-const char kTizenNamespacePrefix[] = "http://tizen.org/ns/widgets";
-const char kNamespaceKey[] = "@namespace";
-const char kTizenApplicationIdKey[] = "@id";
-const char kTizenApplicationPackageKey[] = "@package";
-const char kTizenApplicationLaunchModeKey[] = "@launch_mode";
-const char kTizenApplicationRequiredVersionKey[] = "@required_version";
-const char kTizenApplicationAmbientSupportKey[] = "@ambient_support";
-const utils::VersionNumber kLaunchModeRequiredVersion("2.4");
-} // namespace
-
-TizenApplicationInfo::TizenApplicationInfo() {}
-
-TizenApplicationInfo::~TizenApplicationInfo() {}
-
-TizenApplicationHandler::TizenApplicationHandler() {}
-
-TizenApplicationHandler::~TizenApplicationHandler() {}
-
-bool TizenApplicationHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output, std::string* error) {
- std::shared_ptr<TizenApplicationInfo> app_info(new TizenApplicationInfo);
- parser::Value* app_value = nullptr;
- manifest.Get(kTizenApplicationKey, &app_value);
- // Find an application element with tizen namespace
- parser::DictionaryValue* app_dict;
- std::string value;
- bool found = false;
- if (app_value && app_value->IsType(parser::Value::TYPE_DICTIONARY)) {
- app_value->GetAsDictionary(&app_dict);
- found = app_dict->GetString(kNamespaceKey, &value);
- found = found && (value == kTizenNamespacePrefix);
- } else if (app_value && app_value->IsType(parser::Value::TYPE_LIST)) {
- parser::ListValue* list;
- app_value->GetAsList(&list);
- for (parser::ListValue::iterator it = list->begin(); it != list->end();
- ++it) {
- (*it)->GetAsDictionary(&app_dict);
- app_dict->GetString(kNamespaceKey, &value);
- bool is_tizen = (value == kTizenNamespacePrefix);
- if (is_tizen) {
- if (found) {
- *error = "There should be no more than one tizen:application element";
- return false;
- }
- found = true;
- }
- }
- }
-
- if (!found) {
- *error =
- "Cannot find application element with tizen namespace "
- "or the tizen namespace prefix is incorrect.\n";
- return false;
- }
- if (app_dict->GetString(kTizenApplicationIdKey, &value))
- app_info->set_id(value);
- if (app_dict->GetString(kTizenApplicationPackageKey, &value)) {
- app_info->set_package(value);
- }
- if (app_dict->GetString(kTizenApplicationRequiredVersionKey, &value)) {
- if (!value.empty()) {
- utils::VersionNumber req_version(value);
- utils::VersionNumber min_version = parser::GetMinimumPlatformVersion();
- if (req_version < min_version) {
- app_info->set_required_version(min_version.ToString());
- } else {
- app_info->set_required_version(value);
- }
- }
- }
- std::string ambient_support;
- if (app_dict->GetString(kTizenApplicationAmbientSupportKey,
- &ambient_support)) {
- app_info->set_ambient_support(ambient_support == "enable");
- }
-
- std::string launch_mode;
- app_dict->GetString(kTizenApplicationLaunchModeKey, &launch_mode);
- app_info->set_launch_mode(launch_mode);
-
- *output = std::static_pointer_cast<parser::ManifestData>(app_info);
- return true;
-}
-
-bool TizenApplicationHandler::Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const TizenApplicationInfo& app_info =
- static_cast<const TizenApplicationInfo&>(data);
-
- if (!parser::ValidateTizenApplicationId(app_info.id())) {
- *error =
- "The id property of application element "
- "does not match the format\n";
- return false;
- }
-
- if (!parser::ValidateTizenPackageId(app_info.package())) {
- *error =
- "The package property of application element "
- "does not match the format\n";
- return false;
- }
-
- if (app_info.id().find(app_info.package()) != 0) {
- *error =
- "The application element property id "
- "does not start with package.\n";
- return false;
- }
- if (app_info.required_version().empty()) {
- *error =
- "The required_version property of application "
- "element does not exist.\n";
- return false;
- }
- utils::VersionNumber supported_version = parser::GetCurrentPlatformVersion();
- if (!supported_version.IsValid()) {
- *error = "Cannot retrieve supported API version from platform";
- return false;
- }
- utils::VersionNumber required_version(app_info.required_version());
- if (!required_version.IsValid()) {
- *error = "Cannot retrieve supported API version from widget";
- return false;
- }
- if (supported_version < required_version) {
- *error =
- "The required_version of Tizen Web API "
- "is not supported.\n";
- return false;
- }
- if (required_version >= kLaunchModeRequiredVersion) {
- if (app_info.launch_mode().empty()) {
- // FIXME for now, this const_cast is used, but it is not the best way.
- TizenApplicationInfo &tmp = const_cast<TizenApplicationInfo &>(app_info);
- tmp.set_launch_mode("single"); // default parameter
- } else if (app_info.launch_mode() != "caller" &&
- app_info.launch_mode() != "group" &&
- app_info.launch_mode() != "single") {
- *error = "Wrong value of launch mode";
- return false;
- }
- } else if (!app_info.launch_mode().empty()) {
- *error = "launch_mode attribute cannot be used for api version lower"
- " than 2.4";
- return false;
- }
- return true;
-}
-
-std::string TizenApplicationInfo::Key() {
- return kTizenApplicationKey;
-}
-
-std::string TizenApplicationHandler::Key() const {
- return kTizenApplicationKey;
-}
-
-bool TizenApplicationHandler::AlwaysParseForKey() const { return true; }
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_TIZEN_APPLICATION_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_TIZEN_APPLICATION_HANDLER_H_
-
-#include <map>
-#include <string>
-#include <vector>
-#include <utility>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-class TizenApplicationInfo : public parser::ManifestData {
- public:
- TizenApplicationInfo();
- virtual ~TizenApplicationInfo();
-
- static std::string Key();
-
- void set_id(std::string id) {
- id_ = std::move(id);
- }
- void set_launch_mode(std::string launch_mode) {
- launch_mode_ = std::move(launch_mode);
- }
- void set_package(std::string package) {
- package_ = std::move(package);
- }
- void set_required_version(
- std::string required_version) {
- required_version_ = std::move(required_version);
- }
- void set_ambient_support(bool ambient_support) {
- ambient_support_ = ambient_support;
- }
- const std::string& id() const {
- return id_;
- }
- const std::string& launch_mode() const {
- return launch_mode_;
- }
- const std::string& package() const {
- return package_;
- }
- const std::string& required_version() const {
- return required_version_;
- }
- bool ambient_support() const {
- return ambient_support_;
- }
-
- private:
- std::string id_;
- std::string launch_mode_;
- std::string package_;
- std::string required_version_;
- bool ambient_support_;
-};
-
-/**
- * @brief The TizenApplicationHandler class
- *
- * Handler of config.xml for xml elements:
- * - <tizen:application>.
- */
-class TizenApplicationHandler : public parser::ManifestHandler {
- public:
- TizenApplicationHandler();
- virtual ~TizenApplicationHandler();
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
- bool AlwaysParseForKey() const override;
- std::string Key() const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_TIZEN_APPLICATION_HANDLER_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-xwalk file.
-
-#include "wgt_manifest_handlers/warp_handler.h"
-
-#include <string.h>
-#include <cassert>
-#include <map>
-#include <utility>
-
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-const char kAccessKey[] = "widget.access";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kAccessSubdomainsKey[] = "@subdomains";
-const char kAccessOriginKey[] = "@origin";
-}
-
-void WarpHandler::ParseSingleAccessElement(
- const parser::DictionaryValue& item_dict,
- std::shared_ptr<WarpInfo> info) {
- std::string domain_name;
- std::string subdomains_str;
- bool subdomains = false;
-
- if (item_dict.HasKey(kAccessSubdomainsKey)) {
- item_dict.GetString(kAccessSubdomainsKey, &subdomains_str);
- if (subdomains_str == "true")
- subdomains = true;
- }
- // TODO(w.kosowicz): address validation
- item_dict.GetString(kAccessOriginKey, &domain_name);
- if (domain_name == "*")
- subdomains = true;
- info->set_access_element(std::make_pair(domain_name, subdomains));
-}
-
-bool WarpHandler::Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* /*error*/) {
- if (!manifest.HasPath(kAccessKey))
- return true;
-
- auto info = std::make_shared<WarpInfo>();
-
- for (const auto& dict : parser::GetOneOrMany(manifest.value(),
- kAccessKey, kWidgetNamespacePrefix)) {
- ParseSingleAccessElement(*dict, info);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(info);
-
- return true;
-}
-
-std::string WarpInfo::Key() {
- return kAccessKey;
-}
-
-std::string WarpHandler::Key() const {
- return kAccessKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /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-xwalk file.
-
-#ifndef WGT_MANIFEST_HANDLERS_WARP_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_WARP_HANDLER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "manifest_parser/values.h"
-#include "manifest_parser/manifest_handler.h"
-
-namespace wgt {
-namespace parse {
-
-class WarpInfo : public parser::ManifestData {
- public:
- static std::string Key();
-
- WarpInfo() {}
- ~WarpInfo() override {}
- /**
- * @brief set_access_element push single access_element inside vector
- * @param access_element
- */
- void set_access_element(const std::pair<std::string, bool>& access_element) {
- access_map_.push_back(access_element);
- }
- /**
- * @brief access_map
- * @return vector containing access_elements
- */
- const std::vector<std::pair<std::string, bool> >& access_map() const {
- return access_map_;
- }
-
- private:
- std::vector<std::pair<std::string, bool> > access_map_;
-};
-
-/**
- * @brief The WarpHandler class
- *
- * Handler of config.xml for xml elements:
- * - <w3c:access>.
- */
-class WarpHandler : public parser::ManifestHandler {
- public:
- WarpHandler() {}
- ~WarpHandler() override {}
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- void ParseSingleAccessElement(
- const parser::DictionaryValue& item_dict,
- std::shared_ptr<WarpInfo> info);
- std::string Key() const override;
-};
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_WARP_HANDLER_H_
+++ /dev/null
-prefix=@PREFIX@
-exec_prefix=@PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: wgt-manifest-handlers
-Description: Manifest handlers for wgt manifest parser
-Version: @VERSION@
-Requires: manifest-parser
-Libs: -L${libdir} -lwgt-manifest-handlers
-Cflags: -I${includedir}
\ No newline at end of file
+++ /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_manifest_handlers/widget_config_parser.h"
-
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <xdgmime.h>
-
-#include <algorithm>
-#include <string>
-#include <map>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/language_tag_validator.h"
-#include "manifest_parser/utils/logging.h"
-#include "wgt_manifest_handlers/account_handler.h"
-#include "wgt_manifest_handlers/app_control_handler.h"
-#include "wgt_manifest_handlers/application_icons_handler.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-#include "wgt_manifest_handlers/appwidget_handler.h"
-#include "wgt_manifest_handlers/background_category_handler.h"
-#include "wgt_manifest_handlers/category_handler.h"
-#include "wgt_manifest_handlers/content_handler.h"
-#include "wgt_manifest_handlers/csp_handler.h"
-#include "wgt_manifest_handlers/ime_handler.h"
-#include "wgt_manifest_handlers/metadata_handler.h"
-#include "wgt_manifest_handlers/navigation_handler.h"
-#include "wgt_manifest_handlers/permissions_handler.h"
-#include "wgt_manifest_handlers/service_handler.h"
-#include "wgt_manifest_handlers/setting_handler.h"
-#include "wgt_manifest_handlers/splash_screen_handler.h"
-#include "wgt_manifest_handlers/tizen_application_handler.h"
-#include "wgt_manifest_handlers/warp_handler.h"
-#include "wgt_manifest_handlers/widget_handler.h"
-
-namespace ba = boost::algorithm;
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-
-namespace {
-
-const char kLocaleDirectory[] = "locales";
-
-const char* kDefaultStartFiles[] = {
- "index.htm",
- "index.html",
- "index.svg",
- "index.xhtml",
- "index.xht"
-};
-
-const char* kDefaultIconFiles[] = {
- "icon.svg",
- "icon.ico",
- "icon.png",
- "icon.gif",
- "icon.jpg"
-};
-
-const std::map<std::string, std::string> kFileIdenticationTable = {
- {".html", "text/html"},
- {".htm", "text/html"},
- {".css", "text/css"},
- {".js", "application/javascript"},
- {".xml", "application/xml"},
- {".txt", "text/plain"},
- {".wav", "audio/x-wav"},
- {".xhtml", "application/xhtml+xml"},
- {".xht", "application/xhtml+xml"},
- {".gif", "image/gif"},
- {".png", "image/png"},
- {".ico", "image/vnd.microsoft.icon"},
- {".svg", "image/svg+xml"},
- {".jpg", "image/jpeg"},
- {".mp3", "audio/mpeg"}
-};
-
-const char* kIconsSupportedMimeTypes[] = {
- "image/gif",
- "image/png",
- "image/vnd.microsoft.icon",
- "image/svg+xml",
- "image/jpeg"
-};
-
-// http://www.w3.org/TR/widgets/#rule-for-identifying-the-media-type-of-a-file-0
-bool IsIconMimeTypeSupported(const bf::path& icon_path) {
- std::string ext = icon_path.extension().string();
- std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
- std::string mime_type;
- if (!ext.empty() && std::all_of(++ext.begin(), ext.end(), ::isalpha)) {
- auto iter = kFileIdenticationTable.find(ext);
- if (iter != kFileIdenticationTable.end()) {
- mime_type = iter->second;
- }
- }
- if (mime_type.empty()) {
- // sniff the mime type
- mime_type =
- xdg_mime_get_mime_type_for_file(icon_path.string().c_str(), nullptr);
- }
- for (auto mime : kIconsSupportedMimeTypes) {
- if (mime_type == mime)
- return true;
- }
- return false;
-}
-
-enum class FindResult {
- OK,
- NUL,
- ERROR
-};
-
-// http://www.w3.org/TR/widgets/#rule-for-finding-a-file-within-a-widget-package-0 // NOLINT
-FindResult FindFileWithinWidget(const bf::path& widget_path,
- const std::string& content, bf::path* file = nullptr) {
- std::string content_value = content;
- if (content_value.empty())
- return FindResult::ERROR;
- if (content_value[0] == '/') {
- content_value = content_value.substr(1);
- }
- // Steps 4. && 5.
- std::vector<std::string> path_components;
- ba::split(path_components, content_value, ba::is_any_of("/"));
- if (path_components.size() >= 1 && path_components[0] == kLocaleDirectory) {
- if (path_components.size() == 1)
- return FindResult::NUL;
-
- if (!utils::w3c_languages::ValidateLanguageTag(path_components[1]))
- return FindResult::NUL;
-
- path_components.erase(path_components.begin(), ++++path_components.begin());
- content_value = ba::join(path_components, "/");
- }
- // for each locale in widget
- // TODO(t.iwanek): this algorithm should accept input of preferred locale list
- bs::error_code error;
- bf::path locale_directory = widget_path / kLocaleDirectory;
- if (bf::exists(locale_directory, error)) {
- for (auto iter = bf::directory_iterator(locale_directory);
- iter != bf::directory_iterator(); ++iter) {
- const bf::path& path = *iter;
-
- if (!utils::w3c_languages::ValidateLanguageTag(path.filename().string()))
- continue;
-
- bf::path candidate = path / content_value;
- if (bf::exists(candidate, error)) {
- if (bf::is_directory(candidate, error)) {
- return FindResult::ERROR;
- }
- if (file)
- *file = candidate;
- return FindResult::OK;
- }
- }
- }
-
- // default locale
- bf::path root_candidate = widget_path / content_value;
- if (bf::exists(root_candidate, error)) {
- if (bf::is_directory(root_candidate, error)) {
- return FindResult::ERROR;
- }
- if (file)
- *file = root_candidate;
- return FindResult::OK;
- }
-
- return FindResult::NUL;
-}
-
-bool CheckW3CContentSrcExits(const bf::path& widget_path,
- const std::string& content) {
- if (!content.empty()) {
- if (FindFileWithinWidget(widget_path, content) == FindResult::OK) {
- return true;
- }
- }
- return false;
-}
-
-// http://www.w3.org/TR/widgets/#step-8-locate-the-start-file
-bool CheckStartFileInWidget(const bf::path& widget_path) {
- for (auto& file : kDefaultStartFiles) {
- if (FindFileWithinWidget(widget_path, file) == FindResult::OK) {
- LOG(INFO) << "Start file is: " << file;
- return true;
- }
- }
- LOG(ERROR) << "No valid start file found";
- return false;
-}
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-WidgetConfigParser::WidgetConfigParser() {
- std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
- std::make_shared<AccountHandler>(),
- std::make_shared<AppControlHandler>(),
- std::make_shared<ApplicationIconsHandler>(),
- std::make_shared<AppWidgetHandler>(),
- std::make_shared<CategoryHandler>(),
- std::make_shared<ContentHandler>(),
- std::make_shared<CSPHandler>(CSPHandler::SecurityType::CSP),
- std::make_shared<CSPHandler>(CSPHandler::SecurityType::CSP_REPORT_ONLY),
- std::make_shared<ImeHandler>(),
- std::make_shared<MetaDataHandler>(),
- std::make_shared<NavigationHandler>(),
- std::make_shared<PermissionsHandler>(),
- std::make_shared<ServiceHandler>(),
- std::make_shared<SettingHandler>(),
- std::make_shared<SplashScreenHandler>(),
- std::make_shared<TizenApplicationHandler>(),
- std::make_shared<WarpHandler>(),
- std::make_shared<WidgetHandler>(),
- std::make_shared<BackgroundCategoryHandler>()
- };
-
- std::unique_ptr<parser::ManifestHandlerRegistry> registry(
- new parser::ManifestHandlerRegistry(handlers));
-
- parser_.reset(new parser::ManifestParser(std::move(registry)));
-}
-
-std::shared_ptr<const parser::ManifestData> WidgetConfigParser::GetManifestData(
- const std::string& key) {
- // TODO(t.iwanek): replace this method with required getters
- // do not force client to use keyys from application_manifest_constants
- return parser_->GetManifestData(key);
-}
-
-const std::string& WidgetConfigParser::GetErrorMessage() const {
- if (!error_.empty())
- return error_;
- return parser_->GetErrorMessage();
-}
-
-bool WidgetConfigParser::CheckStartFile() {
- std::shared_ptr<const ContentInfo> content_info =
- std::static_pointer_cast<const ContentInfo>(parser_->GetManifestData(
- ContentInfo::Key()));
- if (content_info) {
- const std::string& content = content_info->src();
- // To support any existing applications
- // content as well as tizen:content may be external url
- if (parser::utils::IsValidIRI(content))
- return true;
-
- if (CheckW3CContentSrcExits(widget_path_, content)) {
- // Content is valid
- LOG(INFO) << "Start file is: " << content
- << " type: " << content_info->type()
- << " encoding: " << content_info->encoding();
-
- return true;
- } else {
- // Remove content as it is invalid
- parser_->EraseManifestData(ContentInfo::Key());
- }
- }
-
- if (!CheckStartFileInWidget(widget_path_)) {
- parser_->EraseManifestData(ContentInfo::Key());
- error_ = "Could not find valid start file";
- return false;
- }
- return true;
-}
-
-bool WidgetConfigParser::CheckServicesStartFiles() {
- std::shared_ptr<const ServiceList> service_list =
- std::static_pointer_cast<const ServiceList>(
- parser_->GetManifestData(ServiceInfo::Key()));
- if (!service_list)
- return true;
- for (auto& service_info : service_list->services) {
- bf::path start_file = widget_path_ / service_info.content();
- if (!bf::exists(start_file)) {
- error_ = std::string("Could not find valid service start file: ")
- + start_file.string();
- return false;
- }
- }
- return true;
-}
-
-bool WidgetConfigParser::CheckWidgetIcons() {
- std::shared_ptr<ApplicationIconsInfo> icons_info =
- std::static_pointer_cast<ApplicationIconsInfo>(
- parser_->AccessManifestData(application_widget_keys::kIconsKey));
- if (!icons_info) {
- error_ = "Failed to get icon info";
- return false;
- }
- ApplicationIconsInfo icons;
- // custom icons
- for (auto& icon : icons_info->icons()) {
- bf::path result;
- if (FindFileWithinWidget(widget_path_, icon.path(), &result)
- == FindResult::OK) {
- if (!IsIconMimeTypeSupported(result)) {
- LOG(WARNING) << "Unsupported icon: " << result;
- continue;
- }
- std::string relative =
- result.string().substr(widget_path_.string().size() + 1);
- int width = -1;
- int height = -1;
- icon.GetWidth(&width);
- icon.GetHeight(&height);
- icons.AddIcon(ApplicationIcon(relative, height, width));
- }
- }
- // default icons
- for (auto& icon : kDefaultIconFiles) {
- bf::path result;
- if (FindFileWithinWidget(widget_path_, icon, &result)
- == FindResult::OK) {
- if (!IsIconMimeTypeSupported(result)) {
- LOG(WARNING) << "Unsupported icon: " << result;
- continue;
- }
- std::string relative =
- result.string().substr(widget_path_.string().size() + 1);
- icons.AddIcon(ApplicationIcon(relative));
- }
- }
- for (auto& icon : icons.icons()) {
- LOG(DEBUG) << "Valid icon: " << icon.path();
- int value = 0;
- if (icon.GetWidth(&value))
- LOG(DEBUG) << " with width: " << value;
- if (icon.GetHeight(&value))
- LOG(DEBUG) << " with height: " << value;
- }
- *icons_info = icons;
- return true;
-}
-
-bool WidgetConfigParser::ParseManifest(const boost::filesystem::path& path) {
- widget_path_ = path.parent_path();
- if (!parser_->ParseManifest(path))
- return false;
-
- if (!CheckWidgetIcons())
- return false;
-
- has_valid_start_file_ = CheckStartFile();
- has_valid_services_start_files_ = CheckServicesStartFiles();
-
- return true;
-}
-
-bool WidgetConfigParser::HasValidStartFile() const {
- return has_valid_start_file_;
-}
-
-bool WidgetConfigParser::HasValidServicesStartFiles() const {
- return has_valid_services_start_files_;
-}
-
-} // namespace parse
-} // 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_MANIFEST_HANDLERS_WIDGET_CONFIG_PARSER_H_
-#define WGT_MANIFEST_HANDLERS_WIDGET_CONFIG_PARSER_H_
-
-#include <boost/filesystem/path.hpp>
-
-#include <memory>
-#include <string>
-
-#include "manifest_parser/manifest_parser.h"
-
-namespace wgt {
-namespace parse {
-
-/**
- * @brief The WidgetConfigParser class
- * Parser class of widget's config.xml configuration file.
- *
- * Instance of this class may be used to parse single configuration file.
- * Depending on boolean result of @ref ParseManifest method, client code may
- * call:
- * - on success -> @ref GetManifestData(), passing the key of ManifestData
- * instance that it is interested in.
- * - on failure -> @ref GetErrorMessage(), to get value of error which was set
- * during the processing of config.xml
- *
- * Additional check of presence of start files may be done via calling
- * @ref HasValidStartFile(). This method is extracted separetly as missing start
- * file will not cause the failure of parsing the config.xml file.
- *
- * To investigate which key do you need to get certain parsed piece of data,
- * check the key reported by handler's @ref ManifestHandler::Key() method.
- * Key returned by this method is the key to access data set by handler.
- */
-class WidgetConfigParser {
- public:
- WidgetConfigParser();
-
- std::shared_ptr<const parser::ManifestData> GetManifestData(
- const std::string& key);
- const std::string& GetErrorMessage() const;
- bool ParseManifest(const boost::filesystem::path& path);
- /**
- * @brief HasValidStartFile
- * @return true valid start file exists
- */
- bool HasValidStartFile() const;
- /**
- * @brief HasValidServicesStartFiles
- * @return true if has valid service start files
- */
- bool HasValidServicesStartFiles() const;
-
- private:
- /**
- * @brief CheckStartFile
- * @return true if start file is correct
- */
- bool CheckStartFile();
- /**
- * @brief CheckServicesStartFiles
- * @return true if services start files are correct
- */
- bool CheckServicesStartFiles();
- // This function creates list of icons that are valid disregarding
- // (in actual version) current system's locale as installer do not need to
- // know about it.
- // Edited/Created list is present as kIconsKey key in parser.
- /**
- * @brief CheckWidgetIcons
- * @return true if widget icons are correct
- */
- bool CheckWidgetIcons();
-
- std::unique_ptr<parser::ManifestParser> parser_;
- boost::filesystem::path widget_path_;
- std::string error_;
- bool has_valid_start_file_;
- bool has_valid_services_start_files_;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_WIDGET_CONFIG_PARSER_H_
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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 "wgt_manifest_handlers/widget_handler.h"
-
-#include <string.h>
-
-#include <algorithm>
-#include <cassert>
-#include <map>
-#include <utility>
-#include <set>
-
-#include "manifest_parser/utils/iri_util.h"
-#include "manifest_parser/utils/language_tag_validator.h"
-#include "manifest_parser/utils/logging.h"
-#include "manifest_parser/values.h"
-#include "wgt_manifest_handlers/application_manifest_constants.h"
-
-namespace wgt {
-namespace parse {
-
-namespace {
-const char kWidgetKey[] = "widget";
-
-const char kAuthorKey[] = "widget.author";
-const char kWidgetNamespacePrefix[] = "http://www.w3.org/ns/widgets";
-const char kWidgetNamespaceKey[] = "widget.@namespace";
-const char kAuthorHrefKey[] = "@href";
-const char kAuthorEmailKey[] = "@email";
-const char kVersionKey[] = "widget.@version";
-const char kNameKey[] = "widget.name";
-const char kPreferencesNameKey[] = "@name";
-const char kPreferencesValueKey[] = "@value";
-const char kPreferencesReadonlyKey[] = "@readonly";
-const char kXmlLangKey[] = "@lang";
-const char kXmlHrefKey[] = "@href";
-const char kLicenseKey[] = "widget.license";
-const char kShortKey[] = "@short";
-const char kWidgetLangKey[] = "widget.@lang";
-const char kIDKey[] = "widget.@id";
-const char kHeightKey[] = "widget.@height";
-const char kWidthKey[] = "widget.@width";
-const char kDefaultLocaleKey[] = "widget.@defaultlocale";
-const char kViewModesKey[] = "widget.@viewmodes";
-const char kPreferencesKey[] = "widget.preference";
-const char kXmlTextKey[] = "#text";
-const char kDescriptionKey[] = "widget.description";
-
-bool ParserPreferenceItem(const parser::Value* val, Preference** output,
- std::string* error) {
- const parser::DictionaryValue* pref_dict;
- if (!val->GetAsDictionary(&pref_dict)) {
- *error = "Parsing preference element failed";
- return false;
- }
- std::string name;
- std::string value;
- std::string readonly = "false";
- pref_dict->GetString(kPreferencesNameKey, &name);
- pref_dict->GetString(kPreferencesValueKey, &value);
- pref_dict->GetString(kPreferencesReadonlyKey, &readonly);
- *output = new Preference(name, value, readonly == "true");
- return true;
-}
-
-} // namespace
-
-void WidgetHandler::ParseSingleLocalizedLicenseElement(
- const parser::DictionaryValue* item_dict, const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info) {
- bool lang_overwriten = false;
- std::string lang;
- std::string text;
- std::string href;
-
- if (item_dict->HasKey(kXmlLangKey)) {
- lang_overwriten = true;
- item_dict->GetString(kXmlLangKey, &lang);
- if (!utils::w3c_languages::ValidateLanguageTag(lang)) {
- LOG(ERROR) << "Tag " << lang << " is invalid";
- return;
- }
- }
- if (item_dict->HasKey(kXmlHrefKey)) {
- item_dict->GetString(kXmlHrefKey, &href);
- }
- item_dict->GetString(kXmlTextKey, &text);
- // TODO(w.kosowicz) check where href should be put...
- if (lang_overwriten) {
- info->license_set_.insert(std::make_pair(lang, text + href));
- } else {
- info->license_set_.insert(std::make_pair(parent_lang, text + href));
- }
-}
-
-void WidgetHandler::ParseLocalizedLicenseElements(
- const parser::Manifest& manifest, const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info) {
- if (!manifest.HasPath(kLicenseKey)) return;
-
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- if (manifest.Get(kLicenseKey, &val)) {
- if (val->GetAsDictionary(&dict)) {
- if (parser::VerifyElementNamespace(*dict, kWidgetNamespacePrefix))
- ParseSingleLocalizedLicenseElement(dict, parent_lang, info);
- } else if (val->GetAsList(&list)) {
- for_each(list->begin(), list->end(),
- [list, &dict, parent_lang, info, this](parser::Value* item) {
- if (item->GetAsDictionary(&dict))
- if (parser::VerifyElementNamespace(*dict, kWidgetNamespacePrefix))
- ParseSingleLocalizedLicenseElement(dict, parent_lang, info);
- });
- }
- }
-}
-
-void WidgetHandler::ParseSingleLocalizedDescriptionElement(
- const parser::DictionaryValue* item_dict, const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info) {
- bool lang_overwriten = false;
- std::string lang;
- std::string text;
-
- if (item_dict->HasKey(kXmlLangKey)) {
- lang_overwriten = true;
- item_dict->GetString(kXmlLangKey, &lang);
- if (!utils::w3c_languages::ValidateLanguageTag(lang)) {
- LOG(ERROR) << "Tag " << lang << " is invalid";
- return;
- }
- }
- item_dict->GetString(kXmlTextKey, &text);
- if (lang_overwriten) {
- info->description_set_.insert(std::make_pair(lang, text));
- } else {
- info->description_set_.insert(std::make_pair(parent_lang, text));
- }
-}
-
-void WidgetHandler::ParseLocalizedDescriptionElements(
- const parser::Manifest& manifest, const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info) {
- if (!manifest.HasPath(kDescriptionKey)) return;
-
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- if (manifest.Get(kDescriptionKey, &val)) {
- if (val->GetAsDictionary(&dict)) {
- if (parser::VerifyElementNamespace(*dict, kWidgetNamespacePrefix))
- ParseSingleLocalizedDescriptionElement(dict, parent_lang, info);
- } else if (val->GetAsList(&list)) {
- for (auto& item : *list)
- if (item->GetAsDictionary(&dict))
- if (parser::VerifyElementNamespace(*dict, kWidgetNamespacePrefix))
- ParseSingleLocalizedDescriptionElement(dict, parent_lang, info);
- }
- }
-}
-
-void WidgetHandler::ParseSingleLocalizedNameElement(
- const parser::DictionaryValue* item_dict, const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info) {
- bool lang_overwriten = false;
- std::string lang;
- std::string name;
- std::string short_name;
-
- if (item_dict->HasKey(kXmlLangKey)) {
- lang_overwriten = true;
- item_dict->GetString(kXmlLangKey, &lang);
- if (!utils::w3c_languages::ValidateLanguageTag(lang)) {
- LOG(ERROR) << "Tag " << lang << " is invalid";
- return;
- }
- }
- if (item_dict->HasKey(kShortKey)) {
- item_dict->GetString(kShortKey, &short_name);
- }
- item_dict->GetString(kXmlTextKey, &name);
-
- // ignore if given language already spotted
- if (info->name_set_.find(lang) != info->name_set_.end()) return;
-
- if (lang_overwriten) {
- info->name_set_.insert(std::make_pair(lang, name));
- if (!short_name.empty())
- info->short_name_set_.insert(std::make_pair(lang, short_name));
- } else {
- info->name_set_.insert(std::make_pair(parent_lang, name));
- if (!short_name.empty())
- info->short_name_set_.insert(std::make_pair(parent_lang, short_name));
- }
-}
-
-void WidgetHandler::ParseLocalizedNameElements(
- const parser::Manifest& manifest, const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info) {
- if (!manifest.HasPath(kNameKey)) return;
-
- const parser::Value* val = nullptr;
- const parser::DictionaryValue* dict = nullptr;
- const parser::ListValue* list = nullptr;
- if (manifest.Get(kNameKey, &val)) {
- if (val->GetAsDictionary(&dict)) {
- if (parser::VerifyElementNamespace(*dict, kWidgetNamespacePrefix))
- ParseSingleLocalizedNameElement(dict, parent_lang, info);
- } else if (val->GetAsList(&list)) {
- for (auto& item : *list)
- if (item->GetAsDictionary(&dict))
- if (parser::VerifyElementNamespace(*dict, kWidgetNamespacePrefix))
- ParseSingleLocalizedNameElement(dict, parent_lang, info);
- }
- }
-}
-
-void WidgetHandler::ParseSingleAuthorElement(
- const parser::DictionaryValue* author_dict,
- std::shared_ptr<WidgetInfo> info) {
- author_dict->GetString(kXmlTextKey, &info->author_);
- author_dict->GetString(kAuthorEmailKey, &info->author_email_);
- std::string author_href;
- author_dict->GetString(kAuthorHrefKey, &author_href);
- if (!author_href.empty() && parser::utils::IsValidIRI(author_href))
- info->author_href_ = author_href;
-}
-
-void WidgetHandler::ParseAuthorElements(const parser::Manifest& manifest,
- std::shared_ptr<WidgetInfo> info) {
- if (manifest.HasPath(kAuthorKey)) {
- const parser::Value* author_value = nullptr;
- manifest.Get(kAuthorKey, &author_value);
-
- auto& authors = parser::GetOneOrMany(manifest.value(), kAuthorKey,
- kWidgetNamespacePrefix);
- if (!authors.empty())
- ParseSingleAuthorElement(authors[0], info);
- }
-}
-
-bool WidgetHandler::Parse(const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) {
- std::shared_ptr<WidgetInfo> widget_info(new WidgetInfo());
- widget_info->preferences_ = std::vector<Preference*>();
-
- std::string parent_lang;
-
- if (manifest.HasPath(kWidgetNamespaceKey)) {
- manifest.GetString(kWidgetNamespaceKey, &widget_info->widget_namespace_);
- manifest.GetString(kWidgetLangKey, &parent_lang);
- }
-
- if (widget_info->widget_namespace_ != kWidgetNamespacePrefix) {
- *error = "Wrong namespace of <widget> element. Config.xml is invalid";
- return false;
- }
-
- ParseAuthorElements(manifest, widget_info);
-
- ParseLocalizedDescriptionElements(manifest, parent_lang, widget_info);
- ParseLocalizedNameElements(manifest, parent_lang, widget_info);
- ParseLocalizedLicenseElements(manifest, parent_lang, widget_info);
-
- if (manifest.HasPath(kVersionKey))
- manifest.GetString(kVersionKey, &widget_info->version_);
- if (manifest.HasPath(kIDKey)) {
- std::string id;
- manifest.GetString(kIDKey, &id);
- if (!id.empty() && parser::utils::IsValidIRI(id)) widget_info->id_ = id;
- }
- if (manifest.HasPath(kHeightKey)) {
- int h;
- manifest.GetInteger(kHeightKey, &h);
- widget_info->height_ = static_cast<unsigned int>(h);
- }
- if (manifest.HasPath(kWidthKey)) {
- int w;
- manifest.GetInteger(kWidthKey, &w);
- widget_info->width_ = static_cast<unsigned int>(w);
- }
- if (manifest.HasPath(kDefaultLocaleKey))
- manifest.GetString(kDefaultLocaleKey, &widget_info->default_locale_);
- if (manifest.HasPath(kViewModesKey))
- manifest.GetString(kViewModesKey, &widget_info->viewmodes_);
-
- for (auto& pref_dict : parser::GetOneOrMany(manifest.value(),
- kPreferencesKey,
- kWidgetNamespacePrefix)) {
- Preference* preference = nullptr;
- if (!ParserPreferenceItem(pref_dict, &preference, error))
- return false;
- widget_info->preferences_.push_back(preference);
- }
-
- *output = std::static_pointer_cast<parser::ManifestData>(widget_info);
- return true;
-}
-
-bool WidgetHandler::Validate(const parser::ManifestData& data,
- const parser::ManifestDataMap& /*handlers_output*/,
- std::string* error) const {
- const WidgetInfo& widget_info = static_cast<const WidgetInfo&>(data);
- if (widget_info.widget_namespace() != kWidgetNamespacePrefix) {
- *error = "The widget namespace is invalid.";
- return false;
- }
- return true;
-}
-
-
-std::string WidgetHandler::Key() const {
- return kWidgetKey;
-}
-
-std::string WidgetInfo::Key() {
- return kWidgetKey;
-}
-
-} // namespace parse
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Copyright (c) 2015 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_WIDGET_HANDLER_H_
-#define WGT_MANIFEST_HANDLERS_WIDGET_HANDLER_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "manifest_parser/manifest_handler.h"
-#include "manifest_parser/values.h"
-
-namespace wgt {
-namespace parse {
-
-class Preference {
- public:
- Preference(const std::string& name, const std::string& value,
- bool readonly)
- : name_(name),
- value_(value),
- readonly_(readonly) {}
-
- std::string Name() const { return name_; }
- std::string Value() const { return value_; }
- bool ReadOnly() const { return readonly_; }
- private:
- std::string name_;
- std::string value_;
- bool readonly_;
-};
-
-typedef std::map<std::string, std::string> LangValMap;
-
-class WidgetInfo : public parser::ManifestData {
- public:
- WidgetInfo() {}
- WidgetInfo(const WidgetInfo&) = delete;
- WidgetInfo& operator=(const WidgetInfo&) = delete;
- virtual ~WidgetInfo() {
- for (auto p : preferences_)
- delete p;
- }
- static std::string Key();
-
- const LangValMap& name_set() const { return name_set_; }
- const LangValMap& short_name_set() const { return short_name_set_; }
- const LangValMap& description_set() const { return description_set_; }
- const LangValMap& license_set() const { return license_set_; }
-
- const std::string& id() const { return id_; }
- const std::string& version() const { return version_; }
- const std::string& view_modes() const { return viewmodes_; }
- const std::string& default_locale() const { return default_locale_; }
- const std::string& author() const { return author_; }
- const std::string& author_email() const { return author_email_; }
- const std::string& author_href() const { return author_href_; }
- const std::string& widget_namespace() const { return widget_namespace_; }
- const std::vector<Preference*>& preferences() const { return preferences_; }
- unsigned int height() const { return height_; }
- unsigned int width() const { return width_; }
-
- private:
- std::vector<Preference*> preferences_;
- std::string id_;
- std::string version_;
- std::string viewmodes_;
- std::string default_locale_;
- std::string author_;
- LangValMap description_set_;
- LangValMap name_set_;
- LangValMap short_name_set_;
- LangValMap license_set_;
- std::string author_email_;
- std::string author_href_;
- std::string widget_namespace_;
- unsigned int height_;
- unsigned int width_;
-
- friend class WidgetHandler;
-};
-
-/**
- * @brief The WidgetHandler class
- *
- * Handler of config.xml for root xml element <w3c:widget>.
- * Children parsed within this handlers:
- * - <w3c:author>,
- * - <w3c:description>,
- * - <w3c:license>,
- * - <w3c:name>,
- * - <w3c:preference>.
- *
- * Code parsing rest of children is located in other handlers.
- */
-class WidgetHandler : public parser::ManifestHandler {
- public:
- WidgetHandler() {}
- virtual ~WidgetHandler() {}
-
- bool Parse(
- const parser::Manifest& manifest,
- std::shared_ptr<parser::ManifestData>* output,
- std::string* error) override;
- bool AlwaysParseForKey() const override { return true; }
- std::string Key() const override;
- /**
- * @brief ParseSingleLocalizedLicenseElement parses single license element
- * @param item_dict
- * @param parent_lang
- * @param info
- */
- void ParseSingleLocalizedLicenseElement(
- const parser::DictionaryValue* item_dict,
- const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseLocalizedLicenseElements parser localized element
- * @param manifest
- * @param parent_lang
- * @param info
- */
- void ParseLocalizedLicenseElements(
- const parser::Manifest& manifest,
- const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseSingleLocalizedDescriptionElement parses
- * single localized description
- * @param item_dict
- * @param parent_lang
- * @param info
- */
- void ParseSingleLocalizedDescriptionElement(
- const parser::DictionaryValue* item_dict,
- const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseLocalizedDescriptionElements parses localized description
- * element
- * @param manifest
- * @param parent_lang
- * @param info
- */
- void ParseLocalizedDescriptionElements(
- const parser::Manifest& manifest,
- const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseSingleLocalizedNameElement parses single localized name
- * @param item_dict
- * @param parent_lang
- * @param info
- */
- void ParseSingleLocalizedNameElement(
- const parser::DictionaryValue* item_dict,
- const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseLocalizedNameElements parses localized name
- * @param manifest
- * @param parent_lang
- * @param info
- */
- void ParseLocalizedNameElements(
- const parser::Manifest& manifest,
- const std::string& parent_lang,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseAuthorElements parses author element
- * @param manifest
- * @param info
- */
- void ParseAuthorElements(
- const parser::Manifest& manifest,
- std::shared_ptr<WidgetInfo> info);
- /**
- * @brief ParseSingleAuthorElement parses single author element
- * @param author_dict
- * @param info
- */
- void ParseSingleAuthorElement(
- const parser::DictionaryValue* author_dict,
- std::shared_ptr<WidgetInfo> info);
-
- bool Validate(
- const parser::ManifestData& data,
- const parser::ManifestDataMap& handlers_output,
- std::string* error) const override;
-};
-
-} // namespace parse
-} // namespace wgt
-
-#endif // WGT_MANIFEST_HANDLERS_WIDGET_HANDLER_H_