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 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
74 * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
75 * @brief This API parses the manifest file of the package after installation and stores the data in DB.
77 * @par This API is for package-manager installer backends.
78 * @par Sync (or) Async : Synchronous API
80 * @param[in] manifest pointer to package manifest file
81 * @param[in] uid the addressee user id of the instruction
82 * @param[in] tagv array of xml tags or NULL
83 * @return 0 if success, error code(<0) if fail
84 * @retval PMINFO_R_OK success
85 * @retval PMINFO_R_EINVAL invalid argument
86 * @retval PMINFO_R_ERROR internal error
90 static int parse_manifest_file_for_installation(const char *manifest)
93 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
100 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
101 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]);
102 int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest);
103 int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid);
106 * @fn int pkgmgr_parser_update_tep(const char* pkgid, const char * tep_path)
107 * @fn int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid)
108 * @brief This API updates tep path information stored in DB.
110 * @par This API is for package-manager installer backends.
111 * @par Sync (or) Async : Synchronous API
113 * @param[in] pkgid pointer to package ID
114 * @param[in]tep_path pointer to path of TEP file
115 * @param[in] uid the addressee user id of the instruction
116 * @return 0 if success, error code(<0) if fail
117 * @retval PMINFO_R_OK success
118 * @retval PMINFO_R_EINVAL invalid argument
119 * @retval PMINFO_R_ERROR internal error
123 static int update_tep_info_for_upgrade(const char *pkgid, const char *tep_path)
126 ret = pkgmgr_parser_update_tep(pkgid, tep_path);
133 int pkgmgr_parser_update_tep(const char* pkgid, const char* tep_path);
134 int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid);
137 * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
138 * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
139 * @brief This API parses the manifest file of the package after upgrade and stores the data in DB.
141 * @par This API is for package-manager installer backends.
142 * @par Sync (or) Async : Synchronous API
144 * @param[in] manifest pointer to package manifest file
145 * @param[in] uid the addressee user id of the instruction
146 * @param[in] tagv array of xml tags or NULL
147 * @return 0 if success, error code(<0) if fail
148 * @retval PMINFO_R_OK success
149 * @retval PMINFO_R_EINVAL invalid argument
150 * @retval PMINFO_R_ERROR internal error
154 static int parse_manifest_file_for_upgrade(const char *manifest)
157 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
164 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
165 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]);
166 int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest);
167 int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid);
170 * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
171 * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
172 * @brief This API parses the manifest file of the package after uninstallation and deletes the data from DB.
174 * @par This API is for package-manager installer backends.
175 * @par Sync (or) Async : Synchronous API
177 * @param[in] manifest pointer to package manifest file
178 * @param[in] uid the addressee user id of the instruction
179 * @param[in] tagv array of xml tags or NULL
180 * @return 0 if success, error code(<0) if fail
181 * @retval PMINFO_R_OK success
182 * @retval PMINFO_R_EINVAL invalid argument
183 * @retval PMINFO_R_ERROR internal error
187 static int parse_manifest_file_for_uninstallation(const char *manifest)
190 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
197 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
198 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]);
199 int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest);
200 int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid);
203 * @fn int pkgmgr_parser_parse_manifest_for_preload()
204 * @fn int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
205 * @brief This API update preload information to DB.
207 * @par This API is for package-manager installer backends.
208 * @par Sync (or) Async : Synchronous API
210 * @return 0 if success, error code(<0) if fail
211 * @retval PMINFO_R_OK success
212 * @retval PMINFO_R_EINVAL invalid argument
213 * @retval PMINFO_R_ERROR internal error
217 static int parser_parse_manifest_for_preload()
220 ret = pkgmgr_parser_parse_manifest_for_preload();
227 int pkgmgr_parser_parse_manifest_for_preload();
228 int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid);
231 * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
232 * @brief This API validates the manifest file against the manifest schema.
234 * @par This API is for package-manager installer backends.
235 * @par Sync (or) Async : Synchronous API
237 * @param[in] manifest pointer to package manifest file
238 * @return 0 if success, error code(<0) if fail
239 * @retval PMINFO_R_OK success
240 * @retval PMINFO_R_EINVAL invalid argument
241 * @retval PMINFO_R_ERROR internal error
245 static int validate_manifest_file(const char *manifest)
248 ret = pkgmgr_parser_check_manifest_validation(manifest);
255 int pkgmgr_parser_check_manifest_validation(const char *manifest);
258 * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
259 * @brief This API will free the manifest pointer by recursively freeing all sub elements.
261 * @par This API is for package-manager installer backends.
262 * @par Sync (or) Async : Synchronous API
264 * @param[in] mfx pointer to parsed manifest data
265 * @pre pkgmgr_parser_process_manifest_xml()
268 static int parse_manifest_file(const char *manifest)
270 manifest_x *mfx = NULL
271 mfx = pkgmgr_parser_process_manifest_xml(manifest);
274 printf("Parsing Manifest Success\n");
275 pkgmgr_parser_free_manifest_xml(mfx);
280 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
283 * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
284 * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
285 * @brief This API parses the manifest file and stores all the data in the manifest structure.
287 * @par This API is for package-manager installer backends.
288 * @par Sync (or) Async : Synchronous API
290 * @param[in] manifest pointer to package manifest file
291 * @param[in] uid the addressee user id of the instruction
292 * @return manifest pointer on success, NULL on failure
294 * @post pkgmgr_parser_free_manifest_xml()
296 static int parse_manifest_file(const char *manifest)
298 manifest_x *mfx = NULL
299 mfx = pkgmgr_parser_process_manifest_xml(manifest);
302 printf("Parsing Manifest Success\n");
303 pkgmgr_parser_free_manifest_xml(mfx);
308 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
309 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid);
312 * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
313 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package installation
315 * @par This API is for package-manager installer backends.
316 * @par Sync (or) Async : Synchronous API
318 * @param[in] docPtr XML doxument pointer
319 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
320 * @param[in] pkgid the package id
321 * @return 0 if success, error code(<0) if fail
322 * @retval PMINFO_R_OK success
323 * @retval PMINFO_R_EINVAL invalid argument
324 * @retval PMINFO_R_ERROR internal error
328 static int parse_docptr_for_installation(xmlDocPtr docPtr)
331 ret = pkgmgr_parser_run_parser_for_installation(docPtr, "theme", "com.samsung.test");
338 int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
341 * @fn int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
342 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package upgrade
344 * @par This API is for package-manager installer backends.
345 * @par Sync (or) Async : Synchronous API
347 * @param[in] docPtr XML doxument pointer
348 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
349 * @param[in] pkgid the package id
350 * @return 0 if success, error code(<0) if fail
351 * @retval PMINFO_R_OK success
352 * @retval PMINFO_R_EINVAL invalid argument
353 * @retval PMINFO_R_ERROR internal error
357 static int parse_docptr_for_upgrade(xmlDocPtr docPtr)
360 ret = pkgmgr_parser_run_parser_for_upgrade(docPtr, "theme", "com.samsung.test");
367 int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid);
370 * @fn int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
371 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package uninstallation
373 * @par This API is for package-manager installer backends.
374 * @par Sync (or) Async : Synchronous API
376 * @param[in] docPtr XML doxument pointer
377 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
378 * @param[in] pkgid the package id
379 * @return 0 if success, error code(<0) if fail
380 * @retval PMINFO_R_OK success
381 * @retval PMINFO_R_EINVAL invalid argument
382 * @retval PMINFO_R_ERROR internal error
386 static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
389 ret = pkgmgr_parser_run_parser_for_uninstallation(docPtr, "theme", "com.samsung.test");
396 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
401 * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
402 * @fn int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
403 * @brief This API generates the application desktop file
405 * @par This API is for package-manager installer backends.
406 * @par Sync (or) Async : Synchronous API
408 * @param[in] mfx manifest pointer
409 * @param[in] uid the addressee user id of the instruction
410 * @return 0 if success, error code(<0) if fail
411 * @retval PMINFO_R_OK success
412 * @retval PMINFO_R_EINVAL invalid argument
413 * @retval PMINFO_R_ERROR internal error
414 * @pre pkgmgr_parser_process_manifest_xml()
415 * @post pkgmgr_parser_free_manifest_xml()
417 static int create_desktop_file(char *manifest)
420 manifest_x *mfx = NULL;
421 mfx = pkgmgr_parser_process_manifest_xml(manifest);
422 ret = pkgmgr_parser_create_desktop_file(mfx);
425 pkgmgr_parser_free_manifest_xml(mfx);
430 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
431 int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid);
437 #endif /* __PKGMGR_PARSER_H__ */