Revise parser, insert db
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser.c
old mode 100755 (executable)
new mode 100644 (file)
index 1042f36..a3cd194
@@ -63,7 +63,7 @@
 #define PKG_TAG_LEN_MAX 128
 #define OWNER_ROOT 0
 #define BUFSIZE 4096
-#define GLOBAL_USER 0
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
 
 /* operation_type */
 typedef enum {
@@ -106,7 +106,6 @@ static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
-static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
@@ -115,7 +114,6 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar
 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid);
 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
-static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
@@ -169,9 +167,78 @@ static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action
 static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
-static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
 API int __is_admin();
 
+static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, const char **xml_attribute, char *default_value)
+{
+       xmlChar *attrib_val = xmlTextReaderGetAttribute(reader, XMLCHAR(attribute));
+       if (attrib_val) {
+               *xml_attribute = strdup((const char *)attrib_val);
+               xmlFree(attrib_val);
+       } else {
+               if (default_value != NULL) {
+                       *xml_attribute = strdup(default_value);
+               }
+       }
+}
+
+static void __save_xml_lang(xmlTextReaderPtr reader, const char **xml_attribute)
+{
+       const xmlChar *attrib_val = xmlTextReaderConstXmlLang(reader);
+       if (attrib_val != NULL)
+               *xml_attribute = strdup(ASCII(attrib_val));
+       else
+               *xml_attribute = strdup(DEFAULT_LOCALE);
+}
+
+static void __save_xml_value(xmlTextReaderPtr reader, const char **xml_attribute)
+{
+       xmlTextReaderRead(reader);
+       const xmlChar *attrib_val = xmlTextReaderConstValue(reader);
+
+       if (attrib_val)
+               *xml_attribute = strdup((const char *)attrib_val);
+}
+
+static void __save_xml_installed_time(manifest_x *mfx)
+{
+       char buf[PKG_STRING_LEN_MAX] = {'\0'};
+       char *val = NULL;
+       time_t current_time;
+       time(&current_time);
+       snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", (int)current_time);
+       val = strndup(buf, PKG_STRING_LEN_MAX - 1);
+       mfx->installed_time = val;
+}
+
+static void __save_xml_root_path(manifest_x *mfx, uid_t uid)
+{
+       char root[PKG_STRING_LEN_MAX] = { '\0' };
+       const char *path;
+
+       if (mfx->root_path)
+               return;
+
+       tzplatform_set_user(uid);
+       path = tzplatform_getenv((uid == OWNER_ROOT || uid == GLOBAL_USER) ? TZ_SYS_RO_APP : TZ_USER_APP);
+       snprintf(root, PKG_STRING_LEN_MAX - 1, "%s/%s", path, mfx->package);
+
+       mfx->root_path = strdup(root);
+
+       tzplatform_reset_user();
+}
+
+static void __save_xml_default_value(manifest_x * mfx)
+{
+       mfx->preload = strdup("False");
+       mfx->removable = strdup("True");
+       mfx->readonly = strdup("False");
+       mfx->update = strdup("False");
+       mfx->system = strdup("False");
+       mfx->installed_storage= strdup("installed_internal");
+       package = mfx->package;
+}
+
 void *__open_lib_handle(char *tag)
 {
        char *lib_path = NULL;
@@ -221,73 +288,6 @@ API int __is_admin()
 
 
 
-static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
-{
-       if (!pkgid || !appid || !newappid) {
-               _LOGD("Arg supplied is NULL\n");
-               return -1;
-       }
-       int pkglen = strlen(pkgid);
-       int applen = strlen(appid);
-       char *ptr = NULL;
-       char *newapp = NULL;
-       int len = 0;
-       if (strncmp(appid, ".", 1) == 0) {
-               len = pkglen + applen + 1;
-               newapp = calloc(1,len);
-               if (newapp == NULL) {
-                       _LOGD("Malloc failed\n");
-                       return -1;
-               }
-               strncpy(newapp, pkgid, pkglen);
-               strncat(newapp, appid, applen);
-               _LOGD("new appid is %s\n", newapp);
-               *newappid = newapp;
-               return 0;
-       }
-       if (applen < pkglen) {
-               _LOGD("app id is not proper\n");
-               *newappid = NULL;
-#ifdef _VALIDATE_APPID_
-               return -1;
-#else
-               return 0;
-#endif
-       }
-       if (!strcmp(appid, pkgid)) {
-               _LOGD("appid is proper\n");
-               *newappid = NULL;
-               return 0;
-       }
-       else if (strncmp(appid, pkgid, pkglen) == 0) {
-               ptr = strstr(appid, pkgid);
-               ptr = ptr + pkglen;
-               if (strncmp(ptr, ".", 1) == 0) {
-                       _LOGD("appid is proper\n");
-                       *newappid = NULL;
-                       return 0;
-               }
-               else {
-                       _LOGD("appid is not proper\n");
-                       *newappid = NULL;
-#ifdef _VALIDATE_APPID_
-                       return -1;
-#else
-                       return 0;
-#endif
-               }
-       } else {
-               _LOGD("appid is not proper\n");
-               *newappid = NULL;
-#ifdef _VALIDATE_APPID_
-               return -1;
-#else
-               return 0;
-#endif
-       }
-       return 0;
-}
-
 static char * __get_tag_by_key(char *md_key)
 {
        char *md_tag = NULL;
@@ -1703,15 +1703,13 @@ static void __ps_free_datacontrol(datacontrol_x *datacontrol)
                free((void *)datacontrol->providerid);
                datacontrol->providerid = NULL;
        }
-       /*Free Capability*/
-       if (datacontrol->capability) {
-               capability_x *capability = datacontrol->capability;
-               capability_x *tmp = NULL;
-               while(capability != NULL) {
-                       tmp = capability->next;
-                       __ps_free_capability(capability);
-                       capability = tmp;
-               }
+       if (datacontrol->access) {
+               free((void *)datacontrol->access);
+               datacontrol->access = NULL;
+       }
+       if (datacontrol->type) {
+               free((void *)datacontrol->type);
+               datacontrol->type = NULL;
        }
        free((void*)datacontrol);
        datacontrol = NULL;
@@ -1743,50 +1741,15 @@ static void __ps_free_appcontrol(appcontrol_x *appcontrol)
 {
        if (appcontrol == NULL)
                return;
-       if (appcontrol->text) {
-               free((void *)appcontrol->text);
-               appcontrol->text = NULL;
-       }
        /*Free Operation*/
-       if (appcontrol->operation) {
-               operation_x *operation = appcontrol->operation;
-               operation_x *tmp = NULL;
-               while(operation != NULL) {
-                       tmp = operation->next;
-                       __ps_free_operation(operation);
-                       operation = tmp;
-               }
-       }
+       if (appcontrol->operation)
+               free(appcontrol->operation);
        /*Free Uri*/
-       if (appcontrol->uri) {
-               uri_x *uri = appcontrol->uri;
-               uri_x *tmp = NULL;
-               while(uri != NULL) {
-                       tmp = uri->next;
-                       __ps_free_uri(uri);
-                       uri = tmp;
-               }
-       }
+       if (appcontrol->uri)
+               free(appcontrol->uri);
        /*Free Mime*/
-       if (appcontrol->mime) {
-               mime_x *mime = appcontrol->mime;
-               mime_x *tmp = NULL;
-               while(mime != NULL) {
-                       tmp = mime->next;
-                       __ps_free_mime(mime);
-                       mime = tmp;
-               }
-       }
-       /*Free subapp*/
-       if (appcontrol->subapp) {
-               subapp_x *subapp = appcontrol->subapp;
-               subapp_x *tmp = NULL;
-               while(subapp != NULL) {
-                       tmp = subapp->next;
-                       __ps_free_subapp(subapp);
-                       subapp = tmp;
-               }
-       }
+       if (appcontrol->mime)
+               free(appcontrol->mime);
        free((void*)appcontrol);
        appcontrol = NULL;
 }
@@ -2162,6 +2125,16 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
                        permission = tmp;
                }
        }
