From 016feb213f6f7e563ac1fcece618b6ef4e333711 Mon Sep 17 00:00:00 2001 From: Soyoung Kim Date: Tue, 23 Oct 2012 13:50:45 +0900 Subject: [PATCH] merge test --- CMakeLists.txt | 14 +- debian/changelog | 129 ++++++++ etc/wrt_commons_reset_db.sh | 4 +- .../encryption/src/resource_decryption.cpp | 2 +- .../encryption/src/resource_encryption.cpp | 2 +- modules/localization/config.cmake | 2 + .../include/LanguageTagsProvider.h | 81 +++++ .../dpl/localization/localization_utils.h | 8 +- .../dpl/localization/w3c_file_localization.h | 13 +- .../localization/src/LanguageTagsProvider.cpp | 152 ++++++++++ .../localization/src/localization_utils.cpp | 72 +---- .../src/w3c_file_localization.cpp | 74 +++-- modules/log/include/dpl/log/log.h | 3 - modules/log/src/log.cpp | 12 - .../include/dpl/test/test_results_collector.h | 1 - modules/test/include/dpl/test/test_runner.h | 42 +-- modules/test/src/test_results_collector.cpp | 12 +- modules/test/src/test_runner.cpp | 191 ++++++++---- modules/utils/config.cmake | 2 + modules/utils/include/dpl/utils/bash_utils.h | 38 +++ modules/utils/include/dpl/utils/file_utils.h | 1 + .../include/dpl/utils/wrt_global_settings.h | 8 +- modules/utils/include/dpl/utils/wrt_utility.h | 120 ++++---- modules/utils/src/bash_utils.cpp | 47 +++ modules/utils/src/file_utils.cpp | 10 + modules/utils/src/wrt_global_settings.cpp | 64 +++- modules/utils/src/wrt_utility.cpp | 280 +++++++++--------- modules/widget_dao/CMakeLists.txt | 1 + modules/widget_dao/dao/feature_dao.cpp | 43 +++ .../widget_dao/dao/feature_dao_read_only.cpp | 34 +++ modules/widget_dao/dao/plugin_dao.cpp | 33 +++ modules/widget_dao/dao/widget_dao.cpp | 49 ++- .../widget_dao/dao/widget_dao_read_only.cpp | 71 ++++- .../include/dpl/wrt-dao-ro/common_dao_types.h | 8 + .../dpl/wrt-dao-ro/config_parser_data.h | 3 +- .../dpl/wrt-dao-ro/feature_dao_read_only.h | 3 + .../include/dpl/wrt-dao-ro/feature_model.h | 5 + .../include/dpl/wrt-dao-ro/global_config.h | 16 +- .../dpl/wrt-dao-ro/widget_dao_read_only.h | 41 ++- .../include/dpl/wrt-dao-ro/wrt_db_types.h | 1 + .../include/dpl/wrt-dao-rw/feature_dao.h | 1 + .../include/dpl/wrt-dao-rw/plugin_dao.h | 2 + .../include/dpl/wrt-dao-rw/widget_dao.h | 15 +- modules/widget_dao/orm/wrt_db | 39 ++- packaging/wrt-commons.spec | 22 +- wrt-commons.manifest | 12 + 46 files changed, 1315 insertions(+), 468 deletions(-) create mode 100644 modules/localization/include/LanguageTagsProvider.h create mode 100644 modules/localization/src/LanguageTagsProvider.cpp create mode 100644 modules/utils/include/dpl/utils/bash_utils.h create mode 100644 modules/utils/src/bash_utils.cpp create mode 100644 wrt-commons.manifest diff --git a/CMakeLists.txt b/CMakeLists.txt index cd2d925..35ebc04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,9 +44,17 @@ ADD_DEFINITIONS("-DGLOBAL_SETTINGS_CONTROL") IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release") ENDIF(NOT CMAKE_BUILD_TYPE) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") -SET(CMAKE_CXX_FLAGS "-O2 -g -fPIC -D_FORTIFY_SOURCE=0") -SET(CMAKE_CXX_FLAGS_CCOV "-O0 -g -fPIC -D_FORTIFY_SOURCE=0 --coverage") + +# Compiler flags +SET(CMAKE_C_FLAGS_PROFILING "-O0 -g -pg") +SET(CMAKE_CXX_FLAGS_PROFILING "-O0 -std=c++0x -g -pg") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++0x -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x -g") +SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++0x -g --coverage") + +ADD_DEFINITIONS("-fPIC") # If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC. (BJ: our ARM too?) # CMake settings MESSAGE(STATUS "========================================") diff --git a/debian/changelog b/debian/changelog index dbc7c88..e1c3083 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,132 @@ +wrt-commons (0.2.66) unstable; urgency=low + + * Release wrt-commons_0.2.66 + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.66 + + -- Soyoung Kim Thu, 18 Oct 2012 11:33:54 +0900 + +wrt-commons (0.2.65) unstable; urgency=low + + * [Engine] Add method to get widget list + * [Commons] New utility functions in wrt_utility + * [Commons] Escaping bash sequences in argument programs + * [Engine] Allow to call methods using dao pointer + * [Engine] Remove mutex from log system. + * [Engine] Support for authors certificates (part 4). + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.65 + + -- Soyoung Kim Wed, 17 Oct 2012 22:08:33 +0900 + +wrt-commons (0.2.64) unstable; urgency=low + + * Revert "Localization cleaning from unused API" + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.64 + + -- Jihoon Chung Fri, 12 Oct 2012 14:21:43 +0900 + +wrt-commons (0.2.63) unstable; urgency=low + + * Support for authors certificate + * WidgetDAO new CTOR (based on TizenID) + * Localization related cleanup + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.63 + + -- Pawel Sikorski Thu, 11 Oct 2012 12:53:19 +0200 + +wrt-commons (0.2.62) unstable; urgency=low + + * [Engine] Add license installing + * [Engine] clean up .gitignore + + * Git : slp/pkgs/w/wrt-commons + * Tag : wrt-commons_0.2.62 + + -- Jihoon Chung Thu, 11 Oct 2012 08:02:04 +0900 + +wrt-commons (0.2.61) unstable; urgency=low + + * [Commons] Support for Debug and Release build configuration + * Deprecated localization API removal + * Localization refactoring and cleaning + * [Commons] Refactoring featureDAO, pluginDAO table + + * Git : slp/pkgs/w/wrt-commons + * Tag : wrt-commons_0.2.61 + + -- Jihoon Chung Fri, 05 Oct 2012 07:29:49 +0900 + +wrt-commons (0.2.60) unstable; urgency=low + + * for SEL verification + * [Commons] POWDER remains removed + * [Commons] Fixed PLM P120926-3287 + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.60 + + -- Soyoung Kim Fri, 28 Sep 2012 15:27:25 +0900 + +wrt-commons (0.2.59) unstalbe; urgency=low + + * Add smack manifest + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.59 + + -- Tae-Jeong Lee Thu, 20 Sep 2012 20:08:44 +0900 + +wrt-commons (0.2.58) unstalbe; urgency=low + + * for SEL verification + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.58 + + -- Tae-Jeong Lee Thu, 20 Sep 2012 12:02:41 +0900 + +wrt-commons (0.2.57) unstalbe; urgency=low + + * Proper list support in LanguageTagsProvider + * User Agent Database update + * Language tags providing class added + * Add a feature dao function giving requested features' data + + * Git : framework/web/wrt-commons + * Tag : wrt-commons_0.2.57 + + -- Tae-Jeong Lee Wed, 19 Sep 2012 12:03:09 +0900 + +wrt-commons (0.2.56) unstalbe; urgency=low + + * [Commons] Test mode environment variable changed + + * Git : slp/pkgs/w/wrt-commons + * Tag : wrt-commons_0.2.56 + + -- Jihoon Chung Wed, 12 Sep 2012 15:46:28 +0900 + +wrt-commons (0.2.55) unstable; urgency=low + + * [Commons] Table ExternalFiles renamed to ExternalLocations + * [Commons] Fix in base path removal in localization module. + * [Commons] Add multiple output types in test framework + * [Commons] Slash added to global config paths + * [Commons] Background page support in WidgetModel + * [Commons] New table - WidgetExternalFiles + + * Git : slp/pkgs/w/wrt-commons + * Tag : wrt-commons_0.2.55 + + -- Yunchan Cho Thu, 06 Sep 2012 00:34:12 +0900 + wrt-commons (0.2.54) unstable; urgency=low * [common] Add XML test collector diff --git a/etc/wrt_commons_reset_db.sh b/etc/wrt_commons_reset_db.sh index 3016223..bc536a5 100755 --- a/etc/wrt_commons_reset_db.sh +++ b/etc/wrt_commons_reset_db.sh @@ -14,13 +14,13 @@ # limitations under the License. # -rm -rf /opt/apps/widget/system/* +rm -rf /opt/share/widget/system/* #Removing of widget desktop icons WIDGET_EXEC_PATH=/opt/apps/ WIDGET_DESKTOP_PATH=/opt/share/applications/ WRT_DB=/opt/dbspace/.wrt.db -PLUGINS_INSTALLATION_REQUIRED_PATH=/opt/apps/widget/ +PLUGINS_INSTALLATION_REQUIRED_PATH=/opt/share/widget/ PLUGINS_INSTALLATION_REQUIRED=plugin-installation-required if [ -f ${WRT_DB} ] diff --git a/modules/encryption/src/resource_decryption.cpp b/modules/encryption/src/resource_decryption.cpp index 499d82e..e8f1590 100644 --- a/modules/encryption/src/resource_decryption.cpp +++ b/modules/encryption/src/resource_decryption.cpp @@ -28,7 +28,7 @@ namespace { inline std::string GetDefaultEncryptKeyPath() { - return "/opt/apps/widget/data/"; + return "/opt/share/widget/data/"; } } namespace WRTDecryptor{ diff --git a/modules/encryption/src/resource_encryption.cpp b/modules/encryption/src/resource_encryption.cpp index 62201bf..8f6de46 100644 --- a/modules/encryption/src/resource_encryption.cpp +++ b/modules/encryption/src/resource_encryption.cpp @@ -30,7 +30,7 @@ const char* ENCRYPTION_FILE = "_enc"; const char* DECRYPTION_FILE = "_dec"; inline std::string GetDefaultEncryptKeyPath() { - return "/opt/apps/widget/data"; + return "/opt/share/widget/data"; } } namespace WRTEncryptor{ diff --git a/modules/localization/config.cmake b/modules/localization/config.cmake index 5f52e6f..218cb71 100644 --- a/modules/localization/config.cmake +++ b/modules/localization/config.cmake @@ -22,6 +22,7 @@ SET(DPL_LOCALIZATION_SOURCES ${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp ${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp + ${PROJECT_SOURCE_DIR}/modules/localization/src/LanguageTagsProvider.cpp PARENT_SCOPE ) @@ -29,6 +30,7 @@ SET(DPL_LOCALIZATION_SOURCES SET(DPL_LOCALIZATION_HEADERS ${PROJECT_SOURCE_DIR}/modules/localization/include/dpl/localization/localization_utils.h ${PROJECT_SOURCE_DIR}/modules/localization/include/dpl/localization/w3c_file_localization.h + ${PROJECT_SOURCE_DIR}/modules/localization/include/LanguageTagsProvider.h PARENT_SCOPE ) diff --git a/modules/localization/include/LanguageTagsProvider.h b/modules/localization/include/LanguageTagsProvider.h new file mode 100644 index 0000000..c32d0fe --- /dev/null +++ b/modules/localization/include/LanguageTagsProvider.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file LanguageTagsProvider.h + * @author Marcin Kaminski (marcin.ka@samsung.com) + * @version 1.0 + */ + +#ifndef LANGUAGETAGSPROVIDER_H +#define LANGUAGETAGSPROVIDER_H + +#include +#include +#include +#include + +typedef std::list LanguageTags; + +class LanguageTagsProvider { + +public: + /* + * Get list of currently set language tags + */ + const LanguageTags getLanguageTags() const; + + /* + * Set new language tags (other than based on system locales) + */ + void setLanguageTags(const LanguageTags& taglist ); + + /* + * Set language tags from given locales. + * Supported format is: xx[-yy[-zz]][.encoding] + */ + void setLanguageTagsFromLocales(const char* locales); + + /* + * Set language tags based on system language settings + */ + void resetLanguageTags(); + + /* + * Function converts language tag string (i.e. en-US) + * into locales string (en_US). + */ + static DPL::String BCP47LanguageTagToLocale(const DPL::String&); + + /* + * Function converts locales string (i.e. en_US.UTF-8) into language tag (i.e. en-US) + */ + static DPL::String LocaleToBCP47LanguageTag(const DPL::String&); + +private: + friend class DPL::Singleton; + + LanguageTags m_languageTagsList; + + LanguageTagsProvider(); + virtual ~LanguageTagsProvider(); + + void loadSystemTags(); + void createTagsFromLocales(const char* language); +}; + +typedef DPL::Singleton LanguageTagsProviderSingleton; + +#endif /* LANGUAGETAGSPROVIDER_H */ diff --git a/modules/localization/include/dpl/localization/localization_utils.h b/modules/localization/include/dpl/localization/localization_utils.h index 8130838..ed72233 100644 --- a/modules/localization/include/dpl/localization/localization_utils.h +++ b/modules/localization/include/dpl/localization/localization_utils.h @@ -73,14 +73,12 @@ struct WidgetStartFileInfo }; typedef DPL::Optional OptionalWidgetIcon; -typedef std::list LanguageTagsList; typedef DPL::Optional OptionalWidgetStartFileInfo; namespace LocalizationUtils { -DPL::String BCP47LanguageTagToLocale(const DPL::String&); -DPL::String LocaleToBCP47LanguageTag(const DPL::String&); +/* Function below is deprecated - please use static functions of LanguageTagsProvider: + * BCP47LanguageTagToLocale() and LocaleToBCP47LanguageTag() */ +DPL::String BCP47LanguageTagToLocale(const DPL::String&) __attribute__((deprecated)); -void SetSystemLanguageTags(const LanguageTagsList& tags); -LanguageTagsList GetUserAgentLanguageTags(); } #endif //LOCALIZATION_UTILS_H diff --git a/modules/localization/include/dpl/localization/w3c_file_localization.h b/modules/localization/include/dpl/localization/w3c_file_localization.h index 156923c..7f26a5b 100644 --- a/modules/localization/include/dpl/localization/w3c_file_localization.h +++ b/modules/localization/include/dpl/localization/w3c_file_localization.h @@ -37,24 +37,23 @@ typedef std::list WidgetIconList; DPL::Optional getFilePathInWidgetPackageFromUrl( WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagsList &languageTags, const DPL::String &url); DPL::Optional getFilePathInWidgetPackage( WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagsList &languageTags, const DPL::String& file); -DPL::OptionalString getStartFile(WrtDB::DbWidgetHandle widgetHandle); +DPL::OptionalString getStartFile(WrtDB::DbWidgetHandle handle); +DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao); OptionalWidgetIcon getIcon(WrtDB::DbWidgetHandle widgetHandle); WidgetIconList getValidIconsList( - WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagsList &languageTags); + WrtDB::DbWidgetHandle widgetHandle); OptionalWidgetStartFileInfo getStartFileInfo( - WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagsList &tagsList); + WrtDB::DbWidgetHandle widgetHandle); + WrtDB::WidgetLocalizedInfo getLocalizedInfo(WrtDB::DbWidgetHandle widgetHandle); +WrtDB::WidgetLocalizedInfo getLocalizedInfo(WrtDB::WidgetDAOReadOnlyPtr dao); } #endif //W3C_FILE_LOCALIZATION_H diff --git a/modules/localization/src/LanguageTagsProvider.cpp b/modules/localization/src/LanguageTagsProvider.cpp new file mode 100644 index 0000000..69e6d41 --- /dev/null +++ b/modules/localization/src/LanguageTagsProvider.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file LanguageTagsProvider.cpp + * @author Marcin Kaminski (marcin.ka@samsung.com) + * @version 1.0 + */ + +#include "LanguageTagsProvider.h" + +#include +#include +#include +#include +#include +#include +IMPLEMENT_SINGLETON(LanguageTagsProvider) + +/* ========== public ========== */ +const LanguageTags LanguageTagsProvider::getLanguageTags() const +{ + return m_languageTagsList; +} + +void LanguageTagsProvider::setLanguageTags(const LanguageTags& taglist) +{ + m_languageTagsList = taglist; + /* If given list does not contain default values ("en" and empty string) + * than append them to the list. + * In case of empty list given as parameter only two default values + * will exist on m_languageTagsList. */ + DPL::String tofind = L"en"; + if(std::find(m_languageTagsList.begin(), m_languageTagsList.end(), + tofind) == m_languageTagsList.end()) { + m_languageTagsList.push_back(L"en"); + } + tofind = L""; + if(std::find(m_languageTagsList.begin(), m_languageTagsList.end(), + tofind) == m_languageTagsList.end()) { + m_languageTagsList.push_back(L""); + } +} + +void LanguageTagsProvider::setLanguageTagsFromLocales(const char* locales) +{ + LogDebug("Setting new language tags for locales " << locales); + this->createTagsFromLocales(locales); +} + +void LanguageTagsProvider::resetLanguageTags() +{ + this->loadSystemTags(); +} + +DPL::String LanguageTagsProvider::BCP47LanguageTagToLocale(const DPL::String& inLanguageTag) +{ + DPL::String languageTag(inLanguageTag); + /* Replace all */ + std::replace(languageTag.begin(), languageTag.end(), '-', '_'); + return languageTag; +} + +DPL::String LanguageTagsProvider::LocaleToBCP47LanguageTag(const DPL::String& inLocaleString) +{ + /* Cut off codepage information from given string (if any exists) + * i.e. change en_US.UTF-8 into en_US */ + DPL::String localeString = inLocaleString.substr( + 0, inLocaleString.find_first_of(L".")); + /* Replace all '_' with '-' */ + std::replace(localeString.begin(), localeString.end(), '_', '-'); + return localeString; +} + +/* ========== private ========== */ +LanguageTagsProvider::LanguageTagsProvider() +{ + LogDebug("Creating LanguageTagsProvider instance"); + this->loadSystemTags(); +} + +LanguageTagsProvider::~LanguageTagsProvider() +{ +} + +void LanguageTagsProvider::loadSystemTags() +{ + char* language = vconf_get_str(VCONFKEY_LANGSET); + if(!language) { + LogError("Failed to get language from vconf"); + } + else { + LogDebug("Language fetched from vconf: " << language); + } + createTagsFromLocales(language); + free(language); +} + +void LanguageTagsProvider::createTagsFromLocales(const char* language) +{ + m_languageTagsList.clear(); + if(!language) { + LogDebug("Setting default language tags"); + /* If NULL language given than set default language tags + * and return. */ + m_languageTagsList.push_back(L"en"); + m_languageTagsList.push_back(L""); + return; + } + + LogDebug("Setting tags for language: " << language); + DPL::String langdescr = LocaleToBCP47LanguageTag(DPL::FromUTF8String(language)); + + size_t position; + if(langdescr.empty()) { + LogError("Empty language description while correct value needed"); + } + else { + /* Language tags list should not be cleared before this place to + * avoid losing current data when new data are invalid */ + while (true) { + LogDebug("Processing language description: " << langdescr); + m_languageTagsList.push_back(langdescr); + + position = langdescr.find_last_of(L"-"); + if (position == DPL::String::npos) { + break; + } + langdescr = langdescr.substr(0, position); + } + } + /* If current content of langdescr (thus last added added tag) + * is not "en" then add english as default locales. + * "en" and empty tag are added even when langdescr is not valid. */ + if (langdescr.compare(L"en") != 0){ + m_languageTagsList.push_back(L"en"); + } + /* Add empty tag for non-localized content */ + m_languageTagsList.push_back(L""); +} diff --git a/modules/localization/src/localization_utils.cpp b/modules/localization/src/localization_utils.cpp index c463276..ab48743 100644 --- a/modules/localization/src/localization_utils.cpp +++ b/modules/localization/src/localization_utils.cpp @@ -20,83 +20,15 @@ */ #include - -#include -#include +#include namespace LocalizationUtils { -static LanguageTagsList m_systemLanguageTags; -static LanguageTagsList m_languageTags; -static DPL::ReadWriteMutex m_readWriteMutex; - -template -void FindAndReplace(StringType& source, - const StringType& find, - const StringType& replace) -{ - size_t pos = 0; - while ((pos = source.find(find, pos)) != StringType::npos) { - source.replace(pos, find.length(), replace); - pos += replace.length(); - } -} DPL::String BCP47LanguageTagToLocale(const DPL::String& inLanguageTag) { DPL::String languageTag(inLanguageTag); - FindAndReplace(languageTag, DPL::String(L"-"), DPL::String(L"_")); + std::replace(languageTag.begin(), languageTag.end(), '-', '_'); return languageTag; } -DPL::String LocaleToBCP47LanguageTag(const DPL::String& inLocaleString) -{ - DPL::String localeString = inLocaleString.substr( - 0, - inLocaleString. - find_first_of(L".")); - FindAndReplace(localeString, DPL::String(L"_"), DPL::String(L"-")); - return localeString; -} - -void UpdateUserAgentLanguageTags() -{ - // WARNING!!!!! This function shall be called - // only when mutex is locked in readWriteMode! - - m_languageTags.clear(); - - FOREACH(i, m_systemLanguageTags) { - DPL::String tag = LocaleToBCP47LanguageTag(*i); - while (true) { //W3C Packaging 9. Step 5. 2. D - if (tag.empty()) { continue; } - - LogDebug("Adding user locale '" << tag << "'"); - m_languageTags.push_back(tag); - - size_t subtagPos = tag.find_last_of(L"-"); - if (subtagPos == DPL::String::npos) { - break; - } - tag = tag.substr(0, subtagPos); - } - } - - m_languageTags.push_back(L"en"); - m_languageTags.push_back(L""); -} - -void SetSystemLanguageTags(const LanguageTagsList& tags) -{ - DPL::ReadWriteMutex::ScopedWriteLock lock(&m_readWriteMutex); - if (m_systemLanguageTags != tags) { - m_systemLanguageTags = tags; - UpdateUserAgentLanguageTags(); - } -} - -LanguageTagsList GetUserAgentLanguageTags() -{ - DPL::ReadWriteMutex::ScopedReadLock lock(&m_readWriteMutex); - return m_languageTags; -} } diff --git a/modules/localization/src/w3c_file_localization.cpp b/modules/localization/src/w3c_file_localization.cpp index c0b4161..8e91255 100644 --- a/modules/localization/src/w3c_file_localization.cpp +++ b/modules/localization/src/w3c_file_localization.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -33,20 +34,24 @@ #include #include +#include + using namespace WrtDB; namespace { const DPL::String FILE_URI_BEGIN = L"file://"; const DPL::String WIDGET_URI_BEGIN = L"widget://"; +const DPL::String LOCALE_PREFIX = L"locales/"; DPL::Optional GetFilePathInWidgetPackageInternal( - const LanguageTagsList &tags, const std::string& basePath, std::string filePath) { LogDebug("Looking for file: " << filePath << " in: " << basePath); using namespace LocalizationUtils; + const LanguageTags& ltags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); + //Check if string isn't empty if (filePath.size() == 0) { return DPL::Optional::Null; } //Removing preceding '/' @@ -54,10 +59,10 @@ DPL::Optional GetFilePathInWidgetPackageInternal( //Check if string isn't empty if (filePath.size() == 0) { return DPL::Optional::Null; } - LogDebug("locales size = " << tags.size()); - for (LanguageTagsList::const_iterator it = tags.begin(); - it != tags.end(); - ++it) { + LogDebug("locales size = " << ltags.size()); + for (LanguageTags::const_iterator it = ltags.begin(); + it != ltags.end(); + ++it) { LogDebug("Trying locale: " << *it); std::string path = basePath; if (path[path.size() - 1] == '/') { @@ -84,13 +89,11 @@ DPL::Optional GetFilePathInWidgetPackageInternal( } DPL::Optional GetFilePathInWidgetPackageInternal( - const LanguageTagsList &languageTags, const DPL::String& basePath, const DPL::String& filePath) { DPL::Optional path = - GetFilePathInWidgetPackageInternal(languageTags, - DPL::ToUTF8String(basePath), + GetFilePathInWidgetPackageInternal(DPL::ToUTF8String(basePath), DPL::ToUTF8String(filePath)); DPL::Optional dplPath; if (!!path) { @@ -103,7 +106,6 @@ DPL::Optional GetFilePathInWidgetPackageInternal( namespace W3CFileLocalization { DPL::Optional getFilePathInWidgetPackageFromUrl( DbWidgetHandle widgetHandle, - const LanguageTagsList &languageTags, const DPL::String &url) { DPL::String req = url; @@ -116,6 +118,15 @@ DPL::Optional getFilePathInWidgetPackageFromUrl( if (req.find(dao.getPath()) == 0) { req.erase(0, dao.getPath().length()); } + if (req.find(LOCALE_PREFIX) == 0) { + req.erase(0, LOCALE_PREFIX.length()); + int position = req.find('/'); + // should always be >0 as correct locales path is + // always locales/xx/ or locales/xx-XX/ + if (position != std::string::npos && position > 0) { + req.erase(0, position+1); + } + } } else { LogDebug("Unknown path format, ignoring"); return DPL::Optional::Null; @@ -124,7 +135,7 @@ DPL::Optional getFilePathInWidgetPackageFromUrl( auto widgetPath = dao.getPath(); DPL::Optional found = - GetFilePathInWidgetPackageInternal(languageTags, widgetPath, req); + GetFilePathInWidgetPackageInternal(widgetPath, req); if (!found) { LogError("Path not found within current locale in current widget"); @@ -138,24 +149,26 @@ DPL::Optional getFilePathInWidgetPackageFromUrl( DPL::Optional getFilePathInWidgetPackage( WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagsList &languageTags, const DPL::String& file) { WidgetDAOReadOnly dao(widgetHandle); - return GetFilePathInWidgetPackageInternal(languageTags, dao.getPath(), file); + return GetFilePathInWidgetPackageInternal(dao.getPath(), file); } -DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle widgetHandle) +DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle handle) { - using namespace LocalizationUtils; + return getStartFile(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(handle))); +} - WidgetDAOReadOnly dao(widgetHandle); +DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao) +{ + using namespace LocalizationUtils; - WidgetDAOReadOnly::LocalizedStartFileList locList = dao.getLocalizedStartFileList(); - WidgetDAOReadOnly::WidgetStartFileList list = dao.getStartFileList(); - LanguageTagsList tagsList = LocalizationUtils::GetUserAgentLanguageTags(); + WidgetDAOReadOnly::LocalizedStartFileList locList = dao->getLocalizedStartFileList(); + WidgetDAOReadOnly::WidgetStartFileList list = dao->getStartFileList(); + LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags(); - DPL::OptionalString defaultLoc = dao.getDefaultlocale(); + DPL::OptionalString defaultLoc = dao->getDefaultlocale(); if (!!defaultLoc) { tagsList.push_back(*defaultLoc); } @@ -185,7 +198,7 @@ OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle) WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList(); WidgetDAOReadOnly::WidgetIconList list = dao.getIconList(); - LanguageTagsList tagsList = LocalizationUtils::GetUserAgentLanguageTags(); + LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags(); DPL::OptionalString defaultLoc = dao.getDefaultlocale(); if (!!defaultLoc) { @@ -215,8 +228,7 @@ OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle) } WidgetIconList getValidIconsList( - WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagsList &languageTags) + WrtDB::DbWidgetHandle widgetHandle) { using namespace LocalizationUtils; WidgetDAOReadOnly dao(widgetHandle); @@ -228,7 +240,6 @@ WidgetIconList getValidIconsList( { LogDebug(":" << it->iconSrc); if (!!getFilePathInWidgetPackage(widgetHandle, - languageTags, it->iconSrc)) { WidgetIcon ret; @@ -242,8 +253,7 @@ WidgetIconList getValidIconsList( } OptionalWidgetStartFileInfo getStartFileInfo( - WrtDB::DbWidgetHandle widgetHandle, - const LanguageTagList &tagsList) + WrtDB::DbWidgetHandle widgetHandle) { using namespace LocalizationUtils; @@ -253,6 +263,7 @@ OptionalWidgetStartFileInfo getStartFileInfo( WidgetDAOReadOnly::LocalizedStartFileList locList = dao.getLocalizedStartFileList(); WidgetDAOReadOnly::WidgetStartFileList list = dao.getStartFileList(); + const LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags(); FOREACH(tag, tagsList) { @@ -284,10 +295,13 @@ OptionalWidgetStartFileInfo getStartFileInfo( WidgetLocalizedInfo getLocalizedInfo(const WrtDB::DbWidgetHandle handle) { - LanguageTagList languages = - LocalizationUtils::GetUserAgentLanguageTags(); - WidgetDAOReadOnly dao(handle); - DPL::OptionalString dl = dao.getDefaultlocale(); + return getLocalizedInfo(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(handle))); +} + +WidgetLocalizedInfo getLocalizedInfo(WidgetDAOReadOnlyPtr dao) +{ + LanguageTags languages = LanguageTagsProviderSingleton::Instance().getLanguageTags(); + DPL::OptionalString dl = dao->getDefaultlocale(); if (!!dl) { languages.push_back(*dl); } @@ -295,7 +309,7 @@ WidgetLocalizedInfo getLocalizedInfo(const WrtDB::DbWidgetHandle handle) WidgetLocalizedInfo result; FOREACH(i, languages) { - WidgetLocalizedInfo languageResult = dao.getLocalizedInfo(*i); + WidgetLocalizedInfo languageResult = dao->getLocalizedInfo(*i); #define OVERWRITE_IF_NULL(FIELD) if (!result.FIELD) { \ result.FIELD = languageResult.FIELD; \ diff --git a/modules/log/include/dpl/log/log.h b/modules/log/include/dpl/log/log.h index c9564bb..7be5c9d 100644 --- a/modules/log/include/dpl/log/log.h +++ b/modules/log/include/dpl/log/log.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -45,8 +44,6 @@ class LogSystem : private Noncopyable { private: - ReadWriteMutex m_spinLock; - typedef std::list AbstractLogProviderPtrList; AbstractLogProviderPtrList m_providers; diff --git a/modules/log/src/log.cpp b/modules/log/src/log.cpp index b03ab61..b24970a 100644 --- a/modules/log/src/log.cpp +++ b/modules/log/src/log.cpp @@ -140,52 +140,40 @@ void LogSystem::SetTag(const char* tag) void LogSystem::AddProvider(AbstractLogProvider *provider) { - ReadWriteMutex::ScopedWriteLock lock(&m_spinLock); m_providers.push_back(provider); } void LogSystem::RemoveProvider(AbstractLogProvider *provider) { - ReadWriteMutex::ScopedWriteLock lock(&m_spinLock); m_providers.remove(provider); } void LogSystem::Debug(const char *message, const char *filename, int line, const char *function) { - ReadWriteMutex::ScopedReadLock lock(&m_spinLock); - for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator) (*iterator)->Debug(message, filename, line, function); } void LogSystem::Info(const char *message, const char *filename, int line, const char *function) { - ReadWriteMutex::ScopedReadLock lock(&m_spinLock); - for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator) (*iterator)->Info(message, filename, line, function); } void LogSystem::Warning(const char *message, const char *filename, int line, const char *function) { - ReadWriteMutex::ScopedReadLock lock(&m_spinLock); - for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator) (*iterator)->Warning(message, filename, line, function); } void LogSystem::Error(const char *message, const char *filename, int line, const char *function) { - ReadWriteMutex::ScopedReadLock lock(&m_spinLock); - for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator) (*iterator)->Error(message, filename, line, function); } void LogSystem::Pedantic(const char *message, const char *filename, int line, const char *function) { - ReadWriteMutex::ScopedReadLock lock(&m_spinLock); - for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator) (*iterator)->Pedantic(message, filename, line, function); } diff --git a/modules/test/include/dpl/test/test_results_collector.h b/modules/test/include/dpl/test/test_results_collector.h index 6c4e24b..cf8fa4e 100644 --- a/modules/test/include/dpl/test/test_results_collector.h +++ b/modules/test/include/dpl/test/test_results_collector.h @@ -52,7 +52,6 @@ class TestResultsCollectorBase NONE, FAILED, IGNORED, - TODO, INTERNAL }; }; diff --git a/modules/test/include/dpl/test/test_runner.h b/modules/test/include/dpl/test/test_runner.h index ab1a626..a4db750 100644 --- a/modules/test/include/dpl/test/test_runner.h +++ b/modules/test/include/dpl/test/test_runner.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace DPL { @@ -39,9 +40,12 @@ namespace Test { class TestRunner { - TestResultsCollectorBasePtr m_collector; - std::string m_collectorName; + typedef std::map + TestResultsCollectors; + TestResultsCollectors m_collectors; + std::string m_startTestId; + bool m_runIgnored; public: typedef void (*TestCase)(); @@ -82,15 +86,21 @@ private: DPL::Atomic m_totalAssertions; void Banner(); - void InvalidArgs(); + void InvalidArgs(const std::string& message = "Invalid arguments!"); void Usage(); - enum Status { FAILED, TODO, IGNORED, PASS }; + enum Status { FAILED, IGNORED, PASS }; Status RunTestCase(const TestCaseStruct& testCase); void RunTests(); + void CollectResult(const std::string& id, + const std::string& description, + const TestResultsCollectorBase::FailStatus::Type status + = TestResultsCollectorBase::FailStatus::NONE, + const std::string& reason = std::string()); + public: class TestFailed { @@ -116,27 +126,6 @@ public: } }; - class ToDo - { - private: - std::string m_message; - - public: - ToDo() - { - } - - ToDo(const std::string &message) - : m_message(message) - { - } - - std::string GetMessage() const - { - return m_message; - } - }; - class Ignored { private: @@ -166,6 +155,7 @@ public: int ExecTestRunner(int argc, char *argv[]); typedef std::vector ArgsList; int ExecTestRunner(const ArgsList& args); + bool getRunIgnored() const; }; typedef DPL::Singleton TestRunnerSingleton; @@ -211,8 +201,6 @@ do #define RUNNER_FAIL RUNNER_ASSERT(false) -#define RUNNER_TODO_MSG(message) do { std::ostringstream assertMsg; assertMsg << message; throw DPL::Test::TestRunner::ToDo(assertMsg.str()); } while (0) - #define RUNNER_IGNORED_MSG(message) do { std::ostringstream assertMsg; assertMsg << message; throw DPL::Test::TestRunner::Ignored(assertMsg.str()); } while (0) #endif // DPL_TEST_RUNNER_H diff --git a/modules/test/src/test_results_collector.cpp b/modules/test/src/test_results_collector.cpp index e36e868..4a91712 100644 --- a/modules/test/src/test_results_collector.cpp +++ b/modules/test/src/test_results_collector.cpp @@ -427,11 +427,12 @@ class XmlCollector // Show result FOREACH(group, m_groupsStats) { PrintStats(group->first, group->second); + size_t posBegin = m_outputBuffer.find("", posBegin); + m_outputBuffer.erase(posBegin - 3, posEnd - posBegin + sizeof("") + 2); } - size_t posBegin = m_outputBuffer.find("", posBegin); - m_outputBuffer.erase(posBegin - 3, posEnd - posBegin + sizeof("") + 2); + remove(m_filename.c_str()); m_fp.Reset(fopen (m_filename.c_str(), "w")); Assert(!!m_fp && "File handle must not be null"); @@ -482,8 +483,9 @@ class XmlCollector default: Assert(false && "Bad status"); } - size_t pos = m_outputBuffer.find("CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::FAILED, - e.GetMessage()); + CollectResult(testCase.name, + "", + TestResultsCollectorBase::FailStatus::FAILED, + e.GetMessage()); return FAILED; } catch (const Ignored &e) { - // Simple test have to be implemented - m_collector->CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::IGNORED, - e.GetMessage()); + if (m_runIgnored) { + // Simple test have to be implemented + CollectResult(testCase.name, + "", + TestResultsCollectorBase::FailStatus::IGNORED, + e.GetMessage()); + } return IGNORED; } - catch (const ToDo &e) - { - // Simple test have to be implemented - m_collector->CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::TODO, - e.GetMessage()); - - return TODO; - } catch (const DPL::Exception &e) { // DPL exception failure - m_collector->CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::INTERNAL, - "DPL exception:" + - e.GetMessage()); + CollectResult(testCase.name, + "", + TestResultsCollectorBase::FailStatus::INTERNAL, + "DPL exception:" + e.GetMessage()); return FAILED; } catch (const std::exception &) { // std exception failure - m_collector->CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::INTERNAL, - "std exception"); + CollectResult(testCase.name, + "", + TestResultsCollectorBase::FailStatus::INTERNAL, + "std exception"); return FAILED; } catch (...) { // Unknown exception failure - m_collector->CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::INTERNAL, - "unknown exception"); + CollectResult(testCase.name, + "", + TestResultsCollectorBase::FailStatus::INTERNAL, + "unknown exception"); return FAILED; } - m_collector->CollectResult(testCase.name, - "", - TestResultsCollectorBase::FailStatus::NONE); + CollectResult(testCase.name, + "", + TestResultsCollectorBase::FailStatus::NONE); + // Everything OK return PASS; } @@ -169,13 +161,25 @@ void TestRunner::RunTests() using namespace DPL::Colors::Text; Banner(); - m_collector->Start(); + std::for_each(m_collectors.begin(), + m_collectors.end(), + [](const TestResultsCollectors::value_type& collector) + { + collector.second->Start(); + }); fprintf(stderr, "%s%s%s\n", GREEN_BEGIN, "Running tests...", GREEN_END); FOREACH(group, m_testGroups) { TestCaseStructList list = group->second; if (!list.empty()) { - m_collector->CollectCurrentTestGroupName(group->first); + std::for_each( + m_collectors.begin(), + m_collectors.end(), + [&group](const TestResultsCollectors::value_type& collector) + { + collector.second-> + CollectCurrentTestGroupName(group->first); + }); list.sort(); for (TestCaseStructList::const_iterator iterator = list.begin(); @@ -193,11 +197,34 @@ void TestRunner::RunTests() } } - m_collector->Finish(); + std::for_each(m_collectors.begin(), + m_collectors.end(), + [](const TestResultsCollectors::value_type& collector) + { + collector.second->Finish(); + }); + // Finished fprintf(stderr, "%s%s%s\n\n", GREEN_BEGIN, "Finished", GREEN_END); } +void TestRunner::CollectResult( + const std::string& id, + const std::string& description, + const TestResultsCollectorBase::FailStatus::Type status, + const std::string& reason) +{ + std::for_each(m_collectors.begin(), + m_collectors.end(), + [&](const TestResultsCollectors::value_type& collector) + { + collector.second->CollectResult(id, + description, + status, + reason); + }); +} + void TestRunner::Banner() { using namespace DPL::Colors::Text; @@ -214,13 +241,13 @@ void TestRunner::Banner() GREEN_END); } -void TestRunner::InvalidArgs() +void TestRunner::InvalidArgs(const std::string& message) { using namespace DPL::Colors::Text; fprintf(stderr, "%s%s%s\n", BOLD_RED_BEGIN, - "Invalid parameters!", + message.c_str(), BOLD_RED_END); } @@ -228,25 +255,36 @@ void TestRunner::Usage() { fprintf(stderr, "Usage: runner [options]\n\n"); fprintf(stderr, "Output type:\n"); - fprintf(stderr, " --output=\n"); - fprintf(stderr, " possible output types:\n"); + fprintf(stderr, " --output= --output= ...\n"); + fprintf(stderr, "\n possible output types:\n"); FOREACH (type, TestResultsCollectorBase::GetCollectorsNames()) { - fprintf(stderr, " --output=%s\n", type->c_str()); + fprintf(stderr, " --output=%s\n", type->c_str()); } + fprintf(stderr, "\n example:\n"); + fprintf(stderr, " test-binary --output=text --output=xml --file=output.xml\n\n"); fprintf(stderr, "Other parameters:\n"); fprintf(stderr, " --regexp='regexp'\t Only selected tests" " which names match regexp run\n\n"); fprintf(stderr, " --start=\tStart from concrete test id"); fprintf(stderr, " --group=\t Run tests only from one group\n"); + fprintf(stderr, " --runignored\t Run also ignored tests\n"); fprintf(stderr, " --list\t Show a list of Test IDs\n"); fprintf(stderr, " --listgroups\t Show a list of Test Group names \n"); fprintf(stderr, " --listingroup=\t Show a list of Test IDS in one group\n"); fprintf(stderr, " --help\t This help\n\n"); - if (m_collector) { - fprintf(stderr, "Output %s has specific args:\n", m_collectorName.c_str()); - fprintf(stderr, "%s\n", m_collector->CollectorSpecificHelp().c_str()); - } + std::for_each(m_collectors.begin(), + m_collectors.end(), + [](const TestResultsCollectors::value_type& collector) + { + fprintf(stderr, + "Output %s has specific args:\n", + collector.first.c_str()); + fprintf(stderr, + "%s\n", + collector.second-> + CollectorSpecificHelp().c_str()); + }); fprintf(stderr, "For bug reporting, please write to:\n"); fprintf(stderr, "\n"); } @@ -268,6 +306,7 @@ void TestRunner::MarkAssertion() int TestRunner::ExecTestRunner(const ArgsList& value) { + m_runIgnored = false; ArgsList args = value; // Parse command line if (args.size() == 1) @@ -281,6 +320,8 @@ int TestRunner::ExecTestRunner(const ArgsList& value) bool showHelp = false; + TestResultsCollectorBasePtr currentCollector; + // Parse each argument FOREACH(it, args) { @@ -288,13 +329,21 @@ int TestRunner::ExecTestRunner(const ArgsList& value) const std::string regexp = "--regexp="; const std::string output = "--output="; const std::string groupId = "--group="; + const std::string runIgnored = "--runignored"; const std::string listCmd = "--list"; const std::string startCmd = "--start="; const std::string listGroupsCmd = "--listgroups"; const std::string listInGroup = "--listingroup="; - if (m_collector && m_collector->ParseCollectorSpecificArg(arg)) continue; - else if (arg.find(startCmd) == 0) + if (currentCollector) + { + if (currentCollector->ParseCollectorSpecificArg(arg)) + { + continue; + } + } + + if (arg.find(startCmd) == 0) { arg.erase(0, startCmd.length()); FOREACH(group, m_testGroups) { @@ -328,6 +377,10 @@ int TestRunner::ExecTestRunner(const ArgsList& value) return -1; } } + else if (arg == runIgnored) + { + m_runIgnored = true; + } else if (arg == listCmd) { FOREACH(group, m_testGroups) { @@ -357,14 +410,19 @@ int TestRunner::ExecTestRunner(const ArgsList& value) else if (arg.find(output) == 0) { arg.erase(0, output.length()); - m_collector.Reset(TestResultsCollectorBase::Create(arg)); - if (!m_collector) { - InvalidArgs(); + if (m_collectors.find(arg) != m_collectors.end()) + { + InvalidArgs("Multiple outputs of the same type are not supported!"); Usage(); return -1; - } else { - m_collectorName = arg; } + currentCollector.Reset(TestResultsCollectorBase::Create(arg)); + if (!currentCollector) { + InvalidArgs("Unsupported output type!"); + Usage(); + return -1; + } + m_collectors[arg] = currentCollector; } else if (arg.find(regexp) == 0) { @@ -410,6 +468,8 @@ int TestRunner::ExecTestRunner(const ArgsList& value) } } + currentCollector.Reset(); + // Show help if (showHelp) { @@ -417,12 +477,20 @@ int TestRunner::ExecTestRunner(const ArgsList& value) return 0; } - if (!m_collector) - m_collector.Reset(TestResultsCollectorBase::Create("text")); + if (m_collectors.empty()) + { + TestResultsCollectorBasePtr collector( + TestResultsCollectorBase::Create("text")); + m_collectors["text"] = collector; + } - if (!m_collector->Configure()) { - fprintf(stderr, "Could not configure selected output"); - return 0; + for (auto it = m_collectors.begin(); it != m_collectors.end(); ++it) + { + if (!it->second->Configure()) + { + fprintf(stderr, "Could not configure selected output"); + return 0; + } } // Run tests @@ -431,5 +499,10 @@ int TestRunner::ExecTestRunner(const ArgsList& value) return 0; } +bool TestRunner::getRunIgnored() const +{ + return m_runIgnored; +} + } } // namespace DPL diff --git a/modules/utils/config.cmake b/modules/utils/config.cmake index 4c65949..ac46c1e 100644 --- a/modules/utils/config.cmake +++ b/modules/utils/config.cmake @@ -20,6 +20,7 @@ # SET(DPL_UTILS_SOURCES + ${PROJECT_SOURCE_DIR}/modules/utils/src/bash_utils.cpp ${PROJECT_SOURCE_DIR}/modules/utils/src/file_utils.cpp ${PROJECT_SOURCE_DIR}/modules/utils/src/folder_size.cpp ${PROJECT_SOURCE_DIR}/modules/utils/src/mime_type_utils.cpp @@ -32,6 +33,7 @@ SET(DPL_UTILS_SOURCES SET(DPL_UTILS_HEADERS + ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/bash_utils.h ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/file_utils.h ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/folder_size.h ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/mime_type_utils.h diff --git a/modules/utils/include/dpl/utils/bash_utils.h b/modules/utils/include/dpl/utils/bash_utils.h new file mode 100644 index 0000000..1eb2ba9 --- /dev/null +++ b/modules/utils/include/dpl/utils/bash_utils.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file bash_utils.h + * @author Iwanek Tomasz + * @version 1.0 + */ + +#ifndef BASH_UTILS_H +#define BASH_UTILS_H + +#include + +namespace BashUtils { + +/** + * Escapes bash special characters in string and return string in double quotes + * @param source string to be escaped + * @return escaped string + */ +std::string escape_arg(const std::string & source); + +} + +#endif // BASH_UTILS_H diff --git a/modules/utils/include/dpl/utils/file_utils.h b/modules/utils/include/dpl/utils/file_utils.h index 4248f70..9936fd6 100644 --- a/modules/utils/include/dpl/utils/file_utils.h +++ b/modules/utils/include/dpl/utils/file_utils.h @@ -34,6 +34,7 @@ DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDirectoryException) DECLARE_EXCEPTION_TYPE(DPL::Exception, RemoveDirectoryException) bool FileExists(const DPL::String& absolutePath); +bool DirectoryExists(const DPL::String& absolutePath); /** * Creates specified path recursively. diff --git a/modules/utils/include/dpl/utils/wrt_global_settings.h b/modules/utils/include/dpl/utils/wrt_global_settings.h index f012542..35fabb3 100644 --- a/modules/utils/include/dpl/utils/wrt_global_settings.h +++ b/modules/utils/include/dpl/utils/wrt_global_settings.h @@ -25,8 +25,14 @@ namespace GlobalSettings { -// Methods for getting/setting test mode environment flag +// Methods for getting test mode environment flag bool TestModeEnabled(); +bool PopupsTestModeEnabled(); +bool WarpTestModeEnabled(); +bool RoamingTestModeEnabled(); +bool OCSPTestModeEnabled(); +bool CrlTestModeEnabled(); +bool MakeScreenTestModeEnabled(); bool IsEmulator(); } diff --git a/modules/utils/include/dpl/utils/wrt_utility.h b/modules/utils/include/dpl/utils/wrt_utility.h index 30f8114..35b700c 100644 --- a/modules/utils/include/dpl/utils/wrt_utility.h +++ b/modules/utils/include/dpl/utils/wrt_utility.h @@ -25,26 +25,19 @@ #define _WRT_UTILITY_H_ #include +#include #ifdef __cplusplus extern "C" { #endif -#ifndef MAX_WIDGET_PATH_LENGTH -#define MAX_WIDGET_PATH_LENGTH 1024 -#endif - /** * File options */ enum { - WRT_FILEUTILS_PRESERVE_STATUS = 1, - WRT_FILEUTILS_PRESERVE_SYMLINKS = 2, - WRT_FILEUTILS_RECUR = 4, - WRT_FILEUTILS_FORCE = 8, - WRT_FILEUTILS_INTERACTIVE = 16 + WRT_FILEUTILS_RECUR = 4 //this is the default for almost all WrtMakeDir calls (once called with 0) }; /** @@ -61,51 +54,16 @@ bool _WrtUtilSetAbsolutePath(char* absolutePath, const char* fileName); /** - * Change the string to bool value,no case sensitive, e.x., "true" or "1" to ture; "False" or "0" to false. - * - * @param[in] value - * @param[out] result - * - * @return if success, return true; or return false. - */ -// KW bool _WrtUtilConvertStrToBool(char* value, bool *result); - -/** - * Get the dir path and file name from the full path. e.x., "/opt/lib/filename" as fullPath, "/opt/lib/" as dirName, "filename" as fileName. - * it's necessary to free *dirName or *fileName if either of them is not NULL. - * - * @param[in] fullPath - * @param[out] dirName - * @param[out] fileName - * - * @return - */ -void _WrtUtilGetDirAndFileName(const char* fullPath, - char** dirName, - char** fileName); - -#if 0 -/** - * Change the provided string into lower case, caller should allocate the memory of source and dest. - * - * @param[in] source the source string to be changed - * @param[out] dest the dest string with lower case - * - * return if success, return true, or return false. - */ -bool _WrtUtilStringToLower(const char* source, - char* dest); -#endif - -/** - * Compare two string, no case sensitive. + * Joins two paths into one * - * @param[in] srcStr - * @param[in] destStr + * @param[out] joined String for storing joined paths + * @param[in] parent String containing the first part of path + * @param[in] child String containing the second part of the path * - * return return true if the two strings are identical, or return false. + * Data stored in joined before the function call will be replaced with joined + * paths. */ -// KW bool _WrtUtilStringCmp(const char* srcStr, const char* destStr); +void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child); /** * This function is used to make a directory. @@ -123,14 +81,18 @@ bool _WrtMakeDir (const char *path, int flags); /** - * This function is used to change to specified directory. - * If the directory does not exist, it will create it directly. + * Creates directories specified by path * - * @param[in] path Specified the directory path + * @param[in] path Path to create + * @param[in] mode access flags, default to 0755 + * @return true on success, false on failure * - * @return TRUE on success or FALSE on failure. + * Function creates directory specified by path argument and all directories + * leading up to it, if they don't exist. Note that if yout wish to create + * several nested directories, you must make sure that the mode flag allows you + * to write and search the direcotries you create. */ -bool _WrtUtilChangeDir(const char* path); +bool WrtUtilMakeDir(const std::string &newpath, mode_t mode=0755); /** * This function is used to remove a directory from the file system. @@ -141,15 +103,14 @@ bool _WrtUtilChangeDir(const char* path); */ bool _WrtUtilRemoveDir(const char* path); -// KW /** -// KW * This function is used to make a temp directory in root directory. -// KW * -// KW * @param[in] root Specified the root directory -// KW * -// KW * @return if fails, return NULL, else return the temp path. -// KW * it's necessary to free the returned memory space. -// KW */ -// KW char* _WrtUtilMakeTempDir(const char* root); +/** + * This function removes the directory or file pointed to by path + * + * @param[in] path Path to the file/directory to be deleted + * + * @return true on success, false otherwise + */ +bool WrtUtilRemove(const std::string &path); /** * This function is used to convert a string to lowercase. @@ -162,6 +123,35 @@ bool _WrtUtilRemoveDir(const char* path); bool _WrtUtilStringToLower(const char* str, char** lowerStr); +/** + * This function converts a string to lowercase + * + * @param[in] in the string to be converted + * @param[out] out the string for placing converted values in + * + * The previous data stored in string out will be replaced with converted + * string from string in + */ +void WrtUtilStringToLower(std::string &out, const std::string &in); + +/** + * Checks if path exists and is a regular file + * + * @param[in] path the string representing path to check + * + * @return true if regular file is accessible under path, false otherwise + */ +bool WrtUtilFileExists(const std::string &path); + +/** + * Checks if path exists and is a directory + * + * @param[in] path the string representing path to check + * + * @return true if directory is accessible under path, false otherwise + */ +bool WrtUtilDirExists(const std::string &path); + #ifdef __cplusplus } #endif diff --git a/modules/utils/src/bash_utils.cpp b/modules/utils/src/bash_utils.cpp new file mode 100644 index 0000000..5796bc6 --- /dev/null +++ b/modules/utils/src/bash_utils.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file bash_utils.cpp + * @author Iwanek Tomasz + * @version 1.0 + */ + +#include +#include + +#include + +namespace BashUtils { + +std::string escape_arg(const std::string & source) +{ + static const std::string special("!$`\\\""); + std::string ret = "\""; + for(std::string::const_iterator iter = source.begin(); iter != source.end(); ++iter) + { + if(special.find(*iter) != std::string::npos) + { + ret += std::string("\\") + *iter; + } + else + { + ret += *iter; + } + } + return ret + "\""; +} + +} diff --git a/modules/utils/src/file_utils.cpp b/modules/utils/src/file_utils.cpp index e5100df..2ca4f1f 100644 --- a/modules/utils/src/file_utils.cpp +++ b/modules/utils/src/file_utils.cpp @@ -141,6 +141,16 @@ bool FileExists(const DPL::String& absolutePath) } } +bool DirectoryExists(const DPL::String& absolutePath) +{ + struct stat statStruct; + if (stat(DPL::ToUTF8String(absolutePath).c_str(), &statStruct) == 0) { + return S_ISDIR(statStruct.st_mode); + } else { + return false; + } +} + void MakePath(const std::string& path, mode_t mode) { diff --git a/modules/utils/src/wrt_global_settings.cpp b/modules/utils/src/wrt_global_settings.cpp index a0877f6..1a420f7 100644 --- a/modules/utils/src/wrt_global_settings.cpp +++ b/modules/utils/src/wrt_global_settings.cpp @@ -23,12 +23,22 @@ #include #include #include +#include #include #include namespace GlobalSettings { namespace { +const int ROAMING_TEST = 0x00000001; +const int POPUPS_TEST = 0x00000002; +const int OCSP_TEST = 0x00000004; +const int WARP_TEST = 0x00000008; +const int CRL_TEST = 0x00000010; +const int SCREEN_SHOT_TEST = 0x00000020; +const int ALL_TEST = (ROAMING_TEST | POPUPS_TEST | OCSP_TEST | WARP_TEST + | CRL_TEST | SCREEN_SHOT_TEST); +const char* WRT_TEST_MODE = "WRT_TEST_MODE"; const char* MACHINE_NAME_EMUL = "emulated"; // "arch_emulated" enum MachineType { @@ -38,12 +48,11 @@ enum MachineType }; struct Settings { - bool testMode; + int testModes; bool isEmulator; Settings() - : testMode(false), - isEmulator(false) + : isEmulator(false), testModes(0) {} }; @@ -81,8 +90,32 @@ bool initializeGlobalSettings() // ignore environment variables if this flag is not set #ifdef GLOBAL_SETTINGS_CONTROL - const char *env = getenv("WRT_TEST_MODE"); - gSettings.testMode = (env != NULL && 0 == strncmp(env, "1", 1)); + char * envStr = getenv(WRT_TEST_MODE); + int testMode = 0; + if (NULL != envStr) { + std::string env = envStr; + if ("1" == env) { + testMode = ALL_TEST; + } else { + std::istringstream str(envStr); + while (std::getline(str, env, '|')) { + if ("popups" == env) { + testMode |= POPUPS_TEST; + } else if ("roaming" == env) { + testMode |= ROAMING_TEST;; + } else if ("ocsp" == env) { + testMode |= OCSP_TEST;; + } else if ("warp" == env) { + testMode |= WARP_TEST;; + } else if ("crl" == env) { + testMode |= CRL_TEST; + } else if ("screen" == env) { + testMode |= SCREEN_SHOT_TEST;; + } + } + } + gSettings.testModes = testMode; + } // TODO other settings initialization #endif @@ -93,7 +126,26 @@ bool initializeGlobalSettings() bool TestModeEnabled() { - return gSettings.testMode; + return ((gSettings.testModes & ALL_TEST) == ALL_TEST); +} + +bool PopupsTestModeEnabled() { + return (gSettings.testModes & POPUPS_TEST); +} +bool WarpTestModeEnabled() { + return (gSettings.testModes & WARP_TEST); +} +bool RoamingTestModeEnabled() { + return (gSettings.testModes & ROAMING_TEST); +} +bool OCSPTestModeEnabled() { + return (gSettings.testModes & OCSP_TEST); +} +bool CrlTestModeEnabled() { + return (gSettings.testModes & CRL_TEST); +} +bool MakeScreenTestModeEnabled() { + return (gSettings.testModes & SCREEN_SHOT_TEST); } bool IsEmulator() diff --git a/modules/utils/src/wrt_utility.cpp b/modules/utils/src/wrt_utility.cpp index 756e00c..e922211 100644 --- a/modules/utils/src/wrt_utility.cpp +++ b/modules/utils/src/wrt_utility.cpp @@ -21,24 +21,21 @@ * @brief This file implemented some common functions for widget manager */ -#include #include -#include -#include -#include #include -#include -#include -#include #include #include +#include #include #include #include #include -using namespace std; +#ifndef MAX_WIDGET_PATH_LENGTH +#define MAX_WIDGET_PATH_LENGTH 1024 +#endif +//will be replaced by WrtUtilJoinPaths bool _WrtUtilSetAbsolutePath(char* absolutePath, const char* parentPath, const char* fileName) @@ -78,125 +75,22 @@ bool _WrtUtilSetAbsolutePath(char* absolutePath, return true; } -// KW bool _WrtUtilConvertStrToBool(char* value, bool *result) -// KW { -// KW bool ret = false; -// KW if (NULL == value || NULL == result) -// KW { -// KW return ret; -// KW } -// KW -// KW char* source = value; -// KW char* changed = (char*)malloc(strlen(value) + 1); -// KW if (NULL == changed) -// KW { -// KW return ret; -// KW } -// KW memset(changed, 0, strlen(value) + 1); -// KW -// KW char* cur = changed; -// KW while(*source) -// KW { -// KW *cur++ = tolower(*source++); -// KW } -// KW if (!strcmp(changed,"false") || !strcmp(changed,"0")) -// KW { -// KW *result = false; -// KW ret = true; -// KW } -// KW else if(!strcmp(changed,"true") || !strcmp(changed,"1")) -// KW { -// KW *result = true; -// KW ret = true; -// KW } -// KW free(changed); -// KW -// KW return ret; -// KW } - -void _WrtUtilGetDirAndFileName(const char* fullPath, - char** dirName, - char** fileName) +void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child) { - int length = 0; - int index = 0; - if (NULL == fullPath || (NULL == dirName && NULL == fileName)) { - return; - } + size_t parent_len = parent.length();; + joined=parent; + joined+=child; + //In case someone used windows-style paths + std::replace(joined.begin(), joined.end(), '\\', '/'); - length = strlen(fullPath); - for (index = length - 1; index >= 0; index--) { - if ('/' == fullPath[index]) { - if (index == length - 1) { - LogDebug(" Warning: The end of directroy is '/'! "); - if (dirName) { - *dirName = (char*)malloc(sizeof(char) * (length + 1)); - if (*dirName != NULL) { - memset(*dirName, 0, sizeof(char) * (length + 1)); - strncpy(*dirName, fullPath, length); - } - } - return; - } - break; - } - } - if (index >= 0) { - if (dirName) { - int dirName_len = index + 2; - - *dirName = (char*)malloc(sizeof(char) * dirName_len); - if (*dirName != NULL) { - memset(*dirName, 0, sizeof(char) * dirName_len); - strncpy(*dirName, fullPath, dirName_len - 1); - } - } - - if (fileName) { - int fileName_len = length - index; - - *fileName = (char*)malloc(sizeof(char) * fileName_len); - if (*fileName != NULL) { - memset(*fileName, 0, sizeof(char) * fileName_len); - strncpy(*fileName, &fullPath[index + 1], fileName_len - 1); - } - } - } else { - if (fileName) { - *fileName = (char*)malloc(sizeof(char) * (length + 1)); - if (*fileName != NULL) { - memset(*fileName, 0, sizeof(char) * (length + 1)); - strncpy(*fileName, fullPath, length); - } - } + if (parent_len != 0 && child.length() != 0) { + if (joined[parent_len-1] != '/' && joined[parent_len] != '/') + joined.insert(parent_len, "/"); + else if (joined[parent_len-1] == '/' && joined[parent_len] == '/') + joined.erase(parent_len, 1); } } -// KW bool _WrtUtilStringCmp(const char* srcStr, const char* destStr) -// KW { -// KW bool ret = false; -// KW char* strString = NULL; -// KW char* destString = NULL; -// KW -// KW if (NULL == srcStr || NULL == destStr ) -// KW { -// KW return ret; -// KW } -// KW -// KW _WrtUtilStringToLower(srcStr, &strString); -// KW _WrtUtilStringToLower(destStr,&destString); -// KW -// KW if(!strcmp(strString, destString)) -// KW { -// KW ret = true; -// KW } -// KW -// KW free(strString); -// KW free(destString); -// KW -// KW return ret; -// KW } - // check it deeply later. bool _WrtMakeDir (const char *path, long mode, @@ -244,28 +138,32 @@ bool _WrtMakeDir (const char *path, return true; } -bool _WrtUtilChangeDir(const char* path) +bool WrtUtilMakeDir(const std::string &newpath, mode_t mode) { - if (NULL == path) { - return false; - } - if (-1 == chdir(path)) { - if (ENOENT == errno) { - if (!_WrtMakeDir(path, 0664, WRT_FILEUTILS_RECUR)) { - return false; - } - if (-1 == chdir(path)) { - remove(path); - return false; - } - } else { + size_t pos = 0; + int error; + + if (newpath.length() == 0) return false; + + std::string path=newpath; + + if (*(path.rbegin()) != '/') path += '/'; + + while ((pos = path.find('/', pos+1)) != std::string::npos) { + if (mkdir(path.substr(0, pos).c_str(), mode) != 0) { + error=errno; + if (error == EEXIST) continue; + LogWarning(__PRETTY_FUNCTION__ << ": failed to create directory " + << path.substr(0,pos) + << ". Error: " + << strerror(error)); return false; } } - return true; } +// will be replaced with the latter function bool _WrtUtilRemoveDir(const char* path) { DIR* dir = NULL; @@ -330,9 +228,83 @@ bool _WrtUtilRemoveDir(const char* path) return true; } -bool -_WrtUtilStringToLower(const char* str, - char** lowerStr) +bool WrtUtilRemove(const std::string &path) +{ + FTS *fts; + FTSENT *ftsent; + bool rv = true; + int error = 0; + char * const paths[] = {const_cast(path.c_str()), NULL}; + + if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) { + //ERROR + error = errno; + LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: " + << strerror(error)); + return false; + } + + while ((ftsent = fts_read(fts)) != NULL) { + switch (ftsent->fts_info) { + case FTS_D: + //directory in preorder - do nothing + break; + case FTS_DP: + //directory in postorder - remove + if (rmdir(ftsent->fts_accpath) != 0) { + error = errno; + LogWarning(__PRETTY_FUNCTION__ + << ": rmdir failed with error: " + << strerror(error)); + rv = false; + } + break; + case FTS_DC: + case FTS_F: + case FTS_NSOK: + case FTS_SL: + case FTS_SLNONE: + case FTS_DEFAULT: + //regular files and other objects that can safely be removed + if (unlink(ftsent->fts_accpath) != 0) { + error = errno; + LogWarning(__PRETTY_FUNCTION__ + << ": unlink failed with error: " + << strerror(error)); + rv = false; + } + break; + case FTS_NS: + LogWarning(__PRETTY_FUNCTION__ + << ": couldn't get stat info for file: " + << ftsent->fts_path + << ". The error was: " + << strerror(ftsent->fts_errno)); + rv = false; + break; + case FTS_DOT: + case FTS_DNR: + case FTS_ERR: + default: + LogWarning(__PRETTY_FUNCTION__ + << ": traversal failed with error: " + << strerror(ftsent->fts_errno)); + rv = false; + break; + } + } + + if (fts_close(fts) == -1) { + error = errno; + LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: " + << strerror(error)); + rv = false; + } + return rv; +} + +// shall be replaced with the latter function +bool _WrtUtilStringToLower(const char* str, char** lowerStr) { if (!str || !lowerStr) { return true; @@ -360,3 +332,31 @@ _WrtUtilStringToLower(const char* str, return true; } +void WrtUtilStringToLower(std::string &out, const std::string &in) +{ + out.clear(); + for (std::string::const_iterator it=in.begin(); it(tolower(*it)); + } +} + +bool WrtUtilFileExists(const std::string &path) +{ + struct stat tmp; + if (stat(path.c_str(),&tmp) == 0) { + return S_ISREG(tmp.st_mode); + } else { + return false; + } +} + +bool WrtUtilDirExists(const std::string &path) +{ + struct stat tmp; + if (stat(path.c_str(),&tmp) == 0) { + return S_ISDIR(tmp.st_mode); + } else { + return false; + } +} + diff --git a/modules/widget_dao/CMakeLists.txt b/modules/widget_dao/CMakeLists.txt index a509ff0..c6f7057 100644 --- a/modules/widget_dao/CMakeLists.txt +++ b/modules/widget_dao/CMakeLists.txt @@ -67,6 +67,7 @@ SET(WRT_DAO_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/modules/core/include ${PROJECT_SOURCE_DIR}/modules/db/include ${PROJECT_SOURCE_DIR}/modules/log/include + ${PROJECT_SOURCE_DIR}/modules/localization/include ${WRT_DAO_DEPS_INCLUDE_DIRS} ) diff --git a/modules/widget_dao/dao/feature_dao.cpp b/modules/widget_dao/dao/feature_dao.cpp index 31979e9..7701019 100755 --- a/modules/widget_dao/dao/feature_dao.cpp +++ b/modules/widget_dao/dao/feature_dao.cpp @@ -113,5 +113,48 @@ FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature, } } +void UnregisterFeature(FeatureHandle featureHandle) +{ + Try + { + LogDebug("Unregistering Feature " << featureHandle); + DPL::DB::ORM::wrt::ScopedTransaction transaction( + &WrtDatabase::interface()); + + if (FeatureDAOReadOnly::isFeatureInstalled(featureHandle)) { + LogError("Feature handle is invalid"); + return; + } + + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + // Unregister DeviceCapabilities + FeatureDAOReadOnly::DeviceCapabilitiesList capabilitiesList = + FeatureDAOReadOnly(featureHandle).GetDeviceCapabilities(); + + FOREACH(it, capabilitiesList) { + WRT_DB_DELETE(del, DeviceCapabilities, &WrtDatabase::interface()) + del->Where( + Equals( + DPL::FromUTF8String(*it))); + del->Execute(); + } + + // Unregister Feature + WRT_DB_DELETE(del, FeaturesList, &WrtDatabase::interface()) + del->Where(Equals(featureHandle)); + del->Execute(); + transaction.Commit(); + + return; + } + Catch(DPL::DB::SqlConnection::Exception::Base){ + ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError, + "Fail to unregister Feature"); + } +} + + } // namespace FeatureDAO } // namespace WrtDB diff --git a/modules/widget_dao/dao/feature_dao_read_only.cpp b/modules/widget_dao/dao/feature_dao_read_only.cpp index 6ce4fd1..6db3f0d 100644 --- a/modules/widget_dao/dao/feature_dao_read_only.cpp +++ b/modules/widget_dao/dao/feature_dao_read_only.cpp @@ -356,4 +356,38 @@ FeatureDAOReadOnly::GetDevCapWithFeatureHandle() } } +FeatureDAOReadOnly::FeatureMap +FeatureDAOReadOnly::GetFeatures(const std::list& featureNames) +{ + Try { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + std::set nameList; + FOREACH(nm, featureNames) { + nameList.insert(DPL::FromUTF8String(*nm)); + } + + WRT_DB_SELECT(select, FeaturesList, &WrtDatabase::interface()) + select->Where(In(nameList)); + + FeatureMap featureMap; + FeatureData featureData; + FeaturesList::Select::RowList rows = select->GetRowList(); + FOREACH(rowIt, rows) { + featureData.featureName = DPL::ToUTF8String( + rowIt->Get_FeatureName()); + featureData.pluginHandle = rowIt->Get_PluginPropertiesId(); + featureMap.insert(std::pair( + rowIt->Get_FeatureUUID(), featureData)); + } + + return featureMap; + } + Catch(DPL::DB::SqlConnection::Exception::Base){ + ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError, + "Failure during getting GetFeatures"); + } +} + } // namespace WrtDB diff --git a/modules/widget_dao/dao/plugin_dao.cpp b/modules/widget_dao/dao/plugin_dao.cpp index ea151f6..a80ae85 100644 --- a/modules/widget_dao/dao/plugin_dao.cpp +++ b/modules/widget_dao/dao/plugin_dao.cpp @@ -209,4 +209,37 @@ void PluginDAO::setPluginInstallationStatus(DbPluginHandle pluginHandle, } } +void PluginDAO::unregisterPlugin(DbPluginHandle pluginHandle) +{ + LogDebug("unregisterPlugin plugin. Handle: " << pluginHandle); + + Try { + DPL::DB::ORM::wrt::ScopedTransaction transaction( + &WrtDatabase::interface()); + DbPluginHandle handle; + + if (!isPluginInstalled(pluginHandle)) { + LogInfo("PluginHandle is invalid. Handle: " << handle); + return; + + } else { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + WRT_DB_DELETE(del, PluginProperties, &WrtDatabase::interface()) + del->Where( + Equals(pluginHandle)); + del->Execute(); + + transaction.Commit(); + LogDebug(" >> Plugin Unregistered. Handle: " << handle); + } + } + Catch(DPL::DB::SqlConnection::Exception::Base) + { + ReThrowMsg(PluginDAO::Exception::DatabaseError, + "Failed in UnregisterPlugin"); + } +} + } // namespace WrtDB diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index e04fd47..4c7084a 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -71,6 +71,11 @@ WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) : { } +WidgetDAO::WidgetDAO(DPL::String pkgName) : + WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(pkgName)) +{ +} + WidgetDAO::~WidgetDAO() { } @@ -157,8 +162,12 @@ void WidgetDAO::registerWidget( registerWidgetCertificates(widgetHandle, wacSecurity); CertificateChainList list; - wacSecurity.getCertificateChainList(list); - registerLaunchCertificates(widgetHandle,list); + wacSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR); + registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list); + + list.clear(); + wacSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR); + registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list); registerWidgetSettings(widgetHandle, widgetRegInfo); @@ -194,6 +203,7 @@ void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle, row.Set_test_widget(regInfo.isTestWidget); row.Set_install_time(regInfo.installedTime); row.Set_splash_img_src(regInfo.configInfo.splashImgSrc); + row.Set_background_page(regInfo.configInfo.backgroundPage); DO_INSERT(row, WidgetExtendedInfo) @@ -481,7 +491,8 @@ void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle, } } -void WidgetDAO::registerLaunchCertificates(DbWidgetHandle widgetHandle, +void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle, + CertificateSource certificateSource, const CertificateChainList &certificateChainList) { using namespace DPL::DB::ORM; @@ -490,6 +501,7 @@ void WidgetDAO::registerLaunchCertificates(DbWidgetHandle widgetHandle, { WidgetCertificate::Row row; row.Set_app_id(widgetHandle); + row.Set_cert_source(certificateSource); row.Set_encoded_chain(DPL::FromASCIIString(*certChain)); DO_INSERT(row, WidgetCertificate); @@ -552,6 +564,37 @@ void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle, } } +void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals) +{ + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); + LogDebug("Inserting external files for widgetHandle: " << m_widgetHandle); + FOREACH(it, externals) + { + WidgetExternalLocations::Row row; + row.Set_app_id(m_widgetHandle); + row.Set_path(DPL::FromUTF8String(*it)); + + DO_INSERT(row, WidgetExternalLocations) + } + transaction.Commit(); + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files"); +} + +void WidgetDAO::unregisterAllExternalLocations() +{ + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle); + WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface()); + del->Where(Equals(m_widgetHandle)); + del->Execute(); +} + #undef DO_INSERT void WidgetDAO::unregisterWidget(DbWidgetHandle widgetHandle) diff --git a/modules/widget_dao/dao/widget_dao_read_only.cpp b/modules/widget_dao/dao/widget_dao_read_only.cpp index a89233b..e9fc3ec 100644 --- a/modules/widget_dao/dao/widget_dao_read_only.cpp +++ b/modules/widget_dao/dao/widget_dao_read_only.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace WrtDB { @@ -104,6 +105,12 @@ WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::OptionalString widgetGUID) : { } +WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::String pkgName) : + m_widgetHandle(WidgetDAOReadOnly::getHandle(pkgName)) +{ + +} + WidgetDAOReadOnly::~WidgetDAOReadOnly() { } @@ -205,7 +212,7 @@ DPL::String WidgetDAOReadOnly::getPath() const DPL::OStringStream strAppId; strAppId << m_widgetHandle; DPL::OptionalString pkgname = getPkgname(); - path += L"/" + *pkgname + L"/"; + path += L"/" + *pkgname; path += srcPath + L"/"; } @@ -373,6 +380,16 @@ DbWidgetHandleList WidgetDAOReadOnly::getHandleList() SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get handle list") } +DbWidgetDAOReadOnlyList WidgetDAOReadOnly::getWidgetList() +{ + LogDebug("Getting DbWidget List"); + DbWidgetDAOReadOnlyList list; + FOREACH(iterator, getHandleList()) { + list.push_back(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(*iterator))); + } + return list; +} + bool WidgetDAOReadOnly::isWidgetInstalled(DbWidgetHandle handle) { LogDebug("Checking if widget exist. Handle: " << handle); @@ -407,12 +424,36 @@ bool WidgetDAOReadOnly::isWidgetInstalled(DPL::String pkgName) SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to check if widget exist") } -CertificateChainList WidgetDAOReadOnly::getWidgetCertificate() const +ExternalLocationList WidgetDAOReadOnly::getWidgetExternalLocations() const +{ + LogDebug("Getting WidgetExtranalFiles List"); + ExternalLocationList result; + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + WRT_DB_SELECT(select, WidgetExternalLocations, &WrtDatabase::interface()); + select->Where(Equals(m_widgetHandle)); + WidgetExternalLocations::Select::RowList rows = select->GetRowList(); + FOREACH(it, rows) + { + result.push_back(DPL::ToUTF8String(it->Get_path())); + } + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get handle list") + return result; +} + +CertificateChainList WidgetDAOReadOnly::getWidgetCertificate( + CertificateSource source) const { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; WRT_DB_SELECT(select, WidgetCertificate, &WrtDatabase::interface()) - select->Where(Equals(m_widgetHandle)); + select->Where( + And( + Equals(m_widgetHandle), + Equals(source))); std::list chainList = select->GetRowList(); @@ -961,7 +1002,7 @@ void WidgetDAOReadOnly::getWidgetAccessInfo( SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get accessinfo list") } -LanguageTagList WidgetDAOReadOnly::getLanguageTags() const +LanguageTags WidgetDAOReadOnly::getLanguageTags() const { //TODO check widget existance SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN @@ -975,7 +1016,7 @@ LanguageTagList WidgetDAOReadOnly::getLanguageTags() const SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get language tags") } -LanguageTagList WidgetDAOReadOnly::getIconLanguageTags() const +LanguageTags WidgetDAOReadOnly::getIconLanguageTags() const { //TODO check widget existance using namespace DPL::DB::ORM; @@ -1104,6 +1145,26 @@ void WidgetDAOReadOnly::getEncryptedFileList(EncryptedFileList& filesList) const } } +DPL::OptionalString WidgetDAOReadOnly::getBackgroundPage() const +{ + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface()) + select->Where(Equals(m_widgetHandle)); + + WidgetExtendedInfo::Select::RowList rows = select->GetRowList(); + if (rows.empty()) { + ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, + "Cannot find widget. Handle: " << m_widgetHandle); + } + + return rows.front().Get_background_page(); + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get background page") +} + #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN #undef SQL_CONNECTION_EXCEPTION_HANDLER_END #undef CHECK_WIDGET_EXISTENCE diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h b/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h index 1b8d466..c13dd75 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace WrtDB { class PluginMetafileData @@ -234,6 +235,13 @@ typedef std::multiset DbWidgetFeatureSet; */ typedef std::list DbWidgetHandleList; +class WidgetDAOReadOnly; //forward declaration +typedef std::shared_ptr WidgetDAOReadOnlyPtr; +/** + * @brief Default container with WidgetDAOReadOnly + */ +typedef std::list DbWidgetDAOReadOnlyList; + /** * @brief Widget specific type * diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h b/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h index 9b9b74f..a0e3a99 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h @@ -219,7 +219,6 @@ class ConfigParserData bool flashNeeded; DPL::OptionalString minVersionRequired; - StringsList powderDescriptionLinks; bool backSupported; bool accessNetwork; @@ -241,6 +240,8 @@ class ConfigParserData DependsPkgList dependsPkgList; // Splash image path DPL::OptionalString splashImgSrc; + // Background page filename + DPL::OptionalString backgroundPage; ConfigParserData() : flashNeeded(false), diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h index 75f673e..1a736f9 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h @@ -50,6 +50,7 @@ class FeatureDAOReadOnly typedef std::set DeviceCapabilitiesList; typedef std::multimap DeviceCapabilitiesMap; typedef std::map NameMap; + typedef std::map FeatureMap; static bool isDeviceCapabilityInstalled(const std::string &deviceCapName); @@ -73,6 +74,8 @@ class FeatureDAOReadOnly static NameMap GetNames(); static DeviceCapabilitiesMap GetDevCapWithFeatureHandle(); + static FeatureMap GetFeatures(const std::list& featureNames); + protected: FeatureHandle m_featureHandle; }; diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h index fc40c8a..d9440da 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h @@ -39,6 +39,11 @@ typedef DPL::SharedPtr FeatureHandleListPtr; typedef int FeatureSetHandle; typedef std::list FeatureSetHandleList; +typedef struct { + std::string featureName; + DbPluginHandle pluginHandle; +} FeatureData; + class FeatureModel : public DPL::Event::Model { public: diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h b/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h index e5f2fe7..a2b1402 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h @@ -57,7 +57,7 @@ inline const char* GetDevicePluginPath() */ inline const char* GetFactoryInstalledWidgetPath() { - return "/opt/apps/widget/system"; + return "/opt/share/widget/system"; } /** @@ -73,7 +73,7 @@ inline const char* GetUserInstalledWidgetPath() */ inline const char* GetWidgetSrcPath() { - return "res/wgt"; + return "/res/wgt"; } /** @@ -81,7 +81,7 @@ inline const char* GetWidgetSrcPath() */ inline const char* GetPublicVirtualRootPath() { - return "/opt/apps/widget/data/Public"; + return "/opt/share/widget/data/Public"; } /** @@ -97,7 +97,7 @@ inline const char* GetWidgetLocalStoragePath() */ inline const char* GetTestsDataPath() { - return "/opt/apps/widget/tests"; + return "/opt/share/widget/tests"; } /** @@ -105,7 +105,7 @@ inline const char* GetTestsDataPath() */ inline const char* GetUserWidgetExecPath() { - return "bin"; + return "/bin"; } /** @@ -154,7 +154,7 @@ inline const char* GetUserWidgetDefaultIconFile() */ // KW inline const char* GetDownloadedWidgetPath() // KW { -// KW return "/opt/apps/widget/test-widgets"; +// KW return "/opt/share/widget/test-widgets"; // KW } inline const char* GetSignatureXmlSchema() @@ -215,7 +215,7 @@ inline const char* GetPluginSuffix() */ inline const char* GetPluginInstallInitializerName() { - return "/opt/apps/widget/plugin-installation-required"; + return "/opt/share/widget/plugin-installation-required"; } /** @@ -275,7 +275,7 @@ inline const char* GetShareDirectoryPath() inline const char* GetTempInstallInfoPath() { - return "/opt/apps/widget/temp_info"; + return "/opt/share/widget/temp_info"; } } // namespace GlobalConfig } // namespace WrtDB diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h index db1de98..37229ea 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h @@ -51,6 +51,11 @@ enum WidgetSignatureType SIGNATURE_TYPE_UNIDENTIFIED }; +enum CertificateSource { + SIGNATURE_DISTRIBUTOR = 0, + SIGNATURE_AUTHOR = 1 +}; + typedef std::list StringList; struct WidgetLocalizedInfo @@ -190,7 +195,8 @@ class IWacSecurity virtual bool isWacSigned() const = 0; - virtual void getCertificateChainList(CertificateChainList& list) const = 0; + virtual void getCertificateChainList(CertificateChainList& list, + CertificateSource source) const = 0; }; /** @@ -221,6 +227,7 @@ typedef std::list LanguageTagList; typedef std::list HostList; typedef std::list FingerPrintList; typedef std::list ResourceAttributeList; +typedef std::list ExternalLocationList; //TODO: if there will be many files registered std::set is better class WidgetDAOReadOnly { @@ -280,7 +287,6 @@ class WidgetDAOReadOnly }; typedef std::list LocalizedStartFileList; - /** * This is a constructor. * @@ -288,6 +294,7 @@ class WidgetDAOReadOnly */ WidgetDAOReadOnly(DbWidgetHandle widgetHandle); WidgetDAOReadOnly(DPL::OptionalString widgetGUID); + WidgetDAOReadOnly(DPL::String pkgName); /** * Destructor @@ -537,7 +544,7 @@ class WidgetDAOReadOnly bool getWebkitPluginsRequired() const; /** - * This method returns a list of all the installed widgets. + * This method returns a list of all the installed widgets' app id. * * @return list of installed widgets' app id. * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. @@ -546,6 +553,16 @@ class WidgetDAOReadOnly */ static DbWidgetHandleList getHandleList(); + /** + * This method returns a list of all the installed widgets. + * + * @return list of installed widgets. + * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. + * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in + * DB table. + */ + static DbWidgetDAOReadOnlyList getWidgetList(); + /** * This method removes a widget's information from EmDB. * @@ -679,6 +696,8 @@ class WidgetDAOReadOnly LanguageTagList getLanguageTags() const; LanguageTagList getIconLanguageTags() const; + + WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const; std::string getCookieDatabasePath() const; // Local storage @@ -695,7 +714,14 @@ class WidgetDAOReadOnly */ DPL::OptionalString getSplashImgSrc() const; - CertificateChainList getWidgetCertificate() const; + ExternalLocationList getWidgetExternalLocations() const; + + /* + * Default value is required to keep compatibility with + * wrt-installer and wrt. + */ + CertificateChainList getWidgetCertificate( + CertificateSource source = SIGNATURE_DISTRIBUTOR) const; void getWidgetSettings(WidgetSettings& outWidgetSettings) const; @@ -719,6 +745,13 @@ class WidgetDAOReadOnly PkgType getPkgType() const; void getEncryptedFileList(EncryptedFileList& filesList) const; + + /** + * This method returns widget's background page filename. + * + * @return Name of file containing background page + */ + DPL::OptionalString getBackgroundPage() const; }; } // namespace WrtDB diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h b/modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h index ed1dc82..1702433 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h @@ -27,6 +27,7 @@ typedef WrtDB::DbWidgetHandle WidgetHandle; typedef WrtDB::DbWidgetHandleList WidgetHandleList; +typedef WrtDB::DbWidgetDAOReadOnlyList WidgetDAOReadOnlyList; typedef WrtDB::DbWidgetFeature WidgetFeature; typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet; diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h index dd98aaf..c525e86 100755 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h @@ -31,6 +31,7 @@ namespace WrtDB { namespace FeatureDAO { FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature, const DbPluginHandle pluginHandle); + void UnregisterFeature(FeatureHandle featureHandle); } // namespace FeatureDB } // namespace WrtDB diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/plugin_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/plugin_dao.h index e8a86d3..70d35f9 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/plugin_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/plugin_dao.h @@ -54,6 +54,8 @@ class PluginDAO : public PluginDAOReadOnly static void setPluginInstallationStatus( DbPluginHandle, PluginInstallationState); + + static void unregisterPlugin(DbPluginHandle pluginHandle); }; } // namespace WrtDB diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h index cdc1f73..e15ac5a 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h @@ -52,6 +52,7 @@ class WidgetDAO : public WidgetDAOReadOnly */ WidgetDAO(DbWidgetHandle widgetHandle); WidgetDAO(DPL::OptionalString widgetGUID); + WidgetDAO(DPL::String pkgName); /** * Destructor @@ -102,6 +103,17 @@ class WidgetDAO : public WidgetDAOReadOnly */ void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key); + /** + * @brief registerExternalLocations Inserts new rows to WidgetExternalLocations + * @param externals list of files + */ + void registerExternalLocations(const ExternalLocationList & externals); + + /** + * @brief registerExternalLocations Removes rows from WidgetExternalLocations + */ + void unregisterAllExternalLocations(); + /* This method sets widget property */ void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key, @@ -151,8 +163,9 @@ class WidgetDAO : public WidgetDAOReadOnly static void registerWidgetCertificates( DbWidgetHandle widgetHandle, const IWacSecurity &wacSecurity); - static void registerLaunchCertificates( + static void registerCertificatesChains( DbWidgetHandle widgetHandle, + CertificateSource certificateSource, const CertificateChainList &list); static void registerWidgetSettings( DbWidgetHandle widgetHandle, diff --git a/modules/widget_dao/orm/wrt_db b/modules/widget_dao/orm/wrt_db index 607b362..ecd3d04 100644 --- a/modules/widget_dao/orm/wrt_db +++ b/modules/widget_dao/orm/wrt_db @@ -42,8 +42,13 @@ CREATE_TABLE(WidgetInfo) COLUMN(pkg_type, INT, DEFAULT 0) CREATE_TABLE_END() +SQL( + CREATE INDEX IF NOT EXISTS WidgetInfo_PkgnameIndex ON WidgetInfo(pkgname); +) + CREATE_TABLE(WidgetCertificate) COLUMN_NOT_NULL(app_id, INT,) + COLUMN_NOT_NULL(cert_source, INT, CHECK(cert_source between 0 and 1)) COLUMN_NOT_NULL(encoded_chain, VARCHAR(16000),) TABLE_CONSTRAINTS( FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE @@ -86,6 +91,7 @@ CREATE_TABLE(WidgetExtendedInfo) COLUMN(update_policy, INT, DEFAULT 0) COLUMN_NOT_NULL(test_widget, INT, CHECK(test_widget between 0 and 1) DEFAULT 0) COLUMN(splash_img_src, VARCHAR(256), DEFAULT '') + COLUMN(background_page, VARCHAR(256), DEFAULT '') TABLE_CONSTRAINTS( FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE ) @@ -166,6 +172,15 @@ CREATE_TABLE(WidgetLocalizedStartFile) ) CREATE_TABLE_END() +CREATE_TABLE(WidgetExternalLocations) + COLUMN_NOT_NULL(app_id, INT,) + COLUMN_NOT_NULL(path, TEXT,) + TABLE_CONSTRAINTS( + FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE, + PRIMARY KEY(app_id, path) + ) +CREATE_TABLE_END() + CREATE_TABLE(WidgetAccessHost) COLUMN_NOT_NULL(app_id, INT,) COLUMN_NOT_NULL(host, VARCHAR(256),) @@ -205,6 +220,10 @@ CREATE_TABLE(FeaturesList) COLUMN_NOT_NULL(FeatureUUID, INTEGER, primary key autoincrement) COLUMN_NOT_NULL(FeatureName, TEXT, unique) COLUMN_NOT_NULL(PluginPropertiesId, INT,) + + TABLE_CONSTRAINTS( + FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE + ) CREATE_TABLE_END() CREATE_TABLE(PluginProperties) @@ -217,16 +236,28 @@ CREATE_TABLE_END() CREATE_TABLE(PluginDependencies) COLUMN_NOT_NULL(PluginPropertiesId, INTEGER, not null) COLUMN_NOT_NULL(RequiredPluginPropertiesId, INTEGER, not null) + + TABLE_CONSTRAINTS( + FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE + ) CREATE_TABLE_END() CREATE_TABLE(PluginImplementedObjects) COLUMN_NOT_NULL(PluginObject, TEXT, unique) COLUMN_NOT_NULL(PluginPropertiesId, INTEGER, not null) + + TABLE_CONSTRAINTS( + FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE + ) CREATE_TABLE_END() CREATE_TABLE(PluginRequiredObjects) COLUMN_NOT_NULL(PluginPropertiesId, INTEGER, not null) COLUMN_NOT_NULL(PluginObject, TEXT, not null) + + TABLE_CONSTRAINTS( + FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE + ) CREATE_TABLE_END() CREATE_TABLE(DeviceCapabilities) @@ -239,7 +270,11 @@ CREATE_TABLE(FeatureDeviceCapProxy) COLUMN_NOT_NULL(FeatureUUID, INT, not null) COLUMN_NOT_NULL(DeviceCapID, INT, not null) - TABLE_CONSTRAINTS(PRIMARY KEY(FeatureUUID,DeviceCapID)) + TABLE_CONSTRAINTS( + FOREIGN KEY (FeatureUUID) REFERENCES FeaturesList (FeatureUUID) ON DELETE CASCADE + FOREIGN KEY (DeviceCapID) REFERENCES DeviceCapabilities (DeviceCapID) ON DELETE CASCADE + PRIMARY KEY(FeatureUUID,DeviceCapID) + ) CREATE_TABLE_END() CREATE_TABLE(OCSPResponseStorage) @@ -311,7 +346,7 @@ SQL( INSERT INTO UserAgents VALUES("Galaxy S II", "Mozilla/5.0 (Linux; U; Android 2.3.5; en-gb; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"); INSERT INTO UserAgents VALUES("Galaxy S III", "Mozilla/5.0 (Linux; U; Android 4.0.3; en-gb; GT-I9300 Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"); INSERT INTO UserAgents VALUES("SLP Galaxy", "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; GT-I9500 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"); - INSERT INTO UserAgents VALUES("Tizen", "Mozilla/5.0 (Linux; U; Tizen 2.0; en-us) AppleWebKit/537.1 (KHTML, like Gecko) Mobile TizenBrowser/2.0"); + INSERT INTO UserAgents VALUES("Tizen", "Mozilla/5.0 (Linux; U; Tizen 2.0; en-us; GT-I8800) AppleWebKit/537.1 (KHTML, like Gecko) Mobile TizenBrowser/2.0"); INSERT INTO UserAgents VALUES("Galaxy Nexus", "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; Galaxy Nexus Build/IML74K) AppleWebKit/535.7 (KHTML, like Gecko) Mobile Safari/535.7"); INSERT INTO UserAgents VALUES("Samsung", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-I9200/1.0; U; Linux/SLP/2.0; ko-kr) AppleWebKit/534.4 (KHTML, like Gecko) Dolfin/2.0 Mobile"); INSERT INTO UserAgents VALUES("Samsung Dolfin", "SAMSUNG-GT-S8500/S8500XXJD2 SHP/VPP/R5 Dolfin/2.0 Nextreaming SMM-MMS/1.2.0 profile/MIDP-2.1 configuration/CLDC-1.1"); diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index 0d0898d..b9e10db 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -1,7 +1,7 @@ -#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.54 +#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.66 Name: wrt-commons Summary: Wrt common library -Version: 0.2.54 +Version: 0.2.66 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 @@ -48,16 +48,18 @@ cmake . -DVERSION=%{version} \ make %{?jobs:-j%jobs} %install +mkdir -p %{buildroot}/usr/share/license +cp %{name} %{buildroot}/usr/share/license/ %make_install %clean rm -rf %{buildroot} %post -mkdir -p /opt/apps/widget/system -mkdir -p /opt/apps/widget/user -mkdir -p /opt/apps/widget/exec -mkdir -p /opt/apps/widget/data/Public +mkdir -p /opt/share/widget/system +mkdir -p /opt/share/widget/user +mkdir -p /opt/share/widget/exec +mkdir -p /opt/share/widget/data/Public mkdir -p /usr/lib/wrt-plugins if [ -z ${2} ]; then @@ -108,14 +110,22 @@ else cp /usr/var/lib/dbus/machine-id /var/lib/dbus/ fi +# Set Smack label for db files +chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db +chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db-journal +chsmack -a 'wrt-commons::db_wrt_autosave' /opt/dbspace/.wrt_autosave.db +chsmack -a 'wrt-commons::db_wrt_autosave' /opt/dbspace/.wrt_autosave.db-journal + echo "[WRT] wrt-commons postinst done ..." %files +%manifest wrt-commons.manifest %{_libdir}/*.so %{_libdir}/*.so.* /usr/share/wrt-engine/* %attr(775,root,root) %{_bindir}/wrt_commons_reset_db.sh %attr(775,root,root) %{_bindir}/wrt_commons_create_clean_db.sh +%{_datadir}/license/%{name} %files devel %{_includedir}/dpl-efl/* diff --git a/wrt-commons.manifest b/wrt-commons.manifest new file mode 100644 index 0000000..e797580 --- /dev/null +++ b/wrt-commons.manifest @@ -0,0 +1,12 @@ + + + + + + + + + + -- 2.34.1