/**
* @brief Gets the display name of privilege with the given privilege.
+ * @remarks If the given @a privilege not exist then it returns PRVMGR_ERR_NONE with NULL @a name.
* @remarks @a name must be released with free() by you.
* @param [in] privilege The privilege
* @param [out] name The display name of the privilege
* @retval #PRVMGR_ERR_NONE Successful
* @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory
* @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
+ * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
*/
EXPORT_API int privilege_info_get_privilege_display_name(const char *privilege, char **name);
/**
+ * @brief Gets the display name of privilege with the given privilege and package_type
+ * @remarks @a display_name must be released with free() by you.
+ * @param [in] privilege The privilege
+ * @param [in] api_version The api version
+ * @param [in] package_type The package type
+ * @param [out] display_name The display name of the 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
+ * @retval #PRVMGR_ERR_NO_EXIST_PRIVILEGE The given privilege doesn't exist
+ * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
+ */
+EXPORT_API int privilege_info_get_privilege_display_name_by_package_type(const char* privilege, const char* api_version, privilege_manager_package_type_e package_type, char** display_name);
+
+/**
* @brief Gets the description of privilege with the given privilege.
+ * @remarks If the given @a privilege not exist then it returns PRVMGR_ERR_NONE with NULL @a name.
* @remarks @a description must be released with free() by you.
* @param [in] privilege The privilege
* @param [out] description The description of the privilege
* @retval #PRVMGR_ERR_NONE Successful
* @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory
* @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
+ * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
*/
EXPORT_API int privilege_info_get_privilege_description(const char *privilege, char **description);
+/*
+ * @brief Gets the description of privilege with the given privilege and package_type
+ * @remarks @a description must be released with free() by you.
+ * @param [in] privilege The privilege
+ * @param [in] api_version The api version
+ * @param [in] package_type The package type
+ * @param [out] description The description of the 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
+ * @retval #PRVMGR_ERR_NO_EXIST_PRIVILEGE The given privilege doesn't exist
+ * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
+ */
+EXPORT_API int privilege_info_get_privilege_description_by_package_type(const char* privilege, const char* api_version, privilege_manager_package_type_e package_type, char** description);
+
/**
* @brief Determines whether the given privilege is valid.
* @param [in] privilege The privilege
* @brief Gets privacy id of the given privilege.
* @remarks @a privacy must be released with free() by you.
* @param [in] privilege The privilege
- * @param [out] privacy The privacy id of the given privilege
+ * @param [out] privacy The privacy name of the given privilege
* @return 0 on success, otherwise a nonzero error value.
* @retval #PRVMGR_ERR_NONE Successful
* @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
return PRVMGR_ERR_NONE;
}
-static int __get_privilege_display_name_string_id_by_package_type(privilege_manager_package_type_e package_type, const char* privilege, char** string_id)
+static int __get_privilege_display_name_string_id(privilege_manager_package_type_e package_type, const char* privilege, char** string_id)
{
char* temp = NULL;
int ret = privilege_db_manager_get_privilege_display(package_type, privilege, NULL, &temp);
*string_id = strdup(temp);
TryReturn(string_id != NULL, SafeFree(temp), PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] strdup() failed.");
} else {
- LOGE("%s privilege %s exist but have no display name", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : "core", privilege);
+ //NOTE: This is a case that shouldn't happen, but if it does, return PRVMGR_ERR_NONE with NULL string_id
+ LOGE("%s privilege %s exist but have no display name", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : package_type == PRVMGR_PACKAGE_TYPE_CORE ? "core" : "", privilege);
}
ret = PRVMGR_ERR_NONE;
} else if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) {
- LOGD("%s privilege %s not exist", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : "core", privilege);
+ LOGD("%s privilege %s not exist", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : package_type == PRVMGR_PACKAGE_TYPE_CORE ? "core" : "", privilege);
ret = PRVMGR_ERR_NO_EXIST_PRIVILEGE;
} else {
LOGE("privilege_db_manager_get_privilege_display() failed. ret = %d", ret);
return ret;
}
-static int __get_privilege_display_name_string_id(const char *privilege, char **string_id)
-{
- TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
-
- int ret = __get_privilege_display_name_string_id_by_package_type(PRVMGR_PACKAGE_TYPE_CORE, privilege, string_id);
-
- if (ret == PRVMGR_ERR_NO_EXIST_PRIVILEGE)
- ret = __get_privilege_display_name_string_id_by_package_type(PRVMGR_PACKAGE_TYPE_WRT, privilege, string_id);
-
- if (ret == PRVMGR_ERR_NO_EXIST_PRIVILEGE)
- LOGE("Privilege [%s] doesn't exist for any type of package", privilege);
-
- return ret;
-}
-
int privilege_info_get_privilege_display_name(const char *privilege, char **name)
{
TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
char *string_id = NULL;
int ret = 0;
- ret = __get_privilege_display_name_string_id(privilege, &string_id);
+ ret = __get_privilege_display_name_string_id(PRVMGR_PACKAGE_TYPE_NONE, privilege, &string_id);
if (ret == PRVMGR_ERR_NONE) {
if (string_id != NULL)
ret = privilege_info_get_privilege_string_by_string_id(string_id, name);
return ret;
}
-static int __get_privilege_description_string_id_by_package_type(privilege_manager_package_type_e package_type, const char* privilege, char** string_id)
+static int __get_privilege_description_string_id(privilege_manager_package_type_e package_type, const char* privilege, char** string_id)
{
char* temp = NULL;
int ret = privilege_db_manager_get_privilege_description(package_type, privilege, NULL, &temp);
*string_id = strdup(temp);
TryReturn(string_id != NULL, SafeFree(temp), PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] strdup() failed.");
} else {
- LOGE("%s privilege %s exist but have no description", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : "core", privilege);
+ //NOTE: This is a case that shouldn't happen, but if it does, return PRVMGR_ERR_NONE with NULL string_id
+ LOGE("%s privilege %s exist but have no description", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : package_type == PRVMGR_PACKAGE_TYPE_CORE ? "core" : "", privilege);
}
ret = PRVMGR_ERR_NONE;
} else if (ret == PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT) {
- LOGD("%s privilege %s not exist", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : "core", privilege);
+ LOGD("%s privilege %s not exist", package_type == PRVMGR_PACKAGE_TYPE_WRT ? "wrt" : package_type == PRVMGR_PACKAGE_TYPE_CORE ? "core" : "", privilege);
ret = PRVMGR_ERR_NO_EXIST_PRIVILEGE;
} else {
LOGE("privilege_db_manager_get_privilege_description() failed. ret = %d", ret);
return ret;
}
-static int __get_privilege_description_string_id(const char *privilege, char **string_id)
+int privilege_info_get_privilege_description(const char *privilege, char **description)
{
TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
- int ret = __get_privilege_description_string_id_by_package_type(PRVMGR_PACKAGE_TYPE_CORE, privilege, string_id);
+ char *string_id = NULL;
+ int ret = 0;
+
+ ret = __get_privilege_description_string_id(PRVMGR_PACKAGE_TYPE_NONE, privilege, &string_id);
+ if (ret == PRVMGR_ERR_NONE) {
+ if (string_id != NULL)
+ ret = privilege_info_get_privilege_string_by_string_id(string_id, description);
+ } else if (ret == PRVMGR_ERR_NO_EXIST_PRIVILEGE) {
+ ret = PRVMGR_ERR_NONE;
+ } else {
+ LOGE("__get_privilege_description_string_id() failed. ret = %d", ret);
+ }
- if (ret == PRVMGR_ERR_NO_EXIST_PRIVILEGE)
- ret = __get_privilege_description_string_id_by_package_type(PRVMGR_PACKAGE_TYPE_WRT, privilege, string_id);
+ SafeFree(string_id);
return ret;
}
-int privilege_info_get_privilege_description(const char *privilege, char **description)
+int privilege_info_get_privilege_display_name_by_package_type(const char* privilege, __attribute__((unused)) const char* api_version, privilege_manager_package_type_e package_type, char** display_name)
{
- TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
+ TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege must not be NULL");
+ TryReturn(package_type == PRVMGR_PACKAGE_TYPE_WRT || package_type == PRVMGR_PACKAGE_TYPE_CORE, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] Unknown package_type %d", package_type);
- char *string_id = NULL;
- int ret = 0;
+ char* string_id = NULL;
+ int ret = __get_privilege_display_name_string_id(package_type, privilege, &string_id);
+ if (ret == PRVMGR_ERR_NONE) {
+ if (string_id != NULL)
+ ret = privilege_info_get_privilege_string_by_string_id(string_id, display_name);
+ } else {
+ LOGE("__get_privilege_display_name_string_id() failed. ret = %d", ret);
+ }
+
+ SafeFree(string_id);
+
+ return ret;
+}
+
+int privilege_info_get_privilege_description_by_package_type(const char* privilege, __attribute__((unused)) const char* api_version, privilege_manager_package_type_e package_type, char** description)
+{
+ TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege must not be NULL");
+ TryReturn(package_type == PRVMGR_PACKAGE_TYPE_WRT || package_type == PRVMGR_PACKAGE_TYPE_CORE, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] Unknown package_type %d", package_type);
- ret = __get_privilege_description_string_id(privilege, &string_id);
+ char* string_id = NULL;
+ int ret = __get_privilege_description_string_id(package_type, privilege, &string_id);
if (ret == PRVMGR_ERR_NONE) {
if (string_id != NULL)
ret = privilege_info_get_privilege_string_by_string_id(string_id, description);
- } else if (ret == PRVMGR_ERR_NO_EXIST_PRIVILEGE) {
- ret = PRVMGR_ERR_NONE;
} else {
LOGE("__get_privilege_description_string_id() failed. ret = %d", ret);
}