+       /*Free DataControl*/
+       if (uiapplication->datacontrol) {
+               datacontrol_x *datacontrol = uiapplication->datacontrol;
+               datacontrol_x *tmp = NULL;
+               while(datacontrol != NULL) {
+                       tmp = datacontrol->next;
+                       __ps_free_datacontrol(datacontrol);
+                       datacontrol = tmp;
+               }
+       }
        /* _PRODUCT_LAUNCHING_ENHANCED_ START */
        if (uiapplication->indicatordisplay) {
                free((void *)uiapplication->indicatordisplay);
@@ -2529,140 +2502,83 @@ int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
 
 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
 {
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               allowed->text = ASCII(xmlTextReaderValue(reader));
+       __save_xml_value(reader, &allowed->text);
        return 0;
 }
 
 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               operation->text = ASCII(xmlTextReaderValue(reader));
-*/
+       __save_xml_attribute(reader, "name", &operation->name, NULL);
        return 0;
 }
 
 static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               uri->text = ASCII(xmlTextReaderValue(reader));
-*/
+       __save_xml_attribute(reader, "name", &uri->name, NULL);
        return 0;
 }
 
 static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               mime->text = ASCII(xmlTextReaderValue(reader));
-*/
+       __save_xml_attribute(reader, "name", &mime->name, NULL);
        return 0;
 }
 
 static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               mime->text = ASCII(xmlTextReaderValue(reader));
-*/
+       __save_xml_attribute(reader, "name", &subapp->name, NULL);
        return 0;
 }
 
 static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               condition->text = ASCII(xmlTextReaderValue(reader));
+       __save_xml_attribute(reader, "name", &condition->name, NULL);
        return 0;
 }
 
 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               notification->text = ASCII(xmlTextReaderValue(reader));
+       __save_xml_attribute(reader, "name", &notification->name, NULL);
+       __save_xml_value(reader, &notification->text);
        return 0;
 }
 
 static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
+       __save_xml_attribute(reader, "name", &category->name, NULL);
        return 0;
 }
 
 static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
 {
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader)) {
-               privilege->text = ASCII(xmlTextReaderValue(reader));
-       }
+       __save_xml_value(reader, &privilege->text);
        return 0;
 }
 
 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
-               metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
-               metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
+       __save_xml_attribute(reader, "key", &metadata->key, NULL);
+       __save_xml_attribute(reader, "value", &metadata->value, NULL);
        return 0;
 }
 
 static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
-               permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               permission->value = ASCII(xmlTextReaderValue(reader));
+       __save_xml_attribute(reader, "type", &permission->type, NULL);
+       __save_xml_value(reader, &permission->value);
        return 0;
 }
 
 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               compatibility->text = ASCII(xmlTextReaderValue(reader));
-       return 0;
-}
-
-static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
-{
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
-               resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
-               resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
+       __save_xml_attribute(reader, "name", &compatibility->name, NULL);
+       __save_xml_value(reader, &compatibility->text);
        return 0;
 }
 
 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
 {
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               request->text = ASCII(xmlTextReaderValue(reader));
+       __save_xml_value(reader, &request->text);
        return 0;
 }
 
@@ -2674,8 +2590,7 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
        allowed_x *tmp1 = NULL;
        request_x *tmp2 = NULL;
 
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
-               define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
+       __save_xml_attribute(reader, "path", &define->path, NULL);
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -2726,10 +2641,6 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       operation_x *tmp1 = NULL;
-       uri_x *tmp2 = NULL;
-       mime_x *tmp3 = NULL;
-       subapp_x *tmp4 = NULL;
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -2740,45 +2651,14 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon
                }
 
                if (!strcmp(ASCII(node), "operation")) {
-                       operation_x *operation = malloc(sizeof(operation_x));
-                       if (operation == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(operation, '\0', sizeof(operation_x));
-                       LISTADD(appcontrol->operation, operation);
-                       ret = __ps_process_operation(reader, operation);
+                       __save_xml_attribute(reader, "name", &appcontrol->operation, NULL);
                        _LOGD("operation processing\n");
                } else if (!strcmp(ASCII(node), "uri")) {
-                       uri_x *uri= malloc(sizeof(uri_x));
-                       if (uri == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(uri, '\0', sizeof(uri_x));
-                       LISTADD(appcontrol->uri, uri);
-                       ret = __ps_process_uri(reader, uri);
+                       __save_xml_attribute(reader, "name", &appcontrol->uri, NULL);
                        _LOGD("uri processing\n");
                } else if (!strcmp(ASCII(node), "mime")) {
-                       mime_x *mime = malloc(sizeof(mime_x));
-                       if (mime == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(mime, '\0', sizeof(mime_x));
-                       LISTADD(appcontrol->mime, mime);
-                       ret = __ps_process_mime(reader, mime);
+                       __save_xml_attribute(reader, "name", &appcontrol->mime, NULL);
                        _LOGD("mime processing\n");
-               } else if (!strcmp(ASCII(node), "subapp")) {
-                       subapp_x *subapp = malloc(sizeof(subapp_x));
-                       if (subapp == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(subapp, '\0', sizeof(subapp_x));
-                       LISTADD(appcontrol->subapp, subapp);
-                       ret = __ps_process_subapp(reader, subapp);
-                       _LOGD("subapp processing\n");
                } else
                        return -1;
                if (ret < 0) {
@@ -2786,26 +2666,6 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon
                        return ret;
                }
        }
-       if (appcontrol->operation) {
-               LISTHEAD(appcontrol->operation, tmp1);
-               appcontrol->operation = tmp1;
-       }
-       if (appcontrol->uri) {
-               LISTHEAD(appcontrol->uri, tmp2);
-               appcontrol->uri = tmp2;
-       }
-       if (appcontrol->mime) {
-               LISTHEAD(appcontrol->mime, tmp3);
-               appcontrol->mime = tmp3;
-       }
-       if (appcontrol->subapp) {
-               LISTHEAD(appcontrol->subapp, tmp4);
-               appcontrol->subapp = tmp4;
-       }
-
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               appcontrol->text = ASCII(xmlTextReaderValue(reader));
 
        return ret;
 }
@@ -2974,9 +2834,7 @@ static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditio
                launchconditions->condition = tmp1;
        }
 
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               launchconditions->text = ASCII(xmlTextReaderValue(reader));
+       __save_xml_value(reader, &launchconditions->text);
 
        return ret;
 }
@@ -3040,7 +2898,6 @@ __get_icon_with_path(const char* icon, uid_t uid)
 
        if (index(icon, '/') == NULL) {
                char* theme = NULL;
-               char* iconPath = NULL;
                char* icon_with_path = NULL;
                char *app_path = NULL;
                int len;
@@ -3077,7 +2934,7 @@ __get_icon_with_path(const char* icon, uid_t uid)
                        if (access (icon_with_path, F_OK)) { //If doesn't exist in case of Global app, try to get icon directly into app's directory
                                app_path = tzplatform_getenv(TZ_SYS_RW_APP);
                                if (app_path)
-                                       snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", app_path  , package, theme, icon);
+                                       snprintf(icon_with_path, len, "%s/%q/res/icons/%q/small/%q", app_path, package, theme, icon);
                                if (access (icon_with_path, F_OK))
                                        _LOGE("Cannot find icon path");
                        }
@@ -3146,28 +3003,17 @@ static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
 
 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-       if (xmlTextReaderConstXmlLang(reader)) {
-               icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
-               if (icon->lang == NULL)
-                       icon->lang = strdup(DEFAULT_LOCALE);
-       } else {
-               icon->lang = strdup(DEFAULT_LOCALE);
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
-               icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
-               icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
-               icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
+       __save_xml_attribute(reader, "name", &icon->name, NULL);
+       __save_xml_attribute(reader, "section", &icon->section, NULL);
+       __save_xml_attribute(reader, "size", &icon->size, NULL);
+       __save_xml_attribute(reader, "resolution", &icon->resolution, NULL);
+       __save_xml_lang(reader, &icon->lang);
+
        xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader)) {
-               const char *text  = ASCII(xmlTextReaderValue(reader));
-               if(text) {
-                       icon->text = (const char *)__get_icon_with_path(text, uid);
-                       free((void *)text);
-               }
+       const char *text  = ASCII(xmlTextReaderValue(reader));
+       if (text) {
+               icon->text = (const char *)__get_icon_with_path(text, uid);
+               free((void *)text);
        }
 
        return 0;
@@ -3175,194 +3021,51 @@ static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
 
 static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-       if (xmlTextReaderConstXmlLang(reader)) {
-               image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
-               if (image->lang == NULL)
-                       image->lang = strdup(DEFAULT_LOCALE);
-       } else {
-               image->lang = strdup(DEFAULT_LOCALE);
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
-               image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               image->text = ASCII(xmlTextReaderValue(reader));
-
+       __save_xml_attribute(reader, "name", &image->name, NULL);
+       __save_xml_attribute(reader, "section", &image->section, NULL);
+       __save_xml_lang(reader, &image->lang);
+       __save_xml_value(reader, &image->text);
        return 0;
 }
 
 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
-               label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-       if (xmlTextReaderConstXmlLang(reader)) {
-               label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
-               if (label->lang == NULL)
-                       label->lang = strdup(DEFAULT_LOCALE);
-       } else 
-               label->lang = strdup(DEFAULT_LOCALE);
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               label->text = ASCII(xmlTextReaderValue(reader));
-
-
-/*     _LOGD("lable name %s\n", label->name);
-       _LOGD("lable lang %s\n", label->lang);
-       _LOGD("lable text %s\n", label->text);
-*/
+       __save_xml_attribute(reader, "name", &label->name, NULL);
+       __save_xml_lang(reader, &label->lang);
+       __save_xml_value(reader, &label->text);
        return 0;
 
 }
 
 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
 {
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
-               author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
-               author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
-       if (xmlTextReaderConstXmlLang(reader)) {
-               author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
-               if (author->lang == NULL)
-                       author->lang = strdup(DEFAULT_LOCALE);
-       } else {
-               author->lang = strdup(DEFAULT_LOCALE);
-       }
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader)) {
-               const char *text  = ASCII(xmlTextReaderValue(reader));
-               if (*text == '\n') {
-                       author->text = NULL;
-                       free((void *)text);
-                       return 0;
-               }
-               author->text = ASCII(xmlTextReaderValue(reader));
-       }
+       __save_xml_attribute(reader, "email", &author->email, NULL);
+       __save_xml_attribute(reader, "href", &author->href, NULL);
+       __save_xml_lang(reader, &author->lang);
+       __save_xml_value(reader, &author->text);
        return 0;
 }
 
 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
 {
-       if (xmlTextReaderConstXmlLang(reader)) {
-               description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
-               if (description->lang == NULL)
-                       description->lang = strdup(DEFAULT_LOCALE);
-       } else {
-               description->lang = strdup(DEFAULT_LOCALE);
-       }
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader)) {
-               const char *text  = ASCII(xmlTextReaderValue(reader));
-               if (*text == '\n') {
-                       description->text = NULL;
-                       free((void *)text);
-                       return 0;
-               }
-               description->text = ASCII(xmlTextReaderValue(reader));
-       }
+       __save_xml_lang(reader, &description->lang);
+       __save_xml_value(reader, &description->text);
        return 0;
 }
 
 static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
 {
-       if (xmlTextReaderConstXmlLang(reader)) {
-               license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
-               if (license->lang == NULL)
-                       license->lang = strdup(DEFAULT_LOCALE);
-       } else {
-               license->lang = strdup(DEFAULT_LOCALE);
-       }
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               license->text = ASCII(xmlTextReaderValue(reader));
+       __save_xml_lang(reader, &license->lang);
+       __save_xml_value(reader, &license->text);
        return 0;
 }
 
