Revise parser, insert db
[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 *operation;
314         const char *uri;
315         const char *mime;
316         struct appcontrol_x *prev;
317         struct appcontrol_x *next;
318 } appcontrol_x;
319
320 typedef struct category_x{
321         const char *name;
322         struct category_x *prev;
323         struct category_x *next;
324 } category_x;
325
326 typedef struct launchconditions_x {
327         const char *text;
328         struct condition_x *condition;
329         struct launchconditions_x *prev;
330         struct launchconditions_x *next;
331 } launchconditions_x;
332
333 typedef struct compatibility_x {
334         const char *name;
335         const char *text;
336         struct compatibility_x *prev;
337         struct compatibility_x *next;
338 }compatibility_x;
339
340 typedef struct deviceprofile_x {
341         const char *name;
342         const char *text;
343         struct deviceprofile_x *prev;
344         struct deviceprofile_x *next;
345 }deviceprofile_x;
346
347 typedef struct resolution_x {
348         const char *mimetype;
349         const char *urischeme;
350         struct resolution_x *prev;
351         struct resolution_x *next;
352 } resolution_x;
353
354 typedef struct capability_x {
355         const char *operationid;
356         const char *access;
357         struct resolution_x *resolution;
358         struct capability_x *prev;
359         struct capability_x *next;
360 } capability_x;
361
362 typedef struct datacontrol_x {
363         const char *providerid;
364         const char *access;
365         const char *type;
366         struct datacontrol_x *prev;
367         struct datacontrol_x *next;
368 } datacontrol_x;
369
370 typedef struct uiapplication_x {
371         const char *appid;
372         const char *exec;
373         const char *nodisplay;
374         const char *multiple;
375         const char *taskmanage;
376         const char *enabled;
377         const char *type;
378         const char *categories;
379         const char *extraid;
380         const char *hwacceleration;
381         const char *screenreader;
382         const char *mainapp;
383         const char *package;
384         const char *recentimage;
385         const char *launchcondition;
386         const char *indicatordisplay;
387         const char *portraitimg;
388         const char *landscapeimg;
389         const char *guestmode_visibility;
390         const char *app_component;
391         const char *permission_type;
392         const char *component_type;
393         const char *preload;
394         const char *submode;
395         const char *submode_mainid;
396         const char *launch_mode;
397         struct label_x *label;
398         struct icon_x *icon;
399         struct image_x *image;
400         struct appsvc_x *appsvc;
401         struct appcontrol_x *appcontrol;
402         struct category_x *category;
403         struct metadata_x *metadata;
404         struct permission_x *permission;
405         struct launchconditions_x *launchconditions;
406         struct notification_x *notification;
407         struct datashare_x *datashare;
408         struct datacontrol_x *datacontrol;
409         struct uiapplication_x *prev;
410         struct uiapplication_x *next;
411
412 } uiapplication_x;
413
414 typedef struct serviceapplication_x {
415         const char *appid;
416         const char *exec;
417         const char *onboot;
418         const char *autorestart;
419         const char *enabled;
420         const char *type;
421         const char *package;
422         const char *permission_type;
423         struct label_x *label;
424         struct icon_x *icon;
425         struct appsvc_x *appsvc;
426         struct appcontrol_x *appcontrol;
427         struct category_x *category;
428         struct metadata_x *metadata;
429         struct permission_x *permission;
430         struct datacontrol_x *datacontrol;
431         struct launchconditions_x *launchconditions;
432         struct notification_x *notification;
433         struct datashare_x *datashare;
434         struct serviceapplication_x *prev;
435         struct serviceapplication_x *next;
436 } serviceapplication_x;
437
438 typedef struct daemon_x {
439         const char *name;
440         const char *text;
441         struct daemon_x *prev;
442         struct daemon_x *next;
443 } daemon_x;
444
445 typedef struct theme_x {
446         const char *name;
447         const char *text;
448         struct theme_x *prev;
449         struct theme_x *next;
450 } theme_x;
451
452 typedef struct font_x {
453         const char *name;
454         const char *text;
455         struct font_x *prev;
456         struct font_x *next;
457 } font_x;
458
459 typedef struct ime_x {
460         const char *name;
461         const char *text;
462         struct ime_x *prev;
463         struct ime_x *next;
464 } ime_x;
465
466 typedef struct manifest_x {
467         const char *for_all_users;              /**< Flag that indicates if the package is available for everyone or for current user only*/
468         const char *package;            /**< package name*/
469         const char *version;            /**< package version*/
470         const char *installlocation;            /**< package install location*/
471         const char *ns;         /**<name space*/
472         const char *removable;          /**< package removable flag*/
473         const char *preload;            /**< package preload flag*/
474         const char *readonly;           /**< package readonly flag*/
475         const char *update;                     /**< package update flag*/
476         const char *appsetting;         /**< package app setting flag*/
477         const char *system;             /**< package system flag*/
478         const char *type;               /**< package type*/
479         const char *package_size;               /**< package size for external installation*/
480         const char *installed_time;             /**< installed time after finishing of installation*/
481         const char *installed_storage;          /**< package currently installed storage*/
482         const char *storeclient_id;             /**< id of store client for installed package*/
483         const char *mainapp_id;         /**< app id of main application*/
484         const char *package_url;                /**< app id of main application*/
485         const char *root_path;          /**< package root path*/
486         const char *csc_path;           /**< package csc path*/
487         const char *nodisplay_setting;          /**< package no display setting menu*/
488         const char *api_version;                /**< minimum version of API package using*/
489         struct icon_x *icon;            /**< package icon*/
490         struct label_x *label;          /**< package label*/
491         struct author_x *author;                /**< package author*/
492         struct description_x *description;              /**< package description*/
493         struct license_x *license;              /**< package license*/
494         struct privileges_x *privileges;        /**< package privileges*/
495         struct uiapplication_x *uiapplication;          /**< package's ui application*/
496         struct serviceapplication_x *serviceapplication;                /**< package's service application*/
497         struct daemon_x *daemon;                /**< package daemon*/
498         struct theme_x *theme;          /**< package theme*/
499         struct font_x *font;            /**< package font*/
500         struct ime_x *ime;              /**< package ime*/
501         struct compatibility_x *compatibility;          /**< package compatibility*/
502         struct deviceprofile_x *deviceprofile;          /**< package device profile*/
503 } manifest_x;
504
505 /*enum uid_value {
506         ROOT,
507         GLOBAL,
508         USER
509 };*/
510
511 /**uid check
512  * 
513  */
514 /* int check_uid(uid_t uid)
515  {
516          switch(uid)
517          {
518                 case GLOBAL_USER: return GLOBAL;
519                 case 0: return ROOT;
520                 default: goto user; break;
521         }
522 user:
523 cf getdbpath
524 */
525  
526
527 /**
528  * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
529  * @brief       This API gets the manifest file of the package.
530  *
531  * @par         This API is for package-manager installer backends.
532  * @par Sync (or) Async : Synchronous API
533  *
534  * @param[in]   pkgid   pointer to package ID
535  * @return      manifest file path on success, NULL on failure
536  * @pre         None
537  * @post                Free the manifest file pointer that is returned by API
538  * @code
539 static int get_manifest_file(const char *pkgid)
540 {
541         char *manifest = NULL;
542         manifest = pkgmgr_parser_get_manifest_file(pkgid);
543         if (manifest == NULL)
544                 return -1;
545         printf("Manifest File Path is %s\n", manifest);
546         free(manifest);
547         return 0;
548 }
549  * @endcode
550  */
551 char *pkgmgr_parser_get_manifest_file(const char *pkgid);
552 char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid);
553
554 /**
555  * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
556  * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
557  * @brief       This API parses the manifest file of the package after installation and stores the data in DB.
558  *
559  * @par         This API is for package-manager installer backends.
560  * @par Sync (or) Async : Synchronous API
561  *
562  * @param[in]   manifest        pointer to package manifest file
563  * @param[in]   uid     the addressee user id of the instruction
564  * @param[in]   tagv            array of xml tags or NULL
565  * @return      0 if success, error code(<0) if fail
566  * @retval      PMINFO_R_OK     success
567  * @retval      PMINFO_R_EINVAL invalid argument
568  * @retval      PMINFO_R_ERROR  internal error
569  * @pre         None
570  * @post                None
571  * @code
572 static int parse_manifest_file_for_installation(const char *manifest)
573 {
574         int ret = 0;
575         ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
576         if (ret)
577                 return -1;
578         return 0;
579 }
580  * @endcode
581  */
582 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
583 int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]);
584
585 /**
586  * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest,  uid_t uid, char *const tagv[])
587  * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
588  * @brief       This API parses the manifest file of the package after upgrade and stores the data in DB.
589  *
590  * @par         This API is for package-manager installer backends.
591  * @par Sync (or) Async : Synchronous API
592  *
593  * @param[in]   manifest        pointer to package manifest file
594  * @param[in]   uid     the addressee user id of the instruction
595  * @param[in]   tagv            array of xml tags or NULL
596  * @return      0 if success, error code(<0) if fail
597  * @retval      PMINFO_R_OK     success
598  * @retval      PMINFO_R_EINVAL invalid argument
599  * @retval      PMINFO_R_ERROR  internal error
600  * @pre         None
601  * @post                None
602  * @code
603 static int parse_manifest_file_for_upgrade(const char *manifest)
604 {
605         int ret = 0;
606         ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
607         if (ret)
608                 return -1;
609         return 0;
610 }
611  * @endcode
612  */
613 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
614 int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]);
615 /**
616  * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
617  * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
618  * @brief       This API parses the manifest file of the package after uninstallation and deletes the data from DB.
619  *
620  * @par         This API is for package-manager installer backends.
621  * @par Sync (or) Async : Synchronous API
622  *
623  * @param[in]   manifest        pointer to package manifest file
624  * @param[in]   uid     the addressee user id of the instruction
625  * @param[in]   tagv            array of xml tags or NULL
626  * @return      0 if success, error code(<0) if fail
627  * @retval      PMINFO_R_OK     success
628  * @retval      PMINFO_R_EINVAL invalid argument
629  * @retval      PMINFO_R_ERROR  internal error
630  * @pre         None
631  * @post                None
632  * @code
633 static int parse_manifest_file_for_uninstallation(const char *manifest)
634 {
635         int ret = 0;
636         ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
637         if (ret)
638                 return -1;
639         return 0;
640 }
641  * @endcode
642  */
643 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
644 int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]);
645 /**
646  * @fn int pkgmgr_parser_parse_manifest_for_preload()
647  * @fn int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
648  * @brief       This API update  preload information to DB.
649  *
650  * @par         This API is for package-manager installer backends.
651  * @par Sync (or) Async : Synchronous API
652  *
653  * @return      0 if success, error code(<0) if fail
654  * @retval      PMINFO_R_OK     success
655  * @retval      PMINFO_R_EINVAL invalid argument
656  * @retval      PMINFO_R_ERROR  internal error
657  * @pre         None
658  * @post                None
659  * @code
660 static int parser_parse_manifest_for_preload()
661 {
662         int ret = 0;
663         ret = pkgmgr_parser_parse_manifest_for_preload();
664         if (ret)
665                 return -1;
666         return 0;
667 }
668  * @endcode
669  */
670 int pkgmgr_parser_parse_manifest_for_preload();
671 int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid);
672
673 /**
674  * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
675  * @brief       This API validates the manifest file against the manifest schema.
676  *
677  * @par         This API is for package-manager installer backends.
678  * @par Sync (or) Async : Synchronous API
679  *
680  * @param[in]   manifest        pointer to package manifest file
681  * @return      0 if success, error code(<0) if fail
682  * @retval      PMINFO_R_OK     success
683  * @retval      PMINFO_R_EINVAL invalid argument
684  * @retval      PMINFO_R_ERROR  internal error
685  * @pre         None
686  * @post                None
687  * @code
688 static int validate_manifest_file(const char *manifest)
689 {
690         int ret = 0;
691         ret = pkgmgr_parser_check_manifest_validation(manifest);
692         if (ret)
693                 return -1;
694         return 0;
695 }
696  * @endcode
697  */
698 int pkgmgr_parser_check_manifest_validation(const char *manifest);
699
700 /**
701  * @fn void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
702  * @brief       This API will free the manifest pointer by recursively freeing all sub elements.
703  *
704  * @par         This API is for package-manager installer backends.
705  * @par Sync (or) Async : Synchronous API
706  *
707  * @param[in]   mfx     pointer to parsed manifest data
708  * @pre         pkgmgr_parser_process_manifest_xml()
709  * @post                None
710  * @code
711 static int parse_manifest_file(const char *manifest)
712 {
713         manifest_x *mfx = NULL
714         mfx = pkgmgr_parser_process_manifest_xml(manifest);
715         if (mfx == NULL)
716                 return -1;
717         printf("Parsing Manifest Success\n");
718         pkgmgr_parser_free_manifest_xml(mfx);
719         return 0;
720 }
721  * @endcode
722  */
723 void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
724
725 /**
726  * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
727  * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
728  * @brief       This API parses the manifest file and stores all the data in the manifest structure.
729  *
730  * @par         This API is for package-manager installer backends.
731  * @par Sync (or) Async : Synchronous API
732  *
733  * @param[in]   manifest        pointer to package manifest file
734  * @param[in]   uid     the addressee user id of the instruction
735  * @return      manifest pointer on success, NULL on failure
736  * @pre         None
737  * @post                pkgmgr_parser_free_manifest_xml()
738  * @code
739 static int parse_manifest_file(const char *manifest)
740 {
741         manifest_x *mfx = NULL
742         mfx = pkgmgr_parser_process_manifest_xml(manifest);
743         if (mfx == NULL)
744                 return -1;
745         printf("Parsing Manifest Success\n");
746         pkgmgr_parser_free_manifest_xml(mfx);
747         return 0;
748 }
749  * @endcode
750  */
751 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
752 manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid);
753
754 /**
755  * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
756  * @brief       This API calls the parser directly by supplying the xml docptr. It is used during package installation
757  *
758  * @par         This API is for package-manager installer backends.
759  * @par Sync (or) Async : Synchronous API
760  *
761  * @param[in]   docPtr  XML doxument pointer
762  * @param[in]   tag             the xml tag corresponding to the parser that will parse the docPtr
763  * @param[in]   pkgid           the package id
764  * @return      0 if success, error code(<0) if fail
765  * @retval      PMINFO_R_OK     success
766  * @retval      PMINFO_R_EINVAL invalid argument
767  * @retval      PMINFO_R_ERROR  internal error
768  * @pre         None
769  * @post                None
770  * @code
771 static int parse_docptr_for_installation(xmlDocPtr docPtr)
772 {
773         int ret = 0;
774         ret = pkgmgr_parser_run_parser_for_installation(docPtr, "theme", "com.samsung.test");
775         if (ret)
776                 return -1;
777         return 0;
778 }
779  * @endcode
780  */
781 int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
782
783 /**
784  * @fn int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
785  * @brief       This API calls the parser directly by supplying the xml docptr. It is used during package upgrade
786  *
787  * @par         This API is for package-manager installer backends.
788  * @par Sync (or) Async : Synchronous API
789  *
790  * @param[in]   docPtr  XML doxument pointer
791  * @param[in]   tag             the xml tag corresponding to the parser that will parse the docPtr
792  * @param[in]   pkgid           the package id
793  * @return      0 if success, error code(<0) if fail
794  * @retval      PMINFO_R_OK     success
795  * @retval      PMINFO_R_EINVAL invalid argument
796  * @retval      PMINFO_R_ERROR  internal error
797  * @pre         None
798  * @post                None
799  * @code
800 static int parse_docptr_for_upgrade(xmlDocPtr docPtr)
801 {
802         int ret = 0;
803         ret = pkgmgr_parser_run_parser_for_upgrade(docPtr, "theme", "com.samsung.test");
804         if (ret)
805                 return -1;
806         return 0;
807 }
808  * @endcode
809  */
810 int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid);
811
812 /**
813  * @fn int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
814  * @brief       This API calls the parser directly by supplying the xml docptr. It is used during package uninstallation
815  *
816  * @par         This API is for package-manager installer backends.
817  * @par Sync (or) Async : Synchronous API
818  *
819  * @param[in]   docPtr  XML doxument pointer
820  * @param[in]   tag             the xml tag corresponding to the parser that will parse the docPtr
821  * @param[in]   pkgid           the package id
822  * @return      0 if success, error code(<0) if fail
823  * @retval      PMINFO_R_OK     success
824  * @retval      PMINFO_R_EINVAL invalid argument
825  * @retval      PMINFO_R_ERROR  internal error
826  * @pre         None
827  * @post                None
828  * @code
829 static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
830 {
831         int ret = 0;
832         ret = pkgmgr_parser_run_parser_for_uninstallation(docPtr, "theme", "com.samsung.test");
833         if (ret)
834                 return -1;
835         return 0;
836 }
837  * @endcode
838  */
839 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
840
841
842
843 /**
844  * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
845  * @fn int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
846  * @brief       This API generates the application desktop file
847  *
848  * @par         This API is for package-manager installer backends.
849  * @par Sync (or) Async : Synchronous API
850  *
851  * @param[in]   mfx     manifest pointer
852  * @param[in]   uid     the addressee user id of the instruction
853  * @return      0 if success, error code(<0) if fail
854  * @retval      PMINFO_R_OK     success
855  * @retval      PMINFO_R_EINVAL invalid argument
856  * @retval      PMINFO_R_ERROR  internal error
857  * @pre         pkgmgr_parser_process_manifest_xml()
858  * @post        pkgmgr_parser_free_manifest_xml()
859  * @code
860 static int create_desktop_file(char *manifest)
861 {
862         int ret = 0;
863         manifest_x *mfx = NULL;
864         mfx = pkgmgr_parser_process_manifest_xml(manifest);
865         ret = pkgmgr_parser_create_desktop_file(mfx);
866         if (ret)
867                 return -1;
868         pkgmgr_parser_free_manifest_xml(mfx);
869         return 0;
870 }
871  * @endcode
872  */
873 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
874 int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid);
875
876 /** @} */
877 #ifdef __cplusplus
878 }
879 #endif
880 #endif                          /* __PKGMGR_PARSER_H__ */