2 * Copyright (c) 2017 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 __PRIVACY_PRIVILEGE_MANAGER_H__
18 #define __PRIVACY_PRIVILEGE_MANAGER_H__
27 * @addtogroup CAPI_PRIVACY_PRIVILEGE_MANAGER_MODULE
32 * @brief Enumeration of error codes for Privacy Privilege Manager.
38 PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE,
40 PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR,
41 /**< Invalid parameter */
42 PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
43 /**< Operation already in progress */
44 PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS,
46 PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
48 PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN,
52 * @brief Enumeration of privilege check results.
56 /**< An application has a privilege. */
57 PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW,
58 /**< An application doesn't have a privilege. */
59 PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_DENY,
60 /**< A user has to be asked whether grant a privilege to an application or not. */
61 PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK,
65 * @brief Enumeration of user decision results for the pop-up resonse callback.
69 /**< A user granted a privilege to an application for an indefinite period of time. */
70 PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_ALLOW_FOREVER,
71 /**< A user did not grant a privilege to an application for an indefinite period of time. */
72 PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_DENY_FOREVER,
73 /**< A user did not grant a privilege to an application once. */
74 PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_DENY_ONCE,
78 * @brief Enumeration of status codes for the pop-up response callback.
82 /**< Callback was called with a valid answer. */
83 PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ANSWER,
84 /**< Callback was called because of an error. */
85 PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ERROR,
89 * @brief Called when an application receives a response upon calling ppm_popup_request().
93 * @param[in] cause A value representing the reason why this callback
95 * @param[in] result A result of a response triggered by calling ppm_popup_request().
96 * This is a valid value only if the @a cause parameter is equal to
97 * **PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ANSWER**.
98 * @param[in] privilege A privilege that has been checked.
99 * @param[in] user_data User specific data, this parameter has been passed
100 * to ppm_popup_request().
102 * @see ppm_popup_request()
104 typedef void (*ppm_popup_response_cb) (ppm_call_cause_e cause,
105 ppm_popup_result_e result,
106 const char *privilege,
110 * @brief Checks if an application, which calls this API, has permission for a
115 * @param[in] privilege A privilege that is to be checked.
116 * @param[out] result A result of the privilege check.
118 * @return 0 on success, otherwise a negative error value
119 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE Successful
120 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR I/O error
121 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
122 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
123 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN Unknown error
125 int ppm_check_privilege(const char *privilege, ppm_check_result_e *result);
128 * @brief Requests a user's response to determine permission for a given privilege.
130 * @details When this function is called, an underlying service may show an appropriate
131 * UI dialogue box (pop-up) with a question about granting the application access
132 * to a given privilege. Once a user makes a decision, the service may modify
133 * the privacy policy (when it is a definitive decision). After that, the service
134 * sends the response back to the application. The possible response values are as follows:
135 * PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_ALLOW_FOREVER or
136 * PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_DENY_FOREVER or
137 * PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_DENY_ONCE.
138 * The application is informed about the user's decision by invoking previously
139 * registered ppm_popup_response_callback. When a privacy policy for the given privilege
140 * has already been resolved, no pop-up will be shown and the service will return
141 * a response immediately with an appropriate value:
142 * PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_ALLOW_FOREVER or
143 * PRIVACY_PRIVILEGE_MANAGER_POPUP_RESULT_DENY_FOREVER.
147 * @remarks Before calling this function, call ppm_check_privilege() to check
148 * permission for a given privilege. If a result of calling ppm_check_privilege() is
149 * **PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK**, an application should call
150 * this function to determine whether a user allows the application to use
151 * the privilege or not.
153 * @param[in] privilege A privilege for which a popup must be shown.
154 * @param[in] callback A callback function which will be invoked
155 * when the API receives a pop-up response.
156 * @param[in] user_data User specific data which will be passed to
157 * the registered callback.
159 * @return 0 on success, otherwise a negative error value
160 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE Successful
161 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR I/O error
162 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
163 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
164 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS Operation already in progress
165 * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN Unknown error
167 * @post ppm_popup_response_cb() will be invoked.
168 * @see ppm_popup_response_cb()
170 int ppm_popup_request(const char *privilege,
171 ppm_popup_response_cb callback,
182 #endif /* __PRIVACY_PRIVILEGE_MANAGER_H__ */