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