Add new APIs retrieving package dependency info from archive
[platform/core/api/package-manager.git] / include / package_archive_info.h
1 /*
2  * Copyright (c) 2017 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 #ifndef __TIZEN_APPFW_PACKAGE_ARCHIVE_INFO_H
18 #define __TIZEN_APPFW_PACKAGE_ARCHIVE_INFO_H
19
20 #include <package_info.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /**
27  * @file package_archive_info.h
28  */
29
30 /**
31  * @addtogroup CAPI_PACKAGE_ARCHIVE_INFO_MODULE
32  * @{
33  */
34
35
36 /**
37  * @brief The package archive information handle.
38  * @since_tizen 4.0
39  */
40 typedef struct package_archive_info_s *package_archive_info_h;
41
42 /**
43  * @brief Creates the package archive information for the given package.
44  * @since_tizen 4.0
45  * @remarks If the given path is relevant to media storage, the privilege
46  *          http://tizen.org/privilege/mediastorage is needed.
47  * @remarks If the given path is relevant to external storage, the privilege
48  *          http://tizen.org/privilege/externalstorage is needed.
49  * @remarks You must release @a archive_info
50  *          using package_archive_info_destroy().
51  * @param[in]  path         The path of the package
52  * @param[out] archive_info The package archive information for
53  *                          the given package
54  * @return @c 0 on success,
55  *         otherwise a negative error value
56  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
57  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
58  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
59  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          Internal I/O error
60  * @see package_archive_info_destroy()
61  */
62 int package_archive_info_create(const char *path,
63                 package_archive_info_h *archive_info);
64
65 /**
66  * @brief Destroys the package archive information handle.
67  * @since_tizen 4.0
68  * @param[in] archive_info The package archive information handle
69  * @return @c 0 on success,
70  *         otherwise a negative error value
71  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
72  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
73  * @see package_archive_info_create()
74  */
75 int package_archive_info_destroy(package_archive_info_h archive_info);
76
77 /**
78  * @brief Gets the package name.
79  * @since_tizen 4.0
80  * @remarks You must release @a package using free().
81  * @param[in]  archive_info The package archive information
82  * @param[out] package      The package name
83  * @return @c 0 on success,
84  *         otherwise a negative error value
85  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
86  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
87  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
88  */
89 int package_archive_info_get_package(package_archive_info_h archive_info,
90                 char **package);
91
92 /**
93  * @brief Gets the type of the package.
94  * @since_tizen 4.0
95  * @remarks You must release @a type using free().
96  * @param[in]  archive_info The package archive information
97  * @param[out] type         The type of the package
98  * @return @c 0 on success,
99  *         otherwise a negative error value
100  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
101  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
102  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
103  */
104 int package_archive_info_get_type(package_archive_info_h archive_info,
105                 char **type);
106
107 /**
108  * @brief Gets the version of the package.
109  * @since_tizen 4.0
110  * @remarks You must release @a version using free().
111  * @param[in]  archive_info The package archive information
112  * @param[out] version      The version of the package
113  * @return @c 0 on success,
114  *         otherwise a negative error value
115  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
116  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
117  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
118  */
119 int package_archive_info_get_version(package_archive_info_h archive_info,
120                 char **version);
121
122 /**
123  * @brief Gets the API version of the package.
124  * @since_tizen 4.0
125  * @remarks You must release @a api_version using free().
126  * @param[in]  archive_info The package archive information
127  * @param[out] api_version  The API version of the package
128  * @return @c 0 on success,
129  *         otherwise a negative error value
130  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
131  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
132  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
133  */
134 int package_archive_info_get_api_version(package_archive_info_h archive_info,
135                 char **api_version);
136
137 /**
138  * @brief Gets the description of the package.
139  * @since_tizen 4.0
140  * @remarks You must release @a description using free().
141  * @param[in]  archive_info The package archive information
142  * @param[out] description  The description of the package
143  * @return @c 0 on success,
144  *         otherwise a negative error value
145  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
146  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
147  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
148  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
149  */
150 int package_archive_info_get_description(package_archive_info_h archive_info,
151                 char **description);
152
153 /**
154  * @brief Gets the label of the package.
155  * @since_tizen 4.0
156  * @remarks You must release @a label using free().
157  * @param[in]  archive_info The package archive information
158  * @param[out] label        The label of the package
159  * @return @c 0 on success,
160  *         otherwise a negative error value
161  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
162  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
163  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
164  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
165  */
166 int package_archive_info_get_label(package_archive_info_h archive_info,
167                 char **label);
168
169 /**
170  * @brief Gets the author of the package.
171  * @since_tizen 4.0
172  * @remarks You must release @a author using free().
173  * @param[in]  archive_info The package archive information
174  * @param[out] author       The author of the package
175  * @return @c 0 on success,
176  *         otherwise a negative error value
177  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
178  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
179  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
180  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
181  */
182 int package_archive_info_get_author(package_archive_info_h archive_info,
183                 char **author);
184
185 /**
186  * @brief Gets the raw icon of the package.
187  * @since_tizen 4.0
188  * @remarks You must release @a icon using free().
189  * @param[in]  archive_info The package archive information
190  * @param[out] icon         The raw icon of the package
191  * @param[out] icon_size    The size of the icon
192  * @return @c 0 on success,
193  *         otherwise a negative error value
194  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
195  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
196  * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
197  * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
198  */
199 int package_archive_info_get_icon(package_archive_info_h archive_info,
200                 unsigned char **icon, size_t *icon_size);
201
202 /**
203  * @brief Retrieves direct dependencies of the given package.
204  * @details package_info_dependency_info_cb() is called for each direct dependency of the given package.
205  *          For example, if there are packages having the following relationship:
206  *
207  * <pre>
208  *                B --> E
209  *          A --> B --> C
210  *                D --> C
211  * </pre>
212  * A --> B means that A depends on B.
213  *
214  * If package_archive_info_foreach_direct_dependency(A) is called, the callback will be called once with the following argument values: @e from = A, @e to = B.
215  * @since_tizen 5.5
216  * @remarks The function provides the results synchronously. If there are no dependencies, this function will return PACKAGE_MANAGER_ERROR_NONE immediately and the callback will not be invoked.
217  * @param[in] archive_info The package archive information
218  * @param[in] callback     The iteration callback function
219  * @param[in] user_data    The user data to be passed to the callback function
220  * @return @c 0 on success,
221  *         otherwise a negative error value
222  * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
223  * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
224  * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR      Severe system error
225  */
226 int package_archive_info_foreach_direct_dependency(
227                 package_archive_info_h archive_info,
228                 package_info_dependency_info_cb callback, void *user_data);
229
230
231 /**
232 * @}
233 */
234
235 #ifdef __cplusplus
236 }
237 #endif
238
239 #endif /* __TIZEN_APPFW_PACKAGE_ARCHIVE_INFO_H */