Separate the information of external privilege
authorhb.min <hb.min@samsung.com>
Tue, 9 Jul 2013 05:20:33 +0000 (14:20 +0900)
committerhb.min <hb.min@samsung.com>
Tue, 9 Jul 2013 05:20:33 +0000 (14:20 +0900)
Change-Id: I3331f403714ad2027e66162d7c3f6effa26dcb19
Signed-off-by: hb.min <hb.min@samsung.com>
capi/include/privilege_info.h
capi/include/privilege_info_types.h
capi/src/privilege_info.c
packaging/privilege-checker.spec

index e25c2b5..ec10687 100644 (file)
@@ -118,6 +118,18 @@ EXPORT_API int privilege_info_get_privilege_display_name(const char *privilege,
  */
 EXPORT_API int privilege_info_get_privilege_description(const char *privilege, char **description);
 
+/**
+ * @brief Gets the privilege level of external privilege.
+ * @remarks @a privilege_level must be released with free() by you.
+ * @param [in] privilege The privilege
+ * @param [out] privilege_level The privilege_level of the external privilege
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVMGR_ERR_NONE Successful
+ * @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory
+ * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
+ */
+EXPORT_API int privilege_info_get_external_privilege_level(const char *privilege, char **privilege_level);
+
 #ifdef __cplusplus
 }
 #endif
index 9bbbf45..6a82424 100644 (file)
@@ -31,7 +31,6 @@ typedef enum _privilegeGroup
        MAX_PRV_GROUP,
 } privilegeGroup;
 
-#define PRIVILEGE_NUM 131
 #define EXTRA_GROUP MAX_PRV_GROUP - 1
 
 typedef struct
@@ -39,12 +38,22 @@ typedef struct
        const char* privilege;
        const char* name_string_id;
        const char* description_string_id;
+       const char* privilege_level;
        privilegeGroup privilege_group_enum;
 
 } privilege_info_s;
 
 typedef struct
 {
+       const char* privilege;
+       const char* name_string_id;
+       const char* description_string_id;
+       privilegeGroup privilege_group_enum;
+
+} external_privilege_info_s;
+
+typedef struct
+{
        const char* privilege_group;
        privilegeGroup privilege_group_enum;
        const char* name_string_id;
@@ -65,6 +74,8 @@ const static privilege_group_info_s privilege_group_info_table[MAX_PRV_GROUP] =
        {"http://tizen.org/privilege/group3", _PRV_GROUP_3, "IDS_PRIVILEGE_GROUP_NAME3"},
 };
 
