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>
45 #include "pkgmgrinfo_basic.h"
46 #include "pkgmgr_parser_feature.h"
52 /* defined path and file*/
53 #define DESKTOP_RW_PATH "/opt/share/applications/"
54 #define DESKTOP_RO_PATH "/usr/share/applications/"
55 #define MANIFEST_RO_PREFIX "/usr/share/packages/"
56 #define MANIFEST_RW_PREFIX "/opt/share/packages/"
58 #define SCHEMA_FILE "/usr/etc/package-manager/preload/manifest.xsd"
60 #define BUFMAX 1024*128
63 #define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
64 #define LIBAIL_PATH "/usr/lib/libail.so.0"
66 /** Integer property for mode*/
67 #define PMINFO_SUPPORT_MODE_ULTRA_POWER_SAVING 0x00000001
68 #define PMINFO_SUPPORT_MODE_COOL_DOWN 0x00000002
69 #define PMINFO_SUPPORT_MODE_SCREEN_READER 0x00000004
71 #define PMINFO_SUPPORT_FEATURE_MULTI_WINDOW 0x00000001
72 #define PMINFO_SUPPORT_FEATURE_OOM_TERMINATION 0x00000002
73 #define PMINFO_SUPPORT_FEATURE_LARGE_MEMORY 0x00000004
94 * @brief API return values
97 PM_PARSER_R_EINVAL = -2, /**< Invalid argument */
98 PM_PARSER_R_ERROR = -1, /**< General error */
99 PM_PARSER_R_OK = 0 /**< General success */
103 * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
104 * @brief This API gets the manifest file of the package.
106 * @par This API is for package-manager installer backends.
107 * @par Sync (or) Async : Synchronous API
109 * @param[in] pkgid pointer to package ID
110 * @return manifest file path on success, NULL on failure
112 * @post Free the manifest file pointer that is returned by API
114 static int get_manifest_file(const char *pkgid)
116 char *manifest = NULL;
117 manifest = pkgmgr_parser_get_manifest_file(pkgid);
118 if (manifest == NULL)
120 printf("Manifest File Path is %s\n", manifest);
126 char *pkgmgr_parser_get_manifest_file(const char *pkgid);
129 * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
130 * @brief This API parses the manifest file of the package after installation and stores the data in DB.
132 * @par This API is for package-manager installer backends.
133 * @par Sync (or) Async : Synchronous API
135 * @param[in] manifest pointer to package manifest file
136 * @param[in] tagv array of xml tags or NULL
137 * @return 0 if success, error code(<0) if fail
138 * @retval PMINFO_R_OK success
139 * @retval PMINFO_R_EINVAL invalid argument
140 * @retval PMINFO_R_ERROR internal error
144 static int parse_manifest_file_for_installation(const char *manifest)
147 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
154 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
157 * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
158 * @brief This API parses the manifest file of the package after upgrade and stores the data in DB.
160 * @par This API is for package-manager installer backends.
161 * @par Sync (or) Async : Synchronous API
163 * @param[in] manifest pointer to package manifest file
164 * @param[in] tagv array of xml tags or NULL
165 * @return 0 if success, error code(<0) if fail
166 * @retval PMINFO_R_OK success
167 * @retval PMINFO_R_EINVAL invalid argument
168 * @retval PMINFO_R_ERROR internal error
172 static int parse_manifest_file_for_upgrade(const char *manifest)
175 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
182 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
185 * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
186 * @brief This API parses the manifest file of the package after uninstallation and deletes the data from DB.
188 * @par This API is for package-manager installer backends.
189 * @par Sync (or) Async : Synchronous API
191 * @param[in] manifest pointer to package manifest file
192 * @param[in] tagv array of xml tags or NULL
193 * @return 0 if success, error code(<0) if fail
194 * @retval PMINFO_R_OK success
195 * @retval PMINFO_R_EINVAL invalid argument
196 * @retval PMINFO_R_ERROR internal error
200 static int parse_manifest_file_for_uninstallation(const char *manifest)
203 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
210 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
213 * @fn int pkgmgr_parser_parse_manifest_for_preload()
214 * @brief This API update preload information to DB.
216 * @par This API is for package-manager installer backends.
217 * @par Sync (or) Async : Synchronous API
219 * @return 0 if success, error code(<0) if fail
220 * @retval PMINFO_R_OK success
221 * @retval PMINFO_R_EINVAL invalid argument
222 * @retval PMINFO_R_ERROR internal error
226 static int parser_parse_manifest_for_preload()
229 ret = pkgmgr_parser_parse_manifest_for_preload();
236 int pkgmgr_parser_parse_manifest_for_preload();
239 * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
240 * @brief This API validates the manifest file against the manifest schema.
242 * @par This API is for package-manager installer backends.
243 * @par Sync (or) Async : Synchronous API
245 * @param[in] manifest pointer to package manifest file
246 * @return 0 if success, error code(<0) if fail
247 * @retval PMINFO_R_OK success
248 * @retval PMINFO_R_EINVAL invalid argument
249 * @retval PMINFO_R_ERROR internal error
253 static int validate_manifest_file(const char *manifest)
256 ret = pkgmgr_parser_check_manifest_validation(manifest);
263 int pkgmgr_parser_check_manifest_validation(const char *manifest);
266 * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
267 * @brief This API will free the manifest pointer by recursively freeing all sub elements.
269 * @par This API is for package-manager installer backends.
270 * @par Sync (or) Async : Synchronous API
272 * @param[in] mfx pointer to parsed manifest data
273 * @pre pkgmgr_parser_process_manifest_xml()
276 static int parse_manifest_file(const char *manifest)
278 manifest_x *mfx = NULL
279 mfx = pkgmgr_parser_process_manifest_xml(manifest);
282 printf("Parsing Manifest Success\n");
283 pkgmgr_parser_free_manifest_xml(mfx);
288 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
291 * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
292 * @brief This API parses the manifest file and stores all the data in the manifest structure.
294 * @par This API is for package-manager installer backends.
295 * @par Sync (or) Async : Synchronous API
297 * @param[in] manifest pointer to package manifest file
298 * @return manifest pointer on success, NULL on failure
300 * @post pkgmgr_parser_free_manifest_xml()
302 static int parse_manifest_file(const char *manifest)
304 manifest_x *mfx = NULL
305 mfx = pkgmgr_parser_process_manifest_xml(manifest);
308 printf("Parsing Manifest Success\n");
309 pkgmgr_parser_free_manifest_xml(mfx);
314 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
317 * @fn manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid)
318 * @brief This API gets the manifest info from DB and stores all the data in the manifest structure.
320 * @par This API is for package-manager installer backends.
321 * @par Sync (or) Async : Synchronous API
323 * @param[in] pkgid package id for package
324 * @return manifest pointer on success, NULL on failure
326 * @post pkgmgr_parser_free_manifest_xml()
328 static int get_manifest_info(const char *pkgid)
330 manifest_x *mfx = NULL
331 mfx = pkgmgr_parser_get_manifest_info(pkgid);
334 printf("Parsing Manifest Success\n");
335 pkgmgr_parser_free_manifest_xml(mfx);
340 manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid);
342 /* These APIs are intended to call parser directly */
343 typedef int (*ps_iter_fn) (const char *tag, int type, void *userdata);
345 int pkgmgr_parser_has_parser(const char *tag, int *type);
346 int pkgmgr_parser_get_list(ps_iter_fn iter_fn, void *data);
349 * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
350 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package installation
352 * @par This API is for package-manager installer backends.
353 * @par Sync (or) Async : Synchronous API
355 * @param[in] docPtr XML doxument pointer
356 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
357 * @param[in] pkgid the package id
358 * @return 0 if success, error code(<0) if fail
359 * @retval PMINFO_R_OK success
360 * @retval PMINFO_R_EINVAL invalid argument
361 * @retval PMINFO_R_ERROR internal error
365 static int parse_docptr_for_installation(xmlDocPtr docPtr)
368 ret = pkgmgr_parser_run_parser_for_installation(docPtr, "theme", "org.tizen.test");
375 int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
378 * @fn int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
379 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package upgrade
381 * @par This API is for package-manager installer backends.
382 * @par Sync (or) Async : Synchronous API
384 * @param[in] docPtr XML doxument pointer
385 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
386 * @param[in] pkgid the package id
387 * @return 0 if success, error code(<0) if fail
388 * @retval PMINFO_R_OK success
389 * @retval PMINFO_R_EINVAL invalid argument
390 * @retval PMINFO_R_ERROR internal error
394 static int parse_docptr_for_upgrade(xmlDocPtr docPtr)
397 ret = pkgmgr_parser_run_parser_for_upgrade(docPtr, "theme", "org.tizen.test");
404 int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid);
407 * @fn int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
408 * @brief This API calls the parser directly by supplying the xml docptr. It is used during package uninstallation
410 * @par This API is for package-manager installer backends.
411 * @par Sync (or) Async : Synchronous API
413 * @param[in] docPtr XML doxument pointer
414 * @param[in] tag the xml tag corresponding to the parser that will parse the docPtr
415 * @param[in] pkgid the package id
416 * @return 0 if success, error code(<0) if fail
417 * @retval PMINFO_R_OK success
418 * @retval PMINFO_R_EINVAL invalid argument
419 * @retval PMINFO_R_ERROR internal error
423 static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
426 ret = pkgmgr_parser_run_parser_for_uninstallation(docPtr, "theme", "org.tizen.test");
433 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
438 * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
439 * @brief This API generates the application desktop file
441 * @par This API is for package-manager installer backends.
442 * @par Sync (or) Async : Synchronous API
444 * @param[in] mfx manifest pointer
445 * @return 0 if success, error code(<0) if fail
446 * @retval PMINFO_R_OK success
447 * @retval PMINFO_R_EINVAL invalid argument
448 * @retval PMINFO_R_ERROR internal error
449 * @pre pkgmgr_parser_process_manifest_xml()
450 * @post pkgmgr_parser_free_manifest_xml()
452 static int create_desktop_file(char *manifest)
455 manifest_x *mfx = NULL;
456 mfx = pkgmgr_parser_process_manifest_xml(manifest);
457 ret = pkgmgr_parser_create_desktop_file(mfx);
460 pkgmgr_parser_free_manifest_xml(mfx);
465 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
468 * @fn int pkgmgr_parser_enable_pkg(const char *pkgid, char *const tagv[])
469 * @brief This API updates the data of the enabled package in DB.
471 * @par This API is for package-manager.
472 * @par Sync (or) Async : Synchronous API
474 * @param[in] pkgid pointer to pkgid
475 * @param[in] tagv array of xml tags or NULL
476 * @return 0 if success, error code(<0) if fail
477 * @retval PMINFO_R_OK success
478 * @retval PMINFO_R_EINVAL invalid argument
479 * @retval PMINFO_R_ERROR internal error
483 static int parser_disabled_pkg_for_installation(const char *pkgid)
486 ret = pkgmgr_parser_enable_pkg(pkgid, NULL);
493 int pkgmgr_parser_enable_pkg(const char *pkgid, char *const tagv[]);
496 * @fn int pkgmgr_parser_disable_pkg(const char *pkgid, char *const tagv[])
497 * @brief This API updates the data of the disabled package in DB.
499 * @par This API is for package-manager.
500 * @par Sync (or) Async : Synchronous API
502 * @param[in] pkgid pointer to pkgid
503 * @param[in] tagv array of xml tags or NULL
504 * @return 0 if success, error code(<0) if fail
505 * @retval PMINFO_R_OK success
506 * @retval PMINFO_R_EINVAL invalid argument
507 * @retval PMINFO_R_ERROR internal error
511 static int parse_disabled_pkg_file_for_uninstallation(const char *pkgid)
514 ret = pkgmgr_parser_disable_pkg(pkgid, NULL);
521 int pkgmgr_parser_disable_pkg(const char *pkgid, char *const tagv[]);
524 * @fn int pkgmgr_parser_insert_app_aliasid(void)
525 * @brief This API updates the app aliasid table.
527 * @par This API is for pkg_initdb and pkg_fota.
528 * @par Sync (or) Async : Synchronous API
530 * @return 0 if success, error code(<0) if fail
531 * @retval PMINFO_R_OK success
532 * @retval PMINFO_R_ERROR internal error
536 static int parse_insert_app_aliasid(void)
539 ret = pkgmgr_parser_insert_app_aliasid();
546 int pkgmgr_parser_insert_app_aliasid(void );
549 * @fn int pkgmgr_parser_update_app_aliasid(void)
550 * @brief This API updates the app aliasid table.
552 * @par This API is for csc.
553 * @par Sync (or) Async : Synchronous API
555 * @return 0 if success, error code(<0) if fail
556 * @retval PMINFO_R_OK success
557 * @retval PMINFO_R_ERROR internal error
561 static int parse_update_app_aliasid(void)
564 ret = pkgmgr_parser_update_app_aliasid();
571 int pkgmgr_parser_update_app_aliasid(void );
577 #endif /* __PKGMGR_PARSER_H__ */