4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
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>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #ifndef __PKGMGR_PARSER_H__
24 #define __PKGMGR_PARSER_H__
27 * @file pkgmgr_parser.h
28 * @author Sewook Park <sewook7.park@samsung.com>
29 * @author Shobhit Srivastava <shobhit.s@samsung.com>
31 * @brief This file declares API of pkgmgr_parser
32 * @addtogroup APPLICATION_FRAMEWORK
35 * @defgroup PackageManagerParser
36 * @section Header Header file to include:
38 * #include <pkgmgr_parser.h>
44 #include <libxml/xmlreader.h>
46 /* For multi-user support */
47 #include <tzplatform_config.h>
48 #include "pkgmgrinfo_basic.h"
55 #define DEPRECATED __attribute__ ((__deprecated__))
58 #define DEFAULT_LOCALE "No Locale"
60 #define PKG_STRING_LEN_MAX 1024
62 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
65 * @brief Structure which is used by metadata plugin
74 * @brief Structure which is used by category plugin
90 * @brief API return values
93 PM_PARSER_R_EINVAL = -2, /**< Invalid argument */
94 PM_PARSER_R_ERROR = -1, /**< General error */
95 PM_PARSER_R_OK = 0 /**< General success */
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.
103 * @par This API is for package-manager installer backends.
104 * @par Sync (or) Async : Synchronous API
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
116 static int parse_manifest_file_for_installation(const char *manifest)
119 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
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);
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.
136 * @par This API is for package-manager installer backends.
137 * @par Sync (or) Async : Synchronous API
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
149 static int update_tep_info_for_upgrade(const char *pkgid, const char *tep_path)
152 ret = pkgmgr_parser_update_tep(pkgid, tep_path);
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);
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.
167 * @par This API is for package-manager installer backends.
168 * @par Sync (or) Async : Synchronous API
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
180 static int parse_manifest_file_for_upgrade(const char *manifest)
183 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
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);
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.
200 * @par This API is for package-manager installer backends.
201 * @par Sync (or) Async : Synchronous API
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
213 static int parse_manifest_file_for_uninstallation(const char *manifest)
216 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
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);
229 * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
230 * @brief This API validates the manifest file against the manifest schema.
232 * @par This API is for package-manager installer backends.
233 * @par Sync (or) Async : Synchronous API
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
243 static int validate_manifest_file(const char *manifest)
246 ret = pkgmgr_parser_check_manifest_validation(manifest);
253 int pkgmgr_parser_check_manifest_validation(const char *manifest);
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.
259 * @par This API is for package-manager installer backends.
260 * @par Sync (or) Async : Synchronous API
262 * @param[in] mfx pointer to parsed manifest data
263 * @pre pkgmgr_parser_process_manifest_xml()
266 static int parse_manifest_file(const char *manifest)
268 manifest_x *mfx = NULL
269 mfx = pkgmgr_parser_process_manifest_xml(manifest);
272 printf("Parsing Manifest Success\n");
273 pkgmgr_parser_free_manifest_xml(mfx);
278 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
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.
285 * @par This API is for package-manager installer backends.
286 * @par Sync (or) Async : Synchronous API
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
292 * @post pkgmgr_parser_free_manifest_xml()
294 static int parse_manifest_file(const char *manifest)
296 manifest_x *mfx = NULL
297 mfx = pkgmgr_parser_process_manifest_xml(manifest);
300 printf("Parsing Manifest Success\n");
301 pkgmgr_parser_free_manifest_xml(mfx);
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;
313 #endif /* __PKGMGR_PARSER_H__ */