-static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
-{
-       const xmlChar *node;
-       int ret = -1;
-       int depth = -1;
-       resolution_x *tmp1 = NULL;
-
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
-               capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
-
-       depth = xmlTextReaderDepth(reader);
-       while ((ret = __next_child_element(reader, depth))) {
-               node = xmlTextReaderConstName(reader);
-               if (!node) {
-                       _LOGD("xmlTextReaderConstName value is NULL\n");
-                       return -1;
-               }
-
-               if (!strcmp(ASCII(node), "resolution")) {
-                       resolution_x *resolution = malloc(sizeof(resolution_x));
-                       if (resolution == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(resolution, '\0', sizeof(resolution_x));
-                       LISTADD(capability->resolution, resolution);
-                       ret = __ps_process_resolution(reader, resolution);
-               } else
-                       return -1;
-               if (ret < 0) {
-                       _LOGD("Processing capability failed\n");
-                       return ret;
-               }
-       }
-
-       if (capability->resolution) {
-               LISTHEAD(capability->resolution, tmp1);
-               capability->resolution = tmp1;
-       }
-
-       return ret;
-}
-
 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
 {
-       const xmlChar *node;
-       int ret = -1;
-       int depth = -1;
-       capability_x *tmp1 = NULL;
-
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
-               datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
-
-       depth = xmlTextReaderDepth(reader);
-       while ((ret = __next_child_element(reader, depth))) {
-               node = xmlTextReaderConstName(reader);
-               if (!node) {
-                       _LOGD("xmlTextReaderConstName value is NULL\n");
-                       return -1;
-               }
-
-               if (!strcmp(ASCII(node), "capability")) {
-                       capability_x *capability = malloc(sizeof(capability_x));
-                       if (capability == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(capability, '\0', sizeof(capability_x));
-                       LISTADD(datacontrol->capability, capability);
-                       ret = __ps_process_capability(reader, capability);
-               } else
-                       return -1;
-               if (ret < 0) {
-                       _LOGD("Processing datacontrol failed\n");
-                       return ret;
-               }
-       }
-
-       if (datacontrol->capability) {
-               LISTHEAD(datacontrol->capability, tmp1);
-               datacontrol->capability = tmp1;
-       }
-
-       return ret;
+       __save_xml_attribute(reader, "providerid", &datacontrol->providerid, NULL);
+       __save_xml_attribute(reader, "access", &datacontrol->access, NULL);
+       __save_xml_attribute(reader, "type", &datacontrol->type, NULL);
+       return 0;
 }
 
 static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid)
@@ -3370,7 +3073,6 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       char *newappid = NULL;
        label_x *tmp1 = NULL;
        icon_x *tmp2 = NULL;
        appsvc_x *tmp3 = NULL;
@@ -3382,142 +3084,36 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *
        metadata_x *tmp9 = NULL;
        image_x *tmp10 = NULL;
        permission_x *tmp11 = NULL;
-
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
-               uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
-               if (uiapplication->appid == NULL) {
-                       _LOGD("appid cant be NULL\n");
-                       return -1;
-               }
-       } else {
-               _LOGD("appid is mandatory\n");
-               return -1;
-       }
-       /*check appid*/
-       ret = __validate_appid(package, uiapplication->appid, &newappid);
-       if (ret == -1) {
-               _LOGD("appid is not proper\n");
-               return -1;
-       } else {
-               if (newappid) {
-                       if (uiapplication->appid)
-                               free((void *)uiapplication->appid);
-                       uiapplication->appid = newappid;
-               }
-               uiapplication->package= strdup(package);
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
-               uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
-               uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
-               if (uiapplication->nodisplay == NULL)
-                       uiapplication->nodisplay = strdup("false");
-       } else {
-               uiapplication->nodisplay = strdup("false");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
-               uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
-               if (uiapplication->multiple == NULL)
-                       uiapplication->multiple = strdup("false");
-       } else {
-               uiapplication->multiple = strdup("false");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
-               uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
-               uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
-               uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
-               uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
-               if (uiapplication->taskmanage == NULL)
-                       uiapplication->taskmanage = strdup("true");
-       } else {
-               uiapplication->taskmanage = strdup("true");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
-               uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
-               if (uiapplication->enabled == NULL)
-                       uiapplication->enabled = strdup("true");
-       } else {
-               uiapplication->enabled = strdup("true");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
-               uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
-               if (uiapplication->hwacceleration == NULL)
-                       uiapplication->hwacceleration = strdup("use-system-setting");
-       } else {
-               uiapplication->hwacceleration = strdup("use-system-setting");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
-               uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
-               if (uiapplication->screenreader == NULL)
-                       uiapplication->screenreader = strdup("use-system-setting");
-       } else {
-               uiapplication->screenreader = strdup("use-system-setting");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
-               uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
-               uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
-               if (uiapplication->mainapp == NULL)
-                       uiapplication->mainapp = strdup("false");
-       } else {
-               uiapplication->mainapp = strdup("false");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
-               uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
-               if (uiapplication->launchcondition == NULL)
-                       uiapplication->launchcondition = strdup("false");
-       } else {
-               uiapplication->launchcondition = strdup("false");
-       }
-
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
-               uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
-               if (uiapplication->indicatordisplay == NULL)
-                       uiapplication->indicatordisplay = strdup("true");
-       } else {
-               uiapplication->indicatordisplay = strdup("true");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
-               uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
-       else
-               uiapplication->portraitimg = NULL;
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
-               uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
-       else
-               uiapplication->landscapeimg = NULL;
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
-               uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
-               if (uiapplication->guestmode_visibility == NULL)
-                       uiapplication->guestmode_visibility = strdup("true");
-       } else {
-               uiapplication->guestmode_visibility = strdup("true");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
-               uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
-               if (uiapplication->permission_type == NULL)
-                       uiapplication->permission_type = strdup("normal");
-       } else {
-               uiapplication->permission_type = strdup("normal");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
-               uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
-               if (uiapplication->component_type == NULL)
-                       uiapplication->component_type = strdup("uiapp");
-       } else {
-               uiapplication->component_type = strdup("uiapp");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
-               uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
-               if (uiapplication->submode == NULL)
-                       uiapplication->submode = strdup("false");
-       } else {
-               uiapplication->submode = strdup("false");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
-               uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
+       datacontrol_x *tmp12 = NULL;
+
+       __save_xml_attribute(reader, "appid", &uiapplication->appid, NULL);
+       retvm_if(uiapplication->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
+       __save_xml_attribute(reader, "exec", &uiapplication->exec, NULL);
+       __save_xml_attribute(reader, "nodisplay", &uiapplication->nodisplay, "false");
+       __save_xml_attribute(reader, "multiple", &uiapplication->multiple, "false");
+       __save_xml_attribute(reader, "type", &uiapplication->type, NULL);
+       __save_xml_attribute(reader, "categories", &uiapplication->categories, NULL);
+       __save_xml_attribute(reader, "extraid", &uiapplication->extraid, NULL);
+       __save_xml_attribute(reader, "taskmanage", &uiapplication->taskmanage, "true");
+       __save_xml_attribute(reader, "enabled", &uiapplication->enabled, "true");
+       __save_xml_attribute(reader, "hw-acceleration", &uiapplication->hwacceleration, "default");
+       __save_xml_attribute(reader, "screen-reader", &uiapplication->screenreader, "use-system-setting");
+       __save_xml_attribute(reader, "mainapp", &uiapplication->mainapp, "false");
+       __save_xml_attribute(reader, "recentimage", &uiapplication->recentimage, "false");
+       __save_xml_attribute(reader, "launchcondition", &uiapplication->launchcondition, "false");
+       __save_xml_attribute(reader, "indicatordisplay", &uiapplication->indicatordisplay, "true");
+       __save_xml_attribute(reader, "portrait-effectimage", &uiapplication->portraitimg, NULL);
+       __save_xml_attribute(reader, "landscape-effectimage", &uiapplication->landscapeimg, NULL);
+       __save_xml_attribute(reader, "guestmode-visibility", &uiapplication->guestmode_visibility, "true");
+       __save_xml_attribute(reader, "permission-type", &uiapplication->permission_type, "normal");
+       __save_xml_attribute(reader, "component-type", &uiapplication->component_type, "uiapp");
+       /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
+       retvm_if(((strcmp(uiapplication->component_type, "svcapp") != 0) && (strcmp(uiapplication->component_type, "uiapp") != 0) && (strcmp(uiapplication->component_type, "widgetapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]\n", uiapplication->component_type);
+       __save_xml_attribute(reader, "submode", &uiapplication->submode, "false");
+       __save_xml_attribute(reader, "submode-mainid", &uiapplication->submode_mainid, NULL);
+       __save_xml_attribute(reader, "launch_mode", &uiapplication->launch_mode, "caller");
+
+       uiapplication->package= strdup(package);
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -3625,6 +3221,15 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *
                        memset(notification, '\0', sizeof(notification_x));
                        LISTADD(uiapplication->notification, notification);
                        ret = __ps_process_notification(reader, notification);
+               } else if (!strcmp(ASCII(node), "datacontrol")) {
+                       datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
+                       if (datacontrol == NULL) {
+                               _LOGD("Malloc Failed\n");
+                               return -1;
+                       }
+                       memset(datacontrol, '\0', sizeof(datacontrol_x));
+                       LISTADD(uiapplication->datacontrol, datacontrol);
+                       ret = __ps_process_datacontrol(reader, datacontrol);
                } else
                        return -1;
                if (ret < 0) {
@@ -3677,6 +3282,10 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *
                LISTHEAD(uiapplication->permission, tmp11);
                uiapplication->permission = tmp11;
        }
+       if (uiapplication->datacontrol) {
+               LISTHEAD(uiapplication->datacontrol, tmp12);
+               uiapplication->datacontrol = tmp12;
+       }
 
        return ret;
 }
@@ -3686,7 +3295,6 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       char *newappid = NULL;
        label_x *tmp1 = NULL;
        icon_x *tmp2 = NULL;
        appsvc_x *tmp3 = NULL;
@@ -3699,53 +3307,16 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli
        metadata_x *tmp10 = NULL;
        permission_x *tmp11 = NULL;
 
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
-               serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
-               if (serviceapplication->appid == NULL) {
-                       _LOGD("appid cant be NULL\n");
-                       return -1;
-               }
-       } else {
-               _LOGD("appid is mandatory\n");
-               return -1;
-       }
-       /*check appid*/
-       ret = __validate_appid(package, serviceapplication->appid, &newappid);
-       if (ret == -1) {
-               _LOGD("appid is not proper\n");
-               return -1;
-       } else {
-               if (newappid) {
-                       if (serviceapplication->appid)
-                               free((void *)serviceapplication->appid);
-                       serviceapplication->appid = newappid;
-               }
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
-               serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
-               serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
-               serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
-               if (serviceapplication->onboot == NULL)
-                       serviceapplication->onboot = strdup("false");
-       } else {
-               serviceapplication->onboot = strdup("false");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
-               serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
-               if (serviceapplication->autorestart == NULL)
-                       serviceapplication->autorestart = strdup("false");
-       } else {
-               serviceapplication->autorestart = strdup("false");
-       }
-       if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
-               serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
-               if (serviceapplication->permission_type == NULL)
-                       serviceapplication->permission_type = strdup("normal");
-       } else {
-               serviceapplication->permission_type = strdup("normal");
-       }
+       __save_xml_attribute(reader, "appid", &serviceapplication->appid, NULL);
+       retvm_if(serviceapplication->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
+       __save_xml_attribute(reader, "exec", &serviceapplication->exec, NULL);
+       __save_xml_attribute(reader, "type", &serviceapplication->type, NULL);
+       __save_xml_attribute(reader, "enabled", &serviceapplication->enabled, "true");
+       __save_xml_attribute(reader, "permission-type", &serviceapplication->permission_type, "normal");
+       __save_xml_attribute(reader, "auto-restart", &serviceapplication->autorestart, "false");
+       __save_xml_attribute(reader, "on-boot", &serviceapplication->onboot, "false");
+
+       serviceapplication->package= strdup(package);
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -3845,7 +3416,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli
                        memset(notification, '\0', sizeof(notification_x));
                        LISTADD(serviceapplication->notification, notification);
                        ret = __ps_process_notification(reader, notification);
-               } else if (!strcmp(ASCII(node), "data-control")) {
+               } else if (!strcmp(ASCII(node), "datacontrol")) {
                        datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
                        if (datacontrol == NULL) {
                                _LOGD("Malloc Failed\n");
@@ -3962,7 +3533,6 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
        privileges_x *tmp14 = NULL;
 
        depth = xmlTextReaderDepth(reader);
-       int  i =0;
        while ((ret = __next_child_element(reader, depth))) {
                node = xmlTextReaderConstName(reader);
                if (!node) {
@@ -4078,7 +3648,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
                        memset(icon, '\0', sizeof(icon_x));
                        LISTADD(mfx->icon, icon);
                        ret = __ps_process_icon(reader, icon, uid);
-               } else if (!strcmp(ASCII(node), "device-profile")) {
+               } else if (!strcmp(ASCII(node), "profile")) {
                        deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
                        if (deviceprofile == NULL) {
                                _LOGD("Malloc Failed\n");
@@ -4106,8 +3676,12 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
                        continue;
                } else if (!strcmp(ASCII(node), "ime")) {
                        continue;
-               } else
+               } else if (!strcmp(ASCII(node), "feature")) {
+                       continue;
+               } else {
+                       _LOGE("Unknown element: %s", ASCII(node));
                        return -1;
+               }
 
                if (ret < 0) {
                        _LOGD("Processing manifest failed\n");
@@ -4173,7 +3747,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
        return ret;
 }
 
-static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
+static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t uid)
 {
        const xmlChar *node;
        int ret = -1;
@@ -4186,67 +3760,25 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t u
                }
 
                if (!strcmp(ASCII(node), "manifest")) {
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))){
-                               mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
-                       }
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
-                               mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
-                               if (mfx->package == NULL) {
-                                       _LOGD("package cant be NULL\n");
-                                       return -1;
-                               }
-                       } else {
-                               _LOGD("package field is mandatory\n");
-                               return -1;
-                       }
-                       package = mfx->package;
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
-                               mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
-                       /*app2ext needs package size for external installation*/
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
-                               mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
-                               mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
-                               mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
-                               mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
-                               mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")))
-                               mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
-                               mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
-                               if (mfx->appsetting == NULL)
-                                       mfx->appsetting = strdup("false");
-                       } else {
-                               mfx->appsetting = strdup("false");
-                       }
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
-                               mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
-                               mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
-                               if (mfx->nodisplay_setting == NULL)
-                                       mfx->nodisplay_setting = strdup("false");
-                       } else {
-                               mfx->nodisplay_setting = strdup("false");
-                       }
-                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
-                               mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
+                       __save_xml_attribute(reader, "xmlns", &mfx->ns, NULL);
+                       __save_xml_attribute(reader, "package", &mfx->package, NULL);
+                       retvm_if(mfx->package == NULL, PM_PARSER_R_ERROR, "package cant be NULL, package field is mandatory\n");
+                       __save_xml_attribute(reader, "version", &mfx->version, NULL);
+                       __save_xml_attribute(reader, "size", &mfx->package_size, NULL);
+                       __save_xml_attribute(reader, "install-location", &mfx->installlocation, "internal-only");
+                       __save_xml_attribute(reader, "type", &mfx->type, "rpm");
+                       __save_xml_attribute(reader, "root_path", &mfx->root_path, NULL);
+                       __save_xml_attribute(reader, "csc_path", &mfx->csc_path, NULL);
+                       __save_xml_attribute(reader, "appsetting", &mfx->appsetting, "false");
+                       __save_xml_attribute(reader, "storeclient-id", &mfx->storeclient_id, NULL);
+                       __save_xml_attribute(reader, "nodisplay-setting", &mfx->nodisplay_setting, "false");
+                       __save_xml_attribute(reader, "url", &mfx->package_url, NULL);
+                       __save_xml_attribute(reader, "api-version", &mfx->api_version, NULL);
+
+                       __save_xml_installed_time(mfx);
+                       __save_xml_root_path(mfx, uid);
                        /*Assign default values. If required it will be overwritten in __add_preload_info()*/
