From: Soyoung Kim Date: Tue, 20 Nov 2012 06:18:20 +0000 (+0900) Subject: Modify installed path for preload widget. X-Git-Tag: 2.1b_release~6^2~135 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65bd45d41b25132a2f4e5aba8d0c3f6961ad8335;p=framework%2Fweb%2Fwrt-commons.git Modify installed path for preload widget. [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] Add db column for widget installed path at WidgetExtendedInfo [SCMRequest] This commit should release with wrt-installer. Change-Id: If213499637fef81ec9839f4ef24df370c8679e62 --- diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index 56076b1..d46f378 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -392,7 +392,7 @@ void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle, row.Set_install_time(regInfo.installedTime); row.Set_splash_img_src(regInfo.configInfo.splashImgSrc); row.Set_background_page(regInfo.configInfo.backgroundPage); - + row.Set_installed_path(regInfo.widgetInstalledPath); DO_INSERT(row, WidgetExtendedInfo) } diff --git a/modules/widget_dao/dao/widget_dao_read_only.cpp b/modules/widget_dao/dao/widget_dao_read_only.cpp index 4671cb0..0d52aae 100644 --- a/modules/widget_dao/dao/widget_dao_read_only.cpp +++ b/modules/widget_dao/dao/widget_dao_read_only.cpp @@ -215,14 +215,9 @@ DPL::OptionalInt WidgetDAOReadOnly::checkPropertyReadFlag( DPL::String WidgetDAOReadOnly::getPath() const { - DPL::String path = DPL::FromUTF8String( - GlobalConfig::GetUserInstalledWidgetPath()); + DPL::String path = *getWidgetInstalledPath(); DPL::String srcPath = DPL::FromUTF8String(GlobalConfig::GetWidgetSrcPath()); - DPL::OStringStream strAppId; - strAppId << m_widgetHandle; - DPL::OptionalString pkgname = getPkgname(); - path += L"/" + *pkgname; path += srcPath + L"/"; return path; @@ -1142,6 +1137,25 @@ SettingsType WidgetDAOReadOnly::getFileSystemUsage(void) const return static_cast(*result); } +DPL::OptionalString WidgetDAOReadOnly::getWidgetInstalledPath() const +{ + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface()) + select->Where(Equals(m_widgetHandle)); + + WidgetExtendedInfo::Select::RowList rows = select->GetRowList(); + if (rows.empty()) { + ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, + "Cannot find widget. Handle: " << m_widgetHandle); + } + + return rows.front().Get_installed_path(); + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get widdget installed path") +} #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN #undef SQL_CONNECTION_EXCEPTION_HANDLER_END #undef CHECK_WIDGET_EXISTENCE diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h b/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h index 9f18da2..2721214 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h @@ -61,6 +61,22 @@ inline const char* GetUserInstalledWidgetPath() } /** + * WRT widgets that are preloaded + */ +inline const char* GetUserPreloadedWidgetPath() +{ + return "/usr/apps"; +} + +/** + * WRT widgets that are downloaded and installed by user + */ +inline const char* GetWidgetUserDataPath() +{ + return "/opt/usr/apps"; +} + +/** * WRT widgets that are downloaded and installed by user */ inline const char* GetWidgetSrcPath() diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_config.h b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_config.h index bd1ee00..7669701 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_config.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_config.h @@ -35,7 +35,7 @@ namespace WidgetConfig { inline std::string GetWidgetBasePath(DPL::String pkgName) { return PathBuilder() - .Append(GlobalConfig::GetUserInstalledWidgetPath()) + .Append(GlobalConfig::GetWidgetUserDataPath()) .Append(DPL::ToUTF8String(pkgName)) .GetFullPath(); } diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h index 2d776ca..3d33b89 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h @@ -180,6 +180,7 @@ struct WidgetRegisterInfo PackagingType packagingType; EncryptedFileList encryptedFiles; ExternalLocationList externalLocations; + DPL::OptionalString widgetInstalledPath; }; typedef std::list CertificateChainList; @@ -765,6 +766,13 @@ class WidgetDAOReadOnly SettingsType getWebNotificationUsage() const; SettingsType getWebDatabaseUsage() const; SettingsType getFileSystemUsage() const; + + /** + * This method returns widget's installed path + * + * @return path of widget installed + */ + DPL::OptionalString getWidgetInstalledPath() const; }; } // namespace WrtDB diff --git a/modules/widget_dao/orm/wrt_db b/modules/widget_dao/orm/wrt_db index 751addc..56c93a0 100644 --- a/modules/widget_dao/orm/wrt_db +++ b/modules/widget_dao/orm/wrt_db @@ -91,6 +91,7 @@ CREATE_TABLE(WidgetExtendedInfo) 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 '') + COLUMN(installed_path, VARCHAR(512), DEFAULT '') TABLE_CONSTRAINTS( FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE )