Fix the exception about getting effectimage
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser.c
index 9b53af1..b672cf3 100644 (file)
@@ -42,7 +42,6 @@
 #include "pkgmgr_parser.h"
 #include "pkgmgr_parser_internal.h"
 #include "pkgmgr_parser_db.h"
-#include "pkgmgr_parser_signature.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -94,37 +93,26 @@ typedef struct {
 const char *package;
 
 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
-static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
-static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
-static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
-static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
-static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
-static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri);
-static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime);
-static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp);
-static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition);
+static int __ps_process_privilege(xmlTextReaderPtr reader, const char **privilege);
+static int __ps_process_privileges(xmlTextReaderPtr reader, GList **privileges);
+static int __ps_process_allowed(xmlTextReaderPtr reader, const char **allowed);
+static int __ps_process_condition(xmlTextReaderPtr reader, const char **condition);
 static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
-static int __ps_process_category(xmlTextReaderPtr reader, category_x *category);
+static int __ps_process_category(xmlTextReaderPtr reader, const char **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_request(xmlTextReaderPtr reader, request_x *request);
+static int __ps_process_request(xmlTextReaderPtr reader, const char **request);
 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
-static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
-static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
+static int __ps_process_launchconditions(xmlTextReaderPtr reader, GList **launchconditions);
 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
 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_license(xmlTextReaderPtr reader, license_x *license);
-static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
+static int __ps_process_appcontrol(xmlTextReaderPtr reader, GList **appcontrol);
 static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
-static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid);
-static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid);
-static int __ps_process_font(xmlTextReaderPtr reader, font_x *font);
-static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme);
-static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
-static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
+static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid);
 static char *__pkgid_to_manifest(const char *pkgid, uid_t uid);
 static int __next_child_element(xmlTextReaderPtr reader, int depth);
 static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
@@ -754,8 +742,10 @@ static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_
        int ret = -1;
        int tag_exist = 0;
        char buffer[1024] = { 0, };
-       uiapplication_x *up = mfx->uiapplication;
-       metadata_x *md = NULL;
+       GList *app_tmp;
+       application_x *app;
+       GList *md_tmp = NULL;
+       metadata_x *md;
        char *md_tag = NULL;
 
        GList *md_list = NULL;
@@ -767,9 +757,14 @@ static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_
                return -1;
        }
 
-       while(up != NULL) {
-               md = up->metadata;
-               while (md != NULL) {
+       for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
+               app = (application_x *)app_tmp->data;
+               if (app == NULL)
+                       continue;
+               for (md_tmp = app->metadata; md_tmp; md_tmp = md_tmp->next) {
+                       md = (metadata_x *)md_tmp->data;
+                       if (md == NULL)
+                               continue;
                        //get glist of metadata key and value combination
                        memset(buffer, 0x00, 1024);
                        snprintf(buffer, 1024, "%s/", md_key);
@@ -798,12 +793,11 @@ static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_
                                md_list = g_list_append(md_list, (gpointer)md_detail);
                                tag_exist = 1;
                        }
-                       md = md->next;
                }
 
                //send glist to parser when tags for metadata plugin parser exist.
                if (tag_exist) {
-                       ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid);
+                       ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, app->appid);
                        if (ret < 0){
                                _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
                        }
@@ -814,7 +808,6 @@ static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_
                __metadata_parser_clear_dir_list(md_list);
                md_list = NULL;
                tag_exist = 0;
-               up = up->next;
        }
 
        return 0;
@@ -832,8 +825,10 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A
        int ret = -1;
        int tag_exist = 0;
        char buffer[1024] = { 0, };
-       uiapplication_x *up = mfx->uiapplication;
-       category_x *category = NULL;
+       GList *app_tmp;
+       application_x *app;
+       GList *category_tmp;
+       const char *category;
        char *category_tag = NULL;
 
        GList *category_list = NULL;
@@ -845,20 +840,23 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A
                return -1;
        }
 
-       while(up != NULL) {
-               category = up->category;
-               while (category != NULL) {
+       for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
+               app = (application_x *)app_tmp->data;
+               if (app == NULL)
+                       continue;
+               for (category_tmp = app->category; category_tmp; category_tmp = category_tmp->next) {
+                       category = (const char *)category_tmp->data;
                        //get glist of category key and value combination
                        memset(buffer, 0x00, 1024);
                        snprintf(buffer, 1024, "%s/", category_key);
-                       if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) {
+                       if ((category) && (strncmp(category, category_key, strlen(category_key)) == 0)) {
                                category_detail = (__category_t*) calloc(1, sizeof(__category_t));
                                if (category_detail == NULL) {
                                        _LOGD("Memory allocation failed\n");
                                        goto END;
                                }
 
-                               category_detail->name = strdup(category->name);
+                               category_detail->name = strdup(category);
                                if (category_detail->name == NULL) {
                                        _LOGD("Memory allocation failed\n");
                                        free(category_detail);
@@ -868,12 +866,11 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A
                                category_list = g_list_append(category_list, (gpointer)category_detail);
                                tag_exist = 1;
                        }
-                       category = category->next;
                }
 
                //send glist to parser when tags for metadata plugin parser exist.
                if (tag_exist) {
-                       ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid);
+                       ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, app->appid);
                        if (ret < 0)
                                _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag);
                        else
@@ -882,7 +879,6 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A
                __category_parser_clear_dir_list(category_list);
                category_list = NULL;
                tag_exist = 0;
-               up = up->next;
        }
 
        return 0;
@@ -1104,39 +1100,15 @@ int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
        return ret;
 }
 
-static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
-{
-       __save_xml_value(reader, &allowed->text);
-       return 0;
-}
-
-static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
-{
-       __save_xml_attribute(reader, "name", &operation->name, NULL);
-       return 0;
-}
-
-static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
-{
-       __save_xml_attribute(reader, "name", &uri->name, NULL);
-       return 0;
-}
-
-static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
-{
-       __save_xml_attribute(reader, "name", &mime->name, NULL);
-       return 0;
-}
-
-static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
+static int __ps_process_allowed(xmlTextReaderPtr reader, const char **allowed)
 {
-       __save_xml_attribute(reader, "name", &subapp->name, NULL);
+       __save_xml_value(reader, allowed);
        return 0;
 }
 
-static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
+static int __ps_process_condition(xmlTextReaderPtr reader, const char **condition)
 {
-       __save_xml_attribute(reader, "name", &condition->name, NULL);
+       __save_xml_attribute(reader, "name", condition, NULL);
        return 0;
 }
 
@@ -1147,15 +1119,15 @@ static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *no
        return 0;
 }
 
-static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
+static int __ps_process_category(xmlTextReaderPtr reader, const char **category)
 {
-       __save_xml_attribute(reader, "name", &category->name, NULL);
+       __save_xml_attribute(reader, "name", category, NULL);
        return 0;
 }
 
-static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
+static int __ps_process_privilege(xmlTextReaderPtr reader, const char **privilege)
 {
-       __save_xml_value(reader, &privilege->text);
+       __save_xml_value(reader, privilege);
        return 0;
 }
 
@@ -1180,9 +1152,9 @@ static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *
        return 0;
 }
 
-static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
+static int __ps_process_request(xmlTextReaderPtr reader, const char **request)
 {
-       __save_xml_value(reader, &request->text);
+       __save_xml_value(reader, request);
        return 0;
 }
 
@@ -1191,8 +1163,7 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       allowed_x *tmp1 = NULL;
-       request_x *tmp2 = NULL;
+       const char *val;
 
        __save_xml_attribute(reader, "path", &define->path, NULL);
 