-                       mfx->preload = strdup("False");
-                       mfx->removable = strdup("True");
-                       mfx->readonly = strdup("False");
-                       mfx->update = strdup("False");
-                       mfx->system = strdup("False");
-                       char buf[PKG_STRING_LEN_MAX] = {'\0'};
-                       char *val = NULL;
-                       time_t current_time;
-                       time(&current_time);
-                       snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
-                       val = strndup(buf, PKG_STRING_LEN_MAX - 1);
-                       mfx->installed_time = val;
-                       mfx->installed_storage= strdup("installed_internal");
+                       __save_xml_default_value(mfx);
 
                        ret = __start_process(reader, mfx, uid);
                } else {
@@ -4275,495 +3807,17 @@ static char* __convert_to_system_locale(const char *mlocale)
        return locale;
 }
 
-#define LIBAIL_PATH LIB_PATH "/libail.so.0"
-
-/* operation_type */
-typedef enum {
-       AIL_INSTALL = 0,
-       AIL_UPDATE,
-       AIL_REMOVE,
-       AIL_CLEAN,
-       AIL_FOTA,
-       AIL_MAX
-} AIL_TYPE;
-
-static int __ail_change_info(int op, const char *appid, uid_t uid)
-{
-       void *lib_handle = NULL;
-       char *aop = NULL;
-       int ret = 0;
-
-       if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
-               _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
-               goto END;
-       }
-//is_admin
-       if(uid != GLOBAL_USER)
-       {
-               int (*ail_desktop_operation) (const char *, uid_t uid);
-               switch (op) {
-                       case 0:
-                               aop  = "ail_usr_desktop_add";
-                               break;
-                       case 1:
-                               aop  = "ail_usr_desktop_update";
-                               break;
-                       case 2:
-                               aop  = "ail_usr_desktop_remove";
-                               break;
-                       case 3:
-                               aop  = "ail_usr_desktop_clean";
-                               break;
-                       case 4:
-                               aop  = "ail_usr_desktop_fota";
-                               break;
-                       default:
-                               goto END;
-                               break;
-               }
-
-               if ((ail_desktop_operation =
-                       dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
-                       _LOGE("can not find symbol \n");
-                       goto END;
-               }
-
-               ret = ail_desktop_operation(appid, uid);
-       }else{
-               int (*ail_desktop_operation) (const char *);
-               switch (op) {
-                       case 0:
-                               aop  = "ail_desktop_add";
-                               break;
-                       case 1:
-                               aop  = "ail_desktop_update";
-                               break;
-                       case 2:
-                               aop  = "ail_desktop_remove";
-                               break;
-                       case 3:
-                               aop  = "ail_desktop_clean";
-                               break;
-                       case 4:
-                               aop  = "ail_desktop_fota";
-                               break;
-                       default:
-                               goto END;
-                               break;
-               }
-
-               if ((ail_desktop_operation =
-                       dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
-                       _LOGE("can not find symbol \n");
-                       goto END;
-               }
-
-               ret = ail_desktop_operation(appid);
-
-       }
-END:
-       if (lib_handle)
-               dlclose(lib_handle);
-
-       return ret;
-}
-
-/* desktop shoud be generated automatically based on manifest */
-/* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
-#define BUFMAX 1024*128
-static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action, uid_t uid)
-{
-        FILE* file = NULL;
-        int fd = 0;
-        char filepath[PKG_STRING_LEN_MAX] = "";
-        char *buf = NULL;
-       char *buftemp = NULL;
-       char *locale = NULL;
-
-       buf = (char *)calloc(1, BUFMAX);
-       if (!buf) {
-               _LOGE("Malloc Failed\n");
-               return -1;
-       }
-
-       buftemp = (char *)calloc(1, BUFMAX);
-       if (!buftemp) {
-               _LOGE("Malloc Failed\n");
-               free(buf);
-               return -1;
-       }
-
-       if (action == ACTION_UPGRADE)
-               __ail_change_info(AIL_CLEAN, mfx->package, uid);
-
-       for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
-
-               if (manifest != NULL) {
-                       /* skip making a deskfile and update ail, if preload app is updated */
-                       if(strstr(manifest, getUserManifestPath(uid))) {
-                               __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
-                   _LOGE("preload app is update : skip and update ail : %s", manifest);
-                               continue;
-                       }
-               }
-
-               snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), mfx->uiapplication->appid);
-
-               /* skip if desktop exists
-               if (access(filepath, R_OK) == 0)
-                       continue;
-               */
-
-               file = fopen(filepath, "w");
-               if(file == NULL)
-               {
-                   _LOGD("Can't open %s", filepath);
-                   free(buf);
-                   free(buftemp);
-                   return -1;
-               }
-
-               snprintf(buf, BUFMAX, "[Desktop Entry]\n");
-               fwrite(buf, 1, strlen(buf), file);
-
-               for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
-                       if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
-                               snprintf(buf, BUFMAX, "Name=%s\n",      mfx->uiapplication->label->text);
-                       } else {
-                               locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
-                               snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
-                                       mfx->uiapplication->label->text);
-                               free(locale);
-                       }
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
-                       snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-/*
-               else if(mfx->label && mfx->label->text) {
-                       snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
-                       fwrite(buf, 1, strlen(buf), file);
-               } else {
-                       snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-*/
-
-
-               snprintf(buf, BUFMAX, "Type=Application\n");
-               fwrite(buf, 1, strlen(buf), file);
-
-               if(mfx->uiapplication->exec) {
-                       snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
-                       snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
-                       fwrite(buf, 1, strlen(buf), file);
-               } else if(mfx->icon && mfx->icon->text) {
-                       snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               // MIME types
-               if(mfx->uiapplication && mfx->uiapplication->appsvc) {
-                       appsvc_x *asvc = mfx->uiapplication->appsvc;
-                       mime_x *mi = NULL;
-                       const char *mime = NULL;
-                       const char *mime_delim = "; ";
-                       int mime_count = 0;
-
-                       strncpy(buf, "MimeType=", BUFMAX-1);
-                       while (asvc) {
-                               mi = asvc->mime;
-                               while (mi) {
-                                       mime_count++;
-                                       mime = mi->name;
-                                       _LOGD("MIME type: %s\n", mime);
-                                       strncat(buf, mime, BUFMAX-strlen(buf)-1);
-                                       if(mi->next) {
-                                               strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
-                                       }
-
-                                       mi = mi->next;
-                                       mime = NULL;
-                               }
-                               asvc = asvc->next;
-                       }
-                       _LOGD("MIME types: buf[%s]\n", buf);
-                       _LOGD("MIME count: %d\n", mime_count);
-                       if(mime_count)
-                               fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->version) {
-                       snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->nodisplay) {
-                       snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->categories) {
-                       snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->hwacceleration) {
-                       snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->extraid) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->type) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode);
-                       fwrite(buf, 1, strlen(buf), file);
-                       snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid);
-                       fwrite(buf, 1, strlen(buf), file);
-               }
-
-               snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
-               fwrite(buf, 1, strlen(buf), file);
-
-
-//             snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
-//             fwrite(buf, 1, strlen(buf), file);
-
-
-               if(mfx->uiapplication->appsvc) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
-                       _LOGD("buf[%s]\n", buf);
-
-
-                       uiapplication_x *up = mfx->uiapplication;
-                       appsvc_x *asvc = NULL;
-                       operation_x *op = NULL;
-                       mime_x *mi = NULL;
-                       uri_x *ui = NULL;
-                       subapp_x *sub = NULL;
-                       const char *operation = NULL;
-                       const char *mime = NULL;
-                       const char *uri = NULL;
-                       const char *subapp = NULL;
-                       int i = 0;
-
-
-                       asvc = up->appsvc;
-                       while(asvc != NULL) {
-                               op = asvc->operation;
-                               while(op != NULL) {
-                                       if (op)
-                                               operation = op->name;
-                                       mi = asvc->mime;
-
-                                       do
-                                       {
-                                               if (mi)
-                                                       mime = mi->name;
-                                               sub = asvc->subapp;
-                                               do
-                                               {
-                                                       if (sub)
-                                                               subapp = sub->name;
-                                                       ui = asvc->uri;
-                                                       do
-                                                       {
-                                                               if (ui)
-                                                                       uri = ui->name;
-
-                                                               if(i++ > 0) {
-                                                                       strncpy(buftemp, buf, BUFMAX);
-                                                                       snprintf(buf, BUFMAX, "%s;", buftemp);
-                                                               }
-
-
-                                                               strncpy(buftemp, buf, BUFMAX);
-                                                               snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
-                                                               _LOGD("buf[%s]\n", buf);
-
-                                                               if (ui)
-                                                                       ui = ui->next;
-                                                               uri = NULL;
-                                                       } while(ui != NULL);
-                                               if (sub)
-                                                               sub = sub->next;
-                                                       subapp = NULL;
-                                               }while(sub != NULL);
-                                               if (mi)
-                                                       mi = mi->next;
-                                               mime = NULL;
-                                       }while(mi != NULL);
-                                       if (op)
-                                               op = op->next;
-                                       operation = NULL;
-                               }
-                               asvc = asvc->next;
-                       }
-
-
-                       fwrite(buf, 1, strlen(buf), file);
-
-//                     strncpy(buftemp, buf, BUFMAX);
-//                     snprintf(buf, BUFMAX, "%s\n", buftemp);
-//                     fwrite(buf, 1, strlen(buf), file);
-               }
-
-               if(mfx->uiapplication->appcontrol) {
-                       snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
-                       _LOGD("buf[%s]\n", buf);
-
-                       uiapplication_x *up = mfx->uiapplication;
-                       appcontrol_x *acontrol = NULL;
-                       operation_x *op = NULL;
-                       mime_x *mi = NULL;
-                       uri_x *ui = NULL;
-                       subapp_x *sub = NULL;
-                       const char *operation = NULL;
-                       const char *mime = NULL;
-                       const char *uri = NULL;
-                       const char *subapp = NULL;
-                       int i = 0;
-
-                       acontrol = up->appcontrol;
-                       while(acontrol != NULL) {
-                               op = acontrol->operation;
-                               while(op != NULL) {
-                                       if (op)
-                                               operation = op->name;
-                                       mi = acontrol->mime;
-
-                                       do
-                                       {
-                                               if (mi)
-                                                       mime = mi->name;
-                                               sub = acontrol->subapp;
-                                               do
-                                               {
-                                                       if (sub)
-                                                               subapp = sub->name;
-                                                       ui = acontrol->uri;
-                                                       do
-                                                       {
-                                                               if (ui)
-                                                                       uri = ui->name;
-
-                                                               if(i++ > 0) {
-                                                                       strncpy(buftemp, buf, BUFMAX);
-                                                                       snprintf(buf, BUFMAX, "%s;", buftemp);
-                                                               }
-
-                                                               strncpy(buftemp, buf, BUFMAX);
-                                                               snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
-                                                               _LOGD("buf[%s]\n", buf);
-
-                                                               if (ui)
-                                                                       ui = ui->next;
-                                                               uri = NULL;
-                                                       } while(ui != NULL);
-                                               if (sub)
-                                                               sub = sub->next;
-                                                       subapp = NULL;
-                                               }while(sub != NULL);
-                                               if (mi)
-                                                       mi = mi->next;
-                                               mime = NULL;
-                                       }while(mi != NULL);
-                                       if (op)
-                                               op = op->next;
-                                       operation = NULL;
-                               }
-                               acontrol = acontrol->next;
-                       }
-
-
-                       fwrite(buf, 1, strlen(buf), file);
-
-//                     strncpy(buftemp, buf, BUFMAX);
-//                     snprintf(buf, BUFMAX, "%s\n", buftemp);
-//                     fwrite(buf, 1, strlen(buf), file);
-               }
-
-               fflush(file);
-               fd = fileno(file);
-               fsync(fd);
-               fclose(file);
-               if (action == ACTION_FOTA)
-                       __ail_change_info(AIL_FOTA, mfx->uiapplication->appid, uid);
-               else
-                       __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
-       }
-
-       free(buf);
-       free(buftemp);
-
-        return 0;
-}
-
-static int __ps_remove_nativeapp_desktop(manifest_x *mfx, uid_t uid)
-{
-       char filepath[PKG_STRING_LEN_MAX] = "";
-       int ret = 0;
-       uiapplication_x *uiapplication = mfx->uiapplication;
-
-       for(; uiapplication; uiapplication=uiapplication->next) {
-               snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
-
-               __ail_change_info(AIL_REMOVE, uiapplication->appid, uid);
-
-               ret = remove(filepath);
-               if (ret <0)
-                       return -1;
-       }
-
-        return 0;
-}
-
 #define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
 
