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