@@ -1205,171 +1176,176 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
                }
 
                if (!strcmp(ASCII(node), "allowed")) {
-                       allowed_x *allowed= malloc(sizeof(allowed_x));
-                       if (allowed == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(allowed, '\0', sizeof(allowed_x));
-                       LISTADD(define->allowed, allowed);
-                       ret = __ps_process_allowed(reader, allowed);
+                       val = NULL;
+                       ret = __ps_process_allowed(reader, &val);
+                       if (val)
+                               define->allowed = g_list_append(define->allowed, (gpointer)val);
                } else if (!strcmp(ASCII(node), "request")) {
-                       request_x *request = malloc(sizeof(request_x));
-                       if (request == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(request, '\0', sizeof(request_x));
-                       LISTADD(define->request, request);
-                       ret = __ps_process_request(reader, request);
-               } else
+                       val = NULL;
+                       ret = __ps_process_request(reader, &val);
+                       if (val)
+                               define->request = g_list_append(define->request, (gpointer)val);
+               } else {
                        return -1;
+               }
                if (ret < 0) {
                        _LOGD("Processing define failed\n");
                        return ret;
                }
        }
-       if (define->allowed) {
-               LISTHEAD(define->allowed, tmp1);
-               define->allowed = tmp1;
-       }
-       if (define->request) {
-               LISTHEAD(define->request, tmp2);
-               define->request = tmp2;
-       }
        return ret;
 }
 
-static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
+struct appcontrol_data {
+       GList *operations;
+       GList *uris;
+       GList *mimes;
+       GList *appcontrols;
+       char operation[BUFSIZE];
+       char uri[BUFSIZE];
+       char mime[BUFSIZE];
+};
+
+static void __ps_process_mime(gpointer data, gpointer user_data)
 {
-       const xmlChar *node;
-       int ret = -1;
-       int depth = -1;
+       char *mime = (char *)data;
+       struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
+       appcontrol_x *appcontrol;
 
-       depth = xmlTextReaderDepth(reader);
-       while ((ret = __next_child_element(reader, depth))) {
-               node = xmlTextReaderConstName(reader);
-               if (!node) {
-                       _LOGD("xmlTextReaderConstName value is NULL\n");
-                       return -1;
-               }
+       snprintf(ad->mime, sizeof(ad->mime), "%s", mime);
 
-               if (!strcmp(ASCII(node), "operation")) {
-                       __save_xml_attribute(reader, "name", &appcontrol->operation, NULL);
-                       _LOGD("operation processing\n");
-               } else if (!strcmp(ASCII(node), "uri")) {
-                       __save_xml_attribute(reader, "name", &appcontrol->uri, NULL);
-                       _LOGD("uri processing\n");
-               } else if (!strcmp(ASCII(node), "mime")) {
-                       __save_xml_attribute(reader, "name", &appcontrol->mime, NULL);
-                       _LOGD("mime processing\n");
-               } else
-                       return -1;
-               if (ret < 0) {
-                       _LOGD("Processing appcontrol failed\n");
-                       return ret;
-               }
+       appcontrol = calloc(1, sizeof(appcontrol_x));
+       if (strlen(ad->operation))
+               appcontrol->operation = strdup(ad->operation);
+       if (strlen(ad->uri))
+               appcontrol->uri = strdup(ad->uri);
+       appcontrol->mime = strdup(ad->mime);
+       ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
+}
+
+static void __ps_process_uri(gpointer data, gpointer user_data)
+{
+       char *uri = (char *)data;
+       struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
+       appcontrol_x *appcontrol;
+
+       snprintf(ad->uri, sizeof(ad->uri), "%s", uri);
+
+       if (ad->mimes != NULL) {
+               g_list_foreach(ad->mimes, __ps_process_mime, user_data);
+       } else {
+               appcontrol = calloc(1, sizeof(appcontrol_x));
+               if (strlen(ad->operation))
+                       appcontrol->operation = strdup(ad->operation);
+               appcontrol->uri = strdup(ad->uri);
+               ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
        }
+}
 
-       return ret;
+static void __ps_process_operation(gpointer data, gpointer user_data)
+{
+       char *operation = (char *)data;
+       struct appcontrol_data *ad = (struct appcontrol_data *)user_data;
+       appcontrol_x *appcontrol;
+
+       snprintf(ad->operation, sizeof(ad->operation), "%s", operation);
+
+       if (ad->uris != NULL) {
+               g_list_foreach(ad->uris, __ps_process_uri, user_data);
+       } else if (ad->mimes != NULL) {
+               g_list_foreach(ad->mimes, __ps_process_mime, user_data);
+       } else {
+               appcontrol = calloc(1, sizeof(appcontrol_x));
+               appcontrol->operation = strdup(ad->operation);
+               ad->appcontrols = g_list_append(ad->appcontrols, appcontrol);
+       }
+}
+
+static GList *__make_appcontrol_list(GList *operations, GList *uris, GList *mimes)
+{
+       struct appcontrol_data ad = {0, };
+
+       ad.operations = operations;
+       ad.uris = uris;
+       ad.mimes = mimes;
+
+       if (ad.operations == NULL)
+               return NULL;
+
+       g_list_foreach(ad.operations, __ps_process_operation, (gpointer)&ad);
+
+       return ad.appcontrols;
 }
 
-static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
+static int __ps_process_appcontrol(xmlTextReaderPtr reader, GList **appcontrol)
 {
        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;
+       const char *val;
+       GList *operations = NULL;
+       GList *uris = NULL;
+       GList *mimes = NULL;
+       GList *result;
 
        depth = xmlTextReaderDepth(reader);
-       while ((ret = __next_child_element(reader, depth))) {
+       while ((ret = __next_child_element(reader, depth)) > 0) {
                node = xmlTextReaderConstName(reader);
                if (!node) {
                        _LOGD("xmlTextReaderConstName value is NULL\n");
                        return -1;
                }
 
+               val = NULL;
                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(appsvc->operation, operation);
-                       ret = __ps_process_operation(reader, operation);
+                       __save_xml_attribute(reader, "name", &val, NULL);
+                       if (val)
+                               operations = g_list_append(operations, (gpointer)val);
                        _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(appsvc->uri, uri);
-                       ret = __ps_process_uri(reader, uri);
+                       __save_xml_attribute(reader, "name", &val, NULL);
+                       if (val)
+                               uris = g_list_append(uris, (gpointer)val);
                        _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(appsvc->mime, mime);
-                       ret = __ps_process_mime(reader, mime);
+                       __save_xml_attribute(reader, "name", &val, NULL);
+                       if (val)
+                               mimes = g_list_append(mimes, (gpointer)val);
                        _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(appsvc->subapp, subapp);
-                       ret = __ps_process_subapp(reader, subapp);
-                       _LOGD("subapp processing\n");
-               } else
-                       return -1;
-               if (ret < 0) {
-                       _LOGD("Processing appsvc failed\n");
-                       return ret;
+                       continue;
+               } else {
+                       ret = -1;
                }
        }
-       if (appsvc->operation) {
-               LISTHEAD(appsvc->operation, tmp1);
-               appsvc->operation = tmp1;
-       }
-       if (appsvc->uri) {
-               LISTHEAD(appsvc->uri, tmp2);
-               appsvc->uri = tmp2;
-       }
-       if (appsvc->mime) {
-               LISTHEAD(appsvc->mime, tmp3);
-               appsvc->mime = tmp3;
-       }
-       if (appsvc->subapp) {
-               LISTHEAD(appsvc->subapp, tmp4);
-               appsvc->subapp = tmp4;
+
+       if (ret < 0) {
+               _LOGD("Processing appcontrol failed\n");
+               g_list_free_full(operations, free);
+               g_list_free_full(uris, free);
+               g_list_free_full(mimes, free);
+               return ret;
        }
 
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               appsvc->text = ASCII(xmlTextReaderValue(reader));
+       result = __make_appcontrol_list(operations, uris, mimes);
+       if (result)
+               *appcontrol = g_list_concat(*appcontrol, result);
+       else
+               ret = -1;
+
+       g_list_free_full(operations, free);
+       g_list_free_full(uris, free);
+       g_list_free_full(mimes, free);
 
        return ret;
 }
 
-
-static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
+static int __ps_process_privileges(xmlTextReaderPtr reader, GList **privileges)
 {
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       privilege_x *tmp1 = NULL;
+       const char *val;
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -1380,14 +1356,10 @@ static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privil
                }
 
                if (strcmp(ASCII(node), "privilege") == 0) {
-                       privilege_x *privilege = malloc(sizeof(privilege_x));
-                       if (privilege == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(privilege, '\0', sizeof(privilege_x));
-                       LISTADD(privileges->privilege, privilege);
-                       ret = __ps_process_privilege(reader, privilege);
+                       val = NULL;
+                       ret = __ps_process_privilege(reader, &val);
+                       if (val)
+                               *privileges = g_list_append(*privileges, (gpointer)val);
                } else
                        return -1;
                if (ret < 0) {
@@ -1395,19 +1367,15 @@ static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privil
                        return ret;
                }
        }
-       if (privileges->privilege) {
-               LISTHEAD(privileges->privilege, tmp1);
-               privileges->privilege = tmp1;
-       }
        return ret;
 }
 
-static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
+static int __ps_process_launchconditions(xmlTextReaderPtr reader, GList **launchconditions)
 {
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       condition_x *tmp1 = NULL;
+       const char *val;
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -1418,14 +1386,10 @@ static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditio
                }
 
                if (strcmp(ASCII(node), "condition") == 0) {
-                       condition_x *condition = malloc(sizeof(condition_x));
-                       if (condition == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(condition, '\0', sizeof(condition_x));
-                       LISTADD(launchconditions->condition, condition);
-                       ret = __ps_process_condition(reader, condition);
+                       val = NULL;
+                       ret = __ps_process_condition(reader, &val);
+                       if (val)
+                               *launchconditions = g_list_append(*launchconditions, (gpointer)val);
                } else
                        return -1;
                if (ret < 0) {
@@ -1433,12 +1397,6 @@ static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditio
                        return ret;
                }
        }
-       if (launchconditions->condition) {
-               LISTHEAD(launchconditions->condition, tmp1);
-               launchconditions->condition = tmp1;
-       }
-
-       __save_xml_value(reader, &launchconditions->text);
 
        return ret;
 }
