Revise parser, insert db
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser.h
old mode 100755 (executable)
new mode 100644 (file)
index e3a93b0..2d7e082
 
 #include <libxml/xmlreader.h>
 
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 #define DEFAULT_LOCALE         "No Locale"
 
 #define PKG_PARSERLIB  "parserlib:"
-#define PKG_PARSER_CONF_PATH   "/usr/etc/package-manager/parser_path.conf"
+#define PKG_PARSER_CONF_PATH   SYSCONFDIR "/package-manager/parser_path.conf"
 
 #define PKG_STRING_LEN_MAX 1024
 
+#define PKGMGR_PARSER_EMPTY_STR                ""
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+
+/**
+ * @brief API return values
+ */
+enum {
+       PM_PARSER_R_EINVAL = -2,                /**< Invalid argument */
+       PM_PARSER_R_ERROR = -1,         /**< General error */
+       PM_PARSER_R_OK = 0                      /**< General success */
+};
+
 /**
  * @brief List definitions.
  * All lists are doubly-linked, the last element is stored to list pointer,
@@ -295,11 +310,9 @@ typedef struct appsvc_x {
 } appsvc_x;
 
 typedef struct appcontrol_x {
-       const char *text;
-       struct operation_x *operation;
-       struct uri_x *uri;
-       struct mime_x *mime;
-       struct subapp_x *subapp;
+       const char *operation;
+       const char *uri;
+       const char *mime;
        struct appcontrol_x *prev;
        struct appcontrol_x *next;
 } appcontrol_x;
@@ -348,7 +361,8 @@ typedef struct capability_x {
 
 typedef struct datacontrol_x {
        const char *providerid;
-       struct capability_x *capability;
+       const char *access;
+       const char *type;
        struct datacontrol_x *prev;
        struct datacontrol_x *next;
 } datacontrol_x;
@@ -364,6 +378,7 @@ typedef struct uiapplication_x {
        const char *categories;
        const char *extraid;
        const char *hwacceleration;
+       const char *screenreader;
        const char *mainapp;
        const char *package;
        const char *recentimage;
@@ -376,6 +391,9 @@ typedef struct uiapplication_x {
        const char *permission_type;
        const char *component_type;
        const char *preload;
+       const char *submode;
+       const char *submode_mainid;
+       const char *launch_mode;
        struct label_x *label;
        struct icon_x *icon;
        struct image_x *image;
@@ -387,8 +405,10 @@ typedef struct uiapplication_x {
        struct launchconditions_x *launchconditions;
        struct notification_x *notification;
        struct datashare_x *datashare;
+       struct datacontrol_x *datacontrol;
        struct uiapplication_x *prev;
        struct uiapplication_x *next;
+
 } uiapplication_x;
 
 typedef struct serviceapplication_x {
@@ -444,6 +464,7 @@ typedef struct ime_x {
 } ime_x;
 
 typedef struct manifest_x {
+       const char *for_all_users;              /**< Flag that indicates if the package is available for everyone or for current user only*/
        const char *package;            /**< package name*/
        const char *version;            /**< package version*/
        const char *installlocation;            /**< package install location*/
@@ -453,6 +474,7 @@ typedef struct manifest_x {
        const char *readonly;           /**< package readonly flag*/
        const char *update;                     /**< package update flag*/
        const char *appsetting;         /**< package app setting flag*/
+       const char *system;             /**< package system flag*/
        const char *type;               /**< package type*/
        const char *package_size;               /**< package size for external installation*/
        const char *installed_time;             /**< installed time after finishing of installation*/
@@ -463,6 +485,7 @@ typedef struct manifest_x {
        const char *root_path;          /**< package root path*/
        const char *csc_path;           /**< package csc path*/
        const char *nodisplay_setting;          /**< package no display setting menu*/
+       const char *api_version;                /**< minimum version of API package using*/
        struct icon_x *icon;            /**< package icon*/
        struct label_x *label;          /**< package label*/
        struct author_x *author;                /**< package author*/
@@ -479,6 +502,28 @@ typedef struct manifest_x {
        struct deviceprofile_x *deviceprofile;          /**< package device profile*/
 } manifest_x;
 
+/*enum uid_value {
+       ROOT,
+       GLOBAL,
+       USER
+};*/
+
+/**uid check
+ * 
+ */
+/* int check_uid(uid_t uid)
+ {
+        switch(uid)
+        {
+               case GLOBAL_USER: return GLOBAL;
+               case 0: return ROOT;
+               default: goto user; break;
+       }
+user:
+cf getdbpath
+*/
+
 /**
  * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
  * @brief      This API gets the manifest file of the package.
@@ -504,15 +549,18 @@ static int get_manifest_file(const char *pkgid)
  * @endcode
  */
 char *pkgmgr_parser_get_manifest_file(const char *pkgid);
+char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid);
 
 /**
  * @fn int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
+ * @fn int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
  * @brief      This API parses the manifest file of the package after installation and stores the data in DB.
  *
  * @par                This API is for package-manager installer backends.
  * @par Sync (or) Async : Synchronous API
  *
  * @param[in]  manifest        pointer to package manifest file
+ * @param[in]  uid     the addressee user id of the instruction
  * @param[in]  tagv            array of xml tags or NULL
  * @return     0 if success, error code(<0) if fail
  * @retval     PMINFO_R_OK     success
@@ -532,8 +580,10 @@ static int parse_manifest_file_for_installation(const char *manifest)
  * @endcode
  */
 int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[]);
