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 "========================================")
+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
# 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} ]
namespace {
inline std::string GetDefaultEncryptKeyPath() {
- return "/opt/apps/widget/data/";
+ return "/opt/share/widget/data/";
}
}
namespace WRTDecryptor{
const char* DECRYPTION_FILE = "_dec";
inline std::string GetDefaultEncryptKeyPath() {
- return "/opt/apps/widget/data";
+ return "/opt/share/widget/data";
}
}
namespace WRTEncryptor{
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
)
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
)
--- /dev/null
+/*
+ * 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 */
};
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
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
--- /dev/null
+/*
+ * 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"");
+}
*/
#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;
-}
}
#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 '/'
//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] == '/') {
}
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) {
namespace W3CFileLocalization {
DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
DbWidgetHandle widgetHandle,
- const LanguageTagsList &languageTags,
const DPL::String &url)
{
DPL::String req = url;
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;
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");
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);
}
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) {
}
WidgetIconList getValidIconsList(
- WrtDB::DbWidgetHandle widgetHandle,
- const LanguageTagsList &languageTags)
+ WrtDB::DbWidgetHandle widgetHandle)
{
using namespace LocalizationUtils;
WidgetDAOReadOnly dao(widgetHandle);
{
LogDebug(":" << it->iconSrc);
if (!!getFilePathInWidgetPackage(widgetHandle,
- languageTags,
it->iconSrc))
{
WidgetIcon ret;
}
OptionalWidgetStartFileInfo getStartFileInfo(
- WrtDB::DbWidgetHandle widgetHandle,
- const LanguageTagList &tagsList)
+ WrtDB::DbWidgetHandle widgetHandle)
{
using namespace LocalizationUtils;
WidgetDAOReadOnly::LocalizedStartFileList locList =
dao.getLocalizedStartFileList();
WidgetDAOReadOnly::WidgetStartFileList list = dao.getStartFileList();
+ const LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags();
FOREACH(tag, tagsList)
{
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);
}
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; \
#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>
: private Noncopyable
{
private:
- ReadWriteMutex m_spinLock;
-
typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
AbstractLogProviderPtrList m_providers;
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);
}
NONE,
FAILED,
IGNORED,
- TODO,
INTERNAL
};
};
#include <vector>
#include <list>
#include <set>
+#include <map>
namespace DPL
{
{
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)();
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
{
}
};
- 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:
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;
#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
// 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");
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());
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;
}
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();
}
}
- 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;
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);
}
{
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");
}
int TestRunner::ExecTestRunner(const ArgsList& value)
{
+ m_runIgnored = false;
ArgsList args = value;
// Parse command line
if (args.size() == 1)
bool showHelp = false;
+ TestResultsCollectorBasePtr currentCollector;
+
// Parse each argument
FOREACH(it, args)
{
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) {
return -1;
}
}
+ else if (arg == runIgnored)
+ {
+ m_runIgnored = true;
+ }
else if (arg == listCmd)
{
FOREACH(group, m_testGroups) {
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)
{
}
}
+ currentCollector.Reset();
+
// Show help
if (showHelp)
{
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
return 0;
}
+bool TestRunner::getRunIgnored() const
+{
+ return m_runIgnored;
+}
+
}
} // namespace DPL
#
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
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
--- /dev/null
+/*
+ * 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
DECLARE_EXCEPTION_TYPE(DPL::Exception, RemoveDirectoryException)
bool FileExists(const DPL::String& absolutePath);
+bool DirectoryExists(const DPL::String& absolutePath);
/**
* Creates specified path recursively.
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();
}
#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)
};
/**
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.
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.
*/
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.
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
--- /dev/null
+/*
+ * 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 + "\"";
+}
+
+}
}
}
+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)
{
#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
{
};
struct Settings {
- bool testMode;
+ int testModes;
bool isEmulator;
Settings()
- : testMode(false),
- isEmulator(false)
+ : isEmulator(false), testModes(0)
{}
};
// 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
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()
* @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)
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,
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;
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;
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;
+ }
+}
+
${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}
)
}
}
+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
}
}
+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
}
}
+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
{
}
+WidgetDAO::WidgetDAO(DPL::String pkgName) :
+ WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(pkgName))
+{
+}
+
WidgetDAO::~WidgetDAO()
{
}
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);
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)
}
}
-void WidgetDAO::registerLaunchCertificates(DbWidgetHandle widgetHandle,
+void WidgetDAO::registerCertificatesChains(DbWidgetHandle widgetHandle,
+ CertificateSource certificateSource,
const CertificateChainList &certificateChainList)
{
using namespace DPL::DB::ORM;
{
WidgetCertificate::Row row;
row.Set_app_id(widgetHandle);
+ row.Set_cert_source(certificateSource);
row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
DO_INSERT(row, WidgetCertificate);
}
}
+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)
#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 {
{
}
+WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::String pkgName) :
+ m_widgetHandle(WidgetDAOReadOnly::getHandle(pkgName))
+{
+
+}
+
WidgetDAOReadOnly::~WidgetDAOReadOnly()
{
}
DPL::OStringStream strAppId;
strAppId << m_widgetHandle;
DPL::OptionalString pkgname = getPkgname();
- path += L"/" + *pkgname + L"/";
+ path += L"/" + *pkgname;
path += srcPath + L"/";
}
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);
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();
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
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;
}
}
+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
#include <list>
#include <dpl/optional_typedefs.h>
#include <dpl/shared_ptr.h>
+#include <memory>
namespace WrtDB {
class PluginMetafileData
*/
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
*
bool flashNeeded;
DPL::OptionalString minVersionRequired;
- StringsList powderDescriptionLinks;
bool backSupported;
bool accessNetwork;
DependsPkgList dependsPkgList;
// Splash image path
DPL::OptionalString splashImgSrc;
+ // Background page filename
+ DPL::OptionalString backgroundPage;
ConfigParserData() :
flashNeeded(false),
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);
static NameMap GetNames();
static DeviceCapabilitiesMap GetDevCapWithFeatureHandle();
+ static FeatureMap GetFeatures(const std::list<std::string>& featureNames);
+
protected:
FeatureHandle m_featureHandle;
};
typedef int FeatureSetHandle;
typedef std::list<FeatureSetHandle> FeatureSetHandleList;
+typedef struct {
+ std::string featureName;
+ DbPluginHandle pluginHandle;
+} FeatureData;
+
class FeatureModel : public DPL::Event::Model
{
public:
*/
inline const char* GetFactoryInstalledWidgetPath()
{
- return "/opt/apps/widget/system";
+ return "/opt/share/widget/system";
}
/**
*/
inline const char* GetWidgetSrcPath()
{
- return "res/wgt";
+ return "/res/wgt";
}
/**
*/
inline const char* GetPublicVirtualRootPath()
{
- return "/opt/apps/widget/data/Public";
+ return "/opt/share/widget/data/Public";
}
/**
*/
inline const char* GetTestsDataPath()
{
- return "/opt/apps/widget/tests";
+ return "/opt/share/widget/tests";
}
/**
*/
inline const char* GetUserWidgetExecPath()
{
- return "bin";
+ return "/bin";
}
/**
*/
// 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()
*/
inline const char* GetPluginInstallInitializerName()
{
- return "/opt/apps/widget/plugin-installation-required";
+ return "/opt/share/widget/plugin-installation-required";
}
/**
inline const char* GetTempInstallInfoPath()
{
- return "/opt/apps/widget/temp_info";
+ return "/opt/share/widget/temp_info";
}
} // namespace GlobalConfig
} // namespace WrtDB
SIGNATURE_TYPE_UNIDENTIFIED
};
+enum CertificateSource {
+ SIGNATURE_DISTRIBUTOR = 0,
+ SIGNATURE_AUTHOR = 1
+};
+
typedef std::list<DPL::String> StringList;
struct WidgetLocalizedInfo
virtual bool isWacSigned() const = 0;
- virtual void getCertificateChainList(CertificateChainList& list) const = 0;
+ virtual void getCertificateChainList(CertificateChainList& list,
+ CertificateSource source) const = 0;
};
/**
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
{
};
typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
-
/**
* This is a constructor.
*
*/
WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
+ WidgetDAOReadOnly(DPL::String pkgName);
/**
* Destructor
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.
*/
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.
*
LanguageTagList getLanguageTags() const;
LanguageTagList getIconLanguageTags() const;
+
+
WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
std::string getCookieDatabasePath() const;
// Local storage
*/
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;
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
typedef WrtDB::DbWidgetHandle WidgetHandle;
typedef WrtDB::DbWidgetHandleList WidgetHandleList;
+typedef WrtDB::DbWidgetDAOReadOnlyList WidgetDAOReadOnlyList;
typedef WrtDB::DbWidgetFeature WidgetFeature;
typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet;
namespace FeatureDAO {
FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
const DbPluginHandle pluginHandle);
+ void UnregisterFeature(FeatureHandle featureHandle);
} // namespace FeatureDB
} // namespace WrtDB
static void setPluginInstallationStatus(
DbPluginHandle,
PluginInstallationState);
+
+ static void unregisterPlugin(DbPluginHandle pluginHandle);
};
} // namespace WrtDB
*/
WidgetDAO(DbWidgetHandle widgetHandle);
WidgetDAO(DPL::OptionalString widgetGUID);
+ WidgetDAO(DPL::String pkgName);
/**
* Destructor
*/
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,
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,
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
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
)
)
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),)
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)
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)
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)
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");
-#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
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
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/*
--- /dev/null
+<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>