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"
53 #define DEFAULT_LOCALE "No Locale"
55 #define PKG_PARSERLIB "parserlib:"
56 #define PKG_PARSER_CONF_PATH SYSCONFDIR "/package-manager/parser_path.conf"
58 #define PKG_STRING_LEN_MAX 1024
60 #define PKGMGR_PARSER_EMPTY_STR ""
61 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
64 * @brief Structure which is used by metadata plugin
73 * @brief Structure which is used by category plugin
89 * @brief API return values
92 PM_PARSER_R_EINVAL = -2, /**< Invalid argument */
93 PM_PARSER_R_ERROR = -1, /**< General error */
94 PM_PARSER_R_OK = 0 /**< General success */
98 * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
99 * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
100 * @brief This API parses the manifest file of the package after installation and stores the data in DB.
102 * @par This API is for package-manager installer backends.
103 * @par Sync (or) Async : Synchronous API
105 * @param[in] manifest pointer to package manifest file
106 * @param[in] uid the addressee user id of the instruction
107 * @param[in] tagv array of xml tags or NULL
108 * @return 0 if success, error code(<0) if fail
109 * @retval PMINFO_R_OK success
110 * @retval PMINFO_R_EINVAL invalid argument
111 * @retval PMINFO_R_ERROR internal error
115 static int parse_manifest_file_for_installation(const char *manifest)
118 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
125 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
126 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]);
127 int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest);
128 int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid);
131 * @fn int pkgmgr_parser_update_tep(const char* pkgid, const char * tep_path)
132 * @fn int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid)
133 * @brief This API updates tep path information stored in DB.
135 * @par This API is for package-manager installer backends.
136 * @par Sync (or) Async : Synchronous API
138 * @param[in] pkgid pointer to package ID
139 * @param[in]tep_path pointer to path of TEP file
140 * @param[in] uid the addressee user id of the instruction
141 * @return 0 if success, error code(<0) if fail
142 * @retval PMINFO_R_OK success
143 * @retval PMINFO_R_EINVAL invalid argument
144 * @retval PMINFO_R_ERROR internal error
148 static int update_tep_info_for_upgrade(const char *pkgid, const char *tep_path)
151 ret = pkgmgr_parser_update_tep(pkgid, tep_path);
158 int pkgmgr_parser_update_tep(const char* pkgid, const char* tep_path);
159 int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid);
162 * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
163 * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
164 * @brief This API parses the manifest file of the package after upgrade and stores the data in DB.
166 * @par This API is for package-manager installer backends.
167 * @par Sync (or) Async : Synchronous API
169 * @param[in] manifest pointer to package manifest file
170 * @param[in] uid the addressee user id of the instruction
171 * @param[in] tagv array of xml tags or NULL
172 * @return 0 if success, error code(<0) if fail
173 * @retval PMINFO_R_OK success
174 * @retval PMINFO_R_EINVAL invalid argument
175 * @retval PMINFO_R_ERROR internal error
179 static int parse_manifest_file_for_upgrade(const char *manifest)
182 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
189 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
190 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]);
191 int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest);
192 int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid);
195 * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
196 * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
197 * @brief This API parses the manifest file of the package after uninstallation and deletes the data from DB.
199 * @par This API is for package-manager installer backends.
200 * @par Sync (or) Async : Synchronous API
202 * @param[in] manifest pointer to package manifest file
203 * @param[in] uid the addressee user id of the instruction
204 * @param[in] tagv array of xml tags or NULL
205 * @return 0 if success, error code(<0) if fail
206 * @retval PMINFO_R_OK success
207 * @retval PMINFO_R_EINVAL invalid argument
208 * @retval PMINFO_R_ERROR internal error
212 static int parse_manifest_file_for_uninstallation(const char *manifest)
215 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
222 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
223 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]);
224 int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest);
225 int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid);
228 * @fn int pkgmgr_parser_parse_manifest_for_preload()
229 * @fn int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
230 * @brief This API update preload information to DB.
232 * @par This API is for package-manager installer backends.
233 * @par Sync (or) Async : Synchronous API
235 * @return 0 if success, error code(<0) if fail
236 * @retval PMINFO_R_OK success
237 * @retval PMINFO_R_EINVAL invalid argument
238 * @retval PMINFO_R_ERROR internal error
242 static int parser_parse_manifest_for_preload()
245 ret = pkgmgr_parser_parse_manifest_for_preload();
252 int pkgmgr_parser_parse_manifest_for_preload();
253 int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid);
256 * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
257 * @brief This API validates the manifest file against the manifest schema.
259 * @par This API is for package-manager installer backends.
260 * @par Sync (or) Async : Synchronous API
262 * @param[in] manifest pointer to package manifest file
263 * @return 0 if success, error code(<0) if fail
264 * @retval PMINFO_R_OK success
265 * @retval PMINFO_R_EINVAL invalid argument
266 * @retval PMINFO_R_ERROR internal error
270 static int validate_manifest_file(const char *manifest)
273 ret = pkgmgr_parser_check_manifest_validation(manifest);
280 int pkgmgr_parser_check_manifest_validation(const char *manifest);
283 * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
284 * @brief This API will free the manifest pointer by recursively freeing all sub elements.
286 * @par This API is for package-manager installer backends.
287 * @par Sync (or) Async : Synchronous API
289 * @param[in] mfx pointer to parsed manifest data
290 * @pre pkgmgr_parser_process_manifest_xml()
293 static int parse_manifest_file(const char *manifest)
295 manifest_x *mfx = NULL
296 mfx = pkgmgr_parser_process_manifest_xml(manifest);
299 printf("Parsing Manifest Success\n");
300 pkgmgr_parser_free_manifest_xml(mfx);
305 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
308 * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
309 * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
310 * @brief This API parses the manifest file and stores all the data in the manifest structure.
312 * @par This API is for package-manager installer backends.
313 * @par Sync (or) Async : Synchronous API
315 * @param[in] manifest pointer to package manifest file
316 * @param[in] uid the addressee user id of the instruction
317 * @return manifest pointer on success, NULL on failure
319 * @post pkgmgr_parser_free_manifest_xml()
321 static int parse_manifest_file(const char *manifest)
323 manifest_x *mfx = NULL
324 mfx = pkgmgr_parser_process_manifest_xml(manifest);
327 printf("Parsing Manifest Success\n");
328 pkgmgr_parser_free_manifest_xml(mfx);
333 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
334 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid);
337 * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
338 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package installation
340 * @par This API is for package-manager installer backends.
341 * @par Sync (or) Async : Synchronous API
343 * @param[in] docPtr XML doxument pointer
344 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
345 * @param[in] pkgid the package id
346 * @return 0 if success, error code(<0) if fail
347 * @retval PMINFO_R_OK success
348 * @retval PMINFO_R_EINVAL invalid argument
349 * @retval PMINFO_R_ERROR internal error
353 static int parse_docptr_for_installation(xmlDocPtr docPtr)
356 ret = pkgmgr_parser_run_parser_for_installation(docPtr, "theme", "com.samsung.test");
363 int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
366 * @fn int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
367 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package upgrade
369 * @par This API is for package-manager installer backends.
370 * @par Sync (or) Async : Synchronous API
372 * @param[in] docPtr XML doxument pointer
373 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
374 * @param[in] pkgid the package id
375 * @return 0 if success, error code(<0) if fail
376 * @retval PMINFO_R_OK success
377 * @retval PMINFO_R_EINVAL invalid argument
378 * @retval PMINFO_R_ERROR internal error
382 static int parse_docptr_for_upgrade(xmlDocPtr docPtr)
385 ret = pkgmgr_parser_run_parser_for_upgrade(docPtr, "theme", "com.samsung.test");
392 int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid);
395 * @fn int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
396 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package uninstallation
398 * @par This API is for package-manager installer backends.
399 * @par Sync (or) Async : Synchronous API
401 * @param[in] docPtr XML doxument pointer
402 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
403 * @param[in] pkgid the package id
404 * @return 0 if success, error code(<0) if fail
405 * @retval PMINFO_R_OK success
406 * @retval PMINFO_R_EINVAL invalid argument
407 * @retval PMINFO_R_ERROR internal error
411 static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
414 ret = pkgmgr_parser_run_parser_for_uninstallation(docPtr, "theme", "com.samsung.test");
421 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
426 * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
427 * @fn int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
428 * @brief This API generates the application desktop file
430 * @par This API is for package-manager installer backends.
431 * @par Sync (or) Async : Synchronous API
433 * @param[in] mfx manifest pointer
434 * @param[in] uid the addressee user id of the instruction
435 * @return 0 if success, error code(<0) if fail
436 * @retval PMINFO_R_OK success
437 * @retval PMINFO_R_EINVAL invalid argument
438 * @retval PMINFO_R_ERROR internal error
439 * @pre pkgmgr_parser_process_manifest_xml()
440 * @post pkgmgr_parser_free_manifest_xml()
442 static int create_desktop_file(char *manifest)
445 manifest_x *mfx = NULL;
446 mfx = pkgmgr_parser_process_manifest_xml(manifest);
447 ret = pkgmgr_parser_create_desktop_file(mfx);
450 pkgmgr_parser_free_manifest_xml(mfx);
455 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
456 int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid);
462 #endif /* __PKGMGR_PARSER_H__ */