merge test submit/security-server/20121023.063205
authorSoyoung Kim <sy037.kim@samsung.com>
Tue, 23 Oct 2012 04:50:45 +0000 (13:50 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Tue, 23 Oct 2012 04:50:45 +0000 (13:50 +0900)
46 files changed:
CMakeLists.txt
debian/changelog
etc/wrt_commons_reset_db.sh
modules/encryption/src/resource_decryption.cpp
modules/encryption/src/resource_encryption.cpp
modules/localization/config.cmake
modules/localization/include/LanguageTagsProvider.h [new file with mode: 0644]
modules/localization/include/dpl/localization/localization_utils.h
modules/localization/include/dpl/localization/w3c_file_localization.h
modules/localization/src/LanguageTagsProvider.cpp [new file with mode: 0644]
modules/localization/src/localization_utils.cpp
modules/localization/src/w3c_file_localization.cpp
modules/log/include/dpl/log/log.h
modules/log/src/log.cpp
modules/test/include/dpl/test/test_results_collector.h
modules/test/include/dpl/test/test_runner.h
modules/test/src/test_results_collector.cpp
modules/test/src/test_runner.cpp
modules/utils/config.cmake
modules/utils/include/dpl/utils/bash_utils.h [new file with mode: 0644]
modules/utils/include/dpl/utils/file_utils.h
modules/utils/include/dpl/utils/wrt_global_settings.h
modules/utils/include/dpl/utils/wrt_utility.h
modules/utils/src/bash_utils.cpp [new file with mode: 0644]
modules/utils/src/file_utils.cpp
modules/utils/src/wrt_global_settings.cpp
modules/utils/src/wrt_utility.cpp
modules/widget_dao/CMakeLists.txt
modules/widget_dao/dao/feature_dao.cpp
modules/widget_dao/dao/feature_dao_read_only.cpp
modules/widget_dao/dao/plugin_dao.cpp
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h
modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h
modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h
modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h
modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h
modules/widget_dao/include/dpl/wrt-dao-rw/plugin_dao.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
modules/widget_dao/orm/wrt_db
packaging/wrt-commons.spec
wrt-commons.manifest [new file with mode: 0644]

index cd2d9253a5ccc6b29576396a5c5d9f2dd58358c8..35ebc04aa15b027c9523892fe89b54b0436ffda5 100644 (file)
@@ -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 "========================================")
index dbc7c883d7af3bddfc1fbd03d03bf336330a1908..e1c3083cd63914a09156f056001867b6282c121d 100644 (file)
@@ -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 <sy037.kim@samsung.com>  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 <sy037.kim@samsung.com>  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 <jihoon.chung@samsung.com>  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 <p.sikorski@samsung.com>  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 <jihoon.chung@samsung.com>  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 <jihoon.chung@samsung.com>  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 <sy037.kim@samsung.com>  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 <taejeong.lee@samsung.com>  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 <taejeong.lee@samsung.com>  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 <taejeong.lee@samsung.com>  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 <jihoon.chung@samsung.com>  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 <yunchan.cho@samsung.com>  Thu, 06 Sep 2012 00:34:12 +0900
+
 wrt-commons (0.2.54) unstable; urgency=low
 
   * [common] Add XML test collector
index 3016223ff06e2c9b6fa8dc7c9e89f6f37ff2b8f8..bc536a53103ce12e2af143d60ce57968610c8607 100755 (executable)
 #    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} ]
