Merge "Add boot-sequence to manifest.xsd" into tizen
[platform/core/appfw/pkgmgr-info.git] / parser / include / pkgmgr_parser.h
1 /*
2  * pkgmgr-info
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7  * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __PKGMGR_PARSER_H__
24 #define __PKGMGR_PARSER_H__
25
26 /**
27  * @file pkgmgr_parser.h
28  * @author Sewook Park <sewook7.park@samsung.com>
29  * @author Shobhit Srivastava <shobhit.s@samsung.com>
30  * @version 0.1
31  * @brief    This file declares API of pkgmgr_parser
32  * @addtogroup          APPLICATION_FRAMEWORK
33  * @{
34  *
35  * @defgroup            PackageManagerParser
36  * @section             Header Header file to include:
37  * @code
38  * #include             <pkgmgr_parser.h>
39  * @endcode
40  *
41  * @}
42  */
43
44 #include <libxml/xmlreader.h>
45
46 /* For multi-user support */
47 #include <tzplatform_config.h>
48 #include "pkgmgrinfo_basic.h"
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 #ifndef DEPRECATED
55 #define DEPRECATED      __attribute__ ((__deprecated__))
56 #endif
57
58 #define DEFAULT_LOCALE          "No Locale"
59
60 #define PKG_STRING_LEN_MAX 1024
61
62 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
63
64 /**
65  * @brief Structure which is used by metadata plugin
66  */
67 typedef struct {
68         const char *key;
69         const char *value;
70 } __metadata_t;
71
72
73 /**
74  * @brief Structure which is used by category plugin
75  */
76 typedef struct {
77         const char *name;
78 } __category_t;
79
80 /* operation_type */
81 typedef enum {
82         ACTION_INSTALL = 0,
83         ACTION_UPGRADE,
84         ACTION_UNINSTALL,
85         ACTION_FOTA,
86         ACTION_MAX
87 } ACTION_TYPE;
88
89 /**
90  * @brief API return values
91  */
92 enum {
93         PM_PARSER_R_EINVAL = -2,                /**< Invalid argument */
94         PM_PARSER_R_ERROR = -1,         /**< General error */
95         PM_PARSER_R_OK = 0                      /**< General success */
96 };
97
98 /**
99  * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
100  * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
101  * @brief       This API parses the manifest file of the package after installation and stores the data in DB.
102  *
103  * @par         This API is for package-manager installer backends.
104  * @par Sync (or) Async : Synchronous API
105  *
106  * @param[in]   manifest        pointer to package manifest file
107  * @param[in]   uid     the addressee user id of the instruction
108  * @param[in]   tagv            array of xml tags or NULL
109  * @return      0 if success, error code(<0) if fail
110  * @retval      PMINFO_R_OK     success
111  * @retval      PMINFO_R_EINVAL invalid argument
112  * @retval      PMINFO_R_ERROR  internal error
113  * @pre         None
114  * @post                None
115  * @code
116 static int parse_manifest_file_for_installation(const char *manifest)
117 {
118         int ret = 0;
119         ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
120         if (ret)
121                 return -1;
122         return 0;
123 }
124  * @endcode
125  */
126 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]) DEPRECATED;
127 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
128 int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx);
129 int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, uid_t uid);
130
131 /**
132  * @fn int pkgmgr_parser_update_tep(const char* pkgid, const char * tep_path)
133  * @fn int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid)
134  * @brief       This API updates tep path information stored in DB.
135  *
136  * @par         This API is for package-manager installer backends.
137  * @par Sync (or) Async : Synchronous API
138  *
139  * @param[in]   pkgid   pointer to package ID
140   * @param[in]tep_path  pointer to path of TEP file
141  * @param[in]   uid     the addressee user id of the instruction
142  * @return      0 if success, error code(<0) if fail
143  * @retval      PMINFO_R_OK     success
144  * @retval      PMINFO_R_EINVAL invalid argument
145  * @retval      PMINFO_R_ERROR  internal error
146  * @pre         None
147  * @post                None
148  * @code
149 static int update_tep_info_for_upgrade(const char *pkgid, const char *tep_path)
150 {
151         int ret = 0;
152         ret = pkgmgr_parser_update_tep(pkgid, tep_path);
153         if (ret)
154                 return -1;
155         return 0;
156 }
157  * @endcode
158  */
159 int pkgmgr_parser_update_tep(const char* pkgid, const char* tep_path);
160 int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid);
161
162 /**
163  * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest,  uid_t uid, char *const tagv[])
164  * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
165  * @brief       This API parses the manifest file of the package after upgrade and stores the data in DB.
166  *
167  * @par         This API is for package-manager installer backends.
168  * @par Sync (or) Async : Synchronous API
169  *
170  * @param[in]   manifest        pointer to package manifest file
171  * @param[in]   uid     the addressee user id of the instruction
172  * @param[in]   tagv            array of xml tags or NULL
173  * @return      0 if success, error code(<0) if fail
174  * @retval      PMINFO_R_OK     success
175  * @retval      PMINFO_R_EINVAL invalid argument
176  * @retval      PMINFO_R_ERROR  internal error
177  * @pre         None
178  * @post                None
179  * @code
180 static int parse_manifest_file_for_upgrade(const char *manifest)
181 {
182         int ret = 0;
183         ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
184         if (ret)
185                 return -1;
186         return 0;
187 }
188  * @endcode
189  */
190 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]) DEPRECATED;
191 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
192 int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx);
193 int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, uid_t uid);
194
195 /**
196  * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
197  * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
198  * @brief       This API parses the manifest file of the package after uninstallation and deletes the data from DB.
199  *
200  * @par         This API is for package-manager installer backends.
201  * @par Sync (or) Async : Synchronous API
202  *
203  * @param[in]   manifest        pointer to package manifest file
204  * @param[in]   uid     the addressee user id of the instruction
205  * @param[in]   tagv            array of xml tags or NULL
206  * @return      0 if success, error code(<0) if fail
207  * @retval      PMINFO_R_OK     success
208  * @retval      PMINFO_R_EINVAL invalid argument
209  * @retval      PMINFO_R_ERROR  internal error
210  * @pre         None
211  * @post                None
212  * @code
213 static int parse_manifest_file_for_uninstallation(const char *manifest)
214 {
215         int ret = 0;
216         ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
217         if (ret)
218                 return -1;
219         return 0;
220 }
221  * @endcode
222  */
223 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]) DEPRECATED;
224 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
225 int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx);
226 int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, uid_t uid);
227
228 /**
229  * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
230  * @brief       This API validates the manifest file against the manifest schema.
231  *
232  * @par         This API is for package-manager installer backends.
233  * @par Sync (or) Async : Synchronous API
234  *
235  * @param[in]   manifest        pointer to package manifest file
236  * @return      0 if success, error code(<0) if fail
237  * @retval      PMINFO_R_OK     success
238  * @retval      PMINFO_R_EINVAL invalid argument
239  * @retval      PMINFO_R_ERROR  internal error
240  * @pre         None
241  * @post                None
242  * @code
243 static int validate_manifest_file(const char *manifest)
244 {
245         int ret = 0;
246         ret = pkgmgr_parser_check_manifest_validation(manifest);
247         if (ret)
248                 return -1;
249         return 0;
250 }
251  * @endcode
252  */
253 int pkgmgr_parser_check_manifest_validation(const char *manifest);
254
255 /**
256  * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
257  * @brief       This API will free the manifest pointer by recursively freeing all sub elements.
258  *
259  * @par         This API is for package-manager installer backends.
260  * @par Sync (or) Async : Synchronous API
261  *
262  * @param[in]   mfx     pointer to parsed manifest data
263  * @pre         pkgmgr_parser_process_manifest_xml()
264  * @post                None
265  * @code
266 static int parse_manifest_file(const char *manifest)
267 {
268         manifest_x *mfx = NULL
269         mfx = pkgmgr_parser_process_manifest_xml(manifest);
270         if (mfx == NULL)
271                 return -1;
272         printf("Parsing Manifest Success\n");
273         pkgmgr_parser_free_manifest_xml(mfx);
274         return 0;
275 }
276  * @endcode
277  */
278 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
279
280 /**
281  * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
282  * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
283  * @brief       This API parses the manifest file and stores all the data in the manifest structure.
284  *
285  * @par         This API is for package-manager installer backends.
286  * @par Sync (or) Async : Synchronous API
287  *
288  * @param[in]   manifest        pointer to package manifest file
289  * @param[in]   uid     the addressee user id of the instruction
290  * @return      manifest pointer on success, NULL on failure
291  * @pre         None
292  * @post                pkgmgr_parser_free_manifest_xml()
293  * @code
294 static int parse_manifest_file(const char *manifest)
295 {
296         manifest_x *mfx = NULL
297         mfx = pkgmgr_parser_process_manifest_xml(manifest);
298         if (mfx == NULL)
299                 return -1;
300         printf("Parsing Manifest Success\n");
301         pkgmgr_parser_free_manifest_xml(mfx);
302         return 0;
303 }
304  * @endcode
305  */
306 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) DEPRECATED;
307 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid) DEPRECATED;
308
309 /** @} */
310 #ifdef __cplusplus
311 }
312 #endif
313 #endif                          /* __PKGMGR_PARSER_H__ */