Add privacy feature and deprecate redundant API
[platform/core/security/privilege-info.git] / src / include / privilege_information.h
1 /*
2  * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 #ifndef __TIZEN_SECURITY_PRIVILEGE_INFORMAION_H
19 #define __TIZEN_SECURITY_PRIVILEGE_INFORMAION_H
20
21
22 #include <tizen.h>
23
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29
30 /**
31  * @addtogroup CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE
32  * @{
33  */
34
35
36 /**
37  * @brief Enumeration for error code for Privilege Information.
38  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
39  */
40 typedef enum {
41         PRVINFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
42         PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
43         PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
44         PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
45         PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 5.0) */
46 } privilege_info_error_e;
47
48
49 /**
50  * @brief Gets the display name of the given privilege.
51  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
52  * @remarks @a display_name must be released using free().
53  * @param[in] api_version The API version of the application to get privilege information
54  * @param[in] privilege The privilege
55  * @param[out] display_name The display name of the privilege
56  * @return @c 0 on success,
57  *         otherwise a negative error value
58  * @retval #PRVINFO_ERROR_NONE Successful
59  * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
60  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
61  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
62  */
63 int privilege_info_get_display_name(const char *api_version, const char *privilege, char **display_name);
64
65
66 /**
67  * @brief Gets the display name of the given privilege.
68  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
69  * @remarks @a display_name must be released using free().
70  * @remarks package_type must be one of followings: PRVINFO_PACKAGE_TYPE_NATIVE, PRVINFO_PACKAGE_TYPE_WEB
71  * @param[in] package_type The type of application package
72  * @param[in] api_version The API version of the application to get privilege information
73  * @param[in] privilege The privilege
74  * @param[out] display_name The display name of the privilege
75  * @return @c 0 on success,
76  *         otherwise a negative error value
77  * @retval #PRVINFO_ERROR_NONE Successful
78  * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
79  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
80  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
81  */
82 int privilege_info_get_display_name_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **display_name);
83
84
85 /**
86  * @brief Gets the description of the given privilege.
87  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
88  * @remarks @a description must be released using free().
89  * @param[in] api_version The API version of the application to get privilege information
90  * @param[in] privilege The privilege
91  * @param[out] description The description of the privilege
92  * @return @c 0 on success,
93  *         otherwise a negative error value
94  * @retval #PRVINFO_ERROR_NONE Successful
95  * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
96  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
97  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
98  */
99 int privilege_info_get_description(const char *api_version, const char *privilege, char **description);
100
101
102 /**
103  * @brief Gets the description of the given privilege.
104  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
105  * @remarks @a description must be released using free().
106  * @remarks package_type must be one of followings: PRVINFO_PACKAGE_TYPE_NATIVE, PRVINFO_PACKAGE_TYPE_WEB
107  * @param[in] package_type The type of application package
108  * @param[in] api_version The API version of the application to get privilege information
109  * @param[in]  privilege The privilege
110  * @param[out] description The description of the privilege
111  * @return @c 0 on success,
112  *         otherwise a negative error value
113  * @retval #PRVINFO_ERROR_NONE Successful
114  * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
115  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
116  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
117  */
118 int privilege_info_get_description_by_pkgtype(const char *package_type, const char *api_version, const char *privilege, char **description);
119
120
121 /**
122  * @brief Gets the display name of the privacy group in which the given privilege is included.
123  * @since_tizen 3.0
124  * @remarks @a privacy_name must be released using free().
125  * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned.
126  * @param[in] privilege The privilege
127  * @param[out] privacy_name The privacy group's display name that the given privilege is included in
128  * @return @c 0 on success,
129  *         otherwise a negative error value
130  * @retval #PRVINFO_ERROR_NONE Successful
131  * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
132  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
133  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
134  * @retval #PRVINFO_ERROR_NOT_SUPPORTED Not supported
135  */
136 int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_name);
137
138
139 /**
140  * @deprecated Deprecated since 5.0. Use ppm_check_permission() instead. You can refer to @ref CAPI_PRIVACY_PRIVILEGE_MANAGER_MODULE.
141  * @brief Gets the status of the given privacy related privilege.
142  * @since_tizen 3.0
143  * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned.
144  *          In case of errors, @a status is set to @c true.
145  * @param[in] privilege The privilege
146  * @param[out] status @c true if the privilege is on,
147  *                    and @c false if the privilege is off
148  * @return @c 0 on success,
149  *         otherwise a negative error value
150  * @retval #PRVINFO_ERROR_NONE Successful
151  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
152  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
153  * @retval #PRVINFO_ERROR_NOT_SUPPORTED Not supported
154  */
155 int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status);
156
157
158 /**
159  * @}
160  */
161
162
163 #ifdef __cplusplus
164 }
165 #endif
166
167
168 #endif /* __TIZEN_SECURITY_PRIVILEGE_INFORMAION_H */