Fix exceptions about splash screen
[platform/core/appfw/pkgmgr-info.git] / parser / 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_PARSERLIB   "parserlib:"
61 #define PKG_PARSER_CONF_PATH    SYSCONFDIR "/package-manager/parser_path.conf"
62
63 #define PKG_STRING_LEN_MAX 1024
64
65 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
66
67 /**
68  * @brief Structure which is used by metadata plugin
69  */
70 typedef struct {
71         const char *key;
72         const char *value;
73 } __metadata_t;
74
75
76 /**
77  * @brief Structure which is used by category plugin
78  */
79 typedef struct {
80         const char *name;
81 } __category_t;
82
83 /* operation_type */
84 typedef enum {
85         ACTION_INSTALL = 0,
86         ACTION_UPGRADE,
87         ACTION_UNINSTALL,
88         ACTION_FOTA,
89         ACTION_MAX
90 } ACTION_TYPE;
91
92 /**
93  * @brief API return values
94  */
95 enum {
96         PM_PARSER_R_EINVAL = -2,                /**< Invalid argument */
97         PM_PARSER_R_ERROR = -1,         /**< General error */
98         PM_PARSER_R_OK = 0                      /**< General success */
99 };
100
101 /**
102  * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
103  * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
104  * @brief       This API parses the manifest file of the package after installation and stores the data in DB.
105  *
106  * @par         This API is for package-manager installer backends.
107  * @par Sync (or) Async : Synchronous API
108  *
109  * @param[in]   manifest        pointer to package manifest file
110  * @param[in]   uid     the addressee user id of the instruction
111  * @param[in]   tagv            array of xml tags or NULL
112  * @return      0 if success, error code(<0) if fail
113  * @retval      PMINFO_R_OK     success
114  * @retval      PMINFO_R_EINVAL invalid argument
115  * @retval      PMINFO_R_ERROR  internal error
116  * @pre         None
117  * @post                None
118  * @code
119 static int parse_manifest_file_for_installation(const char *manifest)
120 {
121         int ret = 0;
122         ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
123         if (ret)
124                 return -1;
125         return 0;
126 }
127  * @endcode
128  */
129 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]) DEPRECATED;
130 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
131 int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest);
132 int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid);
133
134 /**
135  * @fn int pkgmgr_parser_update_tep(const char* pkgid, const char * tep_path)
136  * @fn int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid)
137  * @brief       This API updates tep path information stored in DB.
138  *
139  * @par         This API is for package-manager installer backends.
140  * @par Sync (or) Async : Synchronous API
141  *
142  * @param[in]   pkgid   pointer to package ID
143   * @param[in]tep_path  pointer to path of TEP file
144  * @param[in]   uid     the addressee user id of the instruction
145  * @return      0 if success, error code(<0) if fail
146  * @retval      PMINFO_R_OK     success
147  * @retval      PMINFO_R_EINVAL invalid argument
148  * @retval      PMINFO_R_ERROR  internal error
149  * @pre         None
150  * @post                None
151  * @code
152 static int update_tep_info_for_upgrade(const char *pkgid, const char *tep_path)
153 {
154         int ret = 0;
155         ret = pkgmgr_parser_update_tep(pkgid, tep_path);
156         if (ret)
157                 return -1;
158         return 0;
159 }
160  * @endcode
161  */
162 int pkgmgr_parser_update_tep(const char* pkgid, const char* tep_path);
163 int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid);
164
165 /**
166  * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest,  uid_t uid, char *const tagv[])
167  * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
168  * @brief       This API parses the manifest file of the package after upgrade and stores the data in DB.
169  *
170  * @par         This API is for package-manager installer backends.
171  * @par Sync (or) Async : Synchronous API
172  *
173  * @param[in]   manifest        pointer to package manifest file
174  * @param[in]   uid     the addressee user id of the instruction
175  * @param[in]   tagv            array of xml tags or NULL
176  * @return      0 if success, error code(<0) if fail
177  * @retval      PMINFO_R_OK     success
178  * @retval      PMINFO_R_EINVAL invalid argument
179  * @retval      PMINFO_R_ERROR  internal error
180  * @pre         None
181  * @post                None
182  * @code
183 static int parse_manifest_file_for_upgrade(const char *manifest)
184 {
185         int ret = 0;
186         ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
187         if (ret)
188                 return -1;
189         return 0;
190 }
191  * @endcode
192  */
193 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]) DEPRECATED;
194 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
195 int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest);
196 int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid);
197
198 /**
199  * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
200  * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
201  * @brief       This API parses the manifest file of the package after uninstallation and deletes the data from DB.
202  *
203  * @par         This API is for package-manager installer backends.
204  * @par Sync (or) Async : Synchronous API
205  *
206  * @param[in]   manifest        pointer to package manifest file
207  * @param[in]   uid     the addressee user id of the instruction
208  * @param[in]   tagv            array of xml tags or NULL
209  * @return      0 if success, error code(<0) if fail
210  * @retval      PMINFO_R_OK     success
211  * @retval      PMINFO_R_EINVAL invalid argument
212  * @retval      PMINFO_R_ERROR  internal error
213  * @pre         None
214  * @post                None
215  * @code
216 static int parse_manifest_file_for_uninstallation(const char *manifest)
217 {
218         int ret = 0;
219         ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
220         if (ret)
221                 return -1;
222         return 0;
223 }
224  * @endcode
225  */
226 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]) DEPRECATED;
227 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]) DEPRECATED;
228 int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest);
229 int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid);
230
231 /**
232  * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
233  * @brief       This API validates the manifest file against the manifest schema.
234  *
235  * @par         This API is for package-manager installer backends.
236  * @par Sync (or) Async : Synchronous API
237  *
238  * @param[in]   manifest        pointer to package manifest file
239  * @return      0 if success, error code(<0) if fail
240  * @retval      PMINFO_R_OK     success
241  * @retval      PMINFO_R_EINVAL invalid argument
242  * @retval      PMINFO_R_ERROR  internal error
243  * @pre         None
244  * @post                None
245  * @code
246 static int validate_manifest_file(const char *manifest)
247 {
248         int ret = 0;
249         ret = pkgmgr_parser_check_manifest_validation(manifest);
250         if (ret)
251                 return -1;
252         return 0;
253 }
254  * @endcode
255  */
256 int pkgmgr_parser_check_manifest_validation(const char *manifest);
257
258 /**
259  * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
260  * @brief       This API will free the manifest pointer by recursively freeing all sub elements.
261  *
262  * @par         This API is for package-manager installer backends.
263  * @par Sync (or) Async : Synchronous API
264  *
265  * @param[in]   mfx     pointer to parsed manifest data
266  * @pre         pkgmgr_parser_process_manifest_xml()
267  * @post                None
268  * @code
269 static int parse_manifest_file(const char *manifest)
270 {
271         manifest_x *mfx = NULL
272         mfx = pkgmgr_parser_process_manifest_xml(manifest);
273         if (mfx == NULL)
274                 return -1;
275         printf("Parsing Manifest Success\n");
276         pkgmgr_parser_free_manifest_xml(mfx);
277         return 0;
278 }
279  * @endcode
280  */
281 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
282
283 /**
284  * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
285  * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
286  * @brief       This API parses the manifest file and stores all the data in the manifest structure.
287  *
288  * @par         This API is for package-manager installer backends.
289  * @par Sync (or) Async : Synchronous API
290  *
291  * @param[in]   manifest        pointer to package manifest file
292  * @param[in]   uid     the addressee user id of the instruction
293  * @return      manifest pointer on success, NULL on failure
294  * @pre         None
295  * @post                pkgmgr_parser_free_manifest_xml()
296  * @code
297 static int parse_manifest_file(const char *manifest)
298 {
299         manifest_x *mfx = NULL
300         mfx = pkgmgr_parser_process_manifest_xml(manifest);
301         if (mfx == NULL)
302                 return -1;
303         printf("Parsing Manifest Success\n");
304         pkgmgr_parser_free_manifest_xml(mfx);
305         return 0;
306 }
307  * @endcode
308  */
309 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) DEPRECATED;
310 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid) DEPRECATED;
311
312 /** @} */
313 #ifdef __cplusplus
314 }
315 #endif
316 #endif                          /* __PKGMGR_PARSER_H__ */