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 API return values
67 PM_PARSER_R_EINVAL = -2, /**< Invalid argument */
68 PM_PARSER_R_ERROR = -1, /**< General error */
69 PM_PARSER_R_OK = 0 /**< General success */
73 * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
74 * @brief This API gets the manifest file of the package.
76 * @par This API is for package-manager installer backends.
77 * @par Sync (or) Async : Synchronous API
79 * @param[in] pkgid pointer to package ID
80 * @return manifest file path on success, NULL on failure
82 * @post Free the manifest file pointer that is returned by API
84 static int get_manifest_file(const char *pkgid)
86 char *manifest = NULL;
87 manifest = pkgmgr_parser_get_manifest_file(pkgid);
90 printf("Manifest File Path is %s\n", manifest);
96 char *pkgmgr_parser_get_manifest_file(const char *pkgid);
97 char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid);
100 * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
101 * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
102 * @brief This API parses the manifest file of the package after installation and stores the data in DB.
104 * @par This API is for package-manager installer backends.
105 * @par Sync (or) Async : Synchronous API
107 * @param[in] manifest pointer to package manifest file
108 * @param[in] uid the addressee user id of the instruction
109 * @param[in] tagv array of xml tags or NULL
110 * @return 0 if success, error code(<0) if fail
111 * @retval PMINFO_R_OK success
112 * @retval PMINFO_R_EINVAL invalid argument
113 * @retval PMINFO_R_ERROR internal error
117 static int parse_manifest_file_for_installation(const char *manifest)
120 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
127 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
128 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]);
131 * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
132 * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
133 * @brief This API parses the manifest file of the package after upgrade and stores the data in DB.
135 * @par This API is for package-manager installer backends.
136 * @par Sync (or) Async : Synchronous API
138 * @param[in] manifest pointer to package manifest file
139 * @param[in] uid the addressee user id of the instruction
140 * @param[in] tagv array of xml tags or NULL
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 parse_manifest_file_for_upgrade(const char *manifest)
151 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
158 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
159 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]);
161 * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
162 * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
163 * @brief This API parses the manifest file of the package after uninstallation and deletes the data from DB.
165 * @par This API is for package-manager installer backends.
166 * @par Sync (or) Async : Synchronous API
168 * @param[in] manifest pointer to package manifest file
169 * @param[in] uid the addressee user id of the instruction
170 * @param[in] tagv array of xml tags or NULL
171 * @return 0 if success, error code(<0) if fail
172 * @retval PMINFO_R_OK success
173 * @retval PMINFO_R_EINVAL invalid argument
174 * @retval PMINFO_R_ERROR internal error
178 static int parse_manifest_file_for_uninstallation(const char *manifest)
181 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
188 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
189 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]);
191 * @fn int pkgmgr_parser_parse_manifest_for_preload()
192 * @fn int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
193 * @brief This API update preload information to DB.
195 * @par This API is for package-manager installer backends.
196 * @par Sync (or) Async : Synchronous API
198 * @return 0 if success, error code(<0) if fail
199 * @retval PMINFO_R_OK success
200 * @retval PMINFO_R_EINVAL invalid argument
201 * @retval PMINFO_R_ERROR internal error
205 static int parser_parse_manifest_for_preload()
208 ret = pkgmgr_parser_parse_manifest_for_preload();
215 int pkgmgr_parser_parse_manifest_for_preload();
216 int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid);
219 * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
220 * @brief This API validates the manifest file against the manifest schema.
222 * @par This API is for package-manager installer backends.
223 * @par Sync (or) Async : Synchronous API
225 * @param[in] manifest pointer to package manifest file
226 * @return 0 if success, error code(<0) if fail
227 * @retval PMINFO_R_OK success
228 * @retval PMINFO_R_EINVAL invalid argument
229 * @retval PMINFO_R_ERROR internal error
233 static int validate_manifest_file(const char *manifest)
236 ret = pkgmgr_parser_check_manifest_validation(manifest);
243 int pkgmgr_parser_check_manifest_validation(const char *manifest);
246 * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
247 * @brief This API will free the manifest pointer by recursively freeing all sub elements.
249 * @par This API is for package-manager installer backends.
250 * @par Sync (or) Async : Synchronous API
252 * @param[in] mfx pointer to parsed manifest data
253 * @pre pkgmgr_parser_process_manifest_xml()
256 static int parse_manifest_file(const char *manifest)
258 manifest_x *mfx = NULL
259 mfx = pkgmgr_parser_process_manifest_xml(manifest);
262 printf("Parsing Manifest Success\n");
263 pkgmgr_parser_free_manifest_xml(mfx);
268 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
271 * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
272 * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
273 * @brief This API parses the manifest file and stores all the data in the manifest structure.
275 * @par This API is for package-manager installer backends.
276 * @par Sync (or) Async : Synchronous API
278 * @param[in] manifest pointer to package manifest file
279 * @param[in] uid the addressee user id of the instruction
280 * @return manifest pointer on success, NULL on failure
282 * @post pkgmgr_parser_free_manifest_xml()
284 static int parse_manifest_file(const char *manifest)
286 manifest_x *mfx = NULL
287 mfx = pkgmgr_parser_process_manifest_xml(manifest);
290 printf("Parsing Manifest Success\n");
291 pkgmgr_parser_free_manifest_xml(mfx);
296 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
297 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid);
300 * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
301 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package installation
303 * @par This API is for package-manager installer backends.
304 * @par Sync (or) Async : Synchronous API
306 * @param[in] docPtr XML doxument pointer
307 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
308 * @param[in] pkgid the package id
309 * @return 0 if success, error code(<0) if fail
310 * @retval PMINFO_R_OK success
311 * @retval PMINFO_R_EINVAL invalid argument
312 * @retval PMINFO_R_ERROR internal error
316 static int parse_docptr_for_installation(xmlDocPtr docPtr)
319 ret = pkgmgr_parser_run_parser_for_installation(docPtr, "theme", "com.samsung.test");
326 int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
329 * @fn int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
330 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package upgrade
332 * @par This API is for package-manager installer backends.
333 * @par Sync (or) Async : Synchronous API
335 * @param[in] docPtr XML doxument pointer
336 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
337 * @param[in] pkgid the package id
338 * @return 0 if success, error code(<0) if fail
339 * @retval PMINFO_R_OK success
340 * @retval PMINFO_R_EINVAL invalid argument
341 * @retval PMINFO_R_ERROR internal error
345 static int parse_docptr_for_upgrade(xmlDocPtr docPtr)
348 ret = pkgmgr_parser_run_parser_for_upgrade(docPtr, "theme", "com.samsung.test");
355 int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid);
358 * @fn int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
359 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package uninstallation
361 * @par This API is for package-manager installer backends.
362 * @par Sync (or) Async : Synchronous API
364 * @param[in] docPtr XML doxument pointer
365 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
366 * @param[in] pkgid the package id
367 * @return 0 if success, error code(<0) if fail
368 * @retval PMINFO_R_OK success
369 * @retval PMINFO_R_EINVAL invalid argument
370 * @retval PMINFO_R_ERROR internal error
374 static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
377 ret = pkgmgr_parser_run_parser_for_uninstallation(docPtr, "theme", "com.samsung.test");
384 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
389 * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
390 * @fn int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
391 * @brief This API generates the application desktop file
393 * @par This API is for package-manager installer backends.
394 * @par Sync (or) Async : Synchronous API
396 * @param[in] mfx manifest pointer
397 * @param[in] uid the addressee user id of the instruction
398 * @return 0 if success, error code(<0) if fail
399 * @retval PMINFO_R_OK success
400 * @retval PMINFO_R_EINVAL invalid argument
401 * @retval PMINFO_R_ERROR internal error
402 * @pre pkgmgr_parser_process_manifest_xml()
403 * @post pkgmgr_parser_free_manifest_xml()
405 static int create_desktop_file(char *manifest)
408 manifest_x *mfx = NULL;
409 mfx = pkgmgr_parser_process_manifest_xml(manifest);
410 ret = pkgmgr_parser_create_desktop_file(mfx);
413 pkgmgr_parser_free_manifest_xml(mfx);
418 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
419 int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid);
425 #endif /* __PKGMGR_PARSER_H__ */