2 * Copyright (c) 2013-2015 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.
17 #ifndef __TIZEN_SECURITY_PRIVILEGE_INFO_H
18 #define __TIZEN_SECURITY_PRIVILEGE_INFO_H
21 #include "privilege_manager.h"
24 #define EXPORT_API __attribute__((__visibility__("default")))
31 * @brief Called to get a privilege group once for specific package.
32 * @param[in] privilege_group The privilege group
33 * @param[in] user_data The user data passed from the foreach function
34 * @return 0 if success, nonzero value(>0) if fail. Callback is not called if return value is nonzero.
35 * @pre privilege_info_foreach_privilege_group_list_by_pkgid() will invoke this callback.
36 * @see privilege_info_foreach_privilege_group_list_by_pkgid()
38 typedef int (*privilege_info_privilege_groups_cb) (const char *privilege_group, void* user_data);
41 * @brief Called to get a privilege in the privilege group once for specific package.
42 * @param[in] privilege The privilege
43 * @param[in] user_data The user data passed from the foreach function
44 * @return 0 if success, nonzero value(>0) if fail. Callback is not called if return value is nonzero.
45 * @pre privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group() will invoke this callback.
46 * @see privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group()
48 typedef int (*privilege_info_privileges_cb) (const char *privilege, void* user_data);
51 * @brief Retrieves privilege group list of the package.
52 * @param [in] package_id The package id
53 * @param [in] callback The callback function to invoke
54 * @param [in] user_data The user data to be passed to the callback function
55 * @return 0 on success, otherwise a nonzero error value.
56 * @retval #PRVMGR_ERR_NONE Successful
57 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
58 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
59 * @post This function invokes privilege_info_privilege_groups_cb() repeatedly for each application context.
60 * @see privilege_info_privilege_groups_cb()
62 EXPORT_API int privilege_info_foreach_privilege_group_list_by_pkgid(const char *package_id, privilege_info_privilege_groups_cb callback, void* user_data);
65 * @brief Retrieves privilege list in specific group of the package.
66 * @param [in] package_id The package id
67 * @param [in] callback The callback function to invoke
68 * @param [in] user_data The user data to be passed to the callback function
69 * @return 0 on success, otherwise a nonzero error value.
70 * @retval #PRVMGR_ERR_NONE Successful
71 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
72 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
73 * @see privilege_info_privileges_cb()
75 EXPORT_API int privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group(const char *package_id, const char* privilege_group, privilege_info_privileges_cb callback, void* user_data);
78 * @brief Gets the display name of privilege group with the given privilege.
79 * @remarks @a name must be released with free() by you.
80 * @param [in] privilege_group The privilege group
81 * @param [out] name The display name of the privilege group
82 * @return 0 on success, otherwise a nonzero error value.
83 * @retval #PRVMGR_ERR_NONE Successful
84 * @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory
85 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
87 EXPORT_API int privilege_info_get_privilege_group_display_name(const char *privilege_group, char **name);
90 * @brief Gets the display name of privilege with the given privilege.
91 * @remarks @a name must be released with free() by you.
92 * @param [in] privilege The privilege
93 * @param [out] name The display name of the privilege
94 * @return 0 on success, otherwise a nonzero error value.
95 * @retval #PRVMGR_ERR_NONE Successful
96 * @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory
97 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
99 EXPORT_API int privilege_info_get_privilege_display_name(const char *privilege, char **name);
102 * @brief Gets the description of privilege with the given privilege.
103 * @remarks @a description must be released with free() by you.
104 * @param [in] privilege The privilege
105 * @param [out] description The description of the privilege
106 * @return 0 on success, otherwise a nonzero error value.
107 * @retval #PRVMGR_ERR_NONE Successful
108 * @retval #PRVMGR_ERR_OUT_OF_MEMORY Out of memory
109 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
111 EXPORT_API int privilege_info_get_privilege_description(const char *privilege, char **description);
114 * @brief Determines whether the given privilege is valid.
115 * @param [in] privilege The privilege
116 * @return 1 if true(=is valid privilege. the privilege can be granted by security-manager and checked by cynara), 0 if false, and -1 on error
118 EXPORT_API int privilege_info_is_valid(const char *privilege);
121 * @brief Determines whether the given privilege is internal privilege.
122 * @param [in] privilege The privilege
123 * @return 1 if true(=is internal privilege), 0 if false, and -1 on error
125 EXPORT_API int privilege_info_is_internal(const char *privilege);
128 * @brief Determines whether the given privilege is privacy related or not.
129 * @param [in] privilege The privilege
130 * @return 1 if true(=is privacy related privilege), 0 if false, and -1 on error
132 EXPORT_API int privilege_info_is_privacy(const char *privilege);
135 * @brief Determines whether the given privilege is privacy related or not.on the basis of whitelist
136 * @param [in] label The label
137 * @param [in] privilege The privilege
138 * @return 1 if true(=is privacy related privilege), 0 if false, and -1 on error
140 EXPORT_API int privilege_info_is_privacy2(const char *label, const char *privilege);
143 * @brief Determines whether the privacy of given pkgid is user-settable
144 * @param [in] pkgid The package id
145 * @param [in] privacy The privacy name
146 * @return 1 if true, 0 if false, and -1 on error
148 EXPORT_API int privilege_info_is_user_settable(const char *pkgid, const char *privacy);
151 * @brief Gets the type of given privilege on the basis of privacy whitelist and blacklist disabled list
152 * @param [in] uid The uid
153 * @param [in] pkgid The package id
154 * @param [in] privilege The privilege
155 * @param [out] type The type of privilege
156 * @return 0 on success, otherwise a nonzero error value.
157 * @retval #PRVMGR_ERR_NONE Successful
158 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
159 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
161 EXPORT_API int privilege_info_get_privilege_type(uid_t uid, const char* pkgid, const char* privilege, privilege_manager_privilege_type_e *type);
164 * @brief Determines whether the given package id is on the privacy white list
165 * @param [in] pkgid The pkgid of application
166 * @return 1 if true(=given pkgid is listed on the privacy white list), 0 if false, and -1 on error
168 EXPORT_API int privilege_info_is_privacy_white_list_application(const char* pkgid);
171 * @brief Gets all privacy list.
172 * @remarks @a privacy_list must be released with g_list_free() by you.
173 * @param [out] privacy_list The privacy list
174 * @return 0 on success, otherwise a nonzero error value.
175 * @retval #PRVMGR_ERR_NONE Successful
176 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
178 EXPORT_API int privilege_info_get_privacy_list(GList **privacy_list);
181 * @brief Gets privacy display.
182 * @remarks @a privacy_display must be released with g_list_free() by you.
183 * @param [in] privacy The privacy
184 * @param [out] privacy_display The privacy display
185 * @return 0 on success, otherwise a nonzero error value.
186 * @retval #PRVMGR_ERR_NONE Successful
187 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
189 EXPORT_API int privilege_info_get_privacy_display(const char* privacy, char** privacy_display);
192 * @brief Gets privilege list with the given privacy.
193 * @remarks @a privilege_list must be released with g_list_free() by you.
194 * @param [in] privacy The privacy
195 * @param [out] privilege_list The list of privileges mapped to the given privacy
196 * @return 0 on success, otherwise a nonzero error value.
197 * @retval #PRVMGR_ERR_NONE Successful
198 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
199 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
201 EXPORT_API int privilege_info_get_privilege_list_by_privacy(const char *privacy, GList **privilege_list);
204 * @brief Gets privacy id of the given privilege.
205 * @remarks @a privacy must be released with g_list_free() by you.
206 * @param [in] privilege The privilege
207 * @param [out] privacy The privacy id of the given privilege
208 * @return 0 on success, otherwise a nonzero error value.
209 * @retval #PRVMGR_ERR_NONE Successful
210 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
211 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
213 EXPORT_API int privilege_info_get_privacy_by_privilege(const char *privilege, char** privacy);
216 * @brief Gets the list of privilges marked as dpm black list.
217 * @remarks @a privilege_list must be released with g_list_free() by you.
218 * @param [in] uid The UID
219 * @param [in] package_type The privilege_manager_package_type_e
220 * @param [out] privilege_list The list for privileges marked as black list
221 * @return 0 on success, otherwise a nonzero error value.
222 * @retval #PRVMGR_ERR_NONE Successful
223 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
224 * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
226 EXPORT_API int privilege_info_get_black_list(int uid, privilege_manager_package_type_e package_type, GList **privilege_list);
229 * @brief Gets the list of privilges marked as mdm black list for the given uid.
230 * @remarks @a privilege_list must be released with g_list_free() by you.
231 * @param [in] uid The UID
232 * @param [out] privilege_list The list for privileges marked as black list
233 * @return 0 on success, otherwise a nonzero error value.
234 * @retval #PRVMGR_ERR_NONE Successful
235 * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
237 EXPORT_API int privilege_info_get_mdm_black_list(uid_t uid, GList **privilege_list);
243 #endif /* __TIZEN_SECURITY_PRIVILEGE_INFO_H */