merge with master
[platform/core/api/package-manager.git] / include / package_info.h
1 /*
2  * Copyright (c) 2011 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_APPFW_PACKAGE_INFO_H
19 #define __TIZEN_APPFW_PACKAGE_INFO_H
20
21 #include <tizen.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27
28 /**
29  * @brief Package information handle.
30  */
31  typedef struct package_info_s *package_info_h;
32
33 /**
34  * @brief Enumeration of storage type
35  */
36 typedef enum {
37         PACKAGE_INFO_INTERNAL_STORAGE = 0,
38         PACKAGE_INFO_EXTERNAL_STORAGE = 1,
39 } package_info_installed_storage_type_e;
40
41 typedef enum {
42         PACKAGE_INFO_ALLAPP = 0,
43         PACKAGE_INFO_UIAPP = 1,
44         PACKAGE_INFO_SERVICEAPP = 2,
45 } package_info_app_component_type_e;
46
47 typedef enum {
48         PACKAGE_INFO_AUTHOR_ROOT_CERT = 0,                      /**< Author Root Certificate*/
49         PACKAGE_INFO_AUTHOR_INTERMEDIATE_CERT = 1,              /**< Author Intermediate Certificate*/
50         PACKAGE_INFO_AUTHOR_SIGNER_CERT = 2,                    /**< Author Signer Certificate*/
51         PACKAGE_INFO_DISTRIBUTOR_ROOT_CERT = 3,                 /**< Distributor Root Certificate*/
52         PACKAGE_INFO_DISTRIBUTOR_INTERMEDIATE_CERT = 4,         /**< Distributor Intermediate Certificate*/
53         PACKAGE_INFO_DISTRIBUTOR_SIGNER_CERT = 5,               /**< Distributor Signer Certificate*/
54         PACKAGE_INFO_DISTRIBUTOR2_ROOT_CERT = 6,                /**< Distributor2 Root Certificate*/
55         PACKAGE_INFO_DISTRIBUTOR2_INTERMEDIATE_CERT = 7,        /**< Distributor2 Intermediate Certificate*/
56         PACKAGE_INFO_DISTRIBUTOR2_SIGNER_CERT = 8,              /**< Distributor2 Signer Certificate*/
57 } package_cert_type_e;
58
59
60 /**
61  * @brief Called to get the application id once for each installed package.
62  * @param [in] comp_type The Application Component type
63  * @param [in] callback The callback function to invoke
64  * @param [in] user_data The user data passed from the foreach function
65  * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
66  * @pre package_info_foreach_app_from_package() will invoke this callback.
67  * @see package_info_foreach_app_from_package()
68  */
69 /*This callback is not fixed, Don't use it now */
70 typedef bool (*package_info_app_cb) (package_info_app_component_type_e comp_type, const char *app_id, void *user_data);
71
72
73 /**
74  * @brief Called to get the certification information
75  * @param [in] package_info The package info handle
76  * @param [in] cert_type The certificate type
77  * @param [in] cert_value The certificate value of corresponding certificate key. This value is base64 encoded data
78  * @param [in] user_data The user data passed from the foreach function
79  * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
80  * @pre package_info_foreach_cert_info() will invoke this callback.
81  * @see package_info_foreach_cert_info()
82  */
83 typedef bool (*package_info_cert_info_cb) (package_info_h handle, package_cert_type_e cert_type, const char *cert_value, void *user_data);
84
85
86 /**
87  * @brief Retrieves all application id of each package
88  * @param [in] package_info The package info handle
89  * @param [in] comp_type The application component type
90  * @param [in] callback The callback function to invoke
91  * @param [in] user_data The user data to be passed to the callback function
92  * @return 0 on success, otherwise a negative error value.
93  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
94  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
95  * @retval #PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE No such package
96  * @post        This function invokes package_info_app_cb() repeatedly for each package.
97  * @see package_info_app_cb()
98  */
99 /*This API is not fixed, Don't use it now */
100 int package_info_foreach_app_from_package(package_info_h package_info, package_info_app_component_type_e comp_type, package_info_app_cb callback, void *user_data);
101
102
103 /**
104  * @brief Destroys the package information handle and releases all its resources.
105  * @param [in] package_info The package information handle
106  * @return 0 on success, otherwise a negative error value.
107  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
108  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
109  * @see package_manager_foreach_package_info()
110  * @see package_manager_get_package_info()
111  */
112 int package_info_destroy(package_info_h package_info);
113
114
115 /**
116  * @brief Gets the absolute path to the icon image
117  * @remarks @a package must be released with free() by you.
118  * @param [in] package_info The package information
119  * @param [out] package The package name
120  * @return 0 on success, otherwise a negative error value.
121  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
122  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
123  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
124  */
125 int package_info_get_package(package_info_h package_info, char **package);
126
127
128 /**
129  * @brief Gets the label of the package
130  * @remarks @a label must be released with free() by you.
131  * @param [in] package_info The package information
132  * @param [out] name The label of the package
133  * @return 0 on success, otherwise a negative error value.
134  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
135  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
136  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
137  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
138  */
139 int package_info_get_label(package_info_h package_info, char **label);
140
141
142 /**
143  * @brief Gets the absolute path to the icon image
144  * @remarks @a path must be released with free() by you.
145  * @param [in] package_info The package information
146  * @param [out] path The path of the package
147  * @return 0 on success, otherwise a negative error value.
148  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
149  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
150  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
151  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
152  */
153 int package_info_get_icon(package_info_h package_info, char **path);
154
155
156 /**
157  * @brief Gets the version of the package
158  * @remarks @a version must be released with free() by you.
159  * @param [in] package_info The package information
160  * @param [out] path The version of the package
161  * @return 0 on success, otherwise a negative error value.
162  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
163  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
164  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
165  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
166  */
167 int package_info_get_version(package_info_h package_info, char **version);
168
169
170 /**
171  * @brief Gets the type of the package
172  * @remarks @a type must be released with free() by you.
173  * @param [in] package_info The package information
174  * @param [out] version The type of the package
175  * @return 0 on success, otherwise a negative error value.
176  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
177  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
178  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
179  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
180  */
181 int package_info_get_type(package_info_h package_info, char **type);
182
183
184 /**
185  * @internal
186  * @brief Gets the installed storage for the given package
187  * @param [in] package_info The package information
188  * @param[out] storage          The installed storage
189  * @return  0 on success, otherwise a negative error value.
190  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
191  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
192  */
193 int package_info_get_installed_storage(package_info_h package_info, package_info_installed_storage_type_e *storage);
194
195
196 /**
197  * @brief Gets whether the package is system package or not
198  * @param [in] package_info The package information
199  * @param [out] system The system info of the package
200  * @return 0 on success, otherwise a negative error value.
201  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
202  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
203  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
204  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
205  */
206 int package_info_is_system_package(package_info_h package_info, bool *system);
207
208
209 /**
210  * @brief Gets whether the package is removable or not
211  * @param [in] package_info The package information
212  * @param [out] removable The removable info of the package
213  * @return 0 on success, otherwise a negative error value.
214  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
215  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
216  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
217  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
218  */
219 int package_info_is_removable_package(package_info_h package_info, bool *removable);
220
221
222 /**
223  * @brief Gets whether the package is preload or not
224  * @param [in] package_info The package information
225  * @param [out] preload The preload info of the package
226  * @return 0 on success, otherwise a negative error value.
227  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
228  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
229  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
230  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
231  */
232 int package_info_is_preload_package(package_info_h package_info, bool *preload);
233
234
235 /**
236  * @brief Checks whether two package information are equal.
237  * @param [in] lhs      The first package information to compare
238  * @param [in] rhs      The second package information to compare
239  * @param [out] equal true if the package information are equal, otherwise false
240  * @return 0 on success, otherwise a negative error value.
241  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
242  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
243  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
244  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR Database error occurred
245  */
246 int package_info_is_equal(package_info_h lhs, package_info_h rhs, bool *equal);
247
248
249 /**
250  * @internal
251  * @brief Gets the package accessible for the given package
252  * @param [in] package_info The package information
253  * @param[out] accessible               If the given package can access, it returns ture. If it is not, it returns false
254  * @return  0 on success, otherwise a negative error value.
255  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
256  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
257  */
258 int package_info_is_accessible(package_info_h package_info, bool *accessible);
259
260
261 /**
262  * @brief Clones the package information handle.
263  * @param [out] clone If successful, a newly created package information handle will be returned.
264  * @param [in] package_info_h The package information
265  * @return 0 on success, otherwise a negative error value.
266  * @retval #APP_MANAGER_ERROR_NONE Successful
267  * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
268  * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred
269  * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
270  */
271 int package_info_clone(package_info_h *clone, package_info_h package_info);
272
273
274 /**
275  * @brief Retrieves certification information of the package
276  * @param [in] package_info The package information
277  * @param [in] callback The iteration callback function
278  * @param [in] user_data The user data to be passed to the callback function
279  * @return 0 on success, otherwise a negative error value.
280  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
281  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
282  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
283  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
284  */
285 int package_info_foreach_cert_info(package_info_h package_info, package_info_cert_info_cb callback, void* user_data);
286
287
288
289 #ifdef __cplusplus
290 }
291 #endif
292
293 #endif /* __TIZEN_APPFW_PACKAGE_INFO_H */