+int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[]);
 
 /**
+ * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest,  uid_t uid, char *const tagv[])
  * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
  * @brief      This API parses the manifest file of the package after upgrade and stores the data in DB.
  *
@@ -541,6 +591,7 @@ int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *co
  * @par Sync (or) Async : Synchronous API
  *
  * @param[in]  manifest        pointer to package manifest file
+ * @param[in]  uid     the addressee user id of the instruction
  * @param[in]  tagv            array of xml tags or NULL
  * @return     0 if success, error code(<0) if fail
  * @retval     PMINFO_R_OK     success
@@ -560,15 +611,17 @@ static int parse_manifest_file_for_upgrade(const char *manifest)
  * @endcode
  */
 int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[]);
-
+int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[]);
 /**
  * @fn int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
+ * @fn int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
  * @brief      This API parses the manifest file of the package after uninstallation and deletes the data from DB.
  *
  * @par                This API is for package-manager installer backends.
  * @par Sync (or) Async : Synchronous API
  *
  * @param[in]  manifest        pointer to package manifest file
+ * @param[in]  uid     the addressee user id of the instruction
  * @param[in]  tagv            array of xml tags or NULL
  * @return     0 if success, error code(<0) if fail
  * @retval     PMINFO_R_OK     success
@@ -588,6 +641,34 @@ static int parse_manifest_file_for_uninstallation(const char *manifest)
  * @endcode
  */
 int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[]);
+int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[]);
+/**
+ * @fn int pkgmgr_parser_parse_manifest_for_preload()
+ * @fn int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
+ * @brief      This API update  preload information to DB.
+ *
+ * @par                This API is for package-manager installer backends.
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ERROR  internal error
+ * @pre                None
+ * @post               None
+ * @code
+static int parser_parse_manifest_for_preload()
+{
+       int ret = 0;
+       ret = pkgmgr_parser_parse_manifest_for_preload();
+       if (ret)
+               return -1;
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgr_parser_parse_manifest_for_preload();
+int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid);
 
 /**
  * @fn int pkgmgr_parser_check_manifest_validation(const char *manifest)
@@ -643,12 +724,14 @@ void pkgmgr_parser_free_manifest_xml(manifest_x *mfx);
 
 /**
  * @fn manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
+ * @fn manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
  * @brief      This API parses the manifest file and stores all the data in the manifest structure.
  *
  * @par                This API is for package-manager installer backends.
  * @par Sync (or) Async : Synchronous API
  *
  * @param[in]  manifest        pointer to package manifest file
+ * @param[in]  uid     the addressee user id of the instruction
  * @return     manifest pointer on success, NULL on failure
  * @pre                None
  * @post               pkgmgr_parser_free_manifest_xml()
@@ -666,38 +749,7 @@ static int parse_manifest_file(const char *manifest)
  * @endcode
  */
 manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest);
-
-/**
- * @fn manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid)
- * @brief      This API gets the manifest info from DB and stores all the data in the manifest structure.
- *
- * @par                This API is for package-manager installer backends.
- * @par Sync (or) Async : Synchronous API
- *
- * @param[in]  pkgid   package id for package
- * @return     manifest pointer on success, NULL on failure
- * @pre                None
- * @post               pkgmgr_parser_free_manifest_xml()
- * @code
-static int get_manifest_info(const char *pkgid)
-{
-       manifest_x *mfx = NULL
-       mfx = pkgmgr_parser_get_manifest_info(pkgid);
-       if (mfx == NULL)
-               return -1;
-       printf("Parsing Manifest Success\n");
-       pkgmgr_parser_free_manifest_xml(mfx);
-       return 0;
-}
- * @endcode
- */
-manifest_x *pkgmgr_parser_get_manifest_info(const char *pkigid);
-
-/* These APIs are intended to call parser directly */
-typedef int (*ps_iter_fn) (const char *tag, int type, void *userdata);
-
-int pkgmgr_parser_has_parser(const char *tag, int *type);
-int pkgmgr_parser_get_list(ps_iter_fn iter_fn, void *data);
+manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid);
 
 /**
  * @fn int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
@@ -786,14 +838,18 @@ static int parse_docptr_for_uninstallation(xmlDocPtr docPtr)
  */
 int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid);
 
+
+
 /**
  * @fn int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
+ * @fn int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
  * @brief      This API generates the application desktop file
  *
  * @par                This API is for package-manager installer backends.
  * @par Sync (or) Async : Synchronous API
  *
  * @param[in]  mfx     manifest pointer
+ * @param[in]  uid     the addressee user id of the instruction
  * @return     0 if success, error code(<0) if fail
  * @retval     PMINFO_R_OK     success
  * @retval     PMINFO_R_EINVAL invalid argument
@@ -815,6 +871,7 @@ static int create_desktop_file(char *manifest)
  * @endcode
  */
 int pkgmgr_parser_create_desktop_file(manifest_x *mfx);
+int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid);
 
 /** @} */
 #ifdef __cplusplus