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