index 499d82ead97f020302a1a97921657a2c17dede99..e8f1590f373fe200fd806e83966cc4c4cc35c956 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace {
 inline std::string GetDefaultEncryptKeyPath() {
-    return "/opt/apps/widget/data/";
+    return "/opt/share/widget/data/";
 }
 }
 namespace WRTDecryptor{
index 62201bf4e3651eff38e3449c604bb410323b5959..8f6de46606b28bd33d61636793716a493c671664 100644 (file)
@@ -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{
index 5f52e6ff0fefef94cd3516be22c4f85e4c6dedfa..218cb712e9bb574f0ec255297b924e95e256c2a4 100644 (file)
@@ -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 (file)
index 0000000..c32d0fe
--- /dev/null
@@ -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 <dpl/optional.h>
+#include <dpl/string.h>
+#include <dpl/singleton.h>
+#include <list>
+
+typedef std::list<DPL::String> 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<LanguageTagsProvider>;
+
+    LanguageTags m_languageTagsList;
+
+    LanguageTagsProvider();
+    virtual ~LanguageTagsProvider();
+
+    void loadSystemTags();
+    void createTagsFromLocales(const char* language);
+};
+
+typedef DPL::Singleton<LanguageTagsProvider> LanguageTagsProviderSingleton;
+
+#endif /* LANGUAGETAGSPROVIDER_H */
index 813083830345f1c7dcc74c1326cfdd6d17d3d20f..ed72233c8769d88ac3165f102ebdd1e43183f256 100644 (file)
@@ -73,14 +73,12 @@ struct WidgetStartFileInfo
 };
 
 typedef DPL::Optional<WidgetIcon> OptionalWidgetIcon;
-typedef std::list<DPL::String> LanguageTagsList;
 typedef DPL::Optional<WidgetStartFileInfo> 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
index 156923cbbc70f96ee4965faedd820f94417da982..7f26a5bb15f4471686cd28f17914fc69b6b1529c 100644 (file)
@@ -37,24 +37,23 @@ typedef std::list<WidgetIcon> WidgetIconList;
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
         WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags,
         const DPL::String &url);
 
 DPL::Optional<DPL::String> 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 (file)
index 0000000..69e6d41
--- /dev/null
@@ -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 <dpl/log/log.h>
+#include <vconf.h>
+#include <algorithm>
+#include <iostream>
+#include <cassert>
+#include <dpl/singleton_impl.h>
+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"");
+}
index c463276669554af962daa0d0b573f19e1dc37503..ab4874354672140e72f695ee1b72413576b2c982 100644 (file)
  */
 
 #include <dpl/localization/localization_utils.h>
-
-#include <dpl/foreach.h>
-#include <dpl/mutex.h>
+#include <algorithm>
 
 namespace LocalizationUtils {
-static LanguageTagsList m_systemLanguageTags;
-static LanguageTagsList m_languageTags;
-static DPL::ReadWriteMutex m_readWriteMutex;
-
-template<typename StringType>
-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;
-}
 }
index c0b41610d8e2fe48d1fdfbff38ca22b02f4a4e81..8e91255ea55d94288a294118d75ec9ec967a82d6 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <assert.h>
 
 #include <dpl/localization/w3c_file_localization.h>
 
 #include <dpl/optional.h>
 #include <dpl/foreach.h>
 
+#include <LanguageTagsProvider.h>
+
 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<std::string> 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<std::string>::Null; }
     //Removing preceding '/'
