Implement privilege database table
authorJihoon Chung <jihoon.chung@samsung.com>
Thu, 13 Dec 2012 04:51:56 +0000 (13:51 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 14 Dec 2012 00:28:47 +0000 (09:28 +0900)
[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

modules/widget_dao/dao/config_parser_data.cpp
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
modules/widget_dao/orm/wrt_db

index 4d0968b..9e2e2a4 100644 (file)
@@ -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;
index db2e682..5f8ca9b 100644 (file)
@@ -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 &regInfo)
+{
+    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"
index f82ea01..918ae0d 100644 (file)
@@ -77,6 +77,22 @@ class ConfigParserData
     };
     typedef std::set<Feature> 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<Privilege> 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;
 
index e6776d8..3f7b819 100644 (file)
@@ -175,6 +175,9 @@ class WidgetDAO : public WidgetDAOReadOnly
     static void registerWidgetFeatures(
             DbWidgetHandle widgetHandle,
             const WidgetRegisterInfo &regInfo);
+    static void registerWidgetPrivilege(
+            DbWidgetHandle widgetHandle,
+            const WidgetRegisterInfo &regInfo);
     static void registerWidgetWindowModes(
             DbWidgetHandle widgetHandle,
             const WidgetRegisterInfo &regInfo);
index 9f35e25..06c12bc 100644 (file)
@@ -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,)