-static int __ps_remove_appsvc_db(manifest_x *mfx)
+static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
 {
        void *lib_handle = NULL;
-       int (*appsvc_operation) (const char *);
+       int (*appsvc_operation) (const char *, uid_t);
        int ret = 0;
        uiapplication_x *uiapplication = mfx->uiapplication;
 
        if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
-               _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
+               _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
                goto END;
        }
 
@@ -4774,7 +3828,7 @@ static int __ps_remove_appsvc_db(manifest_x *mfx)
        }
 
        for(; uiapplication; uiapplication=uiapplication->next) {
-               ret = appsvc_operation(uiapplication->appid);
+               ret = appsvc_operation(uiapplication->appid, uid);
                if (ret <0)
                        _LOGE("can not operation  symbol \n");
        }
@@ -4854,21 +3908,10 @@ static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
 
 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
 {
-       char filepath[PKG_STRING_LEN_MAX] = "";
-       int ret = 0;
-       uiapplication_x *uiapplication = mfx->uiapplication;
-
-       if(strstr(manifest, getUserManifestPath(uid))) {
-               /* if preload app is updated, then remove previous desktop file on RW*/
-               for(; uiapplication; uiapplication=uiapplication->next) {
-                               snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
-                       ret = remove(filepath);
-                       if (ret <0)
-                               return -1;
-               }
-       } else {
+       if (!strstr(manifest, getUserManifestPath(uid))) {
                /* if downloaded app is updated, then update tag set true*/
-               free((void *)mfx->update);
+               if (mfx->update)
+                       free((void *)mfx->update);
                mfx->update = strdup("true");
        }
 
@@ -4878,32 +3921,14 @@ static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t
 
 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
 {
-        int ret = 0;
-       if (mfx == NULL) {
-               _LOGD("Manifest pointer is NULL\n");
-               return -1;
-       }
-        ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
-        if (ret == -1)
-                _LOGD("Creating desktop file failed\n");
-        else
-                _LOGD("Creating desktop file Success\n");
-        return ret;
+       /* desktop file is no longer used */
+        return 0;
 }
 
 API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
 {
-        int ret = 0;
-       if (mfx == NULL) {
-               _LOGD("Manifest pointer is NULL\n");
-               return -1;
-       }
-        ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
-        if (ret == -1)
-                _LOGD("Creating desktop file failed\n");
-        else
-                _LOGD("Creating desktop file Success\n");
-        return ret;
+       /* desktop file is no longer used */
+        return 0;
 }
 
 
@@ -4991,9 +4016,9 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
                free((void *)mfx->nodisplay_setting);
                mfx->nodisplay_setting = NULL;
        }
-       if (mfx->main_package) {
-               free((void *)mfx->main_package);
-               mfx->main_package = NULL;
+       if (mfx->api_version) {
+               free((void *)mfx->api_version);
+               mfx->api_version = NULL;
        }
 
        /*Free Icon*/
@@ -5214,7 +4239,6 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char
        _LOGD("Parsing Finished\n");
 
 //     __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
-       __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
        __add_preload_info(mfx, manifest, GLOBAL_USER);
 
        _LOGD("Added preload infomation\n");
@@ -5226,6 +4250,7 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char
 
        _LOGD("DB Insert Success\n");
 
+       __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
        ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
        if (ret == -1)
                _LOGD("Creating metadata parser failed\n");
@@ -5234,16 +4259,6 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char
        if (ret == -1)
                _LOGD("Creating category parser failed\n");
 
-       if (__check_action_fota(tagv))
-               ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, GLOBAL_USER);
-       else
-               ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
-
-       if (ret == -1)
-               _LOGD("Creating desktop file failed\n");
-       else
-               _LOGD("Creating desktop file Success\n");
-
        pkgmgr_parser_free_manifest_xml(mfx);
        _LOGD("Free Done\n");
        xmlCleanupParser();
@@ -5264,16 +4279,15 @@ API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest,
 
        _LOGD("Parsing Finished\n");
 //     __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
-       __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
-       __add_preload_info(mfx, manifest, uid);
 
-       _LOGD("Added preload infomation\n");
        __ps_process_tag(mfx, tagv);
 
        ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
        retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
 
        _LOGD("DB Insert Success\n");
+
+       __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
        ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
        if (ret == -1)
                _LOGD("Creating metadata parser failed\n");
@@ -5281,15 +4295,6 @@ API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest,
        if (ret == -1)
                _LOGD("Creating category parser failed\n");
 
-       if (__check_action_fota(tagv))
-               ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, uid);
-       else
-               ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
-
-       if (ret == -1)
-               _LOGD("Creating desktop file failed\n");
-       else
-               _LOGD("Creating desktop file Success\n");
        pkgmgr_parser_free_manifest_xml(mfx);
        _LOGD("Free Done\n");
        xmlCleanupParser();