@@ -54,10 +59,10 @@ DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
     //Check if string isn't empty
     if (filePath.size() == 0) { return DPL::Optional<std::string>::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<std::string> GetFilePathInWidgetPackageInternal(
 }
 
 DPL::Optional<DPL::String> GetFilePathInWidgetPackageInternal(
-        const LanguageTagsList &languageTags,
         const DPL::String& basePath,
         const DPL::String& filePath)
 {
     DPL::Optional<std::string> path =
-        GetFilePathInWidgetPackageInternal(languageTags,
-                                           DPL::ToUTF8String(basePath),
+        GetFilePathInWidgetPackageInternal(DPL::ToUTF8String(basePath),
                                            DPL::ToUTF8String(filePath));
     DPL::Optional<DPL::String> dplPath;
     if (!!path) {
@@ -103,7 +106,6 @@ DPL::Optional<DPL::String> GetFilePathInWidgetPackageInternal(
 namespace W3CFileLocalization {
 DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
         DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags,
         const DPL::String &url)
 {
     DPL::String req = url;
@@ -116,6 +118,15 @@ DPL::Optional<DPL::String> 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<DPL::String>::Null;
@@ -124,7 +135,7 @@ DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
     auto widgetPath = dao.getPath();
 
     DPL::Optional<DPL::String> 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<DPL::String> getFilePathInWidgetPackageFromUrl(
 
 DPL::Optional<DPL::String> 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; \
index c9564bb8ece530726fec31bf8ebf58f7c3dee371..7be5c9dd7dbbac70c5ad2253ef9c03d34aa135bf 100644 (file)
@@ -27,7 +27,6 @@
 #include <dpl/log/abstract_log_provider.h>
 #include <dpl/log/dlog_log_provider.h>
 #include <dpl/log/old_style_log_provider.h>
-#include <dpl/read_write_mutex.h>
 #include <sstream>
 #include <list>
 
@@ -45,8 +44,6 @@ class LogSystem
     : private Noncopyable
 {
 private:
-    ReadWriteMutex m_spinLock;
-
     typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
     AbstractLogProviderPtrList m_providers;
 
index b03ab613ecb1b65594c03d3a60ad1596c0e80767..b24970ac519e950b9a706f6fbbac5583688a1ce0 100644 (file)
@@ -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);
 }
index 6c4e24b38974df65c3ca52f83ade6a5de038f2ce..cf8fa4e20d1bea71e89dc00bd499f5ff10d56a0f 100644 (file)
@@ -52,7 +52,6 @@ class TestResultsCollectorBase
             NONE,
             FAILED,
             IGNORED,
-            TODO,
             INTERNAL
         };
     };
index ab1a626a82357f0b0cdf9a0ac60a62664bd8ca82..a4db750f6531b844856df58fe776d315d92633d2 100644 (file)
@@ -32,6 +32,7 @@
 #include <vector>
 #include <list>
 #include <set>
+#include <map>
 
 namespace DPL
 {
@@ -39,9 +40,12 @@ namespace Test
 {
 class TestRunner
 {
-    TestResultsCollectorBasePtr m_collector;
-    std::string m_collectorName;
+    typedef std::map<std::string, TestResultsCollectorBasePtr>
+            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<std::string> ArgsList;
     int ExecTestRunner(const ArgsList& args);
+    bool getRunIgnored() const;
 };
 
 typedef DPL::Singleton<TestRunner> 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
index e36e86804012d8b6813d59107cf92f689fc1e425..4a9171223f9cdbc60160f9fb354d6d1b5daf62bd 100644 (file)
@@ -427,11 +427,12 @@ class XmlCollector
         // Show result
         FOREACH(group, m_groupsStats) {
             PrintStats(group->first, group->second);
+            size_t posBegin = m_outputBuffer.find("<testcase name=\"unknown\"");
+            size_t posEnd = m_outputBuffer.find("</testcase>", posBegin);
+            m_outputBuffer.erase(posBegin - 3, posEnd - posBegin + sizeof("</testcase>") + 2);
         }
 
-        size_t posBegin = m_outputBuffer.find("<testcase name=\"unknown\"");
-        size_t posEnd = m_outputBuffer.find("</testcase>", posBegin);
-        m_outputBuffer.erase(posBegin - 3, posEnd - posBegin + sizeof("</testcase>") + 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("<testcase name=\"unknown\"");
-        m_outputBuffer.insert(pos - 2, m_resultBuffer);
+        size_t group_pos = m_outputBuffer.find(m_currentGroup);
+        size_t last_case_pos = m_outputBuffer.find("<testcase name=\"unknown\"", group_pos);
+        m_outputBuffer.insert(last_case_pos - 2, m_resultBuffer);
         fseek(m_fp.Get(), 0L, SEEK_SET);
         fprintf(m_fp.Get(), "%s", m_outputBuffer.c_str());
         fflush(m_fp.Get());
index c53be69589740f24ea55ef5b3b85751d473c484e..98f1ba1c3c7d8855439f6a246fbcaa4daebf8cb6 100644 (file)
@@ -99,67 +99,59 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
     catch (const TestFailed &e)
     {
         // Simple test failure
-        m_collector->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=<output type>\n");
-    fprintf(stderr, "  possible output types:\n");
+    fprintf(stderr, "  --output=<output type> --output=<output type> ...\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=<test id>\tStart from concrete test id");
     fprintf(stderr, "  --group=<group name>\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=<group name>\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, "<p.dobrowolsk@samsung.com>\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
index 4c659492c641b3faf36402847e3f96862e851736..ac46c1e138a0852897b1f91043e257604ab7d184 100644 (file)
@@ -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 (file)
index 0000000..1eb2ba9
--- /dev/null
@@ -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<string>
+
+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
index 4248f70acafb3ee1e87c2770dbca195a212a9703..9936fd6f403f79ba931e5f3bd1eb17c1994182af 100644 (file)
@@ -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.
index f012542156b70abc1b5573e1b8a0a9e261c5268a..35fabb35738f75839e2187ccc755dac083ad5041 100644 (file)
 
 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();
 
 }
index 30f811482206b27255b436e121e9d11864d09314..35b700cb48061435a7a1b7cf1cd1afce4c685cd1 100644 (file)
 #define _WRT_UTILITY_H_
 
 #include <stdbool.h>
+#include <sys/stat.h>
 
 #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 (file)
index 0000000..5796bc6
--- /dev/null
@@ -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<dpl/utils/bash_utils.h>
+#include<dpl/log/log.h>
+
+#include<string>
+
+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 + "\"";
+}
+
+}
index e5100df05d7286c08365665cdb24648860063419..2ca4f1f86e05e53c82ac5d432c90d7e325944c8d 100644 (file)
@@ -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)
 {
index a0877f6fdfe84c660130a653991b32d47f12a9f8..1a420f7c7cc008e979dc6ea9ef31d23015bd2080 100644 (file)
 #include <cstdlib>
 #include <cstring>
 #include <string>
+#include <sstream>
 #include <sys/utsname.h>
 #include <dpl/utils/wrt_global_settings.h>
 
 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()
index 756e00c5e9c1dbec4329aab78c8c9d962496b066..e9222114a9b3b7f95a1cccf539b5f52863953745 100644 (file)
  * @brief  This file implemented some common functions for widget manager
  */
 
-#include <assert.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
 #include <dirent.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdarg.h>
 #include <errno.h>
 #include <libgen.h>
+#include <fts.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dpl/log/log.h>
 #include <dpl/utils/wrt_utility.h>
 
-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<char * const>(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<in.end(); ++it) {
+        out += static_cast<char>(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;
+    }
+}
+
index a509ff03772e6cdb0e52f2b5db62659a181380fb..c6f7057a6e5b27c409d2998f8e406841a9b8b393 100644 (file)
@@ -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}
     )
 
index 31979e997c2798828eae5a2095a7f1124cb9831f..7701019fae67e930376c78253bacb933d59e6fce 100755 (executable)
@@ -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<DeviceCapabilities::DeviceCapName>(
+                    DPL::FromUTF8String(*it)));
+            del->Execute();
+        }
+
+        // Unregister Feature
+        WRT_DB_DELETE(del, FeaturesList, &WrtDatabase::interface())
+        del->Where(Equals<FeaturesList::FeatureUUID>(featureHandle));
+        del->Execute();
+        transaction.Commit();
+
+        return;
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+                   "Fail to unregister Feature");
+    }
+}
+
+
 } // namespace FeatureDAO
 } // namespace WrtDB
