From: Jihoon Chung Date: Thu, 13 Dec 2012 04:51:56 +0000 (+0900) Subject: Implement privilege database table X-Git-Tag: 2.1b_release~6^2~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=137bad71be6ee7ef3e655b8c54be91c5fad92e22;p=framework%2Fweb%2Fwrt-commons.git Implement privilege database table [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] "Feature" name will be changed to "Privilege" This commit create new database table for privilege. [SCMRequest] N/A Change-Id: Ieed9cede62936000a03ad445f523059a4246a3d4 --- diff --git a/modules/widget_dao/dao/config_parser_data.cpp b/modules/widget_dao/dao/config_parser_data.cpp index 4d0968b..9e2e2a4 100644 --- a/modules/widget_dao/dao/config_parser_data.cpp +++ b/modules/widget_dao/dao/config_parser_data.cpp @@ -299,6 +299,36 @@ bool ConfigParserData::Feature::operator<=(const Feature& other) const return paramsList <= other.paramsList; } +bool ConfigParserData::Privilege::operator==(const Privilege& other) const +{ + return name == other.name; +} + +bool ConfigParserData::Privilege::operator!=(const Privilege& other) const +{ + return name != other.name; +} + +bool ConfigParserData::Privilege::operator >(const Privilege& other) const +{ + return name > other.name; +} + +bool ConfigParserData::Privilege::operator>=(const Privilege& other) const +{ + return name >= other.name; +} + +bool ConfigParserData::Privilege::operator <(const Privilege& other) const +{ + return name < other.name; +} + +bool ConfigParserData::Privilege::operator<=(const Privilege& other) const +{ + return name < other.name; +} + bool ConfigParserData::Icon::operator==(const Icon& other) const { return src == other.src; diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index db2e682..5f8ca9b 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -338,6 +338,8 @@ void WidgetDAO::registerWidgetInternal( registerWidgetFeatures(widgetHandle, widgetRegInfo); + registerWidgetPrivilege(widgetHandle, widgetRegInfo); + registerWidgetWindowModes(widgetHandle, widgetRegInfo); registerWidgetWarpInfo(widgetHandle, widgetRegInfo); @@ -629,6 +631,22 @@ void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle, } } +void WidgetDAO::registerWidgetPrivilege(DbWidgetHandle widgetHandle, + const WidgetRegisterInfo ®Info) +{ + using namespace DPL::DB::ORM; + const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo; + + FOREACH(it, widgetConfigurationInfo.privilegeList) + { + wrt::WidgetPrivilege::Row widgetPrivilege; + widgetPrivilege.Set_app_id(widgetHandle); + widgetPrivilege.Set_name(it->name); + + DO_INSERT(widgetPrivilege, wrt::WidgetPrivilege) + } +} + void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature){ // This function could be merged with registerWidgetFeature but it requires desing change: // 1. Check "ace step" in installer must be done before "update database step" diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h b/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h index f82ea01..918ae0d 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h @@ -77,6 +77,22 @@ class ConfigParserData }; typedef std::set FeaturesList; + struct Privilege + { + Privilege(const DPL::String& _name) : name(_name) + { + } + DPL::String name; + + bool operator==(const Privilege&) const; + bool operator!=(const Privilege&) const; + bool operator >(const Privilege&) const; + bool operator>=(const Privilege&) const; + bool operator <(const Privilege&) const; + bool operator<=(const Privilege&) const; + }; + typedef std::set PrivilegeList; + struct Icon { Icon(const DPL::String& _src) : src(_src) @@ -202,6 +218,7 @@ class ConfigParserData DPL::OptionalString authorEmail; FeaturesList featuresList; + PrivilegeList privilegeList; SettingsList settingsList; diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h index e6776d8..3f7b819 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h @@ -175,6 +175,9 @@ class WidgetDAO : public WidgetDAOReadOnly static void registerWidgetFeatures( DbWidgetHandle widgetHandle, const WidgetRegisterInfo ®Info); + static void registerWidgetPrivilege( + DbWidgetHandle widgetHandle, + const WidgetRegisterInfo ®Info); static void registerWidgetWindowModes( DbWidgetHandle widgetHandle, const WidgetRegisterInfo ®Info); diff --git a/modules/widget_dao/orm/wrt_db b/modules/widget_dao/orm/wrt_db index 9f35e25..06c12bc 100644 --- a/modules/widget_dao/orm/wrt_db +++ b/modules/widget_dao/orm/wrt_db @@ -124,12 +124,20 @@ CREATE_TABLE(FeatureParam) COLUMN_NOT_NULL(widget_feature_id, INTEGER,) COLUMN_NOT_NULL(name, TEXT,) COLUMN_NOT_NULL(value, TEXT,) - TABLE_CONSTRAINTS( FOREIGN KEY (widget_feature_id) REFERENCES WidgetFeature (widget_feature_id) ON DELETE CASCADE ) CREATE_TABLE_END() +CREATE_TABLE(WidgetPrivilege) + COLUMN_NOT_NULL(widget_privilege_id, INTEGER, primary key autoincrement) + COLUMN_NOT_NULL(app_id, INT,) + COLUMN_NOT_NULL(name, VARCHAR(256),) + TABLE_CONSTRAINTS( + FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE + ) +CREATE_TABLE_END() + CREATE_TABLE(WidgetIcon) COLUMN_NOT_NULL(icon_id, INTEGER, primary key autoincrement) COLUMN_NOT_NULL(app_id, INT,)