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