index 6ce4fd1b6c7c57f5344b723312ac5fd5cf0bb648..6db3f0d44a6187e9b5f68a910ef1208ff564d06f 100644 (file)
@@ -356,4 +356,38 @@ FeatureDAOReadOnly::GetDevCapWithFeatureHandle()
     }
 }
 
+FeatureDAOReadOnly::FeatureMap
+FeatureDAOReadOnly::GetFeatures(const std::list<std::string>& featureNames)
+{
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        std::set<typename FeaturesList::FeatureName::ColumnType> nameList;
+        FOREACH(nm, featureNames) {
+            nameList.insert(DPL::FromUTF8String(*nm));
+        }
+
+        WRT_DB_SELECT(select, FeaturesList, &WrtDatabase::interface())
+        select->Where(In<FeaturesList::FeatureName>(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<FeatureHandle, FeatureData>(
+                    rowIt->Get_FeatureUUID(), featureData));
+        }
+
+        return featureMap;
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+                   "Failure during getting GetFeatures");
+    }
+}
+
 } // namespace WrtDB
index ea151f619bccf4965a3d2795f6c03fb5705a15e7..a80ae85cb061af1908ee527e1bb1ac0600bd9e80 100644 (file)
@@ -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<PluginProperties::PluginPropertiesId>(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
index e04fd475be71d511d80fd4599f5307b5b72d6d24..4c7084a69efd96739dd17717cca500eca4ffe8fa 100644 (file)
@@ -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<WidgetExternalLocations::app_id>(m_widgetHandle));
+    del->Execute();
+}
+
 #undef DO_INSERT
 
 void WidgetDAO::unregisterWidget(DbWidgetHandle widgetHandle)