@@ -5315,7 +4320,6 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
 
        _LOGD("Parsing Finished\n");
 //     __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
-       __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
        __add_preload_info(mfx, manifest, GLOBAL_USER);
        _LOGD("Added preload infomation\n");
        __check_preload_updated(mfx, manifest, GLOBAL_USER);
@@ -5352,7 +4356,10 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
 
        ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
        retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
+
        _LOGD("DB Update Success\n");
+
+       __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
        ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
        if (ret == -1){
                _LOGD("Upgrade metadata parser failed\n");
@@ -5360,11 +4367,6 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
        ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
        if (ret == -1)
                _LOGD("Creating category parser failed\n");
-       ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, GLOBAL_USER);
-       if (ret == -1)
-               _LOGD("Creating desktop file failed\n");
-       else
-               _LOGD("Creating desktop file Success\n");
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
        pkgmgr_parser_free_manifest_xml(mfx);
        _LOGD("Free Done\n");
@@ -5391,10 +4393,6 @@ API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t
 
        _LOGD("Parsing Finished\n");
        //__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
-       __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
-       __add_preload_info(mfx, manifest, uid);
-       _LOGD("Added preload infomation\n");
-       _LOGE("Added preload infomation\n");
        __check_preload_updated(mfx, manifest, uid);
 
        ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
