From 6141ffd1a56e0686a8167fff81abff96c05f9c06 Mon Sep 17 00:00:00 2001 From: Przemyslaw Ciezkowski Date: Tue, 27 Nov 2012 15:50:31 +0100 Subject: [PATCH 1/1] Overload methods to run with tizen id instead of widgetHandle - fixed [Issue#] N/A [Bug] N/A [Cause] N/A [Solution] Overload methods to run with tizen id instead of widgetHandle. [Verification] Rebuild all repos, run DAO tests. Run tests for geolocation. Change-Id: I071e89751c5714b4740bbc697eaf065b3e94206b --- .../dpl/localization/w3c_file_localization.h | 20 +++++ modules/localization/src/w3c_file_localization.cpp | 89 ++++++++++++++++++---- .../dao/security_origin_dao.cpp | 26 +++++++ .../security-origin-dao/security_origin_dao.h | 2 + 4 files changed, 121 insertions(+), 16 deletions(-) diff --git a/modules/localization/include/dpl/localization/w3c_file_localization.h b/modules/localization/include/dpl/localization/w3c_file_localization.h index 1e155ad..e0e5737 100644 --- a/modules/localization/include/dpl/localization/w3c_file_localization.h +++ b/modules/localization/include/dpl/localization/w3c_file_localization.h @@ -38,10 +38,22 @@ typedef std::list WidgetIconList; DPL::Optional getFilePathInWidgetPackageFromUrl( WrtDB::DbWidgetHandle widgetHandle, const DPL::String &url); +DPL::Optional getFilePathInWidgetPackageFromUrl( + const WrtDB::WidgetPkgName &pkgname, + const DPL::String &url); +DPL::Optional getFilePathInWidgetPackageFromUrl( + WrtDB::WidgetDAOReadOnlyPtr dao, + const DPL::String &url); DPL::Optional getFilePathInWidgetPackage( WrtDB::DbWidgetHandle widgetHandle, const DPL::String& file); +DPL::Optional getFilePathInWidgetPackage( + const WrtDB::WidgetPkgName &pkgname, + const DPL::String& file); +DPL::Optional getFilePathInWidgetPackage( + WrtDB::WidgetDAOReadOnlyPtr dao, + const DPL::String& file); DPL::OptionalString getStartFile(WrtDB::DbWidgetHandle handle); DPL::OptionalString getStartFile(const WrtDB::WidgetPkgName & pkgname); @@ -53,9 +65,17 @@ OptionalWidgetIcon getIcon(WrtDB::WidgetDAOReadOnlyPtr dao); WidgetIconList getValidIconsList( WrtDB::DbWidgetHandle widgetHandle); +WidgetIconList getValidIconsList( + const WrtDB::WidgetPkgName &pkgname); +WidgetIconList getValidIconsList( + WrtDB::WidgetDAOReadOnlyPtr dao); OptionalWidgetStartFileInfo getStartFileInfo( WrtDB::DbWidgetHandle widgetHandle); +OptionalWidgetStartFileInfo getStartFileInfo( + const WrtDB::WidgetPkgName &pkgname); +OptionalWidgetStartFileInfo getStartFileInfo( + WrtDB::WidgetDAOReadOnlyPtr dao); WrtDB::WidgetLocalizedInfo getLocalizedInfo(WrtDB::DbWidgetHandle widgetHandle); WrtDB::WidgetLocalizedInfo getLocalizedInfo(const WrtDB::WidgetPkgName & pkgname); diff --git a/modules/localization/src/w3c_file_localization.cpp b/modules/localization/src/w3c_file_localization.cpp index 60ea79d..4a6cfe1 100644 --- a/modules/localization/src/w3c_file_localization.cpp +++ b/modules/localization/src/w3c_file_localization.cpp @@ -105,19 +105,37 @@ DPL::Optional GetFilePathInWidgetPackageInternal( } namespace W3CFileLocalization { + DPL::Optional getFilePathInWidgetPackageFromUrl( DbWidgetHandle widgetHandle, const DPL::String &url) { + return getFilePathInWidgetPackageFromUrl( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)), + url); +} + +DPL::Optional getFilePathInWidgetPackageFromUrl( + const WrtDB::WidgetPkgName &pkgname, + const DPL::String &url) +{ + return getFilePathInWidgetPackageFromUrl( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)), + url); +} + +DPL::Optional getFilePathInWidgetPackageFromUrl( + WrtDB::WidgetDAOReadOnlyPtr dao, + const DPL::String &url) +{ DPL::String req = url; - WidgetDAOReadOnly dao(widgetHandle); if (req.find(WIDGET_URI_BEGIN) == 0) { req.erase(0, WIDGET_URI_BEGIN.length()); } else if (req.find(FILE_URI_BEGIN) == 0) { req.erase(0, FILE_URI_BEGIN.length()); - if (req.find(dao.getPath()) == 0) { - req.erase(0, dao.getPath().length()); + if (req.find(dao->getPath()) == 0) { + req.erase(0, dao->getPath().length()); } if (req.find(LOCALE_PREFIX) == 0) { req.erase(0, LOCALE_PREFIX.length()); @@ -133,7 +151,7 @@ DPL::Optional getFilePathInWidgetPackageFromUrl( return DPL::Optional::Null; } - auto widgetPath = dao.getPath(); + auto widgetPath = dao->getPath(); DPL::Optional found = GetFilePathInWidgetPackageInternal(widgetPath, req); @@ -152,8 +170,25 @@ DPL::Optional getFilePathInWidgetPackage( WrtDB::DbWidgetHandle widgetHandle, const DPL::String& file) { - WidgetDAOReadOnly dao(widgetHandle); - return GetFilePathInWidgetPackageInternal(dao.getPath(), file); + return getFilePathInWidgetPackage( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)), + file); +} + +DPL::Optional getFilePathInWidgetPackage( + const WrtDB::WidgetPkgName &pkgname, + const DPL::String& file) +{ + return getFilePathInWidgetPackage( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)), + file); +} + +DPL::Optional getFilePathInWidgetPackage( + WrtDB::WidgetDAOReadOnlyPtr dao, + const DPL::String& file) +{ + return GetFilePathInWidgetPackageInternal(dao->getPath(), file); } DPL::OptionalString getStartFile(const WrtDB::WidgetPkgName & pkgname) @@ -238,18 +273,28 @@ OptionalWidgetIcon getIcon(WrtDB::WidgetDAOReadOnlyPtr dao) return OptionalWidgetIcon::Null; } -WidgetIconList getValidIconsList( - WrtDB::DbWidgetHandle widgetHandle) +WidgetIconList getValidIconsList(WrtDB::DbWidgetHandle widgetHandle) +{ + return getValidIconsList( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle))); +} + +WidgetIconList getValidIconsList(const WrtDB::WidgetPkgName &pkgname) { - WidgetDAOReadOnly dao(widgetHandle); - WidgetDAOReadOnly::WidgetIconList list = dao.getIconList(); + return getValidIconsList( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname))); +} + +WidgetIconList getValidIconsList(WrtDB::WidgetDAOReadOnlyPtr dao) +{ + WidgetDAOReadOnly::WidgetIconList list = dao->getIconList(); WidgetIconList outlist; FOREACH(it, list) { LogDebug(":" << it->iconSrc); - if (!!getFilePathInWidgetPackage(widgetHandle, + if (!!getFilePathInWidgetPackage(dao->getHandle(), it->iconSrc)) { WidgetIcon ret; @@ -262,15 +307,27 @@ WidgetIconList getValidIconsList( return outlist; } -OptionalWidgetStartFileInfo getStartFileInfo( - WrtDB::DbWidgetHandle widgetHandle) +OptionalWidgetStartFileInfo getStartFileInfo(WrtDB::DbWidgetHandle widgetHandle) +{ + return getStartFileInfo( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle))); +} + +OptionalWidgetStartFileInfo getStartFileInfo(const WrtDB::WidgetPkgName &pkgname) +{ + return getStartFileInfo( + WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname))); + +} + + +OptionalWidgetStartFileInfo getStartFileInfo(WrtDB::WidgetDAOReadOnlyPtr dao) { WidgetStartFileInfo info; - WidgetDAOReadOnly dao(widgetHandle); WidgetDAOReadOnly::LocalizedStartFileList locList = - dao.getLocalizedStartFileList(); - WidgetDAOReadOnly::WidgetStartFileList list = dao.getStartFileList(); + dao->getLocalizedStartFileList(); + WidgetDAOReadOnly::WidgetStartFileList list = dao->getStartFileList(); const LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags(); FOREACH(tag, tagsList) diff --git a/modules/security_origin_dao/dao/security_origin_dao.cpp b/modules/security_origin_dao/dao/security_origin_dao.cpp index 6dde00e..f533661 100644 --- a/modules/security_origin_dao/dao/security_origin_dao.cpp +++ b/modules/security_origin_dao/dao/security_origin_dao.cpp @@ -76,6 +76,24 @@ std::string createDatabasePath(int widgetHandle) } +std::string createDatabasePath(const DPL::String& tizenId) +{ + using namespace DPL::DB::ORM; + using namespace WrtDB::WidgetConfig; + using namespace WrtDB::GlobalConfig; + + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + std::stringstream filename; + filename << GetWidgetPersistentStoragePath(tizenId) + << "/" + << SECURITY_ORIGIN_DB_NAME; + return filename.str(); + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to get database Path") + +} + void checkDatabase(std::string databasePath) { SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN @@ -121,6 +139,14 @@ SecurityOriginDAO::SecurityOriginDAO(int handle) : m_securityOriginDBInterface.AttachToThread(SECURITY_ORIGIN_DB_OPTION); } +SecurityOriginDAO::SecurityOriginDAO(const DPL::String& tizenId): + m_securityOriginDBPath(createDatabasePath(tizenId)), + m_securityOriginDBInterface(m_securityOriginDBPath, SECURITY_ORIGIN_DB_TYPE) +{ + checkDatabase(m_securityOriginDBPath); + m_securityOriginDBInterface.AttachToThread(SECURITY_ORIGIN_DB_OPTION); +} + SecurityOriginDAO::~SecurityOriginDAO() { m_securityOriginDBInterface.DetachFromThread(); diff --git a/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h b/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h index a92650c..3d6a6f3 100644 --- a/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h +++ b/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h @@ -24,6 +24,7 @@ #include #include +#include namespace SecurityOriginDB { @@ -39,6 +40,7 @@ class SecurityOriginDAO }; explicit SecurityOriginDAO(int handle); + explicit SecurityOriginDAO(const DPL::String& tizenId); virtual ~SecurityOriginDAO(); SecurityOriginDataList getSecurityOriginDataList(); Result getResult(const SecurityOriginData &securityOriginData); -- 2.7.4