index a89233b98e882a07e4c07057efa218749bf1a67f..e9fc3ec2efdebec3dd24f826eb6d180b97d413a7 100644 (file)
@@ -35,6 +35,7 @@
 #include <dpl/wrt-dao-ro/widget_config.h>
 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
 #include <orm_generator_wrt.h>
+#include <LanguageTagsProvider.h>
 
 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<WidgetExternalLocations::app_id>(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<WidgetCertificate::app_id>(m_widgetHandle));
+    select->Where(
+        And(
+            Equals<WidgetCertificate::app_id>(m_widgetHandle),
+            Equals<WidgetCertificate::cert_source>(source)));
 
     std::list<DPL::DB::ORM::wrt::WidgetCertificate::Row> 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<WidgetExtendedInfo::app_id>(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
index 1b8d466015848b1fbdd9bd46db68f107829b0bbf..c13dd75ff602808851c31bbe788cc70e026eacee 100644 (file)
@@ -31,6 +31,7 @@
 #include <list>
 #include <dpl/optional_typedefs.h>
 #include <dpl/shared_ptr.h>
+#include <memory>
 
 namespace WrtDB {
 class PluginMetafileData
@@ -234,6 +235,13 @@ typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
  */
 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
 
+class WidgetDAOReadOnly; //forward declaration
+typedef std::shared_ptr<WidgetDAOReadOnly> WidgetDAOReadOnlyPtr;
+/**
+ * @brief Default container with WidgetDAOReadOnly
+ */
+typedef std::list<WidgetDAOReadOnlyPtr> DbWidgetDAOReadOnlyList;
+
 /**
  * @brief Widget specific type
  *
index 9b9b74f68172df280ec087891d0d145ad43f3ccc..a0e3a9924d47bcd888744a45c58925171a49257a 100644 (file)
@@ -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),
index 75f673eb5ae9e9a664f9362790d9f3a20608f87e..1a736f9ca407613515dcfb8d4b3ad20cd211f29b 100644 (file)
@@ -50,6 +50,7 @@ class FeatureDAOReadOnly
     typedef std::set<std::string> DeviceCapabilitiesList;
     typedef std::multimap<FeatureHandle, std::string> DeviceCapabilitiesMap;
     typedef std::map<FeatureHandle, std::string> NameMap;
+    typedef std::map<FeatureHandle, FeatureData> 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<std::string>& featureNames);
+
   protected:
     FeatureHandle m_featureHandle;
 };
index fc40c8a9349f79285b8b69564e9a049c68a5fcec..d9440da7ed0d7ede0dcb26bcdb53ac8b7e7fbde3 100644 (file)
@@ -39,6 +39,11 @@ typedef DPL::SharedPtr<FeatureHandleList> FeatureHandleListPtr;
 typedef int FeatureSetHandle;
 typedef std::list<FeatureSetHandle> FeatureSetHandleList;
 
+typedef struct {
+    std::string     featureName;
+    DbPluginHandle  pluginHandle;
+} FeatureData;
+
 class FeatureModel : public DPL::Event::Model
 {
   public:
index e5f2fe7ff74b659c066d2e7aae4ade0f4f2aad04..a2b1402c5e4188054346cf5d02260e4dfdab8d29 100644 (file)
@@ -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
index db1de98ee9fd009c7acd07c0ea5e5c922382abec..37229ea7f58104e6e50bb880f01dcf2023f54145 100644 (file)
@@ -51,6 +51,11 @@ enum WidgetSignatureType
     SIGNATURE_TYPE_UNIDENTIFIED
 };
 
+enum CertificateSource {
+    SIGNATURE_DISTRIBUTOR = 0,
+    SIGNATURE_AUTHOR = 1
+};
+
 typedef std::list<DPL::String> 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<DPL::String> LanguageTagList;
 typedef std::list<std::string> HostList;
 typedef std::list<std::string> FingerPrintList;
 typedef std::list<std::string> ResourceAttributeList;
+typedef std::list<std::string> ExternalLocationList; //TODO: if there will be many files registered std::set is better
 
 class WidgetDAOReadOnly
 {
@@ -280,7 +287,6 @@ class WidgetDAOReadOnly
     };
     typedef std::list<WidgetLocalizedStartFileRow> 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
index ed1dc82b3fb84e980d68fd4679d5d2ead3a333d3..1702433b70a3052c380e7444e2fe993f72f3a88a 100644 (file)
@@ -27,6 +27,7 @@
 
 typedef WrtDB::DbWidgetHandle WidgetHandle;
 typedef WrtDB::DbWidgetHandleList WidgetHandleList;
+typedef WrtDB::DbWidgetDAOReadOnlyList WidgetDAOReadOnlyList;
 
 typedef WrtDB::DbWidgetFeature WidgetFeature;
 typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet;
index dd98aaf8511657b66bcf261f6db9ec516ef8372f..c525e868c83c4e74e160438ea1d1759da927ee04 100755 (executable)
@@ -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
 
index e8a86d3b18cf7079f419b8aa987aa36b84194e9a..70d35f9e7ae167713fbc51a03eae2ee33dfefa28 100644 (file)
@@ -54,6 +54,8 @@ class PluginDAO : public PluginDAOReadOnly
     static void setPluginInstallationStatus(
             DbPluginHandle,
             PluginInstallationState);
+
+    static void unregisterPlugin(DbPluginHandle pluginHandle);
 };
 
 } // namespace WrtDB
index cdc1f7351a413e678c37847137cb0af9efa8495f..e15ac5a0bb072de89262932c7a654669334c5623 100644 (file)
@@ -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,
index 607b3627b88583356f9d805a543d23b05e533cda..ecd3d0427776a339e14d9d172fda996307ac967d 100644 (file)
@@ -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");
index 0d0898ddb07ded0ff2218e4418ce20f413309242..b9e10db9f49ee79e6cd7db4ed7c8ecac84b237fb 100644 (file)
@@ -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 (file)
index 0000000..e797580
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest>
+  <define>
+    <domain name="wrt-commons"/>
+    <provide>   
+        <label name="wrt-commons::db_wrt"/>
+        <label name="wrt-commons::db_wrt_autosave"/>
+    </provide>
+  </define>
+  <request>
+    <domain name="_"/>
+  </request>
+</manifest>