change GLOBAL_USER to tzplatform_getuid
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser.h
1 /*
2  * pkgmgr-info
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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>
8  *
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
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  */
22
23 #ifndef __PKGMGR_PARSER_H__
24 #define __PKGMGR_PARSER_H__
25
26 /**
27  * @file pkgmgr_parser.h
28  * @author Sewook Park <sewook7.park@samsung.com>
29  * @author Shobhit Srivastava <shobhit.s@samsung.com>
30  * @version 0.1
31  * @brief    This file declares API of pkgmgr_parser
32  * @addtogroup          APPLICATION_FRAMEWORK
33  * @{
34  *
35  * @defgroup            PackageManagerParser
36  * @section             Header Header file to include:
37  * @code
38  * #include             <pkgmgr_parser.h>
39  * @endcode
40  *
41  * @}
42  */
43
44 #include <libxml/xmlreader.h>
45
46 /* For multi-user support */
47 #include <tzplatform_config.h>
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 #define DEFAULT_LOCALE          "No Locale"
53
54 #define PKG_PARSERLIB   "parserlib:"
55 #define PKG_PARSER_CONF_PATH    SYSCONFDIR "/package-manager/parser_path.conf"
56
57 #define PKG_STRING_LEN_MAX 1024
58
59 #define PKGMGR_PARSER_EMPTY_STR         ""
60 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
61
62
63 /**
64  * @brief List definitions.
65  * All lists are doubly-linked, the last element is stored to list pointer,
66  * which means that lists must be looped using the prev pointer, or by
67  * calling LISTHEAD first to go to start in order to use the next pointer.
68  */
69
70  /**
71  * @brief Convinience Macro to add node in list
72  */
73
74 #define LISTADD(list, node)                     \
75     do {                                        \
76         (node)->prev = (list);                  \
77         if (list) (node)->next = (list)->next;  \
78         else (node)->next = NULL;               \
79         if (list) (list)->next = (node);        \
80         (list) = (node);                        \
81     } while (0);
82
83  /**
84  * @brief Convinience Macro to add one node to another node
85  */
86 #define NODEADD(node1, node2)                                   \
87     do {                                                        \
88         (node2)->prev = (node1);                                \
89         (node2)->next = (node1)->next;                          \
90         if ((node1)->next) (node1)->next->prev = (node2);       \
91         (node1)->next = (node2);                                \
92     } while (0);
93
94  /**
95  * @brief Convinience Macro to concatenate two lists
96  */
97 #define LISTCAT(list, first, last)              \
98     if ((first) && (last)) {                    \
99         (first)->prev = (list);                 \
100         (list) = (last);                        \
101     }
102
103  /**
104  * @brief Convinience Macro to delete node from list
105  */
106 #define LISTDEL(list, node)                                     \
107     do {                                                        \
108         if ((node)->prev) (node)->prev->next = (node)->next;    \
109         if ((node)->next) (node)->next->prev = (node)->prev;    \
110         if (!((node)->prev) && !((node)->next)) (list) = NULL;  \
111     } while (0);
112
113  /**
114  * @brief Convinience Macro to get list head
115  */
116 #define LISTHEAD(list, node)                                    \
117     for ((node) = (list); (node)->prev; (node) = (node)->prev)
118
119  /**
120  * @brief Convinience Macro to get list tail
121  */
122 #define LISTTAIL(list, node)                                    \
123     for ((node) = (list); (node)->next; (node) = (node)->next)
124
125 typedef struct metadata_x {
126         const char *key;
127         const char *value;
128         struct metadata_x *prev;
129         struct metadata_x *next;
130 } metadata_x;
131
132 typedef struct privilege_x {
133         const char *text;
134         struct privilege_x *prev;
135         struct privilege_x *next;
136 } privilege_x;
137
138 typedef struct privileges_x {
139         struct privilege_x *privilege;
140         struct privileges_x *prev;
141         struct privileges_x *next;
142 } privileges_x;
143
144 typedef struct permission_x {
145         const char *type;
146         const char *value;
147         struct permission_x *prev;
148         struct permission_x *next;
149 } permission_x;
150
151 typedef struct icon_x {
152         const char *name;
153         const char *text;
154         const char *lang;
155         const char *section;
156         const char *size;
157         const char *resolution;
158         struct icon_x *prev;
159         struct icon_x *next;
160 } icon_x;
161
162 typedef struct image_x {
163         const char *name;
164         const char *text;
165         const char *lang;
166         const char *section;
167         struct image_x *prev;
168         struct image_x *next;
169 } image_x;
170
171 typedef struct allowed_x {
172         const char *name;
173         const char *text;
174         struct allowed_x *prev;
175         struct allowed_x *next;
176 } allowed_x;
177
178 typedef struct request_x {
179         const char *text;
180         struct request_x *prev;
181         struct request_x *next;
182 } request_x;
183
184 typedef struct define_x {
185         const char *path;
186         struct allowed_x *allowed;
187         struct request_x *request;
188         struct define_x *prev;
189         struct define_x *next;
190 } define_x;
191
192 typedef struct datashare_x {
193         struct define_x *define;
194         struct request_x *request;
195         struct datashare_x *prev;
196         struct datashare_x *next;
197 } datashare_x;
198
199 typedef struct description_x {
200         const char *name;
201         const char *text;
202         const char *lang;
203         struct description_x *prev;
204         struct description_x *next;
205 } description_x;
206
207 typedef struct registry_x {
208         const char *name;
209         const char *text;
210         struct registry_x *prev;
211         struct registry_x *next;
212 } registry_x;
213
214 typedef struct database_x {
215         const char *name;
216         const char *text;
217         struct database_x *prev;
218         struct database_x *next;
219 } database_x;
220
221 typedef struct layout_x {
222         const char *name;
223         const char *text;
224         struct layout_x *prev;
225         struct layout_x *next;
226 } layout_x;
227
228 typedef struct label_x {
229         const char *name;
230         const char *text;
231         const char *lang;
232         struct label_x *prev;
233         struct label_x *next;
234 } label_x;
235
236 typedef struct author_x {
237         const char *email;
238         const char *href;
239         const char *text;
240         const char *lang;
241         struct author_x *prev;
242         struct author_x *next;
243 } author_x;
244
245 typedef struct license_x {
246         const char *text;
247         const char *lang;
248         struct license_x *prev;
249         struct license_x *next;
250 } license_x;
251
252 typedef struct operation_x {
253         const char *name;
254         const char *text;
255         struct operation_x *prev;
256         struct operation_x *next;
257 } operation_x;
258
259 typedef struct uri_x {
260         const char *name;
261         const char *text;
262         struct uri_x *prev;
263         struct uri_x *next;
264 } uri_x;
265
266 typedef struct mime_x {
267         const char *name;
268         const char *text;
269         struct mime_x *prev;
270         struct mime_x *next;
271 } mime_x;
272
273 typedef struct subapp_x {
274         const char *name;
275         const char *text;
276         struct subapp_x *prev;
277         struct subapp_x *next;
278 } subapp_x;
279
280 typedef struct condition_x {
281         const char *name;
282         const char *text;
283         struct condition_x *prev;
284         struct condition_x *next;
285 } condition_x;
286
287 typedef struct notification_x {
288         const char *name;
289         const char *text;
290         struct notification_x *prev;
291         struct notification_x *next;
292 } notification_x;
293
294 typedef struct appsvc_x {
295         const char *text;
296         struct operation_x *operation;
297         struct uri_x *uri;
298         struct mime_x *mime;
299         struct subapp_x *subapp;
300         struct appsvc_x *prev;
301         struct appsvc_x *next;
302 } appsvc_x;
303
304 typedef struct appcontrol_x {
305         const char *text;
306         struct operation_x *operation;
307         struct uri_x *uri;
308         struct mime_x *mime;
309         struct subapp_x *subapp;
310         struct appcontrol_x *prev;
311         struct appcontrol_x *next;
312 } appcontrol_x;
313
314 typedef struct category_x{
315         const char *name;
316         struct category_x *prev;
317         struct category_x *next;
318 } category_x;
319
320 typedef struct launchconditions_x {
321         const char *text;
322         struct condition_x *condition;
323         struct launchconditions_x *prev;
324         struct launchconditions_x *next;
325 } launchconditions_x;
326
327 typedef struct compatibility_x {
328         const char *name;
329         const char *text;
330         struct compatibility_x *prev;
331         struct compatibility_x *next;
332 }compatibility_x;
333
334 typedef struct deviceprofile_x {
335         const char *name;
336         const char *text;
337         struct deviceprofile_x *prev;
338         struct deviceprofile_x *next;
339 }deviceprofile_x;
340
341 typedef struct resolution_x {
342         const char *mimetype;
343         const char *urischeme;
344         struct resolution_x *prev;
345         struct resolution_x *next;
346 } resolution_x;
347
348 typedef struct capability_x {
349         const char *operationid;
350         const char *access;
351         struct resolution_x *resolution;
352         struct capability_x *prev;
353         struct capability_x *next;
354 } capability_x;
355
356 typedef struct datacontrol_x {
357         const char *providerid;
358         struct capability_x *capability;
359         struct datacontrol_x *prev;
360         struct datacontrol_x *next;
361 } datacontrol_x;
362
363 typedef struct uiapplication_x {
364         const char *appid;
365         const char *exec;
366         const char *nodisplay;
367         const char *multiple;
368         const char *taskmanage;
369         const char *enabled;
370         const char *type;
371         const char *categories;
372         const char *extraid;
373         const char *hwacceleration;
374         const char *screenreader;
375         const char *mainapp;
376         const char *package;
377         const char *recentimage;
378         const char *launchcondition;
379         const char *indicatordisplay;
380         const char *portraitimg;
381         const char *landscapeimg;
382         const char *guestmode_visibility;
383         const char *app_component;
384         const char *permission_type;
385         const char *component_type;
386         const char *preload;
387         const char *submode;
388         const char *submode_mainid;
389         struct label_x *label;
390         struct icon_x *icon;
391         struct image_x *image;
392         struct appsvc_x *appsvc;
393         struct appcontrol_x *appcontrol;
394         struct category_x *category;
395         struct metadata_x *metadata;
396         struct permission_x *permission;
397         struct launchconditions_x *launchconditions;
398         struct notification_x *notification;
399         struct datashare_x *datashare;
400         struct uiapplication_x *prev;
401         struct uiapplication_x *next;
402 } uiapplication_x;
403
404 typedef struct serviceapplication_x {
405         const char *appid;
406         const char *exec;
407         const char *onboot;
408         const char *autorestart;
409         const char *enabled;
410         const char *type;
411         const char *package;
412         const char *permission_type;
413         struct label_x *label;
414         struct icon_x *icon;
415         struct appsvc_x *appsvc;
416         struct appcontrol_x *appcontrol;
417         struct category_x *category;
418         struct metadata_x *metadata;
419         struct permission_x *permission;
420         struct datacontrol_x *datacontrol;
421         struct launchconditions_x *launchconditions;
422         struct notification_x *notification;
423         struct datashare_x *datashare;
424         struct serviceapplication_x *prev;
425         struct serviceapplication_x *next;
426 } serviceapplication_x;
427
428 typedef struct daemon_x {
429         const char *name;
430         const char *text;
431         struct daemon_x *prev;
432         struct daemon_x *next;
433 } daemon_x;
434
435 typedef struct theme_x {
436         const char *name;
437         const char *text;
438         struct theme_x *prev;
439         struct theme_x *next;
440 } theme_x;
441
442 typedef struct font_x {
443         const char *name;
444         const char *text;
445         struct font_x *prev;
446         struct font_x *next;
447 } font_x;
448
449 typedef struct ime_x {
450         const char *name;
451         const char *text;
452         struct ime_x *prev;
453         struct ime_x *next;
454 } ime_x;
455
456 typedef struct manifest_x {
457         const char *package;            /**< package name*/
458         const char *version;            /**< package version*/
459         const char *installlocation;            /**< package install location*/
460         const char *ns;         /**<name space*/
461         const char *removable;          /**< package removable flag*/
462         const char *preload;            /**< package preload flag*/
463         const char *readonly;           /**< package readonly flag*/
464         const char *update;                     /**< package update flag*/
465         const char *appsetting;         /**< package app setting flag*/
466         const char *system;             /**< package system flag*/
467         const char *type;               /**< package type*/
468         const char *package_size;               /**< package size for external installation*/
469         const char *installed_time;             /**< installed time after finishing of installation*/
470         const char *installed_storage;          /**< package currently installed storage*/
471         const char *storeclient_id;             /**< id of store client for installed package*/
472         const char *mainapp_id;         /**< app id of main application*/
473         const char *package_url;                /**< app id of main application*/
474         const char *root_path;          /**< package root path*/
475         const char *csc_path;           /**< package csc path*/
476         const char *nodisplay_setting;          /**< package no display setting menu*/
477         const char *main_package;               /**< main package id for sub-package(ug)*/
478         struct icon_x *icon;            /**< package icon*/
479         struct label_x *label;          /**< package label*/
480         struct author_x *author;                /**< package author*/
481         struct description_x *description;              /**< package description*/
482         struct license_x *license;              /**< package license*/
483         struct privileges_x *privileges;        /**< package privileges*/
484         struct uiapplication_x *uiapplication;          /**< package's ui application*/
485         struct serviceapplication_x *serviceapplication;                /**< package's service application*/
486         struct daemon_x *daemon;                /**< package daemon*/
487         struct theme_x *theme;          /**< package theme*/
488         struct font_x *font;            /**< package font*/
489         struct ime_x *ime;              /**< package ime*/
490         struct compatibility_x *compatibility;          /**< package compatibility*/
491         struct deviceprofile_x *deviceprofile;          /**< package device profile*/
492 } manifest_x;
493
494 /*enum uid_value {
495         ROOT,
496         GLOBAL,
497         USER
498 };*/
499
500 /**uid check
501  * 
502  */
503 /* int check_uid(uid_t uid)
504  {
505          switch(uid)
506          {
507                 case GLOBAL_USER: return GLOBAL;
508                 case 0: return ROOT;
509                 default: goto user; break;
510         }
511 user:
512 cf getdbpath
513 */
514  
515
516 /**
517  * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
518  * @brief       This API gets the manifest file of the package.
519  *
520  * @par         This API is for package-manager installer backends.
521  * @par Sync (or) Async : Synchronous API
522  *
523  * @param[in]   pkgid   pointer to package ID
524  * @return      manifest file path on success, NULL on failure
525  * @pre         None
526  * @post                Free the manifest file pointer that is returned by API
527  * @code
528 static int get_manifest_file(const char *pkgid)
529 {
530         char *manifest = NULL;
531         manifest = pkgmgr_parser_get_manifest_file(pkgid);
532         if (manifest == NULL)
533                 return -1;
534         printf("Manifest File Path is %s\n", manifest);
535         free(manifest);
536         return 0;
537 }
538  * @endcode
539  */
540 char *pkgmgr_parser_get_manifest_file(const char *pkgid);
541
542 /**
543  * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
544  * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
545  * @brief       This API parses the manifest file of the package after installation and stores the data in DB.
546  *
547  * @par         This API is for package-manager installer backends.
548  * @par Sync (or) Async : Synchronous API
549  *
550  * @param[in]   manifest        pointer to package manifest file
551  * @param[in]   uid     the addressee user id of the instruction
552  * @param[in]   tagv            array of xml tags or NULL
553  * @return      0 if success, error code(<0) if fail
554  * @retval      PMINFO_R_OK     success
555  * @retval      PMINFO_R_EINVAL invalid argument
556  * @retval      PMINFO_R_ERROR  internal error
557  * @pre         None
558  * @post                None
559  * @code
560 static int parse_manifest_file_for_installation(const char *manifest)
561 {
562         int ret = 0;
563         ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
564         if (ret)
565                 return -1;
566         return 0;
567 }
568  * @endcode
569  */
570 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
571 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]);
572
573 /**
574  * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest,  uid_t uid, char *const tagv[])
575  * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
576  * @brief       This API parses the manifest file of the package after upgrade and stores the data in DB.
577  *
578  * @par         This API is for package-manager installer backends.
579  * @par Sync (or) Async : Synchronous API
580  *
581  * @param[in]   manifest        pointer to package manifest file
582  * @param[in]   uid     the addressee user id of the instruction
583  * @param[in]   tagv            array of xml tags or NULL
584  * @return      0 if success, error code(<0) if fail
585  * @retval      PMINFO_R_OK     success
586  * @retval      PMINFO_R_EINVAL invalid argument
587  * @retval      PMINFO_R_ERROR  internal error
588  * @pre         None
589  * @post                None
590  * @code
591 static int parse_manifest_file_for_upgrade(const char *manifest)
592 {
593         int ret = 0;
594         ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
595         if (ret)
596                 return -1;
597         return 0;
598 }
599  * @endcode
600  */
601 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
602 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]);
603 /**
604  * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
605  * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
606  * @brief       This API parses the manifest file of the package after uninstallation and deletes the data from DB.
607  *
608  * @par         This API is for package-manager installer backends.
609  * @par Sync (or) Async : Synchronous API
610  *
611  * @param[in]   manifest        pointer to package manifest file
612  * @param[in]   uid     the addressee user id of the instruction
613  * @param[in]   tagv            array of xml tags or NULL
614  * @return      0 if success, error code(<0) if fail
615  * @retval      PMINFO_R_OK     success
616  * @retval      PMINFO_R_EINVAL invalid argument
617  * @retval      PMINFO_R_ERROR  internal error
618  * @pre         None
619  * @post                None
620  * @code
621 static int parse_manifest_file_for_uninstallation(const char *manifest)
622 {
623         int ret = 0;
624         ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
625         if (ret)
626                 return -1;
627         return 0;
628 }
629  * @endcode
630  */
631 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
632 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]);
633 /**
634  * @fn int pkgmgr_parser_parse_manifest_for_preload()
635  * @fn int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
636  * @brief       This API update  preload information to DB.
637  *
638  * @par         This API is for package-manager installer backends.
639  * @par Sync (or) Async : Synchronous API
640  *
641  * @return      0 if success, error code(<0) if fail
642  * @retval      PMINFO_R_OK     success
643  * @retval      PMINFO_R_EINVAL invalid argument
644  * @retval      PMINFO_R_ERROR  internal error
645  * @pre         None
646  * @post                None
647  * @code
648 static int parser_parse_manifest_for_preload()
649 {
650         int ret = 0;
651         ret = pkgmgr_parser_parse_manifest_for_preload();
652         if (ret)
653                 return -1;
654         return 0;
655 }
656  * @endcode
657  */
658 int pkgmgr_parser_parse_manifest_for_preload();
659 int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid);
660
661 /**
662  * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
663  * @brief       This API validates the manifest file against the manifest schema.
664  *
665  * @par         This API is for package-manager installer backends.
666  * @par Sync (or) Async : Synchronous API
667  *
668  * @param[in]   manifest        pointer to package manifest file
669  * @return      0 if success, error code(<0) if fail
670  * @retval      PMINFO_R_OK     success
671  * @retval      PMINFO_R_EINVAL invalid argument
672  * @retval      PMINFO_R_ERROR  internal error
673  * @pre         None
674  * @post                None
675  * @code
676 static int validate_manifest_file(const char *manifest)
677 {
678         int ret = 0;
679         ret = pkgmgr_parser_check_manifest_validation(manifest);
680         if (ret)
681                 return -1;
682         return 0;
683 }
684  * @endcode
685  */
686 int pkgmgr_parser_check_manifest_validation(const char *manifest);
687
688 /**
689  * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
690  * @brief       This API will free the manifest pointer by recursively freeing all sub elements.
691  *
692  * @par         This API is for package-manager installer backends.
693  * @par Sync (or) Async : Synchronous API
694  *
695  * @param[in]   mfx     pointer to parsed manifest data
696  * @pre         pkgmgr_parser_process_manifest_xml()
697  * @post                None
698  * @code
699 static int parse_manifest_file(const char *manifest)
700 {
701         manifest_x *mfx = NULL
702         mfx = pkgmgr_parser_process_manifest_xml(manifest);
703         if (mfx == NULL)
704                 return -1;
705         printf("Parsing Manifest Success\n");
706         pkgmgr_parser_free_manifest_xml(mfx);
707         return 0;
708 }
709  * @endcode
710  */
711 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
712
713 /**
714  * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
715  * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
716  * @brief       This API parses the manifest file and stores all the data in the manifest structure.
717  *
718  * @par         This API is for package-manager installer backends.
719  * @par Sync (or) Async : Synchronous API
720  *
721  * @param[in]   manifest        pointer to package manifest file
722  * @param[in]   uid     the addressee user id of the instruction
723  * @return      manifest pointer on success, NULL on failure
724  * @pre         None
725  * @post                pkgmgr_parser_free_manifest_xml()
726  * @code
727 static int parse_manifest_file(const char *manifest)
728 {
729         manifest_x *mfx = NULL
730         mfx = pkgmgr_parser_process_manifest_xml(manifest);
731         if (mfx == NULL)
732                 return -1;
733         printf("Parsing Manifest Success\n");
734         pkgmgr_parser_free_manifest_xml(mfx);
735         return 0;
736 }
737  * @endcode
738  */
739 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
740 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid);
741
742 /**
743  * @fn manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid)
744  * @brief       This API gets the manifest info from DB and stores all the data in the manifest structure.
745  *
746  * @par         This API is for package-manager installer backends.
747  * @par Sync (or) Async : Synchronous API
748  *
749  * @param[in]   pkgid   package id for package
750  * @return      manifest pointer on success, NULL on failure
751  * @pre         None
752  * @post                pkgmgr_parser_free_manifest_xml()
753  * @code
754 static int get_manifest_info(const char *pkgid)
755 {
756         manifest_x *mfx = NULL
757         mfx = pkgmgr_parser_get_manifest_info(pkgid);
758         if (mfx == NULL)
759                 return -1;
760         printf("Parsing Manifest Success\n");
761         pkgmgr_parser_free_manifest_xml(mfx);
762         return 0;
763 }
764  * @endcode
765  */
766 manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid);
767
768 /* These APIs are intended to call parser directly */
769 typedef int (*ps_iter_fn) (const char *tag, int type, void *userdata);
770
771 int pkgmgr_parser_has_parser(const char *tag, int *type);
772 int pkgmgr_parser_get_list(ps_iter_fn iter_fn, void *data);
773
774 /**
775  * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
776  * @brief       This API calls the parser directly by supplying the xml docptr. It is used during package installation
777  *
778  * @par         This API is for package-manager installer backends.
779  * @par Sync (or) Async : Synchronous API
780  *
781  * @param[in]   docPtr  XML doxument pointer
782  * @param[in]   tag             the xml tag corresponding to the parser that will parse the docPtr
783  * @param[in]   pkgid           the package id
784  * @return      0 if success, error code(<0) if fail
785  * @retval      PMINFO_R_OK     success
786  * @retval      PMINFO_R_EINVAL invalid argument
787  * @retval      PMINFO_R_ERROR  internal error
788  * @pre         None
789  * @post                None
790  * @code
791 static int parse_docptr_for_installation(xmlDocPtr docPtr)
792 {
793         int ret = 0;
794         ret = pkgmgr_parser_run_parser_for_installation(docPtr, "theme", "com.samsung.test");
795         if (ret)
796                 return -1;
797         return 0;
798 }
799  * @endcode
800  */
801 int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
802
803 /**
804  * @fn int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
805  * @brief       This API calls the parser directly by supplying the xml docptr. It is used during package upgrade
806  *
807  * @par         This API is for package-manager installer backends.
808  * @par Sync (or) Async : Synchronous API
809  *
810  * @param[in]   docPtr  XML doxument pointer
811  * @param[in]   tag             the xml tag corresponding to the parser that will parse the docPtr
812  * @param[in]   pkgid           the package id
813  * @return      0 if success, error code(<0) if fail
814  * @retval      PMINFO_R_OK     success
815  * @retval      PMINFO_R_EINVAL invalid argument
816  * @retval      PMINFO_R_ERROR  internal error
817  * @pre         None
818  * @post                None
819  * @code
820 static int parse_docptr_for_upgrade(xmlDocPtr docPtr)
821 {
822         int ret = 0;
823         ret = pkgmgr_parser_run_parser_for_upgrade(docPtr, "theme", "com.samsung.test");
824         if (ret)
825                 return -1;
826         return 0;
827 }
828  * @endcode
829  */
830 int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid);
831
832 /**
833  * @fn int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
834  * @brief       This API calls the parser directly by supplying the xml docptr. It is used during package uninstallation
835  *
836  * @par         This API is for package-manager installer backends.
837  * @par Sync (or) Async : Synchronous API
838  *
839  * @param[in]   docPtr  XML doxument pointer
840  * @param[in]   tag             the xml tag corresponding to the parser that will parse the docPtr
841  * @param[in]   pkgid           the package id
842  * @return      0 if success, error code(<0) if fail
843  * @retval      PMINFO_R_OK     success
844  * @retval      PMINFO_R_EINVAL invalid argument
845  * @retval      PMINFO_R_ERROR  internal error
846  * @pre         None
847  * @post                None
848  * @code
849 static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
850 {
851         int ret = 0;
852         ret = pkgmgr_parser_run_parser_for_uninstallation(docPtr, "theme", "com.samsung.test");
853         if (ret)
854                 return -1;
855         return 0;
856 }
857  * @endcode
858  */
859 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
860
861
862
863 /**
864  * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
865  * @fn int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
866  * @brief       This API generates the application desktop file
867  *
868  * @par         This API is for package-manager installer backends.
869  * @par Sync (or) Async : Synchronous API
870  *
871  * @param[in]   mfx     manifest pointer
872  * @param[in]   uid     the addressee user id of the instruction
873  * @return      0 if success, error code(<0) if fail
874  * @retval      PMINFO_R_OK     success
875  * @retval      PMINFO_R_EINVAL invalid argument
876  * @retval      PMINFO_R_ERROR  internal error
877  * @pre         pkgmgr_parser_process_manifest_xml()
878  * @post        pkgmgr_parser_free_manifest_xml()
879  * @code
880 static int create_desktop_file(char *manifest)
881 {
882         int ret = 0;
883         manifest_x *mfx = NULL;
884         mfx = pkgmgr_parser_process_manifest_xml(manifest);
885         ret = pkgmgr_parser_create_desktop_file(mfx);
886         if (ret)
887                 return -1;
888         pkgmgr_parser_free_manifest_xml(mfx);
889         return 0;
890 }
891  * @endcode
892  */
893 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
894 int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid);
895
896 /** @} */
897 #ifdef __cplusplus
898 }
899 #endif
900 #endif                          /* __PKGMGR_PARSER_H__ */