+#define PRIVILEGE_NUM 123
+
 const static privilege_info_s privilege_info_table[PRIVILEGE_NUM] =
 {
        {"http://tizen.org/privilege/account.read", "IDS_ST_BODY_READING_ACCOUNTS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_READ_ACCOUNTS", _PRV_GROUP_1},
@@ -190,14 +201,13 @@ const static privilege_info_s privilege_info_table[PRIVILEGE_NUM] =
        {"http://tizen.org/privilege/wifi.wifidirect.admin", "IDS_ST_BODY_MANAGING_WI_FI_DIRECT_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_MANAGE_WI_FI_DIRECT_ON_THE_DEVICE", _PRV_GROUP_1},
        {"http://tizen.org/privilege/wifi.wifidirect.read", "IDS_ST_BODY_READING_WI_FI_DIRECT_INFORMATION_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_REQUEST_WI_FI_DIRECT_INFORMATION", _PRV_GROUP_1},
        {"http://tizen.org/privilege/wifimanager", "IDS_ST_BODY_MANAGING_WI_FI_SYSTEM_SETTINGS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_MANAGE_THE_WI_FI_SYSTEM_SETTINGS_SUCH_AS_UPDATING_AP_INFORMATION", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/audiomanager.session", "IDS_ST_BODY_MANAGING_AUDIO_SESSIONS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_MANAGE_THE_AUDIO_SESSION_POLICY_BETWEEN_APPLICATIONS", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/audiomanager.voipsession", "IDS_ST_BODY_MANAGING_VOIP_AUDIO_SESSIONS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_MANAGE_AUDIO_SESSIONS_WITH_VOIP_CALLS", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/audiomanager.volume", "IDS_ST_BODY_MANAGING_VOLUMES_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_MANAGE_THE_AUDIO_VOLUMES_OF_VARIOUS_AUDIO_STREAM_TYPES", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/contextmanager.upload", "IDS_ST_BODY_UPLOADING_LOGS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_UPLOAD_THE_ACTIVITY_LOG_TO_THE_SERVER", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/mdm", "IDS_ST_BODY_MANAGING_MDM_SERVICE_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_MANAGE_THE_DEVICE", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/mobilecare", "IDS_ST_BODY_MANAGING_SAMSUNG_MOBILECARE_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_CONTROL_SAMSUNG_MOBILECARE", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/nfccardmanager", "IDS_ST_BODY_MANAGING_NFC_CARD_EMULATION_SETTINGS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_CHANGE_NFC_CARD_EMULATION_MODE_SETTINGS_MSG", _PRV_GROUP_1},
-       {"http://developer.samsung.com/tizen/privilege/samsungmaps", "IDS_ST_BODY_MANAGING_SAMSUNG_MAPS_M_NOUN", "IDS_ST_BODY_ALLOWS_THE_APPLICATION_TO_CONTROL_SAMSUNG_MAPS", _PRV_GROUP_1},
+};
+
+#define EXTERNAL_PRIVILEGE_NUM 0
+
+const static privilege_info_s external_privilege_info_table[EXTERNAL_PRIVILEGE_NUM] =
+{
+       //      {"http://privilege", "IDS_PRIVILEGE_NAME_ID", "IDS_PRIVILEGE_DESC_ID", "platform", _PRV_GROUP_ENUM},
 };
 
 #ifdef __cplusplus
index 81d8b03..87f6f9d 100644 (file)
@@ -41,7 +41,7 @@ int privilege_info_privilege_list_by_pkgid_callback (const char *privilege_name,
 
        for (i = 0; i < PRIVILEGE_NUM; i++)
        {
-               if (strcmp(privilege_info_table[i].privilege, privilege_name) == 0)
+               if (strncmp(privilege_info_table[i].privilege, privilege_name, strlen(privilege_info_table[i].privilege)) == 0)
                {
                        groupTable[(privilege_info_table[i].privilege_group_enum)] = 1;
                        matchedFlag = true;
@@ -51,6 +51,19 @@ int privilege_info_privilege_list_by_pkgid_callback (const char *privilege_name,
 
        if (matchedFlag == false)
        {
+               for (i = 0; i < EXTERNAL_PRIVILEGE_NUM; i++)
+               {
+                       if (strncmp(external_privilege_info_table[i].privilege, privilege_name, strlen(external_privilege_info_table[i].privilege)) == 0)
+                       {
+                               groupTable[(external_privilege_info_table[i].privilege_group_enum)] = 1;
+                               matchedFlag = true;
+                               break;
+                       }
+               }
+       }
+
+       if (matchedFlag == false)
+       {
                groupTable[EXTRA_GROUP] = 1;
        }
 
@@ -98,7 +111,7 @@ int privilege_info_privilege_list_callback (const char *privilege_name, void *us
 
        for (i = 0; i < PRIVILEGE_NUM; i++)
        {
-               if (strcmp(privilege_info_table[i].privilege, privilege_name) == 0)
+               if (strncmp(privilege_info_table[i].privilege, privilege_name, strlen(privilege_info_table[i].privilege)) == 0)
                {
                        matchedFlag = true;
                        if (privilege_info_table[i].privilege_group_enum == data.privilege_group)
@@ -111,6 +124,24 @@ int privilege_info_privilege_list_callback (const char *privilege_name, void *us
                }
        }
 
+       if (matchedFlag == false)
+       {
+               for (i = 0; i < EXTERNAL_PRIVILEGE_NUM; i++)
+               {
+                       if (strncmp(external_privilege_info_table[i].privilege, privilege_name, strlen(external_privilege_info_table[i].privilege)) == 0)
+                       {
+                               matchedFlag = true;
+                               if (external_privilege_info_table[i].privilege_group_enum == data.privilege_group)
+                               {
+                                       res = data.callback(privilege_name, data.user_data);
+                                       TryReturn(res >= 0, PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] return value of callback function is negative.");
+
+                                       break;
+                               }
+                       }
+               }
+       }
+
        if ((matchedFlag == false) && (data.privilege_group == EXTRA_GROUP))
        {
                res = data.callback(privilege_name, data.user_data);
@@ -136,7 +167,7 @@ int privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group(const cha
 
        for (i = 0; i < MAX_PRV_GROUP; i++)
        {
-               if (strcmp(privilege_group_info_table[i].privilege_group, privilege_group) == 0)
+               if (strncmp(privilege_group_info_table[i].privilege_group, privilege_group, strlen(privilege_group_info_table[i].privilege_group)) == 0)
                {
                        data.privilege_group = privilege_group_info_table[i].privilege_group_enum;
                        break;
@@ -175,12 +206,14 @@ int privilege_info_get_privilege_group_display_name_by_string_id(const char *str
 int privilege_info_get_name_string_id(const char *privilege, char **name_string_id)
 {
        int index = 0;
+       bool matchedFlag = false;
        TryReturn(privilege != NULL, PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
 
        for (index = 0; index < PRIVILEGE_NUM; index++)
        {
-               if (strcmp(privilege_info_table[index].privilege, privilege) == 0)
+               if (strncmp(privilege_info_table[index].privilege, privilege, strlen(privilege_info_table[index].privilege)) == 0)
                {
+                       matchedFlag = true;
                        *name_string_id = (char*)calloc(strlen(privilege_info_table[index].name_string_id) + 1, sizeof(char));
                        TryReturn(*name_string_id != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed.");
 
@@ -189,6 +222,21 @@ int privilege_info_get_name_string_id(const char *privilege, char **name_string_
                }
        }
 
+       if (matchedFlag == false)
+       {
+               for (index = 0; index < EXTERNAL_PRIVILEGE_NUM; index++)
+               {
+                       if (strncmp(external_privilege_info_table[index].privilege, privilege, strlen(external_privilege_info_table[index].privilege)) == 0)
+                       {
+                               *name_string_id = (char*)calloc(strlen(external_privilege_info_table[index].name_string_id) + 1, sizeof(char));
+                               TryReturn(*name_string_id != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed.");
+
+                               memcpy(*name_string_id, external_privilege_info_table[index].name_string_id, strlen(external_privilege_info_table[index].name_string_id));
+                               break;
+                       }
+               }
+       }
+
        return PRVMGR_ERR_NONE;
 }
 
@@ -245,12 +293,14 @@ int privilege_info_get_privilege_display_name(const char *privilege, char **name
 int privilege_info_get_description_string_id(const char *privilege, char **description_string_id)
 {
        int index = 0;
+       bool matchedFlag = false;
        TryReturn(privilege != NULL, PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
 
        for (index = 0; index < PRIVILEGE_NUM; index++)
        {
-               if (strcmp(privilege_info_table[index].privilege, privilege) == 0)
+               if (strncmp(privilege_info_table[index].privilege, privilege, strlen(privilege_info_table[index].privilege)) == 0)
                {
+                       matchedFlag = true;
                        *description_string_id = (char*)calloc(strlen(privilege_info_table[index].description_string_id) + 1, sizeof(char));
                        TryReturn(*description_string_id != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed.");
 
@@ -259,6 +309,21 @@ int privilege_info_get_description_string_id(const char *privilege, char **descr
                }
        }
 
+       if (matchedFlag == false)
+       {
+               for (index = 0; index < EXTERNAL_PRIVILEGE_NUM; index++)
+               {
+                       if (strncmp(external_privilege_info_table[index].privilege, privilege, strlen(external_privilege_info_table[index].privilege)) == 0)
+                       {
+                               *description_string_id = (char*)calloc(strlen(external_privilege_info_table[index].description_string_id) + 1, sizeof(char));
+                               TryReturn(*description_string_id != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed.");
+
+                               memcpy(*description_string_id, external_privilege_info_table[index].description_string_id, strlen(external_privilege_info_table[index].description_string_id));
+                               break;
+                       }
+               }
+       }
+
        return PRVMGR_ERR_NONE;
 }
 
@@ -302,3 +367,34 @@ int privilege_info_get_privilege_description(const char *privilege, char **descr
        }
        return  PRVMGR_ERR_NONE;
 }
+
+int privilege_info_get_external_privilege_level(const char *privilege, char **privilege_level)
+{
+       int index = 0;
+       bool matchedFlag = false;
+       char* public_level = "public";
+       TryReturn(privilege != NULL, PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
+
+       for (index = 0; index < EXTERNAL_PRIVILEGE_NUM; index++)
+       {
+               if (strncmp(external_privilege_info_table[index].privilege, privilege, strlen(external_privilege_info_table[index].privilege)) == 0)
+               {
+                       matchedFlag = true;
+                       *privilege_level = (char*)calloc(strlen(external_privilege_info_table[index].privilege_level) + 1, sizeof(char));
+                       TryReturn(*privilege_level != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       memcpy(*privilege_level, external_privilege_info_table[index].privilege_level, strlen(external_privilege_info_table[index].privilege_level));
+                       break;
+               }
+       }
+
+       if (matchedFlag == false)
+       {
+               *privilege_level = (char*)calloc(strlen(public_level) + 1, sizeof(char));
+               TryReturn(*privilege_level != NULL, PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] Memory allocation failed.");
+
+               memcpy(*privilege_level, public_level, strlen(public_level));
+       }
+
+       return  PRVMGR_ERR_NONE;
+}
index 716e538..a48f54f 100644 (file)
@@ -1,6 +1,6 @@
 Name:    privilege-checker
 Summary: Privilege Management
-Version: 0.0.2
+Version: 0.0.3
 Release: 3
 Group:   System/Libraries
 License: SAMSUNG
@@ -39,6 +39,7 @@ The Privilege Manager API provides functions to get information about privilege
 %package  -n capi-security-privilege-manager-devel
 Summary:  Privilege Manager API (Development)
 Group:    TO_BE/FILLED_IN
+Requires:      capi-security-privilege-manager
 
 %description -n capi-security-privilege-manager-devel
 The Privilege Manager API provides functions to get information about privilege information of installed packages.(DEV)
@@ -86,9 +87,6 @@ cp util/res/opt/dbspace/.privilegelist.db /%{buildroot}/opt/dbspace/
 
 %files -n capi-security-privilege-manager-devel
 %{_includedir}/privilegemgr/*.h
-%{_libdir}/libcapi-security-privilege-manager.so*
-/usr/share/locale/*
-%manifest packaging/capi-security-privilege-manager.manifest
 
 %clean
 rm -rf %{buildroot}