@@ -1448,8 +1406,7 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       define_x *tmp1 = NULL;
-       request_x *tmp2 = NULL;
+       const char *val;
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
                node = xmlTextReaderConstName(reader);
@@ -1459,23 +1416,18 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar
                }
 
                if (!strcmp(ASCII(node), "define")) {
-                       define_x *define= malloc(sizeof(define_x));
+                       define_x *define = calloc(1, sizeof(define_x));
                        if (define == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(define, '\0', sizeof(define_x));
-                       LISTADD(datashare->define, define);
+                       datashare->define = g_list_append(datashare->define, define);
                        ret = __ps_process_define(reader, define);
                } else if (!strcmp(ASCII(node), "request")) {
-                       request_x *request= malloc(sizeof(request_x));
-                       if (request == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(request, '\0', sizeof(request_x));
-                       LISTADD(datashare->request, request);
-                       ret = __ps_process_request(reader, request);
+                       val = NULL;
+                       ret = __ps_process_request(reader, &val);
+                       if (val)
+                               datashare->request = g_list_append(datashare->request, (gpointer)val);
                } else
                        return -1;
                if (ret < 0) {
@@ -1483,72 +1435,71 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar
                        return ret;
                }
        }
-       if (datashare->define) {
-               LISTHEAD(datashare->define, tmp1);
-               datashare->define = tmp1;
-       }
-       if (datashare->request) {
-               LISTHEAD(datashare->request, tmp2);
-               datashare->request = tmp2;
-       }
        return ret;
 }
 
-static char *__get_icon_with_path(const char * icon, uid_t uid)
+static char *__get_icon_with_path(const char *icon, uid_t uid)
 {
-       char *theme;
-       char *icon_with_path;
-       char *confirmed_icon;
+       char icon_with_path[BUFSIZE];
        const char *app_path;
-       int len;
 
        if (!icon || !package)
                return NULL;
 
-       if (index(icon, '/') == NULL) {
-/* "db/setting/theme" is not exist */
-#if 0
-               theme = vconf_get_str("db/setting/theme");
-               if (!theme) {
-                       theme = strdup("default");
-                       if(!theme) {
-                               return NULL;
-                       }
-               }
-#else
-               theme = strdup("default");
-#endif
+       /* just use absolute path */
+       if (index(icon, '/'))
+               return strdup(icon);
 
-               len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
-               icon_with_path = malloc(len);
-               if(icon_with_path == NULL) {
-                       _LOGD("(icon_with_path == NULL) return\n");
-                       free(theme);
-                       return NULL;
-               }
+       do {
+               snprintf(icon_with_path, sizeof(icon_with_path), "%s%s",
+                               getIconPath(uid), icon);
+               if (access(icon_with_path, F_OK) == 0)
+                       break;
 
-               memset(icon_with_path, 0, len);
-               if (uid != GLOBAL_USER && uid != OWNER_ROOT)
-                       snprintf(icon_with_path, len, "%s%s", getIconPath(uid), icon);
-               else {
-                       snprintf(icon_with_path, len, "%s%s/small/%s", getIconPath(GLOBAL_USER), theme, icon);
-                       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(icon_with_path, len, "%s/%s/res/icons/%s/small/%s", app_path, package, theme, icon);
-                               if (access(icon_with_path, F_OK))
-                                       _LOGE("Cannot find icon path");
-                       }
+               /* for backward compatibility (.../default/small/...)
+                * this should be removed
+                */
+               snprintf(icon_with_path, sizeof(icon_with_path),
+                               "%sdefault/small/%s",
+                               getIconPath(uid), icon);
+               if (access(icon_with_path, F_OK) == 0)
+                       break;
+
+               if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
+                       app_path = tzplatform_getenv(TZ_SYS_RW_APP);
+               } else {
+                       tzplatform_set_user(uid);
+                       app_path = tzplatform_getenv(TZ_USER_APP);
+                       tzplatform_reset_user();
                }
-               free(theme);
-               _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
-               return icon_with_path;
-       } else {
-               confirmed_icon = strdup(icon);
-               if (!confirmed_icon)
-                       return NULL;
-               return confirmed_icon;
-       }
+
+               /* If doesn't exist in case of Global app,
+                * try to get icon directly into app's directory
+                */
+               snprintf(icon_with_path, sizeof(icon_with_path),
+                               "%s/%s/%s", app_path, package, icon);
+               if (access(icon_with_path, F_OK) == 0)
+                       break;
+
+               /* some preload package has icons at below path */
+               snprintf(icon_with_path, sizeof(icon_with_path),
+                               "%s/%s/res/icons/%s", app_path, package, icon);
+               if (access(icon_with_path, F_OK) == 0)
+                       break;
+
+               /* since 2.3 tpk package */
+               snprintf(icon_with_path, sizeof(icon_with_path),
+                               "%s/%s/shared/res/%s", app_path, package, icon);
+               if (access(icon_with_path, F_OK) == 0)
+                       break;
+
+               _LOGE("cannot find icon path for [%s]", icon);
+               return NULL;
+       } while (0);
+
+       _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
+
+       return strdup(icon_with_path);
 }
 
 static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
