2 * Copyright (c) 2014-2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef __TIZEN_SECURITY_PRIVILEGE_INFORMATION_H
19 #define __TIZEN_SECURITY_PRIVILEGE_INFORMATION_H
25 #ifndef TIZEN_DEPRECATED_API
26 #define TIZEN_DEPRECATED_API __attribute__ ((__visibility__("default"), deprecated))
35 * @addtogroup CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE
41 * @brief Enumeration for error code for Privilege Information.
42 * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
45 PRVINFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
46 PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
47 PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
48 PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
49 PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< @deprecated Not supported (Deprecated since 7.5) */
50 PRVINFO_ERROR_NO_MATCHING_PRIVILEGE = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01 /**< No matched privilege (Since 6.0) */
51 } privilege_info_error_e;
55 * @brief Gets the display name of the given privilege.
56 * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
57 * @remarks @a display_name must be released using free().
58 * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist.
59 * @param[in] api_version The API version of the application to get privilege information
60 * @param[in] privilege The privilege
61 * @param[out] display_name The display name of the privilege
62 * @return @c 0 on success,
63 * otherwise a negative error value
64 * @retval #PRVINFO_ERROR_NONE Successful
65 * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege
66 * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
67 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
68 * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
70 int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name);
74 * @brief Gets the display name of the given privilege.
75 * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
76 * @remarks @a display_name must be released using free().
77 * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB"
78 * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist.
79 * @param[in] package_type The type of application package
80 * @param[in] api_version The API version of the application to get privilege information
81 * @param[in] privilege The privilege
82 * @param[out] display_name The display name of the privilege
83 * @return @c 0 on success,
84 * otherwise a negative error value
85 * @retval #PRVINFO_ERROR_NONE Successful
86 * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege
87 * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
88 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
89 * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
91 int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name);
95 * @brief Gets the description of the given privilege.
96 * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
97 * @remarks @a description must be released using free().
98 * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist.
99 * @param[in] api_version The API version of the application to get privilege information
100 * @param[in] privilege The privilege
101 * @param[out] description The description of the privilege
102 * @return @c 0 on success,
103 * otherwise a negative error value
104 * @retval #PRVINFO_ERROR_NONE Successful
105 * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege
106 * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
107 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
108 * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
110 int privilege_info_get_description(const char *api_version, const char *privilege, char **description);
114 * @brief Gets the description of the given privilege.
115 * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
116 * @remarks @a description must be released using free().
117 * @remarks @a package_type must be one of followings: "PRVINFO_PACKAGE_TYPE_NATIVE", "PRVINFO_PACKAGE_TYPE_WEB"
118 * @remarks Since 6.0, this function returns #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE if the given @a privilege doesn't exist.
119 * @param[in] package_type The type of application package
120 * @param[in] api_version The API version of the application to get privilege information
121 * @param[in] privilege The privilege
122 * @param[out] description The description of the privilege
123 * @return @c 0 on success,
124 * otherwise a negative error value
125 * @retval #PRVINFO_ERROR_NONE Successful
126 * @retval #PRVINFO_ERROR_NO_MATCHING_PRIVILEGE No matched privilege
127 * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
128 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
129 * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
131 int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description);
135 * @deprecated Deprecated since 7.5.
136 * @brief Gets the display name of the privacy group in which the given privilege is included.
138 * @remarks @a privacy_name must be released using free().
139 * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned.
140 * @param[in] privilege The privilege
141 * @param[out] privacy_name The privacy group's display name that the given privilege is included in
142 * @return @c 0 on success,
143 * otherwise a negative error value
144 * @retval #PRVINFO_ERROR_NONE Successful
145 * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
146 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
147 * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
148 * @retval #PRVINFO_ERROR_NOT_SUPPORTED Not supported
150 int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_name) TIZEN_DEPRECATED_API;
154 * @brief The structure for privilege information.
157 typedef struct _privilege_info_s {
158 char* privilege_name; /**< The privilege name */
159 char* display_name; /**< The display name of the privilege */
160 char* description; /**< The description of the privilege */
164 * @brief Enumeration for return code to be sent to consumer.
168 PRIVILEGE_CONSUMER_RETURN_CODE_SUCCESS = 0, /**< Successful */
169 PRIVILEGE_CONSUMER_RETURN_CODE_UNKNOWN_LOCALE_CODE, /**< Unknown locale code. */
170 PRIVILEGE_CONSUMER_RETURN_CODE_INVALID_PARAMETER, /**< Invalid parameter. */
171 } privilege_consumer_return_code_e;
174 * @brief Gets the privilege information list of the given locale and privileges.
175 * @details If the given @a locale is not recognized, @a return_result is set to #PRIVILEGE_CONSUMER_RETURN_CODE_UNKNOWN_LOCALE_CODE and the result in the @a privilege_info_list is provided according to the current locale. If all of the privileges in @a privilege_name_list are invalid then @a return_result is set to #PRIVILEGE_CONSUMER_RETURN_CODE_INVALID_PARAMETER. Otherwise, @a return_result is set to #PRIVILEGE_CONSUMER_RETURN_CODE_SUCCESS. If some of the privileges in @a privilege_name_list are invalid then corresponding elements in the @a privilege_info_list will have the display_name and the description set to an empty string.
178 * @remarks You must destroy the newly created privilege_info_list by calling privilege_info_free_privilege_info_list() if it is no longer needed.
180 * @param[in] locale The locale information
181 * @param[in] privilege_name_list The privilege name list
182 * @param[out] privilege_info_list The privilege information list of the given locale and privileges
183 * @param[out] return_result The return code to be sent to consumer.
185 * @return 0 on success, otherwise a negative error value.
187 * @retval #PRVINFO_ERROR_NONE Successful
188 * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
189 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
190 * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
191 * @see privilege_info_free_privilege_info_list()
192 * @see privilege_consumer_return_code_e
194 int privilege_info_get_privilege_info_list(const char* locale, GList* privilege_name_list, GList** privilege_info_list, privilege_consumer_return_code_e* return_result);
197 * @brief Destroys the privilege information list.
200 * @remarks If @a privilege_info_list is NULL, no operation is performed and #PRVINFO_ERROR_INVALID_PARAMETER will be returned.
202 * @param[in] privilege_info_list The privilege information list to destroy
204 * @return 0 on success, otherwise a negative error value.
206 * @retval #PRVINFO_ERROR_NONE Successful
207 * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
209 int privilege_info_free_privilege_info_list(GList* privilege_info_list);
222 #endif /* __TIZEN_SECURITY_PRIVILEGE_INFORMATION_H */