@@ -5430,18 +4428,14 @@ API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t
        ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
        retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
        _LOGD("DB Update Success\n");
-       _LOGE("DB Update Success\n" );
+
+       __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
        ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
        if (ret == -1)
                _LOGD("Upgrade metadata parser failed\n");
        ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
        if (ret == -1)
                _LOGD("Creating category parser failed\n");
-       ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, uid);
-       if (ret == -1)
-               _LOGD("Creating desktop file failed\n");
-       else
-               _LOGD("Creating desktop file Success\n");
        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
        pkgmgr_parser_free_manifest_xml(mfx);
        _LOGD("Free Done\n");
@@ -5484,18 +4478,6 @@ API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, ch
        else
                _LOGD("DB Delete Success\n");
 
-       ret = __ps_remove_nativeapp_desktop(mfx, GLOBAL_USER);
-       if (ret == -1)
-               _LOGD("Removing desktop file failed\n");
-       else
-               _LOGD("Removing desktop file Success\n");
-
-       ret = __ps_remove_appsvc_db(mfx);
-       if (ret == -1)
-               _LOGD("Removing appsvc_db failed\n");
-       else
-               _LOGD("Removing appsvc_db Success\n");
-
        pkgmgr_parser_free_manifest_xml(mfx);
        _LOGD("Free Done\n");
        xmlCleanupParser();
@@ -5521,9 +4503,6 @@ API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest
 //     __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
        __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
 
-       __add_preload_info(mfx, manifest, uid);
-       _LOGD("Added preload infomation\n");
-
        ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
        if (ret == -1)
                _LOGD("Removing metadata parser failed\n");
@@ -5538,13 +4517,7 @@ API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest
        else
                _LOGD("DB Delete Success\n");
 
-       ret = __ps_remove_nativeapp_desktop(mfx, uid);
-       if (ret == -1)
-               _LOGD("Removing desktop file failed\n");
-       else
-               _LOGD("Removing desktop file Success\n");
-
-       ret = __ps_remove_appsvc_db(mfx);
+       ret = __ps_remove_appsvc_db(mfx, uid);
        if (ret == -1)
                _LOGD("Removing appsvc_db failed\n");
        else