@@ -1640,7 +1591,6 @@ static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
 {
        __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;
 }
@@ -1667,53 +1617,58 @@ static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *data
        return 0;
 }
 
-static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication, uid_t uid)
+static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid)
 {
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       appsvc_x *tmp3 = NULL;
-       appcontrol_x *tmp4 = NULL;
-       launchconditions_x *tmp5 = NULL;
-       notification_x *tmp6 = NULL;
-       datashare_x *tmp7 = NULL;
-       category_x *tmp8 = NULL;
-       metadata_x *tmp9 = NULL;
-       image_x *tmp10 = NULL;
-       permission_x *tmp11 = NULL;
-       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");
+       const char *val;
+
+       __save_xml_attribute(reader, "appid", &application->appid, NULL);
+       retvm_if(application->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
+       __save_xml_attribute(reader, "exec", &application->exec, NULL);
+       __save_xml_attribute(reader, "nodisplay", &application->nodisplay, "false");
+       __save_xml_attribute(reader, "multiple", &application->multiple, "false");
+       __save_xml_attribute(reader, "type", &application->type, NULL);
+       __save_xml_attribute(reader, "categories", &application->categories, NULL);
+       __save_xml_attribute(reader, "extraid", &application->extraid, NULL);
+       __save_xml_attribute(reader, "taskmanage", &application->taskmanage, "true");
+       __save_xml_attribute(reader, "enabled", &application->enabled, "true");
+       __save_xml_attribute(reader, "hw-acceleration", &application->hwacceleration, "default");
+       __save_xml_attribute(reader, "screen-reader", &application->screenreader, "use-system-setting");
+       __save_xml_attribute(reader, "mainapp", &application->mainapp, "false");
+       __save_xml_attribute(reader, "recentimage", &application->recentimage, "false");
+       __save_xml_attribute(reader, "launchcondition", &application->launchcondition, "false");
+       __save_xml_attribute(reader, "indicatordisplay", &application->indicatordisplay, "true");
+       __save_xml_attribute(reader, "portrait-effectimage", &application->portraitimg, NULL);
+       __save_xml_attribute(reader, "landscape-effectimage", &application->landscapeimg, NULL);
+       __save_xml_attribute(reader, "guestmode-visibility", &application->guestmode_visibility, "true");
+       __save_xml_attribute(reader, "permission-type", &application->permission_type, "normal");
+       __save_xml_attribute(reader, "component-type", &application->component_type, type == PMINFO_UI_APP ? "uiapp" : type == PMINFO_SVC_APP ? "svcapp" : "widgetapp");
        /*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");
-       __save_xml_attribute(reader, "ui-gadget", &uiapplication->ui_gadget, "false");
-
-       uiapplication->package= strdup(package);
+       retvm_if(((strcmp(application->component_type, "svcapp") != 0) && (strcmp(application->component_type, "uiapp") != 0) && (strcmp(application->component_type, "widgetapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]", application->component_type);
+       __save_xml_attribute(reader, "submode", &application->submode, "false");
+       __save_xml_attribute(reader, "submode-mainid", &application->submode_mainid, NULL);
+       __save_xml_attribute(reader, "process-pool", &application->process_pool, "false");
+       __save_xml_attribute(reader, "launch_mode", &application->launch_mode, "caller");
+       __save_xml_attribute(reader, "ui-gadget", &application->ui_gadget, "false");
+       __save_xml_attribute(reader, "auto-restart", &application->autorestart, "false");
+       __save_xml_attribute(reader, "on-boot", &application->onboot, "false");
+
+       application->package= strdup(package);
+       /* overwrite some attributes if the app is widgetapp */
+       if (type == PMINFO_WIDGET_APP) {
+               free((void *)application->nodisplay);
+               application->nodisplay = strdup("true");
+               free((void *)application->multiple);
+               application->multiple = strdup("true");
+               free((void *)application->type);
+               application->type = strdup("capp");
+               free((void *)application->taskmanage);
+               application->taskmanage = strdup("false");
+               free((void *)application->indicatordisplay);
+               application->indicatordisplay = strdup("false");
+       }
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -1723,200 +1678,97 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *
                        return -1;
                }
                if (!strcmp(ASCII(node), "label")) {
-                       label_x *label = malloc(sizeof(label_x));
+                       label_x *label = calloc(1, sizeof(label_x));
                        if (label == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(label, '\0', sizeof(label_x));
-                       LISTADD(uiapplication->label, label);
+                       application->label = g_list_append(application->label, label);
                        ret = __ps_process_label(reader, label);
                } else if (!strcmp(ASCII(node), "icon")) {
-                       icon_x *icon = malloc(sizeof(icon_x));
+                       icon_x *icon = calloc(1, sizeof(icon_x));
                        if (icon == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(icon, '\0', sizeof(icon_x));
-                       LISTADD(uiapplication->icon, icon);
+                       application->icon = g_list_append(application->icon, icon);
                        ret = __ps_process_icon(reader, icon, uid);
                } else if (!strcmp(ASCII(node), "image")) {
-                       image_x *image = malloc(sizeof(image_x));
+                       image_x *image = calloc(1, sizeof(image_x));
                        if (image == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(image, '\0', sizeof(image_x));
-                       LISTADD(uiapplication->image, image);
+                       application->image = g_list_append(application->image, image);
                        ret = __ps_process_image(reader, image);
                } else if (!strcmp(ASCII(node), "category")) {
-                       category_x *category = malloc(sizeof(category_x));
-                       if (category == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(category, '\0', sizeof(category_x));
-                       LISTADD(uiapplication->category, category);
-                       ret = __ps_process_category(reader, category);
+                       val = NULL;
+                       ret = __ps_process_category(reader, &val);
+                       if (val)
+                               application->category = g_list_append(application->category, (gpointer)val);
                } else if (!strcmp(ASCII(node), "metadata")) {
-                       metadata_x *metadata = malloc(sizeof(metadata_x));
+                       metadata_x *metadata = calloc(1, sizeof(metadata_x));
                        if (metadata == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(metadata, '\0', sizeof(metadata_x));
-                       LISTADD(uiapplication->metadata, metadata);
+                       application->metadata = g_list_append(application->metadata, metadata);
                        ret = __ps_process_metadata(reader, metadata);
                } else if (!strcmp(ASCII(node), "permission")) {
-                       permission_x *permission = malloc(sizeof(permission_x));
+                       permission_x *permission = calloc(1, sizeof(permission_x));
                        if (permission == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(permission, '\0', sizeof(permission_x));
-                       LISTADD(uiapplication->permission, permission);
+                       application->permission = g_list_append(application->permission, permission);
                        ret = __ps_process_permission(reader, permission);
                } else if (!strcmp(ASCII(node), "app-control")) {
-                       appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
-                       if (appcontrol == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(appcontrol, '\0', sizeof(appcontrol_x));
-                       LISTADD(uiapplication->appcontrol, appcontrol);
-                       ret = __ps_process_appcontrol(reader, appcontrol);
+                       ret = __ps_process_appcontrol(reader, &application->appcontrol);
                } else if (!strcmp(ASCII(node), "application-service")) {
-                       appsvc_x *appsvc = malloc(sizeof(appsvc_x));
-                       if (appsvc == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(appsvc, '\0', sizeof(appsvc_x));
-                       LISTADD(uiapplication->appsvc, appsvc);
-                       ret = __ps_process_appsvc(reader, appsvc);
+                       ret = __ps_process_appcontrol(reader, &application->appcontrol);
                } else if (!strcmp(ASCII(node), "data-share")) {
-                       datashare_x *datashare = malloc(sizeof(datashare_x));
+                       datashare_x *datashare = calloc(1, sizeof(datashare_x));
                        if (datashare == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(datashare, '\0', sizeof(datashare_x));
-                       LISTADD(uiapplication->datashare, datashare);
+                       application->datashare = g_list_append(application->datashare, datashare);
                        ret = __ps_process_datashare(reader, datashare);
                } else if (!strcmp(ASCII(node), "launch-conditions")) {
-                       launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
-                       if (launchconditions == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(launchconditions, '\0', sizeof(launchconditions_x));
-                       LISTADD(uiapplication->launchconditions, launchconditions);
-                       ret = __ps_process_launchconditions(reader, launchconditions);
+                       ret = __ps_process_launchconditions(reader, &application->launchconditions);
                } else if (!strcmp(ASCII(node), "notification")) {
-                       notification_x *notification = malloc(sizeof(notification_x));
+                       notification_x *notification = calloc(1, sizeof(notification_x));
                        if (notification == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(notification, '\0', sizeof(notification_x));
-                       LISTADD(uiapplication->notification, notification);
+                       application->notification = g_list_append(application->notification, notification);
                        ret = __ps_process_notification(reader, notification);
                } else if (!strcmp(ASCII(node), "datacontrol")) {
-                       datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
+                       datacontrol_x *datacontrol = calloc(1, sizeof(datacontrol_x));
                        if (datacontrol == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(datacontrol, '\0', sizeof(datacontrol_x));
-                       LISTADD(uiapplication->datacontrol, datacontrol);
+                       application->datacontrol = g_list_append(application->datacontrol, datacontrol);
                        ret = __ps_process_datacontrol(reader, datacontrol);
                } else
-                       return -1;
+                       continue;
                if (ret < 0) {
-                       _LOGD("Processing uiapplication failed\n");
+                       _LOGD("Processing application failed\n");
                        return ret;
                }
        }
 
-       if (uiapplication->label) {
-               LISTHEAD(uiapplication->label, tmp1);
-               uiapplication->label = tmp1;
-       }
-       if (uiapplication->icon) {
-               LISTHEAD(uiapplication->icon, tmp2);
-               uiapplication->icon = tmp2;
-       }
-       if (uiapplication->appsvc) {
-               LISTHEAD(uiapplication->appsvc, tmp3);
-               uiapplication->appsvc = tmp3;
-       }
-       if (uiapplication->appcontrol) {
-               LISTHEAD(uiapplication->appcontrol, tmp4);
-               uiapplication->appcontrol = tmp4;
-       }
-       if (uiapplication->launchconditions) {
-               LISTHEAD(uiapplication->launchconditions, tmp5);
-               uiapplication->launchconditions = tmp5;
-       }
-       if (uiapplication->notification) {
-               LISTHEAD(uiapplication->notification, tmp6);
-               uiapplication->notification = tmp6;
-       }
-       if (uiapplication->datashare) {
-               LISTHEAD(uiapplication->datashare, tmp7);
-               uiapplication->datashare = tmp7;
-       }
-       if (uiapplication->category) {
-               LISTHEAD(uiapplication->category, tmp8);
-               uiapplication->category = tmp8;
-       }
-       if (uiapplication->metadata) {
-               LISTHEAD(uiapplication->metadata, tmp9);
-               uiapplication->metadata = tmp9;
-       }
-       if (uiapplication->image) {
-               LISTHEAD(uiapplication->image, tmp10);
-               uiapplication->image = tmp10;
-       }
-       if (uiapplication->permission) {
-               LISTHEAD(uiapplication->permission, tmp11);
-               uiapplication->permission = tmp11;
-       }
-       if (uiapplication->datacontrol) {
-               LISTHEAD(uiapplication->datacontrol, tmp12);
-               uiapplication->datacontrol = tmp12;
-       }
-
        return ret;
 }
 
-static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication, uid_t uid)
+static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
 {
+       _LOGD("__start_process\n");
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       appsvc_x *tmp3 = NULL;
-       appcontrol_x *tmp4 = NULL;
-       datacontrol_x *tmp5 = NULL;
-       launchconditions_x *tmp6 = NULL;
-       notification_x *tmp7 = NULL;
-       datashare_x *tmp8 = NULL;
-       category_x *tmp9 = NULL;
-       metadata_x *tmp10 = NULL;
-       permission_x *tmp11 = NULL;
-
-       __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))) {
@@ -1927,430 +1779,108 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli
                }
 
                if (!strcmp(ASCII(node), "label")) {
-                       label_x *label = malloc(sizeof(label_x));
+                       label_x *label = calloc(1, sizeof(label_x));
                        if (label == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(label, '\0', sizeof(label_x));
-                       LISTADD(serviceapplication->label, label);
+                       mfx->label = g_list_append(mfx->label, label);
                        ret = __ps_process_label(reader, label);
-               } else if (!strcmp(ASCII(node), "icon")) {
-                       icon_x *icon = malloc(sizeof(icon_x));
-                       if (icon == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(icon, '\0', sizeof(icon_x));
-                       LISTADD(serviceapplication->icon, icon);
-                       ret = __ps_process_icon(reader, icon, uid);
-               } else if (!strcmp(ASCII(node), "category")) {
-                       category_x *category = malloc(sizeof(category_x));
-                       if (category == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(category, '\0', sizeof(category_x));
-                       LISTADD(serviceapplication->category, category);
-                       ret = __ps_process_category(reader, category);
-               } else if (!strcmp(ASCII(node), "metadata")) {
-                       metadata_x *metadata = malloc(sizeof(metadata_x));
-                       if (metadata == NULL) {
+               } else if (!strcmp(ASCII(node), "author")) {
+                       author_x *author = calloc(1, sizeof(author_x));
+                       if (author == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(metadata, '\0', sizeof(metadata_x));
-                       LISTADD(serviceapplication->metadata, metadata);
-                       ret = __ps_process_metadata(reader, metadata);
-               } else if (!strcmp(ASCII(node), "permission")) {
-                       permission_x *permission = malloc(sizeof(permission_x));
-                       if (permission == NULL) {
+                       mfx->author = g_list_append(mfx->author, author);
+                       ret = __ps_process_author(reader, author);
+               } else if (!strcmp(ASCII(node), "description")) {
+                       description_x *description = calloc(1, sizeof(description_x));
+                       if (description == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(permission, '\0', sizeof(permission_x));
-                       LISTADD(serviceapplication->permission, permission);
-                       ret = __ps_process_permission(reader, permission);
-               } else if (!strcmp(ASCII(node), "app-control")) {
-                       appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
-                       if (appcontrol == NULL) {
+                       mfx->description = g_list_append(mfx->description, description);
+                       ret = __ps_process_description(reader, description);
+               } else if (!strcmp(ASCII(node), "license")) {
+                       license_x *license = calloc(1, sizeof(license_x));
+                       if (license == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(appcontrol, '\0', sizeof(appcontrol_x));
-                       LISTADD(serviceapplication->appcontrol, appcontrol);
-                       ret = __ps_process_appcontrol(reader, appcontrol);
-               } else if (!strcmp(ASCII(node), "application-service")) {
-                       appsvc_x *appsvc = malloc(sizeof(appsvc_x));
-                       if (appsvc == NULL) {
+                       mfx->license = g_list_append(mfx->license, license);
+                       ret = __ps_process_license(reader, license);
+               } else if (!strcmp(ASCII(node), "privileges")) {
+                       ret = __ps_process_privileges(reader, &mfx->privileges);
+               } else if (!strcmp(ASCII(node), "ui-application")) {
+                       application_x *application = calloc(1, sizeof(application_x));
+                       if (application == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(appsvc, '\0', sizeof(appsvc_x));
-                       LISTADD(serviceapplication->appsvc, appsvc);
-                       ret = __ps_process_appsvc(reader, appsvc);
-               } else if (!strcmp(ASCII(node), "data-share")) {
-                       datashare_x *datashare = malloc(sizeof(datashare_x));
-                       if (datashare == NULL) {
+                       mfx->application = g_list_append(mfx->application, application);
+                       ret = __ps_process_application(reader, application, PMINFO_UI_APP, uid);
+               } else if (!strcmp(ASCII(node), "service-application")) {
+                       application_x *application = calloc(1, sizeof(application_x));
+                       if (application == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(datashare, '\0', sizeof(datashare_x));
-                       LISTADD(serviceapplication->datashare, datashare);
-                       ret = __ps_process_datashare(reader, datashare);
-               } else if (!strcmp(ASCII(node), "launch-conditions")) {
-                       launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
-                       if (launchconditions == NULL) {
+                       mfx->application = g_list_append(mfx->application, application);
+                       ret = __ps_process_application(reader, application, PMINFO_SVC_APP, uid);
+               } else if (!strcmp(ASCII(node), "widget-application")) {
+                       application_x *application = calloc(1, sizeof(application_x));
+                       if (application == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(launchconditions, '\0', sizeof(launchconditions_x));
-                       LISTADD(serviceapplication->launchconditions, launchconditions);
-                       ret = __ps_process_launchconditions(reader, launchconditions);
-               } else if (!strcmp(ASCII(node), "notification")) {
-                       notification_x *notification = malloc(sizeof(notification_x));
-                       if (notification == NULL) {
+                       mfx->application = g_list_append(mfx->application, application);
+                       ret = __ps_process_application(reader, application, PMINFO_WIDGET_APP, uid);
+               } else if (!strcmp(ASCII(node), "icon")) {
+                       icon_x *icon = calloc(1, sizeof(icon_x));
+                       if (icon == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(notification, '\0', sizeof(notification_x));
-                       LISTADD(serviceapplication->notification, notification);
-                       ret = __ps_process_notification(reader, notification);
-               } else if (!strcmp(ASCII(node), "datacontrol")) {
-                       datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
-                       if (datacontrol == NULL) {
+                       mfx->icon = g_list_append(mfx->icon, icon);
+                       ret = __ps_process_icon(reader, icon, uid);
+               } else if (!strcmp(ASCII(node), "compatibility")) {
+                       compatibility_x *compatibility = calloc(1, sizeof(compatibility_x));
+                       if (compatibility == NULL) {
                                _LOGD("Malloc Failed\n");
                                return -1;
                        }
-                       memset(datacontrol, '\0', sizeof(datacontrol_x));
-                       LISTADD(serviceapplication->datacontrol, datacontrol);
-                       ret = __ps_process_datacontrol(reader, datacontrol);
-               } else
-                       return -1;
+                       mfx->compatibility = g_list_append(mfx->compatibility, compatibility);
+                       ret = __ps_process_compatibility(reader, compatibility);
+               } else if (!strcmp(ASCII(node), "shortcut-list")) {
+                       continue;
+               } else if (!strcmp(ASCII(node), "livebox")) {
+                       continue;
+               } else if (!strcmp(ASCII(node), "account")) {
+                       continue;
+               } else if (!strcmp(ASCII(node), "notifications")) {
+                       continue;
+               } else if (!strcmp(ASCII(node), "ime")) {
+                       continue;
+               } else if (!strcmp(ASCII(node), "feature")) {
+                       continue;
+               } else {
+                       _LOGI("Unknown element: %s", ASCII(node));
+                       continue;
+               }
+
                if (ret < 0) {
-                       _LOGD("Processing serviceapplication failed\n");
+                       _LOGD("Processing manifest failed\n");
                        return ret;
                }
        }
-
-       if (serviceapplication->label) {
-               LISTHEAD(serviceapplication->label, tmp1);
-               serviceapplication->label = tmp1;
-       }
-       if (serviceapplication->icon) {
-               LISTHEAD(serviceapplication->icon, tmp2);
-               serviceapplication->icon = tmp2;
-       }
-       if (serviceapplication->appsvc) {
-               LISTHEAD(serviceapplication->appsvc, tmp3);
-               serviceapplication->appsvc = tmp3;
-       }
-       if (serviceapplication->appcontrol) {
-               LISTHEAD(serviceapplication->appcontrol, tmp4);
-               serviceapplication->appcontrol = tmp4;
-       }
-       if (serviceapplication->datacontrol) {
-               LISTHEAD(serviceapplication->datacontrol, tmp5);
-               serviceapplication->datacontrol = tmp5;
-       }
-       if (serviceapplication->launchconditions) {
-               LISTHEAD(serviceapplication->launchconditions, tmp6);
-               serviceapplication->launchconditions = tmp6;
-       }
-       if (serviceapplication->notification) {
-               LISTHEAD(serviceapplication->notification, tmp7);
-               serviceapplication->notification = tmp7;
-       }
-       if (serviceapplication->datashare) {
-               LISTHEAD(serviceapplication->datashare, tmp8);
-               serviceapplication->datashare = tmp8;
-       }
-       if (serviceapplication->category) {
-               LISTHEAD(serviceapplication->category, tmp9);
-               serviceapplication->category = tmp9;
-       }
-       if (serviceapplication->metadata) {
-               LISTHEAD(serviceapplication->metadata, tmp10);
-               serviceapplication->metadata = tmp10;
-       }
-       if (serviceapplication->permission) {
-               LISTHEAD(serviceapplication->permission, tmp11);
-               serviceapplication->permission = tmp11;
-       }
-
        return ret;
 }
 
-static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
-static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
+static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t uid)
 {
-       /*TODO: once policy is set*/
-       return 0;
-}
-
-static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
-static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
-static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
-static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
-{
-       _LOGD("__start_process\n");
-       const xmlChar *node;
-       int ret = -1;
-       int depth = -1;
-       label_x *tmp1 = NULL;
-       author_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       license_x *tmp4 = NULL;
-       uiapplication_x *tmp5 = NULL;
-       serviceapplication_x *tmp6 = NULL;
-       daemon_x *tmp7 = NULL;
-       theme_x *tmp8 = NULL;
-       font_x *tmp9 = NULL;
-       ime_x *tmp10 = NULL;
-       icon_x *tmp11 = NULL;
-       compatibility_x *tmp12 = NULL;
-       deviceprofile_x *tmp13 = NULL;
-       privileges_x *tmp14 = NULL;
-
-       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), "label")) {
-                       label_x *label = malloc(sizeof(label_x));
-                       if (label == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(label, '\0', sizeof(label_x));
-                       LISTADD(mfx->label, label);
-                       ret = __ps_process_label(reader, label);
-               } else if (!strcmp(ASCII(node), "author")) {
-                       author_x *author = malloc(sizeof(author_x));
-                       if (author == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(author, '\0', sizeof(author_x));
-                       LISTADD(mfx->author, author);
-                       ret = __ps_process_author(reader, author);
-               } else if (!strcmp(ASCII(node), "description")) {
-                       description_x *description = malloc(sizeof(description_x));
-                       if (description == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(description, '\0', sizeof(description_x));
-                       LISTADD(mfx->description, description);
-                       ret = __ps_process_description(reader, description);
-               } else if (!strcmp(ASCII(node), "license")) {
-                       license_x *license = malloc(sizeof(license_x));
-                       if (license == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(license, '\0', sizeof(license_x));
-                       LISTADD(mfx->license, license);
-                       ret = __ps_process_license(reader, license);
-               } else if (!strcmp(ASCII(node), "privileges")) {
-                       privileges_x *privileges = malloc(sizeof(privileges_x));
-                       if (privileges == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(privileges, '\0', sizeof(privileges_x));
-                       LISTADD(mfx->privileges, privileges);
-                       ret = __ps_process_privileges(reader, privileges);
-               } else if (!strcmp(ASCII(node), "ui-application")) {
-                       uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
-                       if (uiapplication == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(uiapplication, '\0', sizeof(uiapplication_x));
-                       LISTADD(mfx->uiapplication, uiapplication);
-                       ret = __ps_process_uiapplication(reader, uiapplication, uid);
-               } else if (!strcmp(ASCII(node), "service-application")) {
-                       serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
-                       if (serviceapplication == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(serviceapplication, '\0', sizeof(serviceapplication_x));
-                       LISTADD(mfx->serviceapplication, serviceapplication);
-                       ret = __ps_process_serviceapplication(reader, serviceapplication, uid);
-               } else if (!strcmp(ASCII(node), "daemon")) {
-                       daemon_x *daemon = malloc(sizeof(daemon_x));
-                       if (daemon == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(daemon, '\0', sizeof(daemon_x));
-                       LISTADD(mfx->daemon, daemon);
-                       ret = __ps_process_daemon(reader, daemon);
-               } else if (!strcmp(ASCII(node), "theme")) {
-                       theme_x *theme = malloc(sizeof(theme_x));
-                       if (theme == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(theme, '\0', sizeof(theme_x));
-                       LISTADD(mfx->theme, theme);
-                       ret = __ps_process_theme(reader, theme);
-               } else if (!strcmp(ASCII(node), "font")) {
-                       font_x *font = malloc(sizeof(font_x));
-                       if (font == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(font, '\0', sizeof(font_x));
-                       LISTADD(mfx->font, font);
-                       ret = __ps_process_font(reader, font);
-               } else if (!strcmp(ASCII(node), "ime")) {
-                       ime_x *ime = malloc(sizeof(ime_x));
-                       if (ime == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(ime, '\0', sizeof(ime_x));
-                       LISTADD(mfx->ime, ime);
-                       ret = __ps_process_ime(reader, ime);
-               } else if (!strcmp(ASCII(node), "icon")) {
-                       icon_x *icon = malloc(sizeof(icon_x));
-                       if (icon == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(icon, '\0', sizeof(icon_x));
-                       LISTADD(mfx->icon, icon);
-                       ret = __ps_process_icon(reader, icon, uid);
-               } else if (!strcmp(ASCII(node), "profile")) {
-                       deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
-                       if (deviceprofile == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(deviceprofile, '\0', sizeof(deviceprofile_x));
-                       LISTADD(mfx->deviceprofile, deviceprofile);
-                       ret = __ps_process_deviceprofile(reader, deviceprofile);
-               } else if (!strcmp(ASCII(node), "compatibility")) {
-                       compatibility_x *compatibility = malloc(sizeof(compatibility_x));
-                       if (compatibility == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(compatibility, '\0', sizeof(compatibility_x));
-                       LISTADD(mfx->compatibility, compatibility);
-                       ret = __ps_process_compatibility(reader, compatibility);
-               } else if (!strcmp(ASCII(node), "shortcut-list")) {
-                       continue;
-               } else if (!strcmp(ASCII(node), "livebox")) {
-                       continue;
-               } else if (!strcmp(ASCII(node), "account")) {
-                       continue;
-               } else if (!strcmp(ASCII(node), "notifications")) {
-                       continue;
-               } else if (!strcmp(ASCII(node), "ime")) {
-                       continue;
-               } else if (!strcmp(ASCII(node), "feature")) {
-                       continue;
-               } else {
-                       _LOGE("Unknown element: %s", ASCII(node));
-                       return -1;
-               }
-
-               if (ret < 0) {
-                       _LOGD("Processing manifest failed\n");
-                       return ret;
-               }
-       }
-       if (mfx->label) {
-               LISTHEAD(mfx->label, tmp1);
-               mfx->label = tmp1;
-       }
-       if (mfx->author) {
-               LISTHEAD(mfx->author, tmp2);
-               mfx->author = tmp2;
-       }
-       if (mfx->description) {
-               LISTHEAD(mfx->description, tmp3);
-               mfx->description= tmp3;
-       }
-       if (mfx->license) {
-               LISTHEAD(mfx->license, tmp4);
-               mfx->license= tmp4;
-       }
-       if (mfx->uiapplication) {
-               LISTHEAD(mfx->uiapplication, tmp5);
-               mfx->uiapplication = tmp5;
-       }
-       if (mfx->serviceapplication) {
-               LISTHEAD(mfx->serviceapplication, tmp6);
-               mfx->serviceapplication = tmp6;
-       }
-       if (mfx->daemon) {
-               LISTHEAD(mfx->daemon, tmp7);
-               mfx->daemon= tmp7;
-       }
-       if (mfx->theme) {
-               LISTHEAD(mfx->theme, tmp8);
-               mfx->theme= tmp8;
-       }
-       if (mfx->font) {
-               LISTHEAD(mfx->font, tmp9);
-               mfx->font= tmp9;
-       }
-       if (mfx->ime) {
-               LISTHEAD(mfx->ime, tmp10);
-               mfx->ime= tmp10;
-       }
-       if (mfx->icon) {
-               LISTHEAD(mfx->icon, tmp11);
-               mfx->icon= tmp11;
-       }
-       if (mfx->compatibility) {
-               LISTHEAD(mfx->compatibility, tmp12);
-               mfx->compatibility= tmp12;
-       }
-       if (mfx->deviceprofile) {
-               LISTHEAD(mfx->deviceprofile, tmp13);
-               mfx->deviceprofile= tmp13;
-       }
-       if (mfx->privileges) {
-               LISTHEAD(mfx->privileges, tmp14);
-               mfx->privileges = tmp14;
-       }
-       return ret;
-}
-
-static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t uid)
-{
-       const xmlChar *node;
-       int ret = -1;
+       const xmlChar *node;
+       int ret = -1;
 
        if ((ret = __next_child_element(reader, -1))) {
                node = xmlTextReaderConstName(reader);
@@ -2374,6 +1904,7 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t ui
                        __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_attribute(reader, "support-disable", &mfx->support_disable, "false");
 
                        __save_xml_installed_time(mfx);
                        __save_xml_root_path(mfx, uid);
@@ -2396,7 +1927,8 @@ static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
        void *lib_handle = NULL;
        int (*appsvc_operation) (const char *, uid_t);
        int ret = 0;
-       uiapplication_x *uiapplication = mfx->uiapplication;
+       GList *tmp;
+       application_x *application;
 
        if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
                _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
@@ -2409,8 +1941,11 @@ static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
                goto END;
        }
 
-       for(; uiapplication; uiapplication=uiapplication->next) {
-               ret = appsvc_operation(uiapplication->appid, uid);
+       for (tmp = mfx->application; tmp; tmp = tmp->next) {
+               application = (application_x *)tmp->data;
+               if (application == NULL)
+                       continue;
+               ret = appsvc_operation(application->appid, uid);
                if (ret <0)
                        _LOGE("can not operation  symbol \n");
        }
@@ -2422,72 +1957,6 @@ END:
        return ret;
 }
 
-#define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
-static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
-{
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
-       int state = 0;
-
-       if(strstr(manifest, getUserManifestPath(uid))) {
-               free((void *)mfx->readonly);
-               mfx->readonly = strdup("True");
-
-               free((void *)mfx->preload);
-               mfx->preload = strdup("True");
-
-               free((void *)mfx->removable);
-               mfx->removable = strdup("False");
-
-               free((void *)mfx->system);
-               mfx->system = strdup("True");
-
-               return 0;
-       }
-
-       fp = fopen(PRELOAD_PACKAGE_LIST, "r");
-       if (fp == NULL) {
-               _LOGE("no preload list\n");
-               return -1;
-       }
-
-       while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-               if (buffer[0] == '#') {
-                       if(strcasestr(buffer, "RW_NORM"))
-                               state = 2;
-                       else if(strcasestr(buffer, "RW_RM"))
-                               state = 3;
-                       else
-                               continue;
-               }
-
-               __str_trim(buffer);
-
-               if(!strcmp(mfx->package, buffer)) {
-                       free((void *)mfx->preload);
-                       mfx->preload = strdup("True");
-                       if(state == 2){
-                               free((void *)mfx->readonly);
-                               mfx->readonly = strdup("False");
-                               free((void *)mfx->removable);
-                               mfx->removable = strdup("False");
-                       } else if(state == 3){
-                               free((void *)mfx->readonly);
-                               mfx->readonly = strdup("False");
-                               free((void *)mfx->removable);
-                               mfx->removable = strdup("True");
-                       }
-               }
-
-               memset(buffer, 0x00, sizeof(buffer));
-       }
-
-       if (fp != NULL)
-               fclose(fp);
-
-       return 0;
-}
-
 static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
 {
        if (!strstr(manifest, getUserManifestPath(uid))) {
@@ -2500,7 +1969,6 @@ static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t
        return 0;
 }
 
-
 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
 {
        /* desktop file is no longer used */
@@ -2574,7 +2042,15 @@ API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid
        return mfx;
 }
 
-/* These APIs are intended to call parser directly */
+API int pkgmgr_parser_usr_update_tep(const char *pkgid, const char *tep_path, uid_t uid)
+{
+       return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, uid);
+}
+
+API int pkgmgr_parser_update_tep(const char *pkgid, const char *tep_path)
+{
+       return pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
+}
 
 API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
 {
@@ -2590,10 +2066,6 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char
 
        _LOGD("Parsing Finished\n");
 
-       __add_preload_info(mfx, manifest, GLOBAL_USER);
-
-       _LOGD("Added preload infomation\n");
-
        __ps_process_tag(mfx, tagv);
 
        ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
@@ -2651,6 +2123,53 @@ API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest,
        return PMINFO_R_OK;
 }
 
+API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest) {
+       retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       _LOGD("processing manifest_x for installation: %s\n", manifest);
+       int ret = -1;
+
+       xmlInitParser();
+
+       _LOGD("Added preload infomation\n");
+
+       ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
+       retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
+       _LOGD("DB Insert Success\n");
+
+       ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
+       if (ret == -1)
+               _LOGD("Creating metadata parser failed\n");
+
+       ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
+       if (ret == -1)
+               _LOGD("Creating category parser failed\n");
+       xmlCleanupParser();
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid) {
+       retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       _LOGD("processing manifest_x for installation: %s\n", manifest);
+       int ret = -1;
+
+       xmlInitParser();
+       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");
+
+       ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
+       if (ret == -1)
+               _LOGD("Creating metadata parser failed\n");
+       ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
+       if (ret == -1)
+               _LOGD("Creating category parser failed\n");
+       xmlCleanupParser();
+       return PMINFO_R_OK;
+}
+
 API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
 {
        retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
@@ -2667,8 +2186,6 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
        retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
 
        _LOGD("Parsing Finished\n");
-       __add_preload_info(mfx, manifest, GLOBAL_USER);
-       _LOGD("Added preload infomation\n");
        __check_preload_updated(mfx, manifest, GLOBAL_USER);
 
        ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
@@ -2789,6 +2306,85 @@ API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t
        return PMINFO_R_OK;
 }
 
+API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest) {
+       retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       _LOGD("pkgmgr_parser_process_manifest_x_for_upgrade  parsing manifest for upgradation: %s\n", manifest);
+       int ret = -1;
+       bool system = false;
+       char *csc_path = NULL;
+       pkgmgrinfo_pkginfo_h handle = NULL;
+
+       xmlInitParser();
+
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
+       if (ret != PMINFO_R_OK)
+               _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
+
+       ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
+       if (ret != PMINFO_R_OK)
+               _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
+       if (system) {
+               free((void *)mfx->system);
+               mfx->system = strdup("true");
+       }
+
+       ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
+       if (ret != PMINFO_R_OK)
+               _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
+
+       if (csc_path != NULL) {
+               if (mfx->csc_path)
+                       free((void *)mfx->csc_path);
+               mfx->csc_path = strdup(csc_path);
+       }
+
+       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");
+
+       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");
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       xmlCleanupParser();
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid) {
+       retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       _LOGD(" pkgmgr_parser_process_usr_manifest_x_for_upgrade parsing manifest for upgradation: %s\n", manifest);
+       int ret = -1;
+       pkgmgrinfo_pkginfo_h handle = NULL;
+
+       xmlInitParser();
+
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
+       if (ret != PMINFO_R_OK)
+               _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
+
+       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");
+
+       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");
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       xmlCleanupParser();
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
 {
        retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
@@ -2804,9 +2400,6 @@ API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, ch
 
        __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
 
-       __add_preload_info(mfx, manifest, GLOBAL_USER);
-       _LOGD("Added preload infomation\n");
-
        ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
        if (ret == -1)
                _LOGD("Removing metadata parser failed\n");
@@ -2871,6 +2464,64 @@ API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest
        return PMINFO_R_OK;
 }
 
+API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest) {
+       retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       _LOGD("processing manifest_x for uninstallation: %s\n", manifest);
+
+       int ret = -1;
+       xmlInitParser();
+
+       ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
+       if (ret == -1)
+               _LOGD("Removing metadata parser failed\n");
+
+       ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
+       if (ret == -1)
+               _LOGD("Creating category parser failed\n");
+
+       ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
+       if (ret == -1)
+               _LOGD("DB Delete failed\n");
+       else
+               _LOGD("DB Delete Success\n");
+       xmlCleanupParser();
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid) {
+       retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+       _LOGD("processing manifest_x for uninstallation: %s\n", manifest);
+
+       int ret = -1;
+       xmlInitParser();
+
+       ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
+       if (ret == -1)
+               _LOGD("Removing metadata parser failed\n");
+
+       ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
+       if (ret == -1)
+               _LOGD("Creating category parser failed\n");
+
+       ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
+       if (ret == -1)
+               _LOGD("DB Delete failed\n");
+       else
+               _LOGD("DB Delete Success\n");
+
+       ret = __ps_remove_appsvc_db(mfx, uid);
+       if (ret == -1)
+               _LOGD("Removing appsvc_db failed\n");
+       else
+               _LOGD("Removing appsvc_db Success\n");
+       xmlCleanupParser();
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgr_parser_parse_manifest_for_preload()
 {
        return pkgmgr_parser_update_preload_info_in_db();
@@ -2940,7 +2591,7 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest)
                _LOGE("xmlSchemaValidateFile() failed\n");
                return PMINFO_R_ERROR;
        } else if (ret == 0) {
-               _LOGE("Manifest is Valid\n");
+               _LOGD("Manifest is Valid\n");
                return PMINFO_R_OK;
        } else {
                _LOGE("Manifest Validation Failed with error code %d\n", ret);