d1886c497363e38d6370bfa156ceb6a156e32870
[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  * @file package_info.h
29  */
30
31 /**
32  * @addtogroup CAPI_PACKAGE_INFO_MODULE
33  * @{
34  */
35
36 /**
37  * @brief The package information handle.
38  * @since_tizen 2.3
39  */
40 typedef struct package_info_s *package_info_h;
41
42 /**
43  * @brief Enumeration for storage type.
44  * @since_tizen 2.3
45  */
46 typedef enum {
47         PACKAGE_INFO_INTERNAL_STORAGE = 0,    /**< Internal storage */
48         PACKAGE_INFO_EXTERNAL_STORAGE = 1,    /**< External storage */
49 } package_info_installed_storage_type_e;
50
51 /**
52  * @brief Enumeration for app component type.
53  * @since_tizen 2.3
54  */
55 typedef enum {
56         PACKAGE_INFO_ALLAPP = 0,        /**< All application */
57         PACKAGE_INFO_UIAPP = 1,         /**< UI application */
58         PACKAGE_INFO_SERVICEAPP = 2,    /**< Service application */
59 } package_info_app_component_type_e;
60
61 /**
62  * @brief Enumeration for certification type.
63  * @since_tizen 2.3
64  */
65 typedef enum {
66         PACKAGE_INFO_AUTHOR_ROOT_CERT = 0,               /**< Author Root Certificate*/
67         PACKAGE_INFO_AUTHOR_INTERMEDIATE_CERT = 1,       /**< Author Intermediate Certificate*/
68         PACKAGE_INFO_AUTHOR_SIGNER_CERT = 2,             /**< Author Signer Certificate*/
69         PACKAGE_INFO_DISTRIBUTOR_ROOT_CERT = 3,          /**< Distributor Root Certificate*/
70         PACKAGE_INFO_DISTRIBUTOR_INTERMEDIATE_CERT = 4,  /**< Distributor Intermediate Certificate*/
71         PACKAGE_INFO_DISTRIBUTOR_SIGNER_CERT = 5,        /**< Distributor Signer Certificate*/
72         PACKAGE_INFO_DISTRIBUTOR2_ROOT_CERT = 6,         /**< Distributor2 Root Certificate*/
73         PACKAGE_INFO_DISTRIBUTOR2_INTERMEDIATE_CERT = 7, /**< Distributor2 Intermediate Certificate*/
74         PACKAGE_INFO_DISTRIBUTOR2_SIGNER_CERT = 8,       /**< Distributor2 Signer Certificate*/
75 } package_cert_type_e;
76
77 /**
78  * @brief Called to get the application ID once for each installed package.
79  * @since_tizen 2.3
80  *
81  * @param[in] comp_type  The Application Component type
82  * @param[in] callback   The callback function to be invoked
83  * @param[in] user_data  The user data passed from the foreach function
84  *
85  * @return  @c true to continue with the next iteration of the loop,
86  *          otherwise @c false to break out of the loop
87  *
88  * @pre package_info_foreach_app_from_package() will invoke this callback.
89  * @see package_info_foreach_app_from_package()
90  */
91 typedef bool (*package_info_app_cb) (package_info_app_component_type_e comp_type, const char *app_id, void *user_data);
92
93 /**
94  * @brief Called to get the certification information.
95  * @since_tizen 2.3
96  *
97  * @param[in] package_info The package info handle
98  * @param[in] cert_type    The certificate type
99  * @param[in] cert_value   The certificate value of corresponding certificate key \n
100  *                         This value is base64 encoded data.
101  * @param[in] user_data    The user data passed from the foreach function
102  *
103  * @return  @c true to continue with the next iteration of the loop,
104  *          otherwise @c false to break out of the loop
105  *
106  * @pre package_info_foreach_cert_info() will invoke this callback.
107  *
108  * @see package_info_foreach_cert_info()
109  */
110 typedef bool (*package_info_cert_info_cb) (package_info_h handle, package_cert_type_e cert_type, const char *cert_value, void *user_data);
111
112 /**
113  * @brief Called to get the privilege information.
114  * @since_tizen 2.3
115  *
116  * @param[in] privilege_name the name of the privilege
117  * @param[in] user_data    The user data passed from the foreach function
118  *
119  * @return  @c true to continue with the next iteration of the loop,
120  *          otherwise @c false to break out of the loop
121  *
122  * @pre package_info_foreach_privilege_info() will invoke this callback.
123  *
124  * @see package_info_foreach_privilege_info()
125  */
126 typedef bool (*package_info_privilege_info_cb) (const char *privilege_name, void *user_data);
127
128 /**
129  * @brief Retrieves all application IDs of each package.
130  * @since_tizen 2.3
131  *
132  * @param[in] package_info  The package info handle
133  * @param[in] comp_type     The application component type
134  * @param[in] callback      The callback function to invoke
135  * @param[in] user_data     The user data to be passed to the callback function
136  *
137  * @return @c 0 on success,
138  *         otherwise a negative error value
139  *
140  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
141  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
142  * @retval #PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE   No such package
143  *
144  * @post  This function invokes package_info_app_cb() repeatedly for each package.
145  *
146  * @see package_info_app_cb()
147  */
148 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);
149
150 /**
151  * @brief Destroys the package information handle and releases all its resources.
152  * @since_tizen 2.3
153  *
154  * @param[in] package_info The package information handle
155  *
156  * @return @c 0 on success,
157  *         otherwise a negative error value
158  *
159  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
160  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
161  *
162  * @see package_manager_foreach_package_info()
163  * @see package_manager_get_package_info()
164  */
165 int package_info_destroy(package_info_h package_info);
166
167 /**
168  * @brief Gets the package name.
169  * @since_tizen 2.3
170  *
171  * @remarks You must release @a package using free().
172  *
173  * @param[in]  package_info The package information
174  * @param[out] package      The package name
175  *
176  * @return @c 0 on success,
177  *         otherwise a negative error value
178  *
179  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
180  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
181  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
182  */
183 int package_info_get_package(package_info_h package_info, char **package);
184
185 /**
186  * @brief Gets the label of the package.
187  * @since_tizen 2.3
188  *
189  * @remarks You must release @a label using free().
190  *
191  * @param[in]  package_info The package information
192  * @param[out] label        The label of the package
193  *
194  * @return @c 0 on success,
195  *         otherwise a negative error value
196  *
197  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
198  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
199  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
200  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
201  */
202 int package_info_get_label(package_info_h package_info, char **label);
203
204 /**
205  * @brief Gets the absolute path to the icon image.
206  * @since_tizen 2.3
207  *
208  * @remarks You must release @a path using free().
209  *
210  * @param[in]  package_info The package information
211  * @param[out] path         The path of the package
212  *
213  * @return @c 0 on success,
214  *         otherwise a negative error value
215  *
216  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
217  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
218  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
219  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
220  */
221 int package_info_get_icon(package_info_h package_info, char **path);
222
223 /**
224  * @brief Gets the version of the package.
225  * @since_tizen 2.3
226  *
227  * @remarks You must release @a version using free().
228  *
229  * @param[in]  package_info The package information
230  * @param[out] version      The version of the package
231  *
232  * @return @c 0 on success,
233  *         otherwise a negative error value
234  *
235  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
236  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
237  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
238  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
239  */
240 int package_info_get_version(package_info_h package_info, char **version);
241
242 /**
243  * @brief Gets the type of the package.
244  * @since_tizen 2.3
245  *
246  * @remarks You must release @a type using free().
247  *
248  * @param[in]  package_info The package information
249  * @param[out] type         The type of the package
250  *
251  * @return @c 0 on success,
252  *         otherwise a negative error value
253  *
254  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
255  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
256  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
257  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
258  */
259 int package_info_get_type(package_info_h package_info, char **type);
260
261 /**
262  * @brief Gets the installed storage for the given package.
263  * @since_tizen 2.3
264  *
265  * @param[in]  package_info The package information
266  * @param[out] storage      The installed storage
267  *
268  * @return  @c 0 on success,
269  *          otherwise a negative error value
270  *
271  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
272  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
273  */
274 int package_info_get_installed_storage(package_info_h package_info, package_info_installed_storage_type_e *storage);
275
276 /**
277  * @brief Gets the root path of the package.
278  * @since_tizen 2.3
279  *
280  * @remarks You must release @a path using free().
281  *
282  * @param[in]  package_info The package information
283  * @param[out] path         The root path of the package
284  *
285  * @return @c 0 on success,
286  *         otherwise a negative error value
287  *
288  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
289  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
290  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
291  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
292  */
293 int package_info_get_root_path(package_info_h package_info, char **path);
294
295 /**
296  * @platform
297  * @brief Gets the name of the TEP(Tizen Expansion Package).
298  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
299  * @privlevel platform
300  * @privilege %http://tizen.org/privilege/packagemanager.admin
301  * @remarks name must be released using free().
302  * @param[in] package_info The package information
303  * @param[out] name The name of the tep
304  * @return 0 on success, otherwise a negative error value
305  * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
306  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
307  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
308  * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR           Severe system error
309  * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
310  */
311 int package_info_get_tep_name(package_info_h package_info, char **name);
312
313 /**
314  * @brief Checks whether the package is system package.
315  * @since_tizen 2.3
316  *
317  * @param[in]  package_info The package information
318  * @param[out] system       @c true if the package is system package,
319  *                          otherwise @c false if the package is not system package
320  *
321  * @return @c 0 on success,
322  *         otherwise a negative error value
323  *
324  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
325  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
326  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
327  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
328  */
329 int package_info_is_system_package(package_info_h package_info, bool *system);
330
331 /**
332  * @brief Checks whether the package is removable.
333  * @since_tizen 2.3
334  *
335  * @param[in]  package_info The package information
336  * @param[out] removable    The removable info of the package
337  *
338  * @return @c 0 on success,
339  *         otherwise a negative error value
340  *
341  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
342  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
343  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
344  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR IO error
345  */
346 int package_info_is_removable_package(package_info_h package_info, bool *removable);
347
348 /**
349  * @brief Checks whether the package is preloaded.
350  * @since_tizen 2.3
351  *
352  * @param[in]  package_info The package information
353  * @param[out] preload      The preload info of the package
354  *
355  * @return @c 0 on success,
356  *         otherwise a negative error value
357  *
358  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
359  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
360  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
361  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
362  */
363 int package_info_is_preload_package(package_info_h package_info, bool *preload);
364
365 /**
366  * @brief Checks whether two package information are equal.
367  * @since_tizen 2.3
368  *
369  * @param[in]  lhs    The first package information to be compared
370  * @param[in]  rhs    The second package information to be compared
371  * @param[out] equal  @c true if the package information are equal,
372  *                    otherwise @c false if package information are not equal
373  *
374  * @return @c 0 on success,
375  *         otherwise a negative error value
376  *
377  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
378  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
379  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
380  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          Database error occurred
381  */
382 int package_info_is_equal(package_info_h lhs, package_info_h rhs, bool *equal);
383
384 /**
385  * @brief Checks whether the package info is accessible for the given package.
386  * @since_tizen 2.3
387  *
388  * @param[in]  package_info The package information
389  * @param[out] accessible   @c true if the package info is accessible,
390  *                          otherwise @c false if the package info is not accessible
391  *
392  * @return  @c 0 on success,
393  *          otherwise a negative error value
394  *
395  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
396  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
397  */
398 int package_info_is_accessible(package_info_h package_info, bool *accessible);
399
400 /**
401  * @brief Clones the package information handle.
402  * @since_tizen 2.3
403  *
404  * @param[out] clone          The newly created package information handle
405  * @param[in]  package_info   The package information
406  *
407  * @return @c 0 on success,
408  *         otherwise a negative error value
409  *
410  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
411  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
412  * @retval #PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE   The package is not installed
413  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
414  */
415 int package_info_clone(package_info_h *clone, package_info_h package_info);
416
417 /**
418  * @brief Gets the package information for the given package
419  * @since_tizen 2.3
420  *
421  * @remarks You must release @a package_info using package_info_destroy().
422  *
423  * @param[in]  package      The ID of the package
424  * @param[out] package_info The package information for the given package ID
425  *
426  * @return @c 0 on success,
427  *         otherwise a negative error value
428  *
429  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
430  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
431  * @retval #PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE   The package is not installed
432  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
433  */
434 int package_info_create(const char *package, package_info_h *package_info);
435
436 /**
437  * @brief Retrieves certification information of the package.
438  * @since_tizen 2.3
439  *
440  * @param[in] package_info The package information
441  * @param[in] callback     The iteration callback function
442  * @param[in] user_data    The user data to be passed to the callback function
443  *
444  * @return @c 0 on success,
445  *         otherwise a negative error value
446  *
447  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
448  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
449  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
450  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
451  */
452 int package_info_foreach_cert_info(package_info_h package_info, package_info_cert_info_cb callback, void *user_data);
453
454 /**
455  * @brief Retrieves privilege information of the package.
456  * @since_tizen 2.3
457  *
458  * @param[in] package_info The package information
459  * @param[in] callback     The iteration callback function
460  * @param[in] user_data    The user data to be passed to the callback function
461  *
462  * @return @c 0 on success,
463  *         otherwise a negative error value
464  *
465  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
466  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
467  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
468  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
469  */
470 int package_info_foreach_privilege_info(package_info_h package_info, package_info_privilege_info_cb callback, void *user_data);
471
472 /**
473 * @}
474 */
475
476 #ifdef __cplusplus
477 }
478 #endif
479
480 #endif /* __TIZEN_APPFW_PACKAGE_INFO_H */