Rewrite query apis 68/44768/9 accepted/tizen/mobile/20150804.062729 accepted/tizen/tv/20150804.062740 accepted/tizen/wearable/20150804.062747 submit/tizen/20150804.021939
authorSangyoon Jang <s89.jang@samsung.com>
Mon, 27 Jul 2015 12:35:42 +0000 (21:35 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Mon, 3 Aug 2015 08:33:19 +0000 (17:33 +0900)
increase package version
set so version using package version
unify uiapplication_x serviceapplication_x to application_x
move data structure free code to pkgmgr-info

rewrite query apis:
pkgmgrinfo_pkginfo_get_pkginfo
pkgmgrinfo_pkginfo_get_list
pkgmgrinfo_pkginfo_filter_foreach_pkginfo
pkgmgrinfo_appinfo_get_appinfo
pkgmgrinfo_appinfo_get_list
pkgmgrinfo_appinfo_get_install_list
pkgmgrinfo_appinfo_get_installed_list
pkgmgrinfo_appinfo_filter_foreach_appinfo
pkgmgrinfo_appinfo_metadata_filter_foreach

TODO:
revise list structure
revise free code

Change-Id: I22b0a9c4c06276d793844b86b89fb339037a2515
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
CMakeLists.txt
include/pkgmgr-info-basic.h [new file with mode: 0644]
include/pkgmgr-info-internal.h
include/pkgmgr-info.h
packaging/pkgmgr-info.spec
parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c
src/pkgmgr-info-basic.c [new file with mode: 0644]
src/pkgmgr-info-internal.c
src/pkgmgr-info.c

index 450a6a1..276c797 100644 (file)
@@ -3,8 +3,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 PROJECT(pkgmgr-info C)
 
-SET(VERSION 0.0.17)
-SET(VERSION_MAJOR 0)
 INCLUDE(TizenCommon)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
@@ -46,11 +44,11 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 add_subdirectory(parser)
 
 ## build pkgmgr-info library
-add_library(pkgmgr-info SHARED src/pkgmgr-info.c src/pkgmgr-info-internal.c src/pkgmgrinfo_resource.c)
+add_library(pkgmgr-info SHARED src/pkgmgr-info-basic.c src/pkgmgr-info.c src/pkgmgr-info-internal.c src/pkgmgrinfo_resource.c)
 
 
-SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES VERSION ${FULLVER})
 TARGET_LINK_LIBRARIES(pkgmgr-info pkgmgr_parser ${libpkgs_LDFLAGS})
 
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/pkgmgr-info.pc.in ${CMAKE_BINARY_DIR}/pkgmgr-info.pc @ONLY)
@@ -62,6 +60,7 @@ configure_file(tag_parser_list.txt.in tag_parser_list.txt @ONLY)
 INSTALL(TARGETS pkgmgr-info DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-info.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgr-info.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgr-info-basic.h DESTINATION include)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgrinfo_resource.h DESTINATION include)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/parser_path.conf DESTINATION ${SYSCONFDIR}/package-manager/)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mdparser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/metadata)
diff --git a/include/pkgmgr-info-basic.h b/include/pkgmgr-info-basic.h
new file mode 100644 (file)
index 0000000..12ff378
--- /dev/null
@@ -0,0 +1,472 @@
+#ifndef __PKGMGR_INFO_BASIC_H__
+#define __PKGMGR_INFO_BASIC_H__
+
+/**
+ * @brief List definitions.
+ * All lists are doubly-linked, the last element is stored to list pointer,
+ * which means that lists must be looped using the prev pointer, or by
+ * calling LISTHEAD first to go to start in order to use the next pointer.
+ */
+
+ /**
+ * @brief Convinience Macro to add node in list
+ */
+
+#define LISTADD(list, node)                    \
+    do {                                       \
+       (node)->prev = (list);                  \
+       if (list) (node)->next = (list)->next;  \
+       else (node)->next = NULL;               \
+       if (list) (list)->next = (node);        \
+       (list) = (node);                        \
+    } while (0);
+
+ /**
+ * @brief Convinience Macro to add one node to another node
+ */
+#define NODEADD(node1, node2)                                  \
+    do {                                                       \
+       (node2)->prev = (node1);                                \
+       (node2)->next = (node1)->next;                          \
+       if ((node1)->next) (node1)->next->prev = (node2);       \
+       (node1)->next = (node2);                                \
+    } while (0);
+
+ /**
+ * @brief Convinience Macro to concatenate two lists
+ */
+#define LISTCAT(list, first, last)             \
+    if ((first) && (last)) {                   \
+       (first)->prev = (list);                 \
+       (list) = (last);                        \
+    }
+
+ /**
+ * @brief Convinience Macro to delete node from list
+ */
+#define LISTDEL(list, node)                                    \
+    do {                                                       \
+       if ((node)->prev) (node)->prev->next = (node)->next;    \
+       if ((node)->next) (node)->next->prev = (node)->prev;    \
+       if (!((node)->prev) && !((node)->next)) (list) = NULL;  \
+    } while (0);
+
+ /**
+ * @brief Convinience Macro to get list head
+ */
+#define LISTHEAD(list, node)                                   \
+    for ((node) = (list); (node)->prev; (node) = (node)->prev)
+
+ /**
+ * @brief Convinience Macro to get list tail
+ */
+#define LISTTAIL(list, node)                                   \
+    for ((node) = (list); (node)->next; (node) = (node)->next)
+
+typedef struct metadata_x {
+       const char *key;
+       const char *value;
+       struct metadata_x *prev;
+       struct metadata_x *next;
+} metadata_x;
+
+typedef struct privilege_x {
+       const char *text;
+       struct privilege_x *prev;
+       struct privilege_x *next;
+} privilege_x;
+
+typedef struct privileges_x {
+       struct privilege_x *privilege;
+       struct privileges_x *prev;
+       struct privileges_x *next;
+} privileges_x;
+
+typedef struct permission_x {
+       const char *type;
+       const char *value;
+       struct permission_x *prev;
+       struct permission_x *next;
+} permission_x;
+
+typedef struct icon_x {
+       const char *name;
+       const char *text;
+       const char *lang;
+       const char *section;
+       const char *size;
+       const char *resolution;
+       struct icon_x *prev;
+       struct icon_x *next;
+} icon_x;
+
+typedef struct image_x {
+       const char *name;
+       const char *text;
+       const char *lang;
+       const char *section;
+       struct image_x *prev;
+       struct image_x *next;
+} image_x;
+
+typedef struct allowed_x {
+       const char *name;
+       const char *text;
+       struct allowed_x *prev;
+       struct allowed_x *next;
+} allowed_x;
+
+typedef struct request_x {
+       const char *text;
+       struct request_x *prev;
+       struct request_x *next;
+} request_x;
+
+typedef struct define_x {
+       const char *path;
+       struct allowed_x *allowed;
+       struct request_x *request;
+       struct define_x *prev;
+       struct define_x *next;
+} define_x;
+
+typedef struct datashare_x {
+       struct define_x *define;
+       struct request_x *request;
+       struct datashare_x *prev;
+       struct datashare_x *next;
+} datashare_x;
+
+typedef struct description_x {
+       const char *name;
+       const char *text;
+       const char *lang;
+       struct description_x *prev;
+       struct description_x *next;
+} description_x;
+
+typedef struct registry_x {
+       const char *name;
+       const char *text;
+       struct registry_x *prev;
+       struct registry_x *next;
+} registry_x;
+
+typedef struct database_x {
+       const char *name;
+       const char *text;
+       struct database_x *prev;
+       struct database_x *next;
+} database_x;
+
+typedef struct layout_x {
+       const char *name;
+       const char *text;
+       struct layout_x *prev;
+       struct layout_x *next;
+} layout_x;
+
+typedef struct label_x {
+       const char *name;
+       const char *text;
+       const char *lang;
+       struct label_x *prev;
+       struct label_x *next;
+} label_x;
+
+typedef struct author_x {
+       const char *email;
+       const char *href;
+       const char *text;
+       const char *lang;
+       struct author_x *prev;
+       struct author_x *next;
+} author_x;
+
+typedef struct license_x {
+       const char *text;
+       const char *lang;
+       struct license_x *prev;
+       struct license_x *next;
+} license_x;
+
+typedef struct operation_x {
+       const char *name;
+       const char *text;
+       struct operation_x *prev;
+       struct operation_x *next;
+} operation_x;
+
+typedef struct uri_x {
+       const char *name;
+       const char *text;
+       struct uri_x *prev;
+       struct uri_x *next;
+} uri_x;
+
+typedef struct mime_x {
+       const char *name;
+       const char *text;
+       struct mime_x *prev;
+       struct mime_x *next;
+} mime_x;
+
+typedef struct subapp_x {
+       const char *name;
+       const char *text;
+       struct subapp_x *prev;
+       struct subapp_x *next;
+} subapp_x;
+
+typedef struct condition_x {
+       const char *name;
+       const char *text;
+       struct condition_x *prev;
+       struct condition_x *next;
+} condition_x;
+
+typedef struct notification_x {
+       const char *name;
+       const char *text;
+       struct notification_x *prev;
+       struct notification_x *next;
+} notification_x;
+
+typedef struct appsvc_x {
+       const char *text;
+       struct operation_x *operation;
+       struct uri_x *uri;
+       struct mime_x *mime;
+       struct subapp_x *subapp;
+       struct appsvc_x *prev;
+       struct appsvc_x *next;
+} appsvc_x;
+
+typedef struct appcontrol_x {
+       const char *operation;
+       const char *uri;
+       const char *mime;
+       struct appcontrol_x *prev;
+       struct appcontrol_x *next;
+} appcontrol_x;
+
+typedef struct category_x{
+       const char *name;
+       struct category_x *prev;
+       struct category_x *next;
+} category_x;
+
+typedef struct launchconditions_x {
+       const char *text;
+       struct condition_x *condition;
+       struct launchconditions_x *prev;
+       struct launchconditions_x *next;
+} launchconditions_x;
+
+typedef struct compatibility_x {
+       const char *name;
+       const char *text;
+       struct compatibility_x *prev;
+       struct compatibility_x *next;
+}compatibility_x;
+
+typedef struct deviceprofile_x {
+       const char *name;
+       const char *text;
+       struct deviceprofile_x *prev;
+       struct deviceprofile_x *next;
+}deviceprofile_x;
+
+typedef struct datacontrol_x {
+       const char *providerid;
+       const char *access;
+       const char *type;
+       struct datacontrol_x *prev;
+       struct datacontrol_x *next;
+} datacontrol_x;
+
+typedef struct application_x {
+       const char *appid;
+       const char *component;
+       const char *exec;
+       const char *nodisplay;
+       const char *type;
+       const char *onboot;
+       const char *multiple;
+       const char *autorestart;
+       const char *taskmanage;
+       const char *enabled;
+       const char *hwacceleration;
+       const char *screenreader;
+       const char *mainapp;
+       const char *recentimage;
+       const char *launchcondition;
+       const char *indicatordisplay;
+       const char *portraitimg;
+       const char *landscapeimg;
+       const char *guestmode_visibility;
+       const char *permission_type;
+       const char *preload;
+       const char *submode;
+       const char *submode_mainid;
+       const char *launch_mode;
+       const char *component_type;
+       const char *package;
+       struct label_x *label;
+       struct icon_x *icon;
+       struct image_x *image;
+       struct appsvc_x *appsvc;
+       struct appcontrol_x *appcontrol;
+       struct category_x *category;
+       struct metadata_x *metadata;
+       struct permission_x *permission;
+       struct launchconditions_x *launchconditions;
+       struct notification_x *notification;
+       struct datashare_x *datashare;
+       struct datacontrol_x *datacontrol;
+       struct application_x *prev;
+       struct application_x *next;
+} application_x;
+
+typedef struct uiapplication_x {
+       const char *appid;
+       const char *exec;
+       const char *nodisplay;
+       const char *multiple;
+       const char *taskmanage;
+       const char *enabled;
+       const char *type;
+       const char *categories;
+       const char *extraid;
+       const char *hwacceleration;
+       const char *screenreader;
+       const char *mainapp;
+       const char *package;
+       const char *recentimage;
+       const char *launchcondition;
+       const char *indicatordisplay;
+       const char *portraitimg;
+       const char *landscapeimg;
+       const char *guestmode_visibility;
+       const char *app_component;
+       const char *permission_type;
+       const char *component_type;
+       const char *preload;
+       const char *submode;
+       const char *submode_mainid;
+       const char *launch_mode;
+       struct label_x *label;
+       struct icon_x *icon;
+       struct image_x *image;
+       struct appsvc_x *appsvc;
+       struct appcontrol_x *appcontrol;
+       struct category_x *category;
+       struct metadata_x *metadata;
+       struct permission_x *permission;
+       struct launchconditions_x *launchconditions;
+       struct notification_x *notification;
+       struct datashare_x *datashare;
+       struct datacontrol_x *datacontrol;
+       struct uiapplication_x *prev;
+       struct uiapplication_x *next;
+
+} uiapplication_x;
+
+typedef struct serviceapplication_x {
+       const char *appid;
+       const char *exec;
+       const char *onboot;
+       const char *autorestart;
+       const char *enabled;
+       const char *type;
+       const char *package;
+       const char *permission_type;
+       struct label_x *label;
+       struct icon_x *icon;
+       struct appsvc_x *appsvc;
+       struct appcontrol_x *appcontrol;
+       struct category_x *category;
+       struct metadata_x *metadata;
+       struct permission_x *permission;
+       struct datacontrol_x *datacontrol;
+       struct launchconditions_x *launchconditions;
+       struct notification_x *notification;
+       struct datashare_x *datashare;
+       struct serviceapplication_x *prev;
+       struct serviceapplication_x *next;
+} serviceapplication_x;
+
+typedef struct daemon_x {
+       const char *name;
+       const char *text;
+       struct daemon_x *prev;
+       struct daemon_x *next;
+} daemon_x;
+
+typedef struct theme_x {
+       const char *name;
+       const char *text;
+       struct theme_x *prev;
+       struct theme_x *next;
+} theme_x;
+
+typedef struct font_x {
+       const char *name;
+       const char *text;
+       struct font_x *prev;
+       struct font_x *next;
+} font_x;
+
+typedef struct ime_x {
+       const char *name;
+       const char *text;
+       struct ime_x *prev;
+       struct ime_x *next;
+} ime_x;
+
+typedef struct package_x {
+       const char *for_all_users;              /**< Flag that indicates if the package is available for everyone or for current user only*/
+       const char *package;            /**< package name*/
+       const char *version;            /**< package version*/
+       const char *installlocation;            /**< package install location*/
+       const char *ns;         /**<name space*/
+       const char *removable;          /**< package removable flag*/
+       const char *preload;            /**< package preload flag*/
+       const char *readonly;           /**< package readonly flag*/
+       const char *update;                     /**< package update flag*/
+       const char *appsetting;         /**< package app setting flag*/
+       const char *system;             /**< package system flag*/
+       const char *type;               /**< package type*/
+       const char *package_size;               /**< package size for external installation*/
+       const char *installed_time;             /**< installed time after finishing of installation*/
+       const char *installed_storage;          /**< package currently installed storage*/
+       const char *storeclient_id;             /**< id of store client for installed package*/
+       const char *mainapp_id;         /**< app id of main application*/
+       const char *package_url;                /**< app id of main application*/
+       const char *root_path;          /**< package root path*/
+       const char *csc_path;           /**< package csc path*/
+       const char *nodisplay_setting;          /**< package no display setting menu*/
+       const char *api_version;                /**< minimum version of API package using*/
+       struct icon_x *icon;            /**< package icon*/
+       struct label_x *label;          /**< package label*/
+       struct author_x *author;                /**< package author*/
+       struct description_x *description;              /**< package description*/
+       struct license_x *license;              /**< package license*/
+       struct privileges_x *privileges;        /**< package privileges*/
+       struct application_x *application;              /**< package's application*/
+       struct uiapplication_x *uiapplication;          /**< package's ui application*/
+       struct serviceapplication_x *serviceapplication;                /**< package's service application*/
+       struct daemon_x *daemon;                /**< package daemon*/
+       struct theme_x *theme;          /**< package theme*/
+       struct font_x *font;            /**< package font*/
+       struct ime_x *ime;              /**< package ime*/
+       struct compatibility_x *compatibility;          /**< package compatibility*/
+       struct deviceprofile_x *deviceprofile;          /**< package device profile*/
+} package_x;
+
+typedef struct package_x manifest_x;
+
+void pkgmgrinfo_basic_free_application(application_x *application);
+void pkgmgrinfo_basic_free_package(package_x *package);
+
+#endif
index 8982f25..f8fe7ae 100644 (file)
@@ -79,7 +79,8 @@ typedef enum _pkgmgrinfo_appinfo_filter_prop_str {
        E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
        E_PMINFO_APPINFO_PROP_APP_CATEGORY,
        E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
-       E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_APP_CATEGORY
+       E_PMINFO_APPINFO_PROP_APP_PACKAGE,
+       E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_APP_PACKAGE
 } pkgmgrinfo_appinfo_filter_prop_str;
 
 /*Boolean properties for filtering based on app info*/
index 93d3b0a..0d82e12 100644 (file)
@@ -423,8 +423,10 @@ typedef enum {
 #define        PMINFO_APPINFO_PROP_APP_CATEGORY        "PMINFO_APPINFO_PROP_APP_CATEGORY"
  /** String property for filtering based on app info*/
 #define        PMINFO_APPINFO_PROP_APP_HWACCELERATION  "PMINFO_APPINFO_PROP_APP_HWACCELERATION"
 /** String property for filtering based on app info*/
+ /** String property for filtering based on app info*/
 #define        PMINFO_APPINFO_PROP_APP_SCREENREADER    "PMINFO_APPINFO_PROP_APP_SCREENREADER"
+ /** String property for filtering based on app info*/
+#define        PMINFO_APPINFO_PROP_APP_PACKAGE         "PMINFO_APPINFO_PROP_APP_PACKAGE"
 
  /** Boolean property for filtering based on app info*/
 #define        PMINFO_APPINFO_PROP_APP_NODISPLAY               "PMINFO_APPINFO_PROP_APP_NODISPLAY"
index 4fb3c65..7441565 100644 (file)
@@ -1,7 +1,7 @@
 Name:       pkgmgr-info
 Summary:    Packager Manager infomation api for package
-Version:    0.0.134
-Release:    0
+Version:    0.1.0
+Release:    1
 Group:      Application Framework/Package Management
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
@@ -48,8 +48,9 @@ Dev package for libpkgmgr-parser
 cp %{SOURCE1001} .
 
 %build
-%cmake . 
-make %{?jobs:-j%jobs}
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%__make %{?jobs:-j%jobs}
 
 %install
 %make_install
@@ -77,6 +78,7 @@ chsmack -a '*' %{TZ_SYS_RW_PACKAGES}
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %{_includedir}/pkgmgr-info.h
+%{_includedir}/pkgmgr-info-basic.h
 %{_includedir}/pkgmgrinfo_resource.h
 %{_libdir}/pkgconfig/pkgmgr-info.pc
 %{_libdir}/libpkgmgr-info.so
index fc0bf7a..368ba2e 100644 (file)
 #include <glib.h>
 #include <grp.h>
 
+#include "pkgmgr-info.h"
+#include "pkgmgr-info-basic.h"
+#include "pkgmgr-info-debug.h"
+
 #include "pkgmgr_parser.h"
 #include "pkgmgr_parser_internal.h"
 #include "pkgmgr_parser_db.h"
-#include "pkgmgr-info.h"
 #include "pkgmgr_parser_signature.h"
-#include "pkgmgr-info-debug.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -123,38 +125,6 @@ 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 void __ps_free_label(label_x *label);
-static void __ps_free_privilege(privilege_x *privilege);
-static void __ps_free_privileges(privileges_x *privileges);
-static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
-static void __ps_free_allowed(allowed_x *allowed);
-static void __ps_free_operation(operation_x *operation);
-static void __ps_free_uri(uri_x *uri);
-static void __ps_free_mime(mime_x *mime);
-static void __ps_free_subapp(subapp_x *subapp);
-static void __ps_free_condition(condition_x *condition);
-static void __ps_free_notification(notification_x *notifiation);
-static void __ps_free_category(category_x *category);
-static void __ps_free_metadata(metadata_x *metadata);
-static void __ps_free_permission(permission_x *permission);
-static void __ps_free_compatibility(compatibility_x *compatibility);
-static void __ps_free_request(request_x *request);
-static void __ps_free_define(define_x *define);
-static void __ps_free_appsvc(appsvc_x *appsvc);
-static void __ps_free_launchconditions(launchconditions_x *launchconditions);
-static void __ps_free_datashare(datashare_x *datashare);
-static void __ps_free_icon(icon_x *icon);
-static void __ps_free_author(author_x *author);
-static void __ps_free_description(description_x *description);
-static void __ps_free_license(license_x *license);
-static void __ps_free_appcontrol(appcontrol_x *appcontrol);
-static void __ps_free_datacontrol(datacontrol_x *datacontrol);
-static void __ps_free_uiapplication(uiapplication_x *uiapplication);
-static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication);
-static void __ps_free_font(font_x *font);
-static void __ps_free_theme(theme_x *theme);
-static void __ps_free_daemon(daemon_x *daemon);
-static void __ps_free_ime(ime_x *ime);
 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);
@@ -1030,962 +1000,6 @@ static int __next_child_element(xmlTextReaderPtr reader, int depth)
        }
        return ret;
 }
-
-static void __ps_free_category(category_x *category)
-{
-       if (category == NULL)
-               return;
-       if (category->name) {
-               free((void *)category->name);
-               category->name = NULL;
-       }
-       free((void*)category);
-       category = NULL;
-}
-
-static void __ps_free_privilege(privilege_x *privilege)
-{
-       if (privilege == NULL)
-               return;
-       if (privilege->text) {
-               free((void *)privilege->text);
-               privilege->text = NULL;
-       }
-       free((void*)privilege);
-       privilege = NULL;
-}
-
-static void __ps_free_privileges(privileges_x *privileges)
-{
-       if (privileges == NULL)
-               return;
-       /*Free Privilege*/
-       if (privileges->privilege) {
-               privilege_x *privilege = privileges->privilege;
-               privilege_x *tmp = NULL;
-               while(privilege != NULL) {
-                       tmp = privilege->next;
-                       __ps_free_privilege(privilege);
-                       privilege = tmp;
-               }
-       }
-       free((void*)privileges);
-       privileges = NULL;
-}
-
-static void __ps_free_metadata(metadata_x *metadata)
-{
-       if (metadata == NULL)
-               return;
-       if (metadata->key) {
-               free((void *)metadata->key);
-               metadata->key = NULL;
-       }
-       if (metadata->value) {
-               free((void *)metadata->value);
-               metadata->value = NULL;
-       }
-       free((void*)metadata);
-       metadata = NULL;
-}
-
-static void __ps_free_permission(permission_x *permission)
-{
-       if (permission == NULL)
-               return;
-       if (permission->type) {
-               free((void *)permission->type);
-               permission->type = NULL;
-       }
-       if (permission->value) {
-               free((void *)permission->value);
-               permission->value = NULL;
-       }
-       free((void*)permission);
-       permission = NULL;
-}
-
-static void __ps_free_icon(icon_x *icon)
-{
-       if (icon == NULL)
-               return;
-       if (icon->text) {
-               free((void *)icon->text);
-               icon->text = NULL;
-       }
-       if (icon->lang) {
-               free((void *)icon->lang);
-               icon->lang = NULL;
-       }
-       if (icon->name) {
-               free((void *)icon->name);
-               icon->name= NULL;
-       }
-       if (icon->section) {
-               free((void *)icon->section);
-               icon->section = NULL;
-       }
-       if (icon->size) {
-               free((void *)icon->size);
-               icon->size = NULL;
-       }
-       if (icon->resolution) {
-               free((void *)icon->resolution);
-               icon->resolution = NULL;
-       }
-       free((void*)icon);
-       icon = NULL;
-}
-
-static void __ps_free_image(image_x *image)
-{
-       if (image == NULL)
-               return;
-       if (image->text) {
-               free((void *)image->text);
-               image->text = NULL;
-       }
-       if (image->lang) {
-               free((void *)image->lang);
-               image->lang = NULL;
-       }
-       if (image->name) {
-               free((void *)image->name);
-               image->name= NULL;
-       }
-       if (image->section) {
-               free((void *)image->section);
-               image->section = NULL;
-       }
-       free((void*)image);
-       image = NULL;
-}
-
-static void __ps_free_operation(operation_x *operation)
-{
-       if (operation == NULL)
-               return;
-       if (operation->text) {
-               free((void *)operation->text);
-               operation->text = NULL;
-       }
-       free((void*)operation);
-       operation = NULL;
-}
-
-static void __ps_free_uri(uri_x *uri)
-{
-       if (uri == NULL)
-               return;
-       if (uri->text) {
-               free((void *)uri->text);
-               uri->text = NULL;
-       }
-       free((void*)uri);
-       uri = NULL;
-}
-
-static void __ps_free_mime(mime_x *mime)
-{
-       if (mime == NULL)
-               return;
-       if (mime->text) {
-               free((void *)mime->text);
-               mime->text = NULL;
-       }
-       free((void*)mime);
-       mime = NULL;
-}
-
-static void __ps_free_subapp(subapp_x *subapp)
-{
-       if (subapp == NULL)
-               return;
-       if (subapp->text) {
-               free((void *)subapp->text);
-               subapp->text = NULL;
-       }
-       free((void*)subapp);
-       subapp = NULL;
-}
-
-static void __ps_free_condition(condition_x *condition)
-{
-       if (condition == NULL)
-               return;
-       if (condition->text) {
-               free((void *)condition->text);
-               condition->text = NULL;
-       }
-       if (condition->name) {
-               free((void *)condition->name);
-               condition->name = NULL;
-       }
-       free((void*)condition);
-       condition = NULL;
-}
-
-static void __ps_free_notification(notification_x *notification)
-{
-       if (notification == NULL)
-               return;
-       if (notification->text) {
-               free((void *)notification->text);
-               notification->text = NULL;
-       }
-       if (notification->name) {
-               free((void *)notification->name);
-               notification->name = NULL;
-       }
-       free((void*)notification);
-       notification = NULL;
-}
-
-static void __ps_free_compatibility(compatibility_x *compatibility)
-{
-       if (compatibility == NULL)
-               return;
-       if (compatibility->text) {
-               free((void *)compatibility->text);
-               compatibility->text = NULL;
-       }
-       if (compatibility->name) {
-               free((void *)compatibility->name);
-               compatibility->name = NULL;
-       }
-       free((void*)compatibility);
-       compatibility = NULL;
-}
-
-static void __ps_free_allowed(allowed_x *allowed)
-{
-       if (allowed == NULL)
-               return;
-       if (allowed->name) {
-               free((void *)allowed->name);
-               allowed->name = NULL;
-       }
-       if (allowed->text) {
-               free((void *)allowed->text);
-               allowed->text = NULL;
-       }
-       free((void*)allowed);
-       allowed = NULL;
-}
-
-static void __ps_free_request(request_x *request)
-{
-       if (request == NULL)
-               return;
-       if (request->text) {
-               free((void *)request->text);
-               request->text = NULL;
-       }
-       free((void*)request);
-       request = NULL;
-}
-
-static void __ps_free_datacontrol(datacontrol_x *datacontrol)
-{
-       if (datacontrol == NULL)
-               return;
-       if (datacontrol->providerid) {
-               free((void *)datacontrol->providerid);
-               datacontrol->providerid = NULL;
-       }
-       if (datacontrol->access) {
-               free((void *)datacontrol->access);
-               datacontrol->access = NULL;
-       }
-       if (datacontrol->type) {
-               free((void *)datacontrol->type);
-               datacontrol->type = NULL;
-       }
-       free((void*)datacontrol);
-       datacontrol = NULL;
-}
-
-static void __ps_free_launchconditions(launchconditions_x *launchconditions)
-{
-       if (launchconditions == NULL)
-               return;
-       if (launchconditions->text) {
-               free((void *)launchconditions->text);
-               launchconditions->text = NULL;
-       }
-       /*Free Condition*/
-       if (launchconditions->condition) {
-               condition_x *condition = launchconditions->condition;
-               condition_x *tmp = NULL;
-               while(condition != NULL) {
-                       tmp = condition->next;
-                       __ps_free_condition(condition);
-                       condition = tmp;
-               }
-       }
-       free((void*)launchconditions);
-       launchconditions = NULL;
-}
-
-static void __ps_free_appcontrol(appcontrol_x *appcontrol)
-{
-       if (appcontrol == NULL)
-               return;
-       /*Free Operation*/
-       if (appcontrol->operation)
-               free((void *)appcontrol->operation);
-       /*Free Uri*/
-       if (appcontrol->uri)
-               free((void *)appcontrol->uri);
-       /*Free Mime*/
-       if (appcontrol->mime)
-               free((void *)appcontrol->mime);
-       free((void*)appcontrol);
-       appcontrol = NULL;
-}
-
-static void __ps_free_appsvc(appsvc_x *appsvc)
-{
-       if (appsvc == NULL)
-               return;
-       if (appsvc->text) {
-               free((void *)appsvc->text);
-               appsvc->text = NULL;
-       }
-       /*Free Operation*/
-       if (appsvc->operation) {
-               operation_x *operation = appsvc->operation;
-               operation_x *tmp = NULL;
-               while(operation != NULL) {
-                       tmp = operation->next;
-                       __ps_free_operation(operation);
-                       operation = tmp;
-               }
-       }
-       /*Free Uri*/
-       if (appsvc->uri) {
-               uri_x *uri = appsvc->uri;
-               uri_x *tmp = NULL;
-               while(uri != NULL) {
-                       tmp = uri->next;
-                       __ps_free_uri(uri);
-                       uri = tmp;
-               }
-       }
-       /*Free Mime*/
-       if (appsvc->mime) {
-               mime_x *mime = appsvc->mime;
-               mime_x *tmp = NULL;
-               while(mime != NULL) {
-                       tmp = mime->next;
-                       __ps_free_mime(mime);
-                       mime = tmp;
-               }
-       }
-       /*Free subapp*/
-       if (appsvc->subapp) {
-               subapp_x *subapp = appsvc->subapp;
-               subapp_x *tmp = NULL;
-               while(subapp != NULL) {
-                       tmp = subapp->next;
-                       __ps_free_subapp(subapp);
-                       subapp = tmp;
-               }
-       }
-       free((void*)appsvc);
-       appsvc = NULL;
-}
-
-static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
-{
-       return;
-}
-
-static void __ps_free_define(define_x *define)
-{
-       if (define == NULL)
-               return;
-       if (define->path) {
-               free((void *)define->path);
-               define->path = NULL;
-       }
-       /*Free Request*/
-       if (define->request) {
-               request_x *request = define->request;
-               request_x *tmp = NULL;
-               while(request != NULL) {
-                       tmp = request->next;
-                       __ps_free_request(request);
-                       request = tmp;
-               }
-       }
-       /*Free Allowed*/
-       if (define->allowed) {
-               allowed_x *allowed = define->allowed;
-               allowed_x *tmp = NULL;
-               while(allowed != NULL) {
-                       tmp = allowed->next;
-                       __ps_free_allowed(allowed);
-                       allowed = tmp;
-               }
-       }
-       free((void*)define);
-       define = NULL;
-}
-
-static void __ps_free_datashare(datashare_x *datashare)
-{
-       if (datashare == NULL)
-               return;
-       /*Free Define*/
-       if (datashare->define) {
-               define_x *define =  datashare->define;
-               define_x *tmp = NULL;
-               while(define != NULL) {
-                       tmp = define->next;
-                       __ps_free_define(define);
-                       define = tmp;
-               }
-       }
-       /*Free Request*/
-       if (datashare->request) {
-               request_x *request = datashare->request;
-               request_x *tmp = NULL;
-               while(request != NULL) {
-                       tmp = request->next;
-                       __ps_free_request(request);
-                       request = tmp;
-               }
-       }
-       free((void*)datashare);
-       datashare = NULL;
-}
-
-static void __ps_free_label(label_x *label)
-{
-       if (label == NULL)
-               return;
-       if (label->name) {
-               free((void *)label->name);
-               label->name = NULL;
-       }
-       if (label->text) {
-               free((void *)label->text);
-               label->text = NULL;
-       }
-       if (label->lang) {
-               free((void *)label->lang);
-               label->lang= NULL;
-       }
-       free((void*)label);
-       label = NULL;
-}
-
-static void __ps_free_author(author_x *author)
-{
-       if (author == NULL)
-               return;
-       if (author->email) {
-               free((void *)author->email);
-               author->email = NULL;
-       }
-       if (author->text) {
-               free((void *)author->text);
-               author->text = NULL;
-       }
-       if (author->href) {
-               free((void *)author->href);
-               author->href = NULL;
-       }
-       if (author->lang) {
-               free((void *)author->lang);
-               author->lang = NULL;
-       }
-       free((void*)author);
-       author = NULL;
-}
-
-static void __ps_free_description(description_x *description)
-{
-       if (description == NULL)
-               return;
-       if (description->name) {
-               free((void *)description->name);
-               description->name = NULL;
-       }
-       if (description->text) {
-               free((void *)description->text);
-               description->text = NULL;
-       }
-       if (description->lang) {
-               free((void *)description->lang);
-               description->lang = NULL;
-       }
-       free((void*)description);
-       description = NULL;
-}
-
-static void __ps_free_license(license_x *license)
-{
-       if (license == NULL)
-               return;
-       if (license->text) {
-               free((void *)license->text);
-               license->text = NULL;
-       }
-       if (license->lang) {
-               free((void *)license->lang);
-               license->lang = NULL;
-       }
-       free((void*)license);
-       license = NULL;
-}
-
-static void __ps_free_uiapplication(uiapplication_x *uiapplication)
-{
-       if (uiapplication == NULL)
-               return;
-       if (uiapplication->exec) {
-               free((void *)uiapplication->exec);
-               uiapplication->exec = NULL;
-       }
-       if (uiapplication->appid) {
-               free((void *)uiapplication->appid);
-               uiapplication->appid = NULL;
-       }
-       if (uiapplication->nodisplay) {
-               free((void *)uiapplication->nodisplay);
-               uiapplication->nodisplay = NULL;
-       }
-       if (uiapplication->multiple) {
-               free((void *)uiapplication->multiple);
-               uiapplication->multiple = NULL;
-       }
-       if (uiapplication->type) {
-               free((void *)uiapplication->type);
-               uiapplication->type = NULL;
-       }
-       if (uiapplication->categories) {
-               free((void *)uiapplication->categories);
-               uiapplication->categories = NULL;
-       }
-       if (uiapplication->extraid) {
-               free((void *)uiapplication->extraid);
-               uiapplication->extraid = NULL;
-       }
-       if (uiapplication->taskmanage) {
-               free((void *)uiapplication->taskmanage);
-               uiapplication->taskmanage = NULL;
-       }
-       if (uiapplication->enabled) {
-               free((void *)uiapplication->enabled);
-               uiapplication->enabled = NULL;
-       }
-       if (uiapplication->hwacceleration) {
-               free((void *)uiapplication->hwacceleration);
-               uiapplication->hwacceleration = NULL;
-       }
-       if (uiapplication->screenreader) {
-               free((void *)uiapplication->screenreader);
-               uiapplication->screenreader = NULL;
-       }
-       if (uiapplication->mainapp) {
-               free((void *)uiapplication->mainapp);
-               uiapplication->mainapp = NULL;
-       }
-       if (uiapplication->recentimage) {
-               free((void *)uiapplication->recentimage);
-               uiapplication->recentimage = NULL;
-       }
-       if (uiapplication->package) {
-               free((void *)uiapplication->package);
-               uiapplication->package = NULL;
-       }
-       if (uiapplication->launchcondition) {
-               free((void *)uiapplication->launchcondition);
-               uiapplication->launchcondition = NULL;
-       }
-       /*Free Label*/
-       if (uiapplication->label) {
-               label_x *label = uiapplication->label;
-               label_x *tmp = NULL;
-               while(label != NULL) {
-                       tmp = label->next;
-                       __ps_free_label(label);
-                       label = tmp;
-               }
-       }
-       /*Free Icon*/
-       if (uiapplication->icon) {
-               icon_x *icon = uiapplication->icon;
-               icon_x *tmp = NULL;
-               while(icon != NULL) {
-                       tmp = icon->next;
-                       __ps_free_icon(icon);
-                       icon = tmp;
-               }
-       }
-       /*Free image*/
-       if (uiapplication->image) {
-               image_x *image = uiapplication->image;
-               image_x *tmp = NULL;
-               while(image != NULL) {
-                       tmp = image->next;
-                       __ps_free_image(image);
-                       image = tmp;
-               }
-       }
-       /*Free AppControl*/
-       if (uiapplication->appcontrol) {
-               appcontrol_x *appcontrol = uiapplication->appcontrol;
-               appcontrol_x *tmp = NULL;
-               while(appcontrol != NULL) {
-                       tmp = appcontrol->next;
-                       __ps_free_appcontrol(appcontrol);
-                       appcontrol = tmp;
-               }
-       }
-       /*Free LaunchConditions*/
-       if (uiapplication->launchconditions) {
-               launchconditions_x *launchconditions = uiapplication->launchconditions;
-               launchconditions_x *tmp = NULL;
-               while(launchconditions != NULL) {
-                       tmp = launchconditions->next;
-                       __ps_free_launchconditions(launchconditions);
-                       launchconditions = tmp;
-               }
-       }
-       /*Free Notification*/
-       if (uiapplication->notification) {
-               notification_x *notification = uiapplication->notification;
-               notification_x *tmp = NULL;
-               while(notification != NULL) {
-                       tmp = notification->next;
-                       __ps_free_notification(notification);
-                       notification = tmp;
-               }
-       }
-       /*Free DataShare*/
-       if (uiapplication->datashare) {
-               datashare_x *datashare = uiapplication->datashare;
-               datashare_x *tmp = NULL;
-               while(datashare != NULL) {
-                       tmp = datashare->next;
-                       __ps_free_datashare(datashare);
-                       datashare = tmp;
-               }
-       }
-       /*Free AppSvc*/
-       if (uiapplication->appsvc) {
-               appsvc_x *appsvc = uiapplication->appsvc;
-               appsvc_x *tmp = NULL;
-               while(appsvc != NULL) {
-                       tmp = appsvc->next;
-                       __ps_free_appsvc(appsvc);
-                       appsvc = tmp;
-               }
-       }
-       /*Free Category*/
-       if (uiapplication->category) {
-               category_x *category = uiapplication->category;
-               category_x *tmp = NULL;
-               while(category != NULL) {
-                       tmp = category->next;
-                       __ps_free_category(category);
-                       category = tmp;
-               }
-       }
-       /*Free Metadata*/
-       if (uiapplication->metadata) {
-               metadata_x *metadata = uiapplication->metadata;
-               metadata_x *tmp = NULL;
-               while(metadata != NULL) {
-                       tmp = metadata->next;
-                       __ps_free_metadata(metadata);
-                       metadata = tmp;
-               }
-       }
-       /*Free permission*/
-       if (uiapplication->permission) {
-               permission_x *permission = uiapplication->permission;
-               permission_x *tmp = NULL;
-               while(permission != NULL) {
-                       tmp = permission->next;
-                       __ps_free_permission(permission);
-                       permission = tmp;
-               }
-       }
-       /*Free DataControl*/
-       if (uiapplication->datacontrol) {
-               datacontrol_x *datacontrol = uiapplication->datacontrol;
-               datacontrol_x *tmp = NULL;
-               while(datacontrol != NULL) {
-                       tmp = datacontrol->next;
-                       __ps_free_datacontrol(datacontrol);
-                       datacontrol = tmp;
-               }
-       }
-       /* _PRODUCT_LAUNCHING_ENHANCED_ START */
-       if (uiapplication->indicatordisplay) {
-               free((void *)uiapplication->indicatordisplay);
-               uiapplication->indicatordisplay = NULL;
-       }
-       if (uiapplication->portraitimg) {
-               free((void *)uiapplication->portraitimg);
-               uiapplication->portraitimg = NULL;
-       }
-       if (uiapplication->landscapeimg) {
-               free((void *)uiapplication->landscapeimg);
-               uiapplication->landscapeimg = NULL;
-       }
-       /* _PRODUCT_LAUNCHING_ENHANCED_ END */
-       if (uiapplication->guestmode_visibility) {
-               free((void *)uiapplication->guestmode_visibility);
-               uiapplication->guestmode_visibility = NULL;
-       }
-       if (uiapplication->app_component) {
-               free((void *)uiapplication->app_component);
-               uiapplication->app_component = NULL;
-       }
-       if (uiapplication->permission_type) {
-               free((void *)uiapplication->permission_type);
-               uiapplication->permission_type = NULL;
-       }
-       if (uiapplication->component_type) {
-               free((void *)uiapplication->component_type);
-               uiapplication->component_type = NULL;
-       }
-       if (uiapplication->preload) {
-               free((void *)uiapplication->preload);
-               uiapplication->preload = NULL;
-       }
-       if (uiapplication->submode) {
-               free((void *)uiapplication->submode);
-               uiapplication->submode = NULL;
-       }
-       if (uiapplication->submode_mainid) {
-               free((void *)uiapplication->submode_mainid);
-               uiapplication->submode_mainid = NULL;
-       }
-
-       free((void*)uiapplication);
-       uiapplication = NULL;
-}
-
-static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
-{
-       if (serviceapplication == NULL)
-               return;
-       if (serviceapplication->exec) {
-               free((void *)serviceapplication->exec);
-               serviceapplication->exec = NULL;
-       }
-       if (serviceapplication->appid) {
-               free((void *)serviceapplication->appid);
-               serviceapplication->appid = NULL;
-       }
-       if (serviceapplication->onboot) {
-               free((void *)serviceapplication->onboot);
-               serviceapplication->onboot = NULL;
-       }
-       if (serviceapplication->autorestart) {
-               free((void *)serviceapplication->autorestart);
-               serviceapplication->autorestart = NULL;
-       }
-       if (serviceapplication->type) {
-               free((void *)serviceapplication->type);
-               serviceapplication->type = NULL;
-       }
-       if (serviceapplication->enabled) {
-               free((void *)serviceapplication->enabled);
-               serviceapplication->enabled = NULL;
-       }
-       if (serviceapplication->package) {
-               free((void *)serviceapplication->package);
-               serviceapplication->package = NULL;
-       }
-       if (serviceapplication->permission_type) {
-               free((void *)serviceapplication->permission_type);
-               serviceapplication->permission_type = NULL;
-       }
-       /*Free Label*/
-       if (serviceapplication->label) {
-               label_x *label = serviceapplication->label;
-               label_x *tmp = NULL;
-               while(label != NULL) {
-                       tmp = label->next;
-                       __ps_free_label(label);
-                       label = tmp;
-               }
-       }
-       /*Free Icon*/
-       if (serviceapplication->icon) {
-               icon_x *icon = serviceapplication->icon;
-               icon_x *tmp = NULL;
-               while(icon != NULL) {
-                       tmp = icon->next;
-                       __ps_free_icon(icon);
-                       icon = tmp;
-               }
-       }
-       /*Free AppControl*/
-       if (serviceapplication->appcontrol) {
-               appcontrol_x *appcontrol = serviceapplication->appcontrol;
-               appcontrol_x *tmp = NULL;
-               while(appcontrol != NULL) {
-                       tmp = appcontrol->next;
-                       __ps_free_appcontrol(appcontrol);
-                       appcontrol = tmp;
-               }
-       }
-       /*Free DataControl*/
-       if (serviceapplication->datacontrol) {
-               datacontrol_x *datacontrol = serviceapplication->datacontrol;
-               datacontrol_x *tmp = NULL;
-               while(datacontrol != NULL) {
-                       tmp = datacontrol->next;
-                       __ps_free_datacontrol(datacontrol);
-                       datacontrol = tmp;
-               }
-       }
-       /*Free LaunchConditions*/
-       if (serviceapplication->launchconditions) {
-               launchconditions_x *launchconditions = serviceapplication->launchconditions;
-               launchconditions_x *tmp = NULL;
-               while(launchconditions != NULL) {
-                       tmp = launchconditions->next;
-                       __ps_free_launchconditions(launchconditions);
-                       launchconditions = tmp;
-               }
-       }
-       /*Free Notification*/
-       if (serviceapplication->notification) {
-               notification_x *notification = serviceapplication->notification;
-               notification_x *tmp = NULL;
-               while(notification != NULL) {
-                       tmp = notification->next;
-                       __ps_free_notification(notification);
-                       notification = tmp;
-               }
-       }
-       /*Free DataShare*/
-       if (serviceapplication->datashare) {
-               datashare_x *datashare = serviceapplication->datashare;
-               datashare_x *tmp = NULL;
-               while(datashare != NULL) {
-                       tmp = datashare->next;
-                       __ps_free_datashare(datashare);
-                       datashare = tmp;
-               }
-       }
-       /*Free AppSvc*/
-       if (serviceapplication->appsvc) {
-               appsvc_x *appsvc = serviceapplication->appsvc;
-               appsvc_x *tmp = NULL;
-               while(appsvc != NULL) {
-                       tmp = appsvc->next;
-                       __ps_free_appsvc(appsvc);
-                       appsvc = tmp;
-               }
-       }
-       /*Free Category*/
-       if (serviceapplication->category) {
-               category_x *category = serviceapplication->category;
-               category_x *tmp = NULL;
-               while(category != NULL) {
-                       tmp = category->next;
-                       __ps_free_category(category);
-                       category = tmp;
-               }
-       }
-       /*Free Metadata*/
-       if (serviceapplication->metadata) {
-               metadata_x *metadata = serviceapplication->metadata;
-               metadata_x *tmp = NULL;
-               while(metadata != NULL) {
-                       tmp = metadata->next;
-                       __ps_free_metadata(metadata);
-                       metadata = tmp;
-               }
-       }
-       /*Free permission*/
-       if (serviceapplication->permission) {
-               permission_x *permission = serviceapplication->permission;
-               permission_x *tmp = NULL;
-               while(permission != NULL) {
-                       tmp = permission->next;
-                       __ps_free_permission(permission);
-                       permission = tmp;
-               }
-       }
-       free((void*)serviceapplication);
-       serviceapplication = NULL;
-}
-
-static void __ps_free_font(font_x *font)
-{
-       if (font == NULL)
-               return;
-       if (font->name) {
-               free((void *)font->name);
-               font->name = NULL;
-       }
-       if (font->text) {
-               free((void *)font->text);
-               font->text = NULL;
-       }
-       free((void*)font);
-       font = NULL;
-}
-
-static void __ps_free_theme(theme_x *theme)
-{
-       if (theme == NULL)
-               return;
-       if (theme->name) {
-               free((void *)theme->name);
-               theme->name = NULL;
-       }
-       if (theme->text) {
-               free((void *)theme->text);
-               theme->text = NULL;
-       }
-       free((void*)theme);
-       theme = NULL;
-}
-
-static void __ps_free_daemon(daemon_x *daemon)
-{
-       if (daemon == NULL)
-               return;
-       if (daemon->name) {
-               free((void *)daemon->name);
-               daemon->name = NULL;
-       }
-       if (daemon->text) {
-               free((void *)daemon->text);
-               daemon->text = NULL;
-       }
-       free((void*)daemon);
-       daemon = NULL;
-}
-
-static void __ps_free_ime(ime_x *ime)
-{
-       if (ime == NULL)
-               return;
-       if (ime->name) {
-               free((void *)ime->name);
-               ime->name = NULL;
-       }
-       if (ime->text) {
-               free((void *)ime->text);
-               ime->text = NULL;
-       }
-       free((void*)ime);
-       ime = NULL;
-}
-
 int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action)
 {
        xmlTextReaderPtr reader;
@@ -3501,236 +2515,7 @@ API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
 
 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
 {
-       if (mfx == NULL)
-               return;
-       if (mfx->ns) {
-               free((void *)mfx->ns);
-               mfx->ns = NULL;
-       }
-       if (mfx->package) {
-               free((void *)mfx->package);
-               mfx->package = NULL;
-       }
-       if (mfx->version) {
-               free((void *)mfx->version);
-               mfx->version = NULL;
-       }
-       if (mfx->installlocation) {
-               free((void *)mfx->installlocation);
-               mfx->installlocation = NULL;
-       }
-       if (mfx->preload) {
-               free((void *)mfx->preload);
-               mfx->preload = NULL;
-       }
-       if (mfx->readonly) {
-               free((void *)mfx->readonly);
-               mfx->readonly = NULL;
-       }
-       if (mfx->removable) {
-               free((void *)mfx->removable);
-               mfx->removable = NULL;
-       }
-       if (mfx->update) {
-               free((void *)mfx->update);
-               mfx->update = NULL;
-       }
-       if (mfx->system) {
-               free((void *)mfx->system);
-               mfx->system = NULL;
-       }
-       if (mfx->type) {
-               free((void *)mfx->type);
-               mfx->type = NULL;
-       }
-       if (mfx->package_size) {
-               free((void *)mfx->package_size);
-               mfx->package_size = NULL;
-       }
-       if (mfx->installed_time) {
-               free((void *)mfx->installed_time);
-               mfx->installed_time = NULL;
-       }
-       if (mfx->installed_storage) {
-               free((void *)mfx->installed_storage);
-               mfx->installed_storage = NULL;
-       }
-       if (mfx->storeclient_id) {
-               free((void *)mfx->storeclient_id);
-               mfx->storeclient_id = NULL;
-       }
-       if (mfx->mainapp_id) {
-               free((void *)mfx->mainapp_id);
-               mfx->mainapp_id = NULL;
-       }
-       if (mfx->package_url) {
-               free((void *)mfx->package_url);
-               mfx->package_url = NULL;
-       }
-       if (mfx->root_path) {
-               free((void *)mfx->root_path);
-               mfx->root_path = NULL;
-       }
-       if (mfx->csc_path) {
-               free((void *)mfx->csc_path);
-               mfx->csc_path = NULL;
-       }
-       if (mfx->appsetting) {
-               free((void *)mfx->appsetting);
-               mfx->appsetting = NULL;
-       }
-       if (mfx->nodisplay_setting) {
-               free((void *)mfx->nodisplay_setting);
-               mfx->nodisplay_setting = NULL;
-       }
-       if (mfx->api_version) {
-               free((void *)mfx->api_version);
-               mfx->api_version = NULL;
-       }
-
-       /*Free Icon*/
-       if (mfx->icon) {
-               icon_x *icon = mfx->icon;
-               icon_x *tmp = NULL;
-               while(icon != NULL) {
-                       tmp = icon->next;
-                       __ps_free_icon(icon);
-                       icon = tmp;
-               }
-       }
-       /*Free Label*/
-       if (mfx->label) {
-               label_x *label = mfx->label;
-               label_x *tmp = NULL;
-               while(label != NULL) {
-                       tmp = label->next;
-                       __ps_free_label(label);
-                       label = tmp;
-               }
-       }
-       /*Free Author*/
-       if (mfx->author) {
-               author_x *author = mfx->author;
-               author_x *tmp = NULL;
-               while(author != NULL) {
-                       tmp = author->next;
-                       __ps_free_author(author);
-                       author = tmp;
-               }
-       }
-       /*Free Description*/
-       if (mfx->description) {
-               description_x *description = mfx->description;
-               description_x *tmp = NULL;
-               while(description != NULL) {
-                       tmp = description->next;
-                       __ps_free_description(description);
-                       description = tmp;
-               }
-       }
-       /*Free License*/
-       if (mfx->license) {
-               license_x *license = mfx->license;
-               license_x *tmp = NULL;
-               while(license != NULL) {
-                       tmp = license->next;
-                       __ps_free_license(license);
-                       license = tmp;
-               }
-       }
-       /*Free Privileges*/
-       if (mfx->privileges) {
-               privileges_x *privileges = mfx->privileges;
-               privileges_x *tmp = NULL;
-               while(privileges != NULL) {
-                       tmp = privileges->next;
-                       __ps_free_privileges(privileges);
-                       privileges = tmp;
-               }
-       }
-       /*Free UiApplication*/
-       if (mfx->uiapplication) {
-               uiapplication_x *uiapplication = mfx->uiapplication;
-               uiapplication_x *tmp = NULL;
-               while(uiapplication != NULL) {
-                       tmp = uiapplication->next;
-                       __ps_free_uiapplication(uiapplication);
-                       uiapplication = tmp;
-               }
-       }
-       /*Free ServiceApplication*/
-       if (mfx->serviceapplication) {
-               serviceapplication_x *serviceapplication = mfx->serviceapplication;
-               serviceapplication_x *tmp = NULL;
-               while(serviceapplication != NULL) {
-                       tmp = serviceapplication->next;
-                       __ps_free_serviceapplication(serviceapplication);
-                       serviceapplication = tmp;
-               }
-       }
-       /*Free Daemon*/
-       if (mfx->daemon) {
-               daemon_x *daemon = mfx->daemon;
-               daemon_x *tmp = NULL;
-               while(daemon != NULL) {
-                       tmp = daemon->next;
-                       __ps_free_daemon(daemon);
-                       daemon = tmp;
-               }
-       }
-       /*Free Theme*/
-       if (mfx->theme) {
-               theme_x *theme = mfx->theme;
-               theme_x *tmp = NULL;
-               while(theme != NULL) {
-                       tmp = theme->next;
-                       __ps_free_theme(theme);
-                       theme = tmp;
-               }
-       }
-       /*Free Font*/
-       if (mfx->font) {
-               font_x *font = mfx->font;
-               font_x *tmp = NULL;
-               while(font != NULL) {
-                       tmp = font->next;
-                       __ps_free_font(font);
-                       font = tmp;
-               }
-       }
-       /*Free Ime*/
-       if (mfx->ime) {
-               ime_x *ime = mfx->ime;
-               ime_x *tmp = NULL;
-               while(ime != NULL) {
-                       tmp = ime->next;
-                       __ps_free_ime(ime);
-                       ime = tmp;
-               }
-       }
-       /*Free Compatibility*/
-       if (mfx->compatibility) {
-               compatibility_x *compatibility = mfx->compatibility;
-               compatibility_x *tmp = NULL;
-               while(compatibility != NULL) {
-                       tmp = compatibility->next;
-                       __ps_free_compatibility(compatibility);
-                       compatibility = tmp;
-               }
-       }
-       /*Free DeviceProfile*/
-       if (mfx->deviceprofile) {
-               deviceprofile_x *deviceprofile = mfx->deviceprofile;
-               deviceprofile_x *tmp = NULL;
-               while(deviceprofile != NULL) {
-                       tmp = deviceprofile->next;
-                       __ps_free_deviceprofile(deviceprofile);
-                       deviceprofile = tmp;
-               }
-       }
-       free((void*)mfx);
-       mfx = NULL;
-       return;
+       pkgmgrinfo_basic_free_package((package_x *)mfx);
 }
 
 API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
index 7cb3f73..db11167 100644 (file)
@@ -45,6 +45,7 @@
 
 /* For multi-user support */
 #include <tzplatform_config.h>
+#include "pkgmgr-info-basic.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -69,447 +70,6 @@ enum {
 };
 
 /**
- * @brief List definitions.
- * All lists are doubly-linked, the last element is stored to list pointer,
- * which means that lists must be looped using the prev pointer, or by
- * calling LISTHEAD first to go to start in order to use the next pointer.
- */
-
- /**
- * @brief Convinience Macro to add node in list
- */
-
-#define LISTADD(list, node)                    \
-    do {                                       \
-       (node)->prev = (list);                  \
-       if (list) (node)->next = (list)->next;  \
-       else (node)->next = NULL;               \
-       if (list) (list)->next = (node);        \
-       (list) = (node);                        \
-    } while (0);
-
- /**
- * @brief Convinience Macro to add one node to another node
- */
-#define NODEADD(node1, node2)                                  \
-    do {                                                       \
-       (node2)->prev = (node1);                                \
-       (node2)->next = (node1)->next;                          \
-       if ((node1)->next) (node1)->next->prev = (node2);       \
-       (node1)->next = (node2);                                \
-    } while (0);
-
- /**
- * @brief Convinience Macro to concatenate two lists
- */
-#define LISTCAT(list, first, last)             \
-    if ((first) && (last)) {                   \
-       (first)->prev = (list);                 \
-       (list) = (last);                        \
-    }
-
- /**
- * @brief Convinience Macro to delete node from list
- */
-#define LISTDEL(list, node)                                    \
-    do {                                                       \
-       if ((node)->prev) (node)->prev->next = (node)->next;    \
-       if ((node)->next) (node)->next->prev = (node)->prev;    \
-       if (!((node)->prev) && !((node)->next)) (list) = NULL;  \
-    } while (0);
-
- /**
- * @brief Convinience Macro to get list head
- */
-#define LISTHEAD(list, node)                                   \
-    for ((node) = (list); (node)->prev; (node) = (node)->prev)
-
- /**
- * @brief Convinience Macro to get list tail
- */
-#define LISTTAIL(list, node)                                   \
-    for ((node) = (list); (node)->next; (node) = (node)->next)
-
-typedef struct metadata_x {
-       const char *key;
-       const char *value;
-       struct metadata_x *prev;
-       struct metadata_x *next;
-} metadata_x;
-
-typedef struct privilege_x {
-       const char *text;
-       struct privilege_x *prev;
-       struct privilege_x *next;
-} privilege_x;
-
-typedef struct privileges_x {
-       struct privilege_x *privilege;
-       struct privileges_x *prev;
-       struct privileges_x *next;
-} privileges_x;
-
-typedef struct permission_x {
-       const char *type;
-       const char *value;
-       struct permission_x *prev;
-       struct permission_x *next;
-} permission_x;
-
-typedef struct icon_x {
-       const char *name;
-       const char *text;
-       const char *lang;
-       const char *section;
-       const char *size;
-       const char *resolution;
-       struct icon_x *prev;
-       struct icon_x *next;
-} icon_x;
-
-typedef struct image_x {
-       const char *name;
-       const char *text;
-       const char *lang;
-       const char *section;
-       struct image_x *prev;
-       struct image_x *next;
-} image_x;
-
-typedef struct allowed_x {
-       const char *name;
-       const char *text;
-       struct allowed_x *prev;
-       struct allowed_x *next;
-} allowed_x;
-
-typedef struct request_x {
-       const char *text;
-       struct request_x *prev;
-       struct request_x *next;
-} request_x;
-
-typedef struct define_x {
-       const char *path;
-       struct allowed_x *allowed;
-       struct request_x *request;
-       struct define_x *prev;
-       struct define_x *next;
-} define_x;
-
-typedef struct datashare_x {
-       struct define_x *define;
-       struct request_x *request;
-       struct datashare_x *prev;
-       struct datashare_x *next;
-} datashare_x;
-
-typedef struct description_x {
-       const char *name;
-       const char *text;
-       const char *lang;
-       struct description_x *prev;
-       struct description_x *next;
-} description_x;
-
-typedef struct registry_x {
-       const char *name;
-       const char *text;
-       struct registry_x *prev;
-       struct registry_x *next;
-} registry_x;
-
-typedef struct database_x {
-       const char *name;
-       const char *text;
-       struct database_x *prev;
-       struct database_x *next;
-} database_x;
-
-typedef struct layout_x {
-       const char *name;
-       const char *text;
-       struct layout_x *prev;
-       struct layout_x *next;
-} layout_x;
-
-typedef struct label_x {
-       const char *name;
-       const char *text;
-       const char *lang;
-       struct label_x *prev;
-       struct label_x *next;
-} label_x;
-
-typedef struct author_x {
-       const char *email;
-       const char *href;
-       const char *text;
-       const char *lang;
-       struct author_x *prev;
-       struct author_x *next;
-} author_x;
-
-typedef struct license_x {
-       const char *text;
-       const char *lang;
-       struct license_x *prev;
-       struct license_x *next;
-} license_x;
-
-typedef struct operation_x {
-       const char *name;
-       const char *text;
-       struct operation_x *prev;
-       struct operation_x *next;
-} operation_x;
-
-typedef struct uri_x {
-       const char *name;
-       const char *text;
-       struct uri_x *prev;
-       struct uri_x *next;
-} uri_x;
-
-typedef struct mime_x {
-       const char *name;
-       const char *text;
-       struct mime_x *prev;
-       struct mime_x *next;
-} mime_x;
-
-typedef struct subapp_x {
-       const char *name;
-       const char *text;
-       struct subapp_x *prev;
-       struct subapp_x *next;
-} subapp_x;
-
-typedef struct condition_x {
-       const char *name;
-       const char *text;
-       struct condition_x *prev;
-       struct condition_x *next;
-} condition_x;
-
-typedef struct notification_x {
-       const char *name;
-       const char *text;
-       struct notification_x *prev;
-       struct notification_x *next;
-} notification_x;
-
-typedef struct appsvc_x {
-       const char *text;
-       struct operation_x *operation;
-       struct uri_x *uri;
-       struct mime_x *mime;
-       struct subapp_x *subapp;
-       struct appsvc_x *prev;
-       struct appsvc_x *next;
-} appsvc_x;
-
-typedef struct appcontrol_x {
-       const char *operation;
-       const char *uri;
-       const char *mime;
-       struct appcontrol_x *prev;
-       struct appcontrol_x *next;
-} appcontrol_x;
-
-typedef struct category_x{
-       const char *name;
-       struct category_x *prev;
-       struct category_x *next;
-} category_x;
-
-typedef struct launchconditions_x {
-       const char *text;
-       struct condition_x *condition;
-       struct launchconditions_x *prev;
-       struct launchconditions_x *next;
-} launchconditions_x;
-
-typedef struct compatibility_x {
-       const char *name;
-       const char *text;
-       struct compatibility_x *prev;
-       struct compatibility_x *next;
-}compatibility_x;
-
-typedef struct deviceprofile_x {
-       const char *name;
-       const char *text;
-       struct deviceprofile_x *prev;
-       struct deviceprofile_x *next;
-}deviceprofile_x;
-
-typedef struct datacontrol_x {
-       const char *providerid;
-       const char *access;
-       const char *type;
-       struct datacontrol_x *prev;
-       struct datacontrol_x *next;
-} datacontrol_x;
-
-typedef struct uiapplication_x {
-       const char *appid;
-       const char *exec;
-       const char *nodisplay;
-       const char *multiple;
-       const char *taskmanage;
-       const char *enabled;
-       const char *type;
-       const char *categories;
-       const char *extraid;
-       const char *hwacceleration;
-       const char *screenreader;
-       const char *mainapp;
-       const char *package;
-       const char *recentimage;
-       const char *launchcondition;
-       const char *indicatordisplay;
-       const char *portraitimg;
-       const char *landscapeimg;
-       const char *guestmode_visibility;
-       const char *app_component;
-       const char *permission_type;
-       const char *component_type;
-       const char *preload;
-       const char *submode;
-       const char *submode_mainid;
-       const char *launch_mode;
-       struct label_x *label;
-       struct icon_x *icon;
-       struct image_x *image;
-       struct appsvc_x *appsvc;
-       struct appcontrol_x *appcontrol;
-       struct category_x *category;
-       struct metadata_x *metadata;
-       struct permission_x *permission;
-       struct launchconditions_x *launchconditions;
-       struct notification_x *notification;
-       struct datashare_x *datashare;
-       struct datacontrol_x *datacontrol;
-       struct uiapplication_x *prev;
-       struct uiapplication_x *next;
-
-} uiapplication_x;
-
-typedef struct serviceapplication_x {
-       const char *appid;
-       const char *exec;
-       const char *onboot;
-       const char *autorestart;
-       const char *enabled;
-       const char *type;
-       const char *package;
-       const char *permission_type;
-       struct label_x *label;
-       struct icon_x *icon;
-       struct appsvc_x *appsvc;
-       struct appcontrol_x *appcontrol;
-       struct category_x *category;
-       struct metadata_x *metadata;
-       struct permission_x *permission;
-       struct datacontrol_x *datacontrol;
-       struct launchconditions_x *launchconditions;
-       struct notification_x *notification;
-       struct datashare_x *datashare;
-       struct serviceapplication_x *prev;
-       struct serviceapplication_x *next;
-} serviceapplication_x;
-
-typedef struct daemon_x {
-       const char *name;
-       const char *text;
-       struct daemon_x *prev;
-       struct daemon_x *next;
-} daemon_x;
-
-typedef struct theme_x {
-       const char *name;
-       const char *text;
-       struct theme_x *prev;
-       struct theme_x *next;
-} theme_x;
-
-typedef struct font_x {
-       const char *name;
-       const char *text;
-       struct font_x *prev;
-       struct font_x *next;
-} font_x;
-
-typedef struct ime_x {
-       const char *name;
-       const char *text;
-       struct ime_x *prev;
-       struct ime_x *next;
-} ime_x;
-
-typedef struct manifest_x {
-       const char *for_all_users;              /**< Flag that indicates if the package is available for everyone or for current user only*/
-       const char *package;            /**< package name*/
-       const char *version;            /**< package version*/
-       const char *installlocation;            /**< package install location*/
-       const char *ns;         /**<name space*/
-       const char *removable;          /**< package removable flag*/
-       const char *preload;            /**< package preload flag*/
-       const char *readonly;           /**< package readonly flag*/
-       const char *update;                     /**< package update flag*/
-       const char *appsetting;         /**< package app setting flag*/
-       const char *system;             /**< package system flag*/
-       const char *type;               /**< package type*/
-       const char *package_size;               /**< package size for external installation*/
-       const char *installed_time;             /**< installed time after finishing of installation*/
-       const char *installed_storage;          /**< package currently installed storage*/
-       const char *storeclient_id;             /**< id of store client for installed package*/
-       const char *mainapp_id;         /**< app id of main application*/
-       const char *package_url;                /**< app id of main application*/
-       const char *root_path;          /**< package root path*/
-       const char *csc_path;           /**< package csc path*/
-       const char *nodisplay_setting;          /**< package no display setting menu*/
-       const char *api_version;                /**< minimum version of API package using*/
-       struct icon_x *icon;            /**< package icon*/
-       struct label_x *label;          /**< package label*/
-       struct author_x *author;                /**< package author*/
-       struct description_x *description;              /**< package description*/
-       struct license_x *license;              /**< package license*/
-       struct privileges_x *privileges;        /**< package privileges*/
-       struct uiapplication_x *uiapplication;          /**< package's ui application*/
-       struct serviceapplication_x *serviceapplication;                /**< package's service application*/
-       struct daemon_x *daemon;                /**< package daemon*/
-       struct theme_x *theme;          /**< package theme*/
-       struct font_x *font;            /**< package font*/
-       struct ime_x *ime;              /**< package ime*/
-       struct compatibility_x *compatibility;          /**< package compatibility*/
-       struct deviceprofile_x *deviceprofile;          /**< package device profile*/
-} manifest_x;
-
-/*enum uid_value {
-       ROOT,
-       GLOBAL,
-       USER
-};*/
-
-/**uid check
- * 
- */
-/* int check_uid(uid_t uid)
- {
-        switch(uid)
-        {
-               case GLOBAL_USER: return GLOBAL;
-               case 0: return ROOT;
-               default: goto user; break;
-       }
-user:
-cf getdbpath
-*/
-
-/**
  * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
  * @brief      This API gets the manifest file of the package.
  *
index 1a4a0bd..85b1399 100644 (file)
 #include <sys/smack.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <db-util.h>
-#include <glib.h>
 #include <grp.h>
 #include <pwd.h>
 
+#include <db-util.h>
+#include <glib.h>
 /* For multi-user support */
 #include <tzplatform_config.h>
 
 #include "pkgmgr-info.h"
+#include "pkgmgr-info-basic.h"
+#include "pkgmgr-info-debug.h"
 #include "pkgmgr_parser_internal.h"
 #include "pkgmgr_parser_db.h"
 
-#include "pkgmgr-info-debug.h"
-
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
diff --git a/src/pkgmgr-info-basic.c b/src/pkgmgr-info-basic.c
new file mode 100644 (file)
index 0000000..113e99e
--- /dev/null
@@ -0,0 +1,1375 @@
+
+#include <stdlib.h>
+
+#include "pkgmgr-info-basic.h"
+#include "pkgmgr-info-internal.h"
+
+static void __ps_free_category(category_x *category)
+{
+       if (category == NULL)
+               return;
+       if (category->name) {
+               free((void *)category->name);
+               category->name = NULL;
+       }
+       free((void*)category);
+       category = NULL;
+}
+
+static void __ps_free_privilege(privilege_x *privilege)
+{
+       if (privilege == NULL)
+               return;
+       if (privilege->text) {
+               free((void *)privilege->text);
+               privilege->text = NULL;
+       }
+       free((void*)privilege);
+       privilege = NULL;
+}
+
+static void __ps_free_privileges(privileges_x *privileges)
+{
+       if (privileges == NULL)
+               return;
+       /*Free Privilege*/
+       if (privileges->privilege) {
+               privilege_x *privilege = privileges->privilege;
+               privilege_x *tmp = NULL;
+               while(privilege != NULL) {
+                       tmp = privilege->next;
+                       __ps_free_privilege(privilege);
+                       privilege = tmp;
+               }
+       }
+       free((void*)privileges);
+       privileges = NULL;
+}
+
+static void __ps_free_metadata(metadata_x *metadata)
+{
+       if (metadata == NULL)
+               return;
+       if (metadata->key) {
+               free((void *)metadata->key);
+               metadata->key = NULL;
+       }
+       if (metadata->value) {
+               free((void *)metadata->value);
+               metadata->value = NULL;
+       }
+       free((void*)metadata);
+       metadata = NULL;
+}
+
+static void __ps_free_permission(permission_x *permission)
+{
+       if (permission == NULL)
+               return;
+       if (permission->type) {
+               free((void *)permission->type);
+               permission->type = NULL;
+       }
+       if (permission->value) {
+               free((void *)permission->value);
+               permission->value = NULL;
+       }
+       free((void*)permission);
+       permission = NULL;
+}
+
+static void __ps_free_icon(icon_x *icon)
+{
+       if (icon == NULL)
+               return;
+       if (icon->text) {
+               free((void *)icon->text);
+               icon->text = NULL;
+       }
+       if (icon->lang) {
+               free((void *)icon->lang);
+               icon->lang = NULL;
+       }
+       if (icon->name) {
+               free((void *)icon->name);
+               icon->name= NULL;
+       }
+       if (icon->section) {
+               free((void *)icon->section);
+               icon->section = NULL;
+       }
+       if (icon->size) {
+               free((void *)icon->size);
+               icon->size = NULL;
+       }
+       if (icon->resolution) {
+               free((void *)icon->resolution);
+               icon->resolution = NULL;
+       }
+       free((void*)icon);
+       icon = NULL;
+}
+
+static void __ps_free_image(image_x *image)
+{
+       if (image == NULL)
+               return;
+       if (image->text) {
+               free((void *)image->text);
+               image->text = NULL;
+       }
+       if (image->lang) {
+               free((void *)image->lang);
+               image->lang = NULL;
+       }
+       if (image->name) {
+               free((void *)image->name);
+               image->name= NULL;
+       }
+       if (image->section) {
+               free((void *)image->section);
+               image->section = NULL;
+       }
+       free((void*)image);
+       image = NULL;
+}
+
+static void __ps_free_operation(operation_x *operation)
+{
+       if (operation == NULL)
+               return;
+       if (operation->text) {
+               free((void *)operation->text);
+               operation->text = NULL;
+       }
+       free((void*)operation);
+       operation = NULL;
+}
+
+static void __ps_free_uri(uri_x *uri)
+{
+       if (uri == NULL)
+               return;
+       if (uri->text) {
+               free((void *)uri->text);
+               uri->text = NULL;
+       }
+       free((void*)uri);
+       uri = NULL;
+}
+
+static void __ps_free_mime(mime_x *mime)
+{
+       if (mime == NULL)
+               return;
+       if (mime->text) {
+               free((void *)mime->text);
+               mime->text = NULL;
+       }
+       free((void*)mime);
+       mime = NULL;
+}
+
+static void __ps_free_subapp(subapp_x *subapp)
+{
+       if (subapp == NULL)
+               return;
+       if (subapp->text) {
+               free((void *)subapp->text);
+               subapp->text = NULL;
+       }
+       free((void*)subapp);
+       subapp = NULL;
+}
+
+static void __ps_free_condition(condition_x *condition)
+{
+       if (condition == NULL)
+               return;
+       if (condition->text) {
+               free((void *)condition->text);
+               condition->text = NULL;
+       }
+       if (condition->name) {
+               free((void *)condition->name);
+               condition->name = NULL;
+       }
+       free((void*)condition);
+       condition = NULL;
+}
+
+static void __ps_free_notification(notification_x *notification)
+{
+       if (notification == NULL)
+               return;
+       if (notification->text) {
+               free((void *)notification->text);
+               notification->text = NULL;
+       }
+       if (notification->name) {
+               free((void *)notification->name);
+               notification->name = NULL;
+       }
+       free((void*)notification);
+       notification = NULL;
+}
+
+static void __ps_free_compatibility(compatibility_x *compatibility)
+{
+       if (compatibility == NULL)
+               return;
+       if (compatibility->text) {
+               free((void *)compatibility->text);
+               compatibility->text = NULL;
+       }
+       if (compatibility->name) {
+               free((void *)compatibility->name);
+               compatibility->name = NULL;
+       }
+       free((void*)compatibility);
+       compatibility = NULL;
+}
+
+static void __ps_free_allowed(allowed_x *allowed)
+{
+       if (allowed == NULL)
+               return;
+       if (allowed->name) {
+               free((void *)allowed->name);
+               allowed->name = NULL;
+       }
+       if (allowed->text) {
+               free((void *)allowed->text);
+               allowed->text = NULL;
+       }
+       free((void*)allowed);
+       allowed = NULL;
+}
+
+static void __ps_free_request(request_x *request)
+{
+       if (request == NULL)
+               return;
+       if (request->text) {
+               free((void *)request->text);
+               request->text = NULL;
+       }
+       free((void*)request);
+       request = NULL;
+}
+
+static void __ps_free_datacontrol(datacontrol_x *datacontrol)
+{
+       if (datacontrol == NULL)
+               return;
+       if (datacontrol->providerid) {
+               free((void *)datacontrol->providerid);
+               datacontrol->providerid = NULL;
+       }
+       if (datacontrol->access) {
+               free((void *)datacontrol->access);
+               datacontrol->access = NULL;
+       }
+       if (datacontrol->type) {
+               free((void *)datacontrol->type);
+               datacontrol->type = NULL;
+       }
+       free((void*)datacontrol);
+       datacontrol = NULL;
+}
+
+static void __ps_free_launchconditions(launchconditions_x *launchconditions)
+{
+       if (launchconditions == NULL)
+               return;
+       if (launchconditions->text) {
+               free((void *)launchconditions->text);
+               launchconditions->text = NULL;
+       }
+       /*Free Condition*/
+       if (launchconditions->condition) {
+               condition_x *condition = launchconditions->condition;
+               condition_x *tmp = NULL;
+               while(condition != NULL) {
+                       tmp = condition->next;
+                       __ps_free_condition(condition);
+                       condition = tmp;
+               }
+       }
+       free((void*)launchconditions);
+       launchconditions = NULL;
+}
+
+static void __ps_free_appcontrol(appcontrol_x *appcontrol)
+{
+       if (appcontrol == NULL)
+               return;
+       /*Free Operation*/
+       if (appcontrol->operation)
+               free((void *)appcontrol->operation);
+       /*Free Uri*/
+       if (appcontrol->uri)
+               free((void *)appcontrol->uri);
+       /*Free Mime*/
+       if (appcontrol->mime)
+               free((void *)appcontrol->mime);
+       free((void*)appcontrol);
+       appcontrol = NULL;
+}
+
+static void __ps_free_appsvc(appsvc_x *appsvc)
+{
+       if (appsvc == NULL)
+               return;
+       if (appsvc->text) {
+               free((void *)appsvc->text);
+               appsvc->text = NULL;
+       }
+       /*Free Operation*/
+       if (appsvc->operation) {
+               operation_x *operation = appsvc->operation;
+               operation_x *tmp = NULL;
+               while(operation != NULL) {
+                       tmp = operation->next;
+                       __ps_free_operation(operation);
+                       operation = tmp;
+               }
+       }
+       /*Free Uri*/
+       if (appsvc->uri) {
+               uri_x *uri = appsvc->uri;
+               uri_x *tmp = NULL;
+               while(uri != NULL) {
+                       tmp = uri->next;
+                       __ps_free_uri(uri);
+                       uri = tmp;
+               }
+       }
+       /*Free Mime*/
+       if (appsvc->mime) {
+               mime_x *mime = appsvc->mime;
+               mime_x *tmp = NULL;
+               while(mime != NULL) {
+                       tmp = mime->next;
+                       __ps_free_mime(mime);
+                       mime = tmp;
+               }
+       }
+       /*Free subapp*/
+       if (appsvc->subapp) {
+               subapp_x *subapp = appsvc->subapp;
+               subapp_x *tmp = NULL;
+               while(subapp != NULL) {
+                       tmp = subapp->next;
+                       __ps_free_subapp(subapp);
+                       subapp = tmp;
+               }
+       }
+       free((void*)appsvc);
+       appsvc = NULL;
+}
+
+static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
+{
+       return;
+}
+
+static void __ps_free_define(define_x *define)
+{
+       if (define == NULL)
+               return;
+       if (define->path) {
+               free((void *)define->path);
+               define->path = NULL;
+       }
+       /*Free Request*/
+       if (define->request) {
+               request_x *request = define->request;
+               request_x *tmp = NULL;
+               while(request != NULL) {
+                       tmp = request->next;
+                       __ps_free_request(request);
+                       request = tmp;
+               }
+       }
+       /*Free Allowed*/
+       if (define->allowed) {
+               allowed_x *allowed = define->allowed;
+               allowed_x *tmp = NULL;
+               while(allowed != NULL) {
+                       tmp = allowed->next;
+                       __ps_free_allowed(allowed);
+                       allowed = tmp;
+               }
+       }
+       free((void*)define);
+       define = NULL;
+}
+
+static void __ps_free_datashare(datashare_x *datashare)
+{
+       if (datashare == NULL)
+               return;
+       /*Free Define*/
+       if (datashare->define) {
+               define_x *define =  datashare->define;
+               define_x *tmp = NULL;
+               while(define != NULL) {
+                       tmp = define->next;
+                       __ps_free_define(define);
+                       define = tmp;
+               }
+       }
+       /*Free Request*/
+       if (datashare->request) {
+               request_x *request = datashare->request;
+               request_x *tmp = NULL;
+               while(request != NULL) {
+                       tmp = request->next;
+                       __ps_free_request(request);
+                       request = tmp;
+               }
+       }
+       free((void*)datashare);
+       datashare = NULL;
+}
+
+static void __ps_free_label(label_x *label)
+{
+       if (label == NULL)
+               return;
+       if (label->name) {
+               free((void *)label->name);
+               label->name = NULL;
+       }
+       if (label->text) {
+               free((void *)label->text);
+               label->text = NULL;
+       }
+       if (label->lang) {
+               free((void *)label->lang);
+               label->lang= NULL;
+       }
+       free((void*)label);
+       label = NULL;
+}
+
+static void __ps_free_author(author_x *author)
+{
+       if (author == NULL)
+               return;
+       if (author->email) {
+               free((void *)author->email);
+               author->email = NULL;
+       }
+       if (author->text) {
+               free((void *)author->text);
+               author->text = NULL;
+       }
+       if (author->href) {
+               free((void *)author->href);
+               author->href = NULL;
+       }
+       if (author->lang) {
+               free((void *)author->lang);
+               author->lang = NULL;
+       }
+       free((void*)author);
+       author = NULL;
+}
+
+static void __ps_free_description(description_x *description)
+{
+       if (description == NULL)
+               return;
+       if (description->name) {
+               free((void *)description->name);
+               description->name = NULL;
+       }
+       if (description->text) {
+               free((void *)description->text);
+               description->text = NULL;
+       }
+       if (description->lang) {
+               free((void *)description->lang);
+               description->lang = NULL;
+       }
+       free((void*)description);
+       description = NULL;
+}
+
+static void __ps_free_license(license_x *license)
+{
+       if (license == NULL)
+               return;
+       if (license->text) {
+               free((void *)license->text);
+               license->text = NULL;
+       }
+       if (license->lang) {
+               free((void *)license->lang);
+               license->lang = NULL;
+       }
+       free((void*)license);
+       license = NULL;
+}
+
+static void __ps_free_uiapplication(uiapplication_x *uiapplication)
+{
+       if (uiapplication == NULL)
+               return;
+       if (uiapplication->exec) {
+               free((void *)uiapplication->exec);
+               uiapplication->exec = NULL;
+       }
+       if (uiapplication->appid) {
+               free((void *)uiapplication->appid);
+               uiapplication->appid = NULL;
+       }
+       if (uiapplication->nodisplay) {
+               free((void *)uiapplication->nodisplay);
+               uiapplication->nodisplay = NULL;
+       }
+       if (uiapplication->multiple) {
+               free((void *)uiapplication->multiple);
+               uiapplication->multiple = NULL;
+       }
+       if (uiapplication->type) {
+               free((void *)uiapplication->type);
+               uiapplication->type = NULL;
+       }
+       if (uiapplication->categories) {
+               free((void *)uiapplication->categories);
+               uiapplication->categories = NULL;
+       }
+       if (uiapplication->extraid) {
+               free((void *)uiapplication->extraid);
+               uiapplication->extraid = NULL;
+       }
+       if (uiapplication->taskmanage) {
+               free((void *)uiapplication->taskmanage);
+               uiapplication->taskmanage = NULL;
+       }
+       if (uiapplication->enabled) {
+               free((void *)uiapplication->enabled);
+               uiapplication->enabled = NULL;
+       }
+       if (uiapplication->hwacceleration) {
+               free((void *)uiapplication->hwacceleration);
+               uiapplication->hwacceleration = NULL;
+       }
+       if (uiapplication->screenreader) {
+               free((void *)uiapplication->screenreader);
+               uiapplication->screenreader = NULL;
+       }
+       if (uiapplication->mainapp) {
+               free((void *)uiapplication->mainapp);
+               uiapplication->mainapp = NULL;
+       }
+       if (uiapplication->recentimage) {
+               free((void *)uiapplication->recentimage);
+               uiapplication->recentimage = NULL;
+       }
+       if (uiapplication->package) {
+               free((void *)uiapplication->package);
+               uiapplication->package = NULL;
+       }
+       if (uiapplication->launchcondition) {
+               free((void *)uiapplication->launchcondition);
+               uiapplication->launchcondition = NULL;
+       }
+       /*Free Label*/
+       if (uiapplication->label) {
+               label_x *label = uiapplication->label;
+               label_x *tmp = NULL;
+               while(label != NULL) {
+                       tmp = label->next;
+                       __ps_free_label(label);
+                       label = tmp;
+               }
+       }
+       /*Free Icon*/
+       if (uiapplication->icon) {
+               icon_x *icon = uiapplication->icon;
+               icon_x *tmp = NULL;
+               while(icon != NULL) {
+                       tmp = icon->next;
+                       __ps_free_icon(icon);
+                       icon = tmp;
+               }
+       }
+       /*Free image*/
+       if (uiapplication->image) {
+               image_x *image = uiapplication->image;
+               image_x *tmp = NULL;
+               while(image != NULL) {
+                       tmp = image->next;
+                       __ps_free_image(image);
+                       image = tmp;
+               }
+       }
+       /*Free AppControl*/
+       if (uiapplication->appcontrol) {
+               appcontrol_x *appcontrol = uiapplication->appcontrol;
+               appcontrol_x *tmp = NULL;
+               while(appcontrol != NULL) {
+                       tmp = appcontrol->next;
+                       __ps_free_appcontrol(appcontrol);
+                       appcontrol = tmp;
+               }
+       }
+       /*Free LaunchConditions*/
+       if (uiapplication->launchconditions) {
+               launchconditions_x *launchconditions = uiapplication->launchconditions;
+               launchconditions_x *tmp = NULL;
+               while(launchconditions != NULL) {
+                       tmp = launchconditions->next;
+                       __ps_free_launchconditions(launchconditions);
+                       launchconditions = tmp;
+               }
+       }
+       /*Free Notification*/
+       if (uiapplication->notification) {
+               notification_x *notification = uiapplication->notification;
+               notification_x *tmp = NULL;
+               while(notification != NULL) {
+                       tmp = notification->next;
+                       __ps_free_notification(notification);
+                       notification = tmp;
+               }
+       }
+       /*Free DataShare*/
+       if (uiapplication->datashare) {
+               datashare_x *datashare = uiapplication->datashare;
+               datashare_x *tmp = NULL;
+               while(datashare != NULL) {
+                       tmp = datashare->next;
+                       __ps_free_datashare(datashare);
+                       datashare = tmp;
+               }
+       }
+       /*Free AppSvc*/
+       if (uiapplication->appsvc) {
+               appsvc_x *appsvc = uiapplication->appsvc;
+               appsvc_x *tmp = NULL;
+               while(appsvc != NULL) {
+                       tmp = appsvc->next;
+                       __ps_free_appsvc(appsvc);
+                       appsvc = tmp;
+               }
+       }
+       /*Free Category*/
+       if (uiapplication->category) {
+               category_x *category = uiapplication->category;
+               category_x *tmp = NULL;
+               while(category != NULL) {
+                       tmp = category->next;
+                       __ps_free_category(category);
+                       category = tmp;
+               }
+       }
+       /*Free Metadata*/
+       if (uiapplication->metadata) {
+               metadata_x *metadata = uiapplication->metadata;
+               metadata_x *tmp = NULL;
+               while(metadata != NULL) {
+                       tmp = metadata->next;
+                       __ps_free_metadata(metadata);
+                       metadata = tmp;
+               }
+       }
+       /*Free permission*/
+       if (uiapplication->permission) {
+               permission_x *permission = uiapplication->permission;
+               permission_x *tmp = NULL;
+               while(permission != NULL) {
+                       tmp = permission->next;
+                       __ps_free_permission(permission);
+                       permission = tmp;
+               }
+       }
+       /*Free DataControl*/
+       if (uiapplication->datacontrol) {
+               datacontrol_x *datacontrol = uiapplication->datacontrol;
+               datacontrol_x *tmp = NULL;
+               while(datacontrol != NULL) {
+                       tmp = datacontrol->next;
+                       __ps_free_datacontrol(datacontrol);
+                       datacontrol = tmp;
+               }
+       }
+       /* _PRODUCT_LAUNCHING_ENHANCED_ START */
+       if (uiapplication->indicatordisplay) {
+               free((void *)uiapplication->indicatordisplay);
+               uiapplication->indicatordisplay = NULL;
+       }
+       if (uiapplication->portraitimg) {
+               free((void *)uiapplication->portraitimg);
+               uiapplication->portraitimg = NULL;
+       }
+       if (uiapplication->landscapeimg) {
+               free((void *)uiapplication->landscapeimg);
+               uiapplication->landscapeimg = NULL;
+       }
+       /* _PRODUCT_LAUNCHING_ENHANCED_ END */
+       if (uiapplication->guestmode_visibility) {
+               free((void *)uiapplication->guestmode_visibility);
+               uiapplication->guestmode_visibility = NULL;
+       }
+       if (uiapplication->app_component) {
+               free((void *)uiapplication->app_component);
+               uiapplication->app_component = NULL;
+       }
+       if (uiapplication->permission_type) {
+               free((void *)uiapplication->permission_type);
+               uiapplication->permission_type = NULL;
+       }
+       if (uiapplication->component_type) {
+               free((void *)uiapplication->component_type);
+               uiapplication->component_type = NULL;
+       }
+       if (uiapplication->preload) {
+               free((void *)uiapplication->preload);
+               uiapplication->preload = NULL;
+       }
+       if (uiapplication->submode) {
+               free((void *)uiapplication->submode);
+               uiapplication->submode = NULL;
+       }
+       if (uiapplication->submode_mainid) {
+               free((void *)uiapplication->submode_mainid);
+               uiapplication->submode_mainid = NULL;
+       }
+
+       free((void*)uiapplication);
+       uiapplication = NULL;
+}
+
+static void __ps_free_serviceapplication(serviceapplication_x *serviceapplication)
+{
+       if (serviceapplication == NULL)
+               return;
+       if (serviceapplication->exec) {
+               free((void *)serviceapplication->exec);
+               serviceapplication->exec = NULL;
+       }
+       if (serviceapplication->appid) {
+               free((void *)serviceapplication->appid);
+               serviceapplication->appid = NULL;
+       }
+       if (serviceapplication->onboot) {
+               free((void *)serviceapplication->onboot);
+               serviceapplication->onboot = NULL;
+       }
+       if (serviceapplication->autorestart) {
+               free((void *)serviceapplication->autorestart);
+               serviceapplication->autorestart = NULL;
+       }
+       if (serviceapplication->type) {
+               free((void *)serviceapplication->type);
+               serviceapplication->type = NULL;
+       }
+       if (serviceapplication->enabled) {
+               free((void *)serviceapplication->enabled);
+               serviceapplication->enabled = NULL;
+       }
+       if (serviceapplication->package) {
+               free((void *)serviceapplication->package);
+               serviceapplication->package = NULL;
+       }
+       if (serviceapplication->permission_type) {
+               free((void *)serviceapplication->permission_type);
+               serviceapplication->permission_type = NULL;
+       }
+       /*Free Label*/
+       if (serviceapplication->label) {
+               label_x *label = serviceapplication->label;
+               label_x *tmp = NULL;
+               while(label != NULL) {
+                       tmp = label->next;
+                       __ps_free_label(label);
+                       label = tmp;
+               }
+       }
+       /*Free Icon*/
+       if (serviceapplication->icon) {
+               icon_x *icon = serviceapplication->icon;
+               icon_x *tmp = NULL;
+               while(icon != NULL) {
+                       tmp = icon->next;
+                       __ps_free_icon(icon);
+                       icon = tmp;
+               }
+       }
+       /*Free AppControl*/
+       if (serviceapplication->appcontrol) {
+               appcontrol_x *appcontrol = serviceapplication->appcontrol;
+               appcontrol_x *tmp = NULL;
+               while(appcontrol != NULL) {
+                       tmp = appcontrol->next;
+                       __ps_free_appcontrol(appcontrol);
+                       appcontrol = tmp;
+               }
+       }
+       /*Free DataControl*/
+       if (serviceapplication->datacontrol) {
+               datacontrol_x *datacontrol = serviceapplication->datacontrol;
+               datacontrol_x *tmp = NULL;
+               while(datacontrol != NULL) {
+                       tmp = datacontrol->next;
+                       __ps_free_datacontrol(datacontrol);
+                       datacontrol = tmp;
+               }
+       }
+       /*Free LaunchConditions*/
+       if (serviceapplication->launchconditions) {
+               launchconditions_x *launchconditions = serviceapplication->launchconditions;
+               launchconditions_x *tmp = NULL;
+               while(launchconditions != NULL) {
+                       tmp = launchconditions->next;
+                       __ps_free_launchconditions(launchconditions);
+                       launchconditions = tmp;
+               }
+       }
+       /*Free Notification*/
+       if (serviceapplication->notification) {
+               notification_x *notification = serviceapplication->notification;
+               notification_x *tmp = NULL;
+               while(notification != NULL) {
+                       tmp = notification->next;
+                       __ps_free_notification(notification);
+                       notification = tmp;
+               }
+       }
+       /*Free DataShare*/
+       if (serviceapplication->datashare) {
+               datashare_x *datashare = serviceapplication->datashare;
+               datashare_x *tmp = NULL;
+               while(datashare != NULL) {
+                       tmp = datashare->next;
+                       __ps_free_datashare(datashare);
+                       datashare = tmp;
+               }
+       }
+       /*Free AppSvc*/
+       if (serviceapplication->appsvc) {
+               appsvc_x *appsvc = serviceapplication->appsvc;
+               appsvc_x *tmp = NULL;
+               while(appsvc != NULL) {
+                       tmp = appsvc->next;
+                       __ps_free_appsvc(appsvc);
+                       appsvc = tmp;
+               }
+       }
+       /*Free Category*/
+       if (serviceapplication->category) {
+               category_x *category = serviceapplication->category;
+               category_x *tmp = NULL;
+               while(category != NULL) {
+                       tmp = category->next;
+                       __ps_free_category(category);
+                       category = tmp;
+               }
+       }
+       /*Free Metadata*/
+       if (serviceapplication->metadata) {
+               metadata_x *metadata = serviceapplication->metadata;
+               metadata_x *tmp = NULL;
+               while(metadata != NULL) {
+                       tmp = metadata->next;
+                       __ps_free_metadata(metadata);
+                       metadata = tmp;
+               }
+       }
+       /*Free permission*/
+       if (serviceapplication->permission) {
+               permission_x *permission = serviceapplication->permission;
+               permission_x *tmp = NULL;
+               while(permission != NULL) {
+                       tmp = permission->next;
+                       __ps_free_permission(permission);
+                       permission = tmp;
+               }
+       }
+       free((void*)serviceapplication);
+       serviceapplication = NULL;
+}
+
+static void __ps_free_font(font_x *font)
+{
+       if (font == NULL)
+               return;
+       if (font->name) {
+               free((void *)font->name);
+               font->name = NULL;
+       }
+       if (font->text) {
+               free((void *)font->text);
+               font->text = NULL;
+       }
+       free((void*)font);
+       font = NULL;
+}
+
+static void __ps_free_theme(theme_x *theme)
+{
+       if (theme == NULL)
+               return;
+       if (theme->name) {
+               free((void *)theme->name);
+               theme->name = NULL;
+       }
+       if (theme->text) {
+               free((void *)theme->text);
+               theme->text = NULL;
+       }
+       free((void*)theme);
+       theme = NULL;
+}
+
+static void __ps_free_daemon(daemon_x *daemon)
+{
+       if (daemon == NULL)
+               return;
+       if (daemon->name) {
+               free((void *)daemon->name);
+               daemon->name = NULL;
+       }
+       if (daemon->text) {
+               free((void *)daemon->text);
+               daemon->text = NULL;
+       }
+       free((void*)daemon);
+       daemon = NULL;
+}
+
+static void __ps_free_ime(ime_x *ime)
+{
+       if (ime == NULL)
+               return;
+       if (ime->name) {
+               free((void *)ime->name);
+               ime->name = NULL;
+       }
+       if (ime->text) {
+               free((void *)ime->text);
+               ime->text = NULL;
+       }
+       free((void*)ime);
+       ime = NULL;
+}
+
+API void pkgmgrinfo_basic_free_application(application_x *application)
+{
+       if (application == NULL)
+               return;
+
+       if (application->appid)
+               free((void *)application->appid);
+       if (application->component)
+               free((void *)application->component);
+       if (application->exec)
+               free((void *)application->exec);
+       if (application->nodisplay)
+               free((void *)application->nodisplay);
+       if (application->type)
+               free((void *)application->type);
+       if (application->onboot)
+               free((void *)application->onboot);
+       if (application->multiple)
+               free((void *)application->multiple);
+       if (application->autorestart)
+               free((void *)application->autorestart);
+       if (application->taskmanage)
+               free((void *)application->taskmanage);
+       if (application->enabled)
+               free((void *)application->enabled);
+       if (application->hwacceleration)
+               free((void *)application->hwacceleration);
+       if (application->screenreader)
+               free((void *)application->screenreader);
+       if (application->mainapp)
+               free((void *)application->mainapp);
+       if (application->recentimage)
+               free((void *)application->recentimage);
+       if (application->launchcondition)
+               free((void *)application->launchcondition);
+       if (application->indicatordisplay)
+               free((void *)application->indicatordisplay);
+       if (application->portraitimg)
+               free((void *)application->portraitimg);
+       if (application->landscapeimg)
+               free((void *)application->landscapeimg);
+       if (application->guestmode_visibility)
+               free((void *)application->guestmode_visibility);
+       if (application->permission_type)
+               free((void *)application->permission_type);
+       if (application->preload)
+               free((void *)application->preload);
+       if (application->submode)
+               free((void *)application->submode);
+       if (application->submode_mainid)
+               free((void *)application->submode_mainid);
+       if (application->launch_mode)
+               free((void *)application->launch_mode);
+       if (application->component_type)
+               free((void *)application->component_type);
+       if (application->package)
+               free((void *)application->package);
+
+       /*Free Label*/
+       if (application->label) {
+               label_x *label = application->label;
+               label_x *tmp = NULL;
+               while(label != NULL) {
+                       tmp = label->next;
+                       __ps_free_label(label);
+                       label = tmp;
+               }
+       }
+       /*Free Icon*/
+       if (application->icon) {
+               icon_x *icon = application->icon;
+               icon_x *tmp = NULL;
+               while(icon != NULL) {
+                       tmp = icon->next;
+                       __ps_free_icon(icon);
+                       icon = tmp;
+               }
+       }
+       /*Free image*/
+       if (application->image) {
+               image_x *image = application->image;
+               image_x *tmp = NULL;
+               while(image != NULL) {
+                       tmp = image->next;
+                       __ps_free_image(image);
+                       image = tmp;
+               }
+       }
+       /*Free AppSvc*/
+       if (application->appsvc) {
+               appsvc_x *appsvc = application->appsvc;
+               appsvc_x *tmp = NULL;
+               while(appsvc != NULL) {
+                       tmp = appsvc->next;
+                       __ps_free_appsvc(appsvc);
+                       appsvc = tmp;
+               }
+       }
+       /*Free AppControl*/
+       if (application->appcontrol) {
+               appcontrol_x *appcontrol = application->appcontrol;
+               appcontrol_x *tmp = NULL;
+               while(appcontrol != NULL) {
+                       tmp = appcontrol->next;
+                       __ps_free_appcontrol(appcontrol);
+                       appcontrol = tmp;
+               }
+       }
+       /*Free Category*/
+       if (application->category) {
+               category_x *category = application->category;
+               category_x *tmp = NULL;
+               while(category != NULL) {
+                       tmp = category->next;
+                       __ps_free_category(category);
+                       category = tmp;
+               }
+       }
+       /*Free Metadata*/
+       if (application->metadata) {
+               metadata_x *metadata = application->metadata;
+               metadata_x *tmp = NULL;
+               while(metadata != NULL) {
+                       tmp = metadata->next;
+                       __ps_free_metadata(metadata);
+                       metadata = tmp;
+               }
+       }
+       /*Free permission*/
+       if (application->permission) {
+               permission_x *permission = application->permission;
+               permission_x *tmp = NULL;
+               while(permission != NULL) {
+                       tmp = permission->next;
+                       __ps_free_permission(permission);
+                       permission = tmp;
+               }
+       }
+       /*Free LaunchConditions*/
+       if (application->launchconditions) {
+               launchconditions_x *launchconditions = application->launchconditions;
+               launchconditions_x *tmp = NULL;
+               while(launchconditions != NULL) {
+                       tmp = launchconditions->next;
+                       __ps_free_launchconditions(launchconditions);
+                       launchconditions = tmp;
+               }
+       }
+       /*Free Notification*/
+       if (application->notification) {
+               notification_x *notification = application->notification;
+               notification_x *tmp = NULL;
+               while(notification != NULL) {
+                       tmp = notification->next;
+                       __ps_free_notification(notification);
+                       notification = tmp;
+               }
+       }
+       /*Free DataShare*/
+       if (application->datashare) {
+               datashare_x *datashare = application->datashare;
+               datashare_x *tmp = NULL;
+               while(datashare != NULL) {
+                       tmp = datashare->next;
+                       __ps_free_datashare(datashare);
+                       datashare = tmp;
+               }
+       }
+       /*Free DataControl*/
+       if (application->datacontrol) {
+               datacontrol_x *datacontrol = application->datacontrol;
+               datacontrol_x *tmp = NULL;
+               while(datacontrol != NULL) {
+                       tmp = datacontrol->next;
+                       __ps_free_datacontrol(datacontrol);
+                       datacontrol = tmp;
+               }
+       }
+}
+
+API void pkgmgrinfo_basic_free_package(package_x *package)
+{
+       if (package == NULL)
+               return;
+       if (package->ns) {
+               free((void *)package->ns);
+               package->ns = NULL;
+       }
+       if (package->package) {
+               free((void *)package->package);
+               package->package = NULL;
+       }
+       if (package->version) {
+               free((void *)package->version);
+               package->version = NULL;
+       }
+       if (package->installlocation) {
+               free((void *)package->installlocation);
+               package->installlocation = NULL;
+       }
+       if (package->preload) {
+               free((void *)package->preload);
+               package->preload = NULL;
+       }
+       if (package->readonly) {
+               free((void *)package->readonly);
+               package->readonly = NULL;
+       }
+       if (package->removable) {
+               free((void *)package->removable);
+               package->removable = NULL;
+       }
+       if (package->update) {
+               free((void *)package->update);
+               package->update = NULL;
+       }
+       if (package->system) {
+               free((void *)package->system);
+               package->system = NULL;
+       }
+       if (package->type) {
+               free((void *)package->type);
+               package->type = NULL;
+       }
+       if (package->package_size) {
+               free((void *)package->package_size);
+               package->package_size = NULL;
+       }
+       if (package->installed_time) {
+               free((void *)package->installed_time);
+               package->installed_time = NULL;
+       }
+       if (package->installed_storage) {
+               free((void *)package->installed_storage);
+               package->installed_storage = NULL;
+       }
+       if (package->storeclient_id) {
+               free((void *)package->storeclient_id);
+               package->storeclient_id = NULL;
+       }
+       if (package->mainapp_id) {
+               free((void *)package->mainapp_id);
+               package->mainapp_id = NULL;
+       }
+       if (package->package_url) {
+               free((void *)package->package_url);
+               package->package_url = NULL;
+       }
+       if (package->root_path) {
+               free((void *)package->root_path);
+               package->root_path = NULL;
+       }
+       if (package->csc_path) {
+               free((void *)package->csc_path);
+               package->csc_path = NULL;
+       }
+       if (package->appsetting) {
+               free((void *)package->appsetting);
+               package->appsetting = NULL;
+       }
+       if (package->nodisplay_setting) {
+               free((void *)package->nodisplay_setting);
+               package->nodisplay_setting = NULL;
+       }
+       if (package->api_version) {
+               free((void *)package->api_version);
+               package->api_version = NULL;
+       }
+
+       /*Free Icon*/
+       if (package->icon) {
+               icon_x *icon = package->icon;
+               icon_x *tmp = NULL;
+               while(icon != NULL) {
+                       tmp = icon->next;
+                       __ps_free_icon(icon);
+                       icon = tmp;
+               }
+       }
+       /*Free Label*/
+       if (package->label) {
+               label_x *label = package->label;
+               label_x *tmp = NULL;
+               while(label != NULL) {
+                       tmp = label->next;
+                       __ps_free_label(label);
+                       label = tmp;
+               }
+       }
+       /*Free Author*/
+       if (package->author) {
+               author_x *author = package->author;
+               author_x *tmp = NULL;
+               while(author != NULL) {
+                       tmp = author->next;
+                       __ps_free_author(author);
+                       author = tmp;
+               }
+       }
+       /*Free Description*/
+       if (package->description) {
+               description_x *description = package->description;
+               description_x *tmp = NULL;
+               while(description != NULL) {
+                       tmp = description->next;
+                       __ps_free_description(description);
+                       description = tmp;
+               }
+       }
+       /*Free License*/
+       if (package->license) {
+               license_x *license = package->license;
+               license_x *tmp = NULL;
+               while(license != NULL) {
+                       tmp = license->next;
+                       __ps_free_license(license);
+                       license = tmp;
+               }
+       }
+       /*Free Privileges*/
+       if (package->privileges) {
+               privileges_x *privileges = package->privileges;
+               privileges_x *tmp = NULL;
+               while(privileges != NULL) {
+                       tmp = privileges->next;
+                       __ps_free_privileges(privileges);
+                       privileges = tmp;
+               }
+       }
+       /*Free UiApplication*/
+       if (package->uiapplication) {
+               uiapplication_x *uiapplication = package->uiapplication;
+               uiapplication_x *tmp = NULL;
+               while(uiapplication != NULL) {
+                       tmp = uiapplication->next;
+                       __ps_free_uiapplication(uiapplication);
+                       uiapplication = tmp;
+               }
+       }
+       /*Free ServiceApplication*/
+       if (package->serviceapplication) {
+               serviceapplication_x *serviceapplication = package->serviceapplication;
+               serviceapplication_x *tmp = NULL;
+               while(serviceapplication != NULL) {
+                       tmp = serviceapplication->next;
+                       __ps_free_serviceapplication(serviceapplication);
+                       serviceapplication = tmp;
+               }
+       }
+       /*Free Daemon*/
+       if (package->daemon) {
+               daemon_x *daemon = package->daemon;
+               daemon_x *tmp = NULL;
+               while(daemon != NULL) {
+                       tmp = daemon->next;
+                       __ps_free_daemon(daemon);
+                       daemon = tmp;
+               }
+       }
+       /*Free Theme*/
+       if (package->theme) {
+               theme_x *theme = package->theme;
+               theme_x *tmp = NULL;
+               while(theme != NULL) {
+                       tmp = theme->next;
+                       __ps_free_theme(theme);
+                       theme = tmp;
+               }
+       }
+       /*Free Font*/
+       if (package->font) {
+               font_x *font = package->font;
+               font_x *tmp = NULL;
+               while(font != NULL) {
+                       tmp = font->next;
+                       __ps_free_font(font);
+                       font = tmp;
+               }
+       }
+       /*Free Ime*/
+       if (package->ime) {
+               ime_x *ime = package->ime;
+               ime_x *tmp = NULL;
+               while(ime != NULL) {
+                       tmp = ime->next;
+                       __ps_free_ime(ime);
+                       ime = tmp;
+               }
+       }
+       /*Free Compatibility*/
+       if (package->compatibility) {
+               compatibility_x *compatibility = package->compatibility;
+               compatibility_x *tmp = NULL;
+               while(compatibility != NULL) {
+                       tmp = compatibility->next;
+                       __ps_free_compatibility(compatibility);
+                       compatibility = tmp;
+               }
+       }
+       /*Free DeviceProfile*/
+       if (package->deviceprofile) {
+               deviceprofile_x *deviceprofile = package->deviceprofile;
+               deviceprofile_x *tmp = NULL;
+               while(deviceprofile != NULL) {
+                       tmp = deviceprofile->next;
+                       __ps_free_deviceprofile(deviceprofile);
+                       deviceprofile = tmp;
+               }
+       }
+       free((void*)package);
+       package = NULL;
+       return;
+}
+
index 70b6589..5e129c7 100644 (file)
@@ -81,7 +81,8 @@ static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
        {E_PMINFO_APPINFO_PROP_APP_MIME,        PMINFO_APPINFO_PROP_APP_MIME},
        {E_PMINFO_APPINFO_PROP_APP_CATEGORY,    PMINFO_APPINFO_PROP_APP_CATEGORY},
        {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,      PMINFO_APPINFO_PROP_APP_HWACCELERATION},
-       {E_PMINFO_APPINFO_PROP_APP_SCREENREADER,        PMINFO_APPINFO_PROP_APP_SCREENREADER}
+       {E_PMINFO_APPINFO_PROP_APP_SCREENREADER,        PMINFO_APPINFO_PROP_APP_SCREENREADER},
+       {E_PMINFO_APPINFO_PROP_APP_PACKAGE,     PMINFO_APPINFO_PROP_APP_PACKAGE}
 };
 
 struct _appinfo_int_map_t {
index c46a13d..a2b62b6 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <db-util.h>
-#include <sqlite3.h>
-#include <vconf.h>
-#include <glib.h>
 #include <ctype.h>
 #include <assert.h>
 #include <dlfcn.h>
 #include <linux/limits.h>
 #include <libgen.h>
 #include <grp.h>
+#include <dirent.h>
+#include <sys/stat.h>
 
 #include <libxml/parser.h>
 #include <libxml/xmlreader.h>
 #include <libxml/xmlschemas.h>
-
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib-lowlevel.h>
+#include <sqlite3.h>
+#include <glib.h>
 
+#include <db-util.h>
+#include <vconf.h>
 /* For multi-user support */
 #include <tzplatform_config.h>
 
 #include "pkgmgr_parser.h"
+#include "pkgmgr-info-basic.h"
 #include "pkgmgr-info-internal.h"
 #include "pkgmgr-info-debug.h"
 #include "pkgmgr-info.h"
 #include "pkgmgr_parser_db.h"
 #include "pkgmgr_parser_internal.h"
-#include <dirent.h>
-#include <sys/stat.h>
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -141,7 +141,7 @@ typedef struct _pkgmgr_certindexinfo_x {
 
 typedef struct _pkgmgr_pkginfo_x {
        uid_t uid;
-       manifest_x *manifest_info;
+       package_x *pkg_info;
        char *locale;
 
        struct _pkgmgr_pkginfo_x *prev;
@@ -178,7 +178,10 @@ typedef struct _pkgmgr_appinfo_x {
        union {
                uiapplication_x *uiapp_info;
                serviceapplication_x *svcapp_info;
+               application_x *app_info;
        };
+       struct _pkgmgr_appinfo_x *prev;
+       struct _pkgmgr_appinfo_x *next;
 } pkgmgr_appinfo_x;
 
 typedef struct _pkgmgr_certinfo_x {
@@ -286,20 +289,13 @@ static int __open_manifest_db(uid_t uid);
 static int __close_manifest_db(void);
 static int __open_cert_db(uid_t uid, char* mode);
 static int __close_cert_db(void);
-static int __exec_pkginfo_query(char *query, void *data);
 static int __exec_certinfo_query(char *query, void *data);
 static int __exec_certindexinfo_query(char *query, void *data);
-static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
@@ -310,6 +306,11 @@ static gint __compare_func(gconstpointer data1, gconstpointer data2);
 static int __delete_certinfo(const char *pkgid, uid_t uid);
 static int _check_create_Cert_db( sqlite3 *certdb);
 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data);
+static char *_get_system_locale(void);
+static int _pkginfo_get_pkg(const char *locale, pkgmgrinfo_filter_x *filter,
+               pkgmgr_pkginfo_x **pkginfo);
+static int _appinfo_get_app(const char *locale, pkgmgrinfo_filter_x *filter,
+               pkgmgr_appinfo_x **appinfo);
 
 static int _mkdir_for_user(const char* dir, uid_t uid, gid_t gid)
 {
@@ -366,21 +367,25 @@ static int __attach_and_create_view(sqlite3 *handle, const char *db, const char
        char *err;
        char query[MAX_QUERY_LEN];
 
-       if (uid == GLOBAL_USER || uid == ROOT_UID)
-               return SQLITE_OK;
-
-       snprintf(query, sizeof(query), "ATTACH DATABASE '%s' AS Global", db);
-       if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
-               _LOGD("Don't execute query = %s error message = %s\n", query, err);
-               sqlite3_free(err);
-               return SQLITE_ERROR;
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               snprintf(query, sizeof(query), "ATTACH DATABASE '%s' AS Global", db);
+               if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
+                       _LOGD("Don't execute query = %s error message = %s\n", query, err);
+                       sqlite3_free(err);
+                       return SQLITE_ERROR;
+               }
        }
 
        for (i = 0; tables[i]; i++) {
-               snprintf(query, sizeof(query), "CREATE TEMP VIEW '%s' AS SELECT * \
-                               FROM (SELECT *,0 AS for_all_users FROM  main.'%s' UNION \
-                               SELECT *,1 AS for_all_users FROM Global.'%s')",
-                               tables[i], tables[i], tables[i]);
+               if (uid != GLOBAL_USER && uid != ROOT_UID)
+                       snprintf(query, sizeof(query), "CREATE TEMP VIEW '%s' AS SELECT * \
+                                       FROM (SELECT *,0 AS for_all_users FROM main.'%s' UNION \
+                                       SELECT *,1 AS for_all_users FROM Global.'%s')",
+                                       tables[i], tables[i], tables[i]);
+               else
+                       snprintf(query, sizeof(query), "CREATE TEMP VIEW '%s' AS SELECT * \
+                                       FROM (SELECT *,1 AS for_all_users FROM main.'%s')",
+                                       tables[i], tables[i]);
                if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
                        _LOGD("Don't execute query = %s error message = %s\n", query, err);
                        sqlite3_free(err);
@@ -701,6 +706,9 @@ static void __get_filter_condition(gpointer data, char **condition)
        case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
                snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
                break;
+       case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
+               snprintf(buf, MAX_QUERY_LEN, "package_app_info.package='%s'", node->value);
+               break;
        default:
                _LOGE("Invalid Property Type\n");
                *condition = NULL;
@@ -733,7 +741,7 @@ static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
                data->locale = NULL;
        }
 
-       pkgmgr_parser_free_manifest_xml(data->manifest_info);
+       pkgmgrinfo_basic_free_package(data->pkg_info);
        free((void *)data);
        data = NULL;
        return;
@@ -751,12 +759,7 @@ static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
                data->locale = NULL;
        }
 
-       manifest_x *mfx = calloc(1, sizeof(manifest_x));
-       if (data->app_component == PMINFO_UI_APP)
-               mfx->uiapplication = data->uiapp_info;
-       else if (data->app_component == PMINFO_SVC_APP)
-               mfx->serviceapplication = data->svcapp_info;
-       pkgmgr_parser_free_manifest_xml(mfx);
+       pkgmgrinfo_basic_free_application(data->app_info);
        free((void *)data);
        data = NULL;
        return;
@@ -893,527 +896,6 @@ static int __open_datacontrol_db()
        return -1;
 }
 
-static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       pkgmgr_pkginfo_x *info = NULL;
-       info = calloc(1, sizeof(pkgmgr_pkginfo_x));
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-
-       LISTADD(udata, info);
-
-       for(i = 0; i < ncols; i++)
-       {
-               if (strcmp(colname[i], "package") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->package = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->package = NULL;
-               } else if (strcmp(colname[i], "for_all_users") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->for_all_users = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->for_all_users = NULL;      
-               } else
-                       continue;
-       }
-       
-       //by default if views are not set , the column for_all_users doesn't exist,
-       // in this case we assume we retreive information about app avaible for all users
-       if (!info->manifest_info->for_all_users)
-               info->manifest_info->for_all_users = strdup("1");
-
-       return 0;
-}
-
-static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       int j = 0;
-       uiapplication_x *uiapp = NULL;
-       serviceapplication_x *svcapp = NULL;
-       for(i = 0; i < ncols; i++)
-       {
-               if ((strcmp(colname[i], "app_component") == 0) ||
-                       (strcmp(colname[i], "package_app_info.app_component") == 0)) {
-                       if (coltxt[i]) {
-                               if (strcmp(coltxt[i], "uiapp") == 0) {
-                                       uiapp = calloc(1, sizeof(uiapplication_x));
-                                       if (uiapp == NULL) {
-                                               _LOGE("Out of Memory!!!\n");
-                                               return -1;
-                                       }
-                                       LISTADD(info->manifest_info->uiapplication, uiapp);
-                                       for(j = 0; j < ncols; j++)
-                                       {
-                                               if ((strcmp(colname[j], "app_id") == 0) ||
-                                                       (strcmp(colname[j], "package_app_info.app_id") == 0)) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
-                                               } else if (strcmp(colname[j], "package") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->package = strdup(coltxt[j]);
-                                               } else
-                                                       continue;
-                                       }
-                               } else {
-                                       svcapp = calloc(1, sizeof(serviceapplication_x));
-                                       if (svcapp == NULL) {
-                                               _LOGE("Out of Memory!!!\n");
-                                               return -1;
-                                       }
-                                       LISTADD(info->manifest_info->serviceapplication, svcapp);
-                                       for(j = 0; j < ncols; j++)
-                                       {
-                                               if ((strcmp(colname[j], "app_id") == 0) ||
-                                                       (strcmp(colname[j], "package_app_info.app_id") == 0)) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
-                                               } else if (strcmp(colname[j], "package") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
-                                               } else
-                                                       continue;
-                                       }
-                               }
-                       }
-               } else
-                       continue;
-       }
-
-       return 0;
-}
-
-
-static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       uiapplication_x *uiapp = NULL;
-       icon_x *icon = NULL;
-       label_x *label = NULL;
-
-       uiapp = calloc(1, sizeof(uiapplication_x));
-       LISTADD(info->manifest_info->uiapplication, uiapp);
-       icon = calloc(1, sizeof(icon_x));
-       LISTADD(info->manifest_info->uiapplication->icon, icon);
-       label = calloc(1, sizeof(label_x));
-       LISTADD(info->manifest_info->uiapplication->label, label);
-
-       for(i = 0; i < ncols; i++)
-       {
-               if (strcmp(colname[i], "app_id") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->appid = NULL;
-               } else if (strcmp(colname[i], "app_exec") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->exec = NULL;
-               } else if (strcmp(colname[i], "app_type") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->type = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->type = NULL;
-               } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->nodisplay = NULL;
-               } else if (strcmp(colname[i], "app_multiple") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->multiple = NULL;
-               } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->taskmanage = NULL;
-               } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->hwacceleration = NULL;
-               } else if (strcmp(colname[i], "app_screenreader") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->screenreader = NULL;
-               } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->indicatordisplay = NULL;
-               } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->portraitimg = NULL;
-               } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->landscapeimg = NULL;
-               } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->guestmode_visibility = NULL;
-               } else if (strcmp(colname[i], "package") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->package = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->package = NULL;
-               } else if (strcmp(colname[i], "app_icon") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->icon->text = NULL;
-               } else if (strcmp(colname[i], "app_enabled") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->enabled = NULL;
-               } else if (strcmp(colname[i], "app_label") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->label->text = NULL;
-               } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->recentimage = NULL;
-               } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->mainapp = NULL;
-               } else if (strcmp(colname[i], "app_locale") == 0 ) {
-                       if (coltxt[i]) {
-                               info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
-                               info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
-                       }
-                       else {
-                               info->manifest_info->uiapplication->icon->lang = NULL;
-                               info->manifest_info->uiapplication->label->lang = NULL;
-                       }
-               } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->permission_type = NULL;
-               } else if (strcmp(colname[i], "component_type") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->component_type = NULL;
-               } else if (strcmp(colname[i], "app_preload") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->preload = NULL;
-               } else if (strcmp(colname[i], "app_submode") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->submode = NULL;
-               } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->submode_mainid = NULL;
-               } else if (strcmp(colname[i], "app_launch_mode") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->uiapplication->launch_mode = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->uiapplication->launch_mode = NULL;
-               } else
-                       continue;
-       }
-       return 0;
-}
-
-static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       serviceapplication_x *svcapp = NULL;
-       icon_x *icon = NULL;
-       label_x *label = NULL;
-
-       svcapp = calloc(1, sizeof(serviceapplication_x));
-       LISTADD(info->manifest_info->serviceapplication, svcapp);
-       icon = calloc(1, sizeof(icon_x));
-       LISTADD(info->manifest_info->serviceapplication->icon, icon);
-       label = calloc(1, sizeof(label_x));
-       LISTADD(info->manifest_info->serviceapplication->label, label);
-       for(i = 0; i < ncols; i++)
-       {
-               if (strcmp(colname[i], "app_id") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->appid = NULL;
-               } else if (strcmp(colname[i], "app_exec") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->exec = NULL;
-               } else if (strcmp(colname[i], "app_type") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->type = NULL;
-               } else if (strcmp(colname[i], "app_onboot") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->onboot = NULL;
-               } else if (strcmp(colname[i], "app_autorestart") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->autorestart = NULL;
-               } else if (strcmp(colname[i], "package") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->package = NULL;
-               } else if (strcmp(colname[i], "app_icon") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->icon->text = NULL;
-               } else if (strcmp(colname[i], "app_label") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->label->text = NULL;
-               } else if (strcmp(colname[i], "app_locale") == 0 ) {
-                       if (coltxt[i]) {
-                               info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
-                               info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
-                       }
-                       else {
-                               info->manifest_info->serviceapplication->icon->lang = NULL;
-                               info->manifest_info->serviceapplication->label->lang = NULL;
-                       }
-               } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                       if (coltxt[i])
-                               info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->serviceapplication->permission_type = NULL;
-               } else
-                       continue;
-       }
-       return 0;
-}
-
-static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       int j = 0;
-       uiapplication_x *uiapp = NULL;
-       serviceapplication_x *svcapp = NULL;
-       for(j = 0; j < ncols; j++)
-       {
-               if (strcmp(colname[j], "app_component") == 0) {
-                       if (coltxt[j]) {
-                               if (strcmp(coltxt[j], "uiapp") == 0) {
-                                       uiapp = calloc(1, sizeof(uiapplication_x));
-                                       if (uiapp == NULL) {
-                                               _LOGE("Out of Memory!!!\n");
-                                               return -1;
-                                       }
-                                       LISTADD(info->manifest_info->uiapplication, uiapp);
-                                       for(i = 0; i < ncols; i++)
-                                       {
-                                               if (strcmp(colname[i], "app_id") == 0) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->appid = NULL;
-                                               } else if (strcmp(colname[i], "app_exec") == 0) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->exec = NULL;
-                                               } else if (strcmp(colname[i], "app_type") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->type = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->type = NULL;
-                                               } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->nodisplay = NULL;
-                                               } else if (strcmp(colname[i], "app_multiple") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->multiple = NULL;
-                                               } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->taskmanage = NULL;
-                                               } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->hwacceleration = NULL;
-                                               } else if (strcmp(colname[i], "app_screenreader") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->screenreader = NULL;
-                                               } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->indicatordisplay = NULL;
-                                               } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->portraitimg = NULL;
-                                               } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->landscapeimg = NULL;
-                                               } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->guestmode_visibility = NULL;
-                                               } else if (strcmp(colname[i], "package") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->package = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->package = NULL;
-                                               } else if (strcmp(colname[i], "app_icon") == 0) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->icon->text = NULL;
-                                               } else if (strcmp(colname[i], "app_label") == 0 ) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->label->text = NULL;
-                                               } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->recentimage = NULL;
-                                               } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->mainapp = NULL;
-                                               } else if (strcmp(colname[i], "app_locale") == 0 ) {
-                                                       if (coltxt[i]) {
-                                                               info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
-                                                               info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
-                                                       }
-                                                       else {
-                                                               info->manifest_info->uiapplication->icon->lang = NULL;
-                                                               info->manifest_info->uiapplication->label->lang = NULL;
-                                                       }
-                                               } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->uiapplication->permission_type = NULL;
-                                               } else
-                                                       continue;
-                                       }
-                               } else {
-                                       svcapp = calloc(1, sizeof(serviceapplication_x));
-                                       if (svcapp == NULL) {
-                                               _LOGE("Out of Memory!!!\n");
-                                               return -1;
-                                       }
-                                       LISTADD(info->manifest_info->serviceapplication, svcapp);
-                                       for(i = 0; i < ncols; i++)
-                                       {
-                                               if (strcmp(colname[i], "app_id") == 0) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->appid = NULL;
-                                               } else if (strcmp(colname[i], "app_exec") == 0) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->exec = NULL;
-                                               } else if (strcmp(colname[i], "app_type") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->type = NULL;
-                                               } else if (strcmp(colname[i], "app_onboot") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->onboot = NULL;
-                                               } else if (strcmp(colname[i], "app_autorestart") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->autorestart = NULL;
-                                               } else if (strcmp(colname[i], "package") == 0 ){
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->package = NULL;
-                                               } else if (strcmp(colname[i], "app_icon") == 0) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->icon->text = NULL;
-                                               } else if (strcmp(colname[i], "app_label") == 0 ) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->label->text = NULL;
-                                               } else if (strcmp(colname[i], "app_locale") == 0 ) {
-                                                       if (coltxt[i]) {
-                                                               info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
-                                                               info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
-                                                       }
-                                                       else {
-                                                               info->manifest_info->serviceapplication->icon->lang = NULL;
-                                                               info->manifest_info->serviceapplication->label->lang = NULL;
-                                                       }
-                                               } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                                                       if (coltxt[i])
-                                                               info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->permission_type = NULL;
-                                               } else
-                                                       continue;
-                                       }
-                               }
-                       }
-               } else
-                       continue;
-       }
-
-       return 0;
-}
-
-
-
 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
 {
        int *p = (int*)data;
@@ -1429,168 +911,6 @@ static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
        return 0;
 }
 
-static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       author_x *author = NULL;
-       icon_x *icon = NULL;
-       label_x *label = NULL;
-       description_x *description = NULL;
-       privilege_x *privilege = NULL;
-
-       author = calloc(1, sizeof(author_x));
-       LISTADD(info->manifest_info->author, author);
-       icon = calloc(1, sizeof(icon_x));
-       LISTADD(info->manifest_info->icon, icon);
-       label = calloc(1, sizeof(label_x));
-       LISTADD(info->manifest_info->label, label);
-       description = calloc(1, sizeof(description_x));
-       LISTADD(info->manifest_info->description, description);
-       privilege = calloc(1, sizeof(privilege_x));
-       LISTADD(info->manifest_info->privileges->privilege, privilege);
-       for(i = 0; i < ncols; i++)
-       {
-               if (strcmp(colname[i], "package_version") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->version = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->version = NULL;
-               } else if (strcmp(colname[i], "package_type") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->type = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->type = NULL;
-               } else if (strcmp(colname[i], "install_location") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->installlocation = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->installlocation = NULL;
-               } else if (strcmp(colname[i], "package_size") == 0) {
-                       if (coltxt[i])
-                               info->manifest_info->package_size = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->package_size = NULL;
-               } else if (strcmp(colname[i], "author_email") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->author->email = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->author->email = NULL;
-               } else if (strcmp(colname[i], "author_href") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->author->href = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->author->href = NULL;
-               } else if (strcmp(colname[i], "package_label") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->label->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->label->text = NULL;
-               } else if (strcmp(colname[i], "package_icon") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->icon->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->icon->text = NULL;
-               } else if (strcmp(colname[i], "package_description") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->description->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->description->text = NULL;
-               } else if (strcmp(colname[i], "package_author") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->author->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->author->text = NULL;
-               } else if (strcmp(colname[i], "package_removable") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->removable = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->removable = NULL;
-               } else if (strcmp(colname[i], "package_preload") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->preload = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->preload = NULL;
-               } else if (strcmp(colname[i], "package_readonly") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->readonly = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->readonly = NULL;
-               } else if (strcmp(colname[i], "package_update") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->update= strdup(coltxt[i]);
-                       else
-                               info->manifest_info->update = NULL;
-               } else if (strcmp(colname[i], "package_system") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->system= strdup(coltxt[i]);
-                       else
-                               info->manifest_info->system = NULL;
-               } else if (strcmp(colname[i], "package_appsetting") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->appsetting = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->appsetting = NULL;
-               } else if (strcmp(colname[i], "installed_time") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->installed_time = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->installed_time = NULL;
-               } else if (strcmp(colname[i], "installed_storage") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->installed_storage = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->installed_storage = NULL;
-               } else if (strcmp(colname[i], "mainapp_id") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->mainapp_id = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->mainapp_id = NULL;
-               } else if (strcmp(colname[i], "storeclient_id") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->storeclient_id = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->storeclient_id = NULL;
-               } else if (strcmp(colname[i], "root_path") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->root_path = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->root_path = NULL;
-               } else if (strcmp(colname[i], "csc_path") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->csc_path = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->csc_path = NULL;
-               } else if (strcmp(colname[i], "privilege") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->privileges->privilege->text = NULL;
-               } else if (strcmp(colname[i], "package_locale") == 0 ){
-                       if (coltxt[i]) {
-                               info->manifest_info->author->lang = strdup(coltxt[i]);
-                               info->manifest_info->icon->lang = strdup(coltxt[i]);
-                               info->manifest_info->label->lang = strdup(coltxt[i]);
-                               info->manifest_info->description->lang = strdup(coltxt[i]);
-                       }
-                       else {
-                               info->manifest_info->author->lang = NULL;
-                               info->manifest_info->icon->lang = NULL;
-                               info->manifest_info->label->lang = NULL;
-                               info->manifest_info->description->lang = NULL;
-                       }
-               } else if (strcmp(colname[i], "package_url") == 0 ){
-                       if (coltxt[i])
-                               info->manifest_info->package_url = strdup(coltxt[i]);
-                       else
-                               info->manifest_info->package_url = NULL;
-               } else
-                       continue;
-       }
-       return 0;
-}
-
-
 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
 {
        if ( strcasecmp(comp, "uiapp") == 0)
@@ -1693,197 +1013,7 @@ static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
        return 0;
 }
 
-static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
-       int i = 0;
-       int j = 0;
-       uiapplication_x *uiapp = NULL;
-       serviceapplication_x *svcapp = NULL;
-       for(i = 0; i < ncols; i++)
-       {
-               if (strcmp(colname[i], "app_component") == 0) {
-                       if (coltxt[i]) {
-                               if (strcmp(coltxt[i], "uiapp") == 0) {
-                                       uiapp = calloc(1, sizeof(uiapplication_x));
-                                       if (uiapp == NULL) {
-                                               _LOGE("Out of Memory!!!\n");
-                                               return -1;
-                                       }
-                                       LISTADD(info->manifest_info->uiapplication, uiapp);
-                                       for(j = 0; j < ncols; j++)
-                                       {
-                                               if (strcmp(colname[j], "app_id") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
-                                               } else if (strcmp(colname[j], "app_exec") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->exec = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->exec = NULL;
-                                               } else if (strcmp(colname[j], "app_nodisplay") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->nodisplay = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->nodisplay = NULL;
-                                               } else if (strcmp(colname[j], "app_type") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->type = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->type = NULL;
-                                               } else if (strcmp(colname[j], "app_multiple") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->multiple = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->multiple = NULL;
-                                               } else if (strcmp(colname[j], "app_taskmanage") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->taskmanage = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->taskmanage = NULL;
-                                               } else if (strcmp(colname[j], "app_hwacceleration") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->hwacceleration = NULL;
-                                               } else if (strcmp(colname[j], "app_screenreader") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->screenreader = NULL;
-                                               } else if (strcmp(colname[j], "app_enabled") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->enabled= strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->enabled = NULL;
-                                               } else if (strcmp(colname[j], "app_indicatordisplay") == 0){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->indicatordisplay = NULL;
-                                               } else if (strcmp(colname[j], "app_portraitimg") == 0){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->portraitimg = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->portraitimg = NULL;
-                                               } else if (strcmp(colname[j], "app_landscapeimg") == 0){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->landscapeimg = NULL;
-                                               } else if (strcmp(colname[j], "app_guestmodevisibility") == 0){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->guestmode_visibility = NULL;
-                                               } else if (strcmp(colname[j], "app_recentimage") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->recentimage = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->recentimage = NULL;
-                                               } else if (strcmp(colname[j], "app_mainapp") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->mainapp = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->mainapp = NULL;
-                                               } else if (strcmp(colname[j], "package") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->package = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->package = NULL;
-                                               } else if (strcmp(colname[j], "app_component") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->app_component = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->app_component = NULL;
-                                               } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->permission_type = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->permission_type = NULL;
-                                               } else if (strcmp(colname[j], "component_type") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->component_type = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->component_type = NULL;
-                                               } else if (strcmp(colname[j], "app_preload") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->preload = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->preload = NULL;
-                                               } else if (strcmp(colname[j], "app_submode") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->submode = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->submode = NULL;
-                                               } else if (strcmp(colname[j], "app_submode_mainid") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->submode_mainid = NULL;
-                                               } else if (strcmp(colname[j], "app_launch_mode") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->uiapplication->launch_mode = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->uiapplication->launch_mode = NULL;
-                                               } else
-                                                       continue;
-                                       }
-                               } else {
-                                       svcapp = calloc(1, sizeof(serviceapplication_x));
-                                       if (svcapp == NULL) {
-                                               _LOGE("Out of Memory!!!\n");
-                                               return -1;
-                                       }
-                                       LISTADD(info->manifest_info->serviceapplication, svcapp);
-                                       for(j = 0; j < ncols; j++)
-                                       {
-                                               if (strcmp(colname[j], "app_id") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
-                                               } else if (strcmp(colname[j], "app_exec") == 0) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->exec = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->exec = NULL;
-                                               } else if (strcmp(colname[j], "app_type") == 0 ){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->type = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->type = NULL;
-                                               } else if (strcmp(colname[j], "app_onboot") == 0 ){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->onboot = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->onboot = NULL;
-                                               } else if (strcmp(colname[j], "app_autorestart") == 0 ){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->autorestart = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->autorestart = NULL;
-                                               } else if (strcmp(colname[j], "package") == 0 ){
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->package = NULL;
-                                               } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
-                                                       if (coltxt[j])
-                                                               info->manifest_info->serviceapplication->permission_type = strdup(coltxt[j]);
-                                                       else
-                                                               info->manifest_info->serviceapplication->permission_type = NULL;
-                                               } else
-                                                       continue;
-                                       }
-                               }
-                       }
-               } else
-                       continue;
-       }
-
-       return 0;
-}
-
-static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
+static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
 {
        char *dup;
        char *token;
@@ -1911,336 +1041,6 @@ static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
        free(dup);
 }
 
-static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
-       int i = 0;
-       icon_x *icon = NULL;
-       label_x *label = NULL;
-       category_x *category = NULL;
-       metadata_x *metadata = NULL;
-       permission_x *permission = NULL;
-       image_x *image = NULL;
-
-       switch (info->app_component) {
-       case PMINFO_UI_APP:
-               icon = calloc(1, sizeof(icon_x));
-               LISTADD(info->uiapp_info->icon, icon);
-               label = calloc(1, sizeof(label_x));
-               LISTADD(info->uiapp_info->label, label);
-               category = calloc(1, sizeof(category_x));
-               LISTADD(info->uiapp_info->category, category);
-               metadata = calloc(1, sizeof(metadata_x));
-               LISTADD(info->uiapp_info->metadata, metadata);
-               permission = calloc(1, sizeof(permission_x));
-               LISTADD(info->uiapp_info->permission, permission);
-               image = calloc(1, sizeof(image_x));
-               LISTADD(info->uiapp_info->image, image);
-
-               for(i = 0; i < ncols; i++)
-               {
-                       if (strcmp(colname[i], "app_id") == 0) {
-                               /*appid being foreign key, is column in every table
-                               Hence appid gets strduped every time leading to memory leak.
-                               If appid is already set, just continue.*/
-                               if (info->uiapp_info->appid)
-                                       continue;
-                               if (coltxt[i])
-                                       info->uiapp_info->appid = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->appid = NULL;
-                       } else if (strcmp(colname[i], "app_exec") == 0) {
-                               if (coltxt[i])
-                                       info->uiapp_info->exec = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->exec = NULL;
-                       } else if (strcmp(colname[i], "app_nodisplay") == 0) {
-                               if (coltxt[i])
-                                       info->uiapp_info->nodisplay = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->nodisplay = NULL;
-                       } else if (strcmp(colname[i], "app_type") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->type = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->type = NULL;
-                       } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->icon->section= strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->icon->section = NULL;
-                       } else if (strcmp(colname[i], "app_icon") == 0) {
-                               if (coltxt[i])
-                                       info->uiapp_info->icon->text = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->icon->text = NULL;
-                       } else if (strcmp(colname[i], "app_label") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->label->text = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->label->text = NULL;
-                       } else if (strcmp(colname[i], "app_multiple") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->multiple = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->multiple = NULL;
-                       } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->taskmanage = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->taskmanage = NULL;
-                       } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->hwacceleration = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->hwacceleration = NULL;
-                       } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->screenreader = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->screenreader = NULL;
-                       } else if (strcmp(colname[i], "app_enabled") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->enabled= strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->enabled = NULL;
-                       } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
-                               if (coltxt[i])
-                                       info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->indicatordisplay = NULL;
-                       } else if (strcmp(colname[i], "app_portraitimg") == 0){
-                               if (coltxt[i])
-                                       info->uiapp_info->portraitimg = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->portraitimg = NULL;
-                       } else if (strcmp(colname[i], "app_landscapeimg") == 0){
-                               if (coltxt[i])
-                                       info->uiapp_info->landscapeimg = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->landscapeimg = NULL;
-                       } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
-                               if (coltxt[i])
-                                       info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->guestmode_visibility = NULL;
-                       } else if (strcmp(colname[i], "category") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->category->name = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->category->name = NULL;
-                       } else if (strcmp(colname[i], "md_key") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->metadata->key = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->metadata->key = NULL;
-                       } else if (strcmp(colname[i], "md_value") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->metadata->value = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->metadata->value = NULL;
-                       } else if (strcmp(colname[i], "pm_type") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->permission->type= strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->permission->type = NULL;
-                       } else if (strcmp(colname[i], "pm_value") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->permission->value = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->permission->value = NULL;
-                       } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->recentimage = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->recentimage = NULL;
-                       } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->mainapp = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->mainapp = NULL;
-                       } else if (strcmp(colname[i], "app_locale") == 0 ) {
-                               if (coltxt[i]) {
-                                       info->uiapp_info->icon->lang = strdup(coltxt[i]);
-                                       info->uiapp_info->label->lang = strdup(coltxt[i]);
-                               }
-                               else {
-                                       info->uiapp_info->icon->lang = NULL;
-                                       info->uiapp_info->label->lang = NULL;
-                               }
-                       } else if (strcmp(colname[i], "app_image") == 0) {
-                                       if (coltxt[i])
-                                               info->uiapp_info->image->text= strdup(coltxt[i]);
-                                       else
-                                               info->uiapp_info->image->text = NULL;
-                       } else if (strcmp(colname[i], "app_image_section") == 0) {
-                                       if (coltxt[i])
-                                               info->uiapp_info->image->section= strdup(coltxt[i]);
-                                       else
-                                               info->uiapp_info->image->section = NULL;
-                       } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->permission_type = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->permission_type = NULL;
-                       } else if (strcmp(colname[i], "component_type") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->component_type = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->component_type = NULL;
-                       } else if (strcmp(colname[i], "app_preload") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->preload = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->preload = NULL;
-                       } else if (strcmp(colname[i], "app_submode") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->submode = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->submode = NULL;
-                       } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->submode_mainid = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->submode_mainid = NULL;
-                       } else if (strcmp(colname[i], "app_launch_mode") == 0 ) {
-                               if (coltxt[i])
-                                       info->uiapp_info->launch_mode = strdup(coltxt[i]);
-                               else
-                                       info->uiapp_info->launch_mode = NULL;
-                       } else if (strcmp(colname[i], "app_control") == 0 ) {
-                               __parse_appcontrol(&info->uiapp_info->appcontrol, coltxt[i]);
-                       } else
-                               continue;
-               }
-               break;
-       case PMINFO_SVC_APP:
-               icon = calloc(1, sizeof(icon_x));
-               LISTADD(info->svcapp_info->icon, icon);
-               label = calloc(1, sizeof(label_x));
-               LISTADD(info->svcapp_info->label, label);
-               category = calloc(1, sizeof(category_x));
-               LISTADD(info->svcapp_info->category, category);
-               metadata = calloc(1, sizeof(metadata_x));
-               LISTADD(info->svcapp_info->metadata, metadata);
-               permission = calloc(1, sizeof(permission_x));
-               LISTADD(info->svcapp_info->permission, permission);
-               for(i = 0; i < ncols; i++)
-               {
-                       if (strcmp(colname[i], "app_id") == 0) {
-                               /*appid being foreign key, is column in every table
-                               Hence appid gets strduped every time leading to memory leak.
-                               If appid is already set, just continue.*/
-                               if (info->svcapp_info->appid)
-                                       continue;
-                               if (coltxt[i])
-                                       info->svcapp_info->appid = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->appid = NULL;
-                       } else if (strcmp(colname[i], "app_exec") == 0) {
-                               if (coltxt[i])
-                                       info->svcapp_info->exec = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->exec = NULL;
-                       } else if (strcmp(colname[i], "app_icon") == 0) {
-                               if (coltxt[i])
-                                       info->svcapp_info->icon->text = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->icon->text = NULL;
-                       } else if (strcmp(colname[i], "app_label") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->label->text = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->label->text = NULL;
-                       } else if (strcmp(colname[i], "app_type") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->type = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->type = NULL;
-                       } else if (strcmp(colname[i], "app_onboot") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->onboot = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->onboot = NULL;
-                       } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->autorestart = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->autorestart = NULL;
-                       } else if (strcmp(colname[i], "app_enabled") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->enabled= strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->enabled = NULL;
-                       } else if (strcmp(colname[i], "category") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->category->name = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->category->name = NULL;
-                       } else if (strcmp(colname[i], "md_key") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->metadata->key = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->metadata->key = NULL;
-                       } else if (strcmp(colname[i], "md_value") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->metadata->value = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->metadata->value = NULL;
-                       } else if (strcmp(colname[i], "pm_type") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->permission->type= strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->permission->type = NULL;
-                       } else if (strcmp(colname[i], "pm_value") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->permission->value = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->permission->value = NULL;
-                       } else if (strcmp(colname[i], "app_locale") == 0 ) {
-                               if (coltxt[i]) {
-                                       info->svcapp_info->icon->lang = strdup(coltxt[i]);
-                                       info->svcapp_info->label->lang = strdup(coltxt[i]);
-                               }
-                               else {
-                                       info->svcapp_info->icon->lang = NULL;
-                                       info->svcapp_info->label->lang = NULL;
-                               }
-                       } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                               if (coltxt[i])
-                                       info->svcapp_info->permission_type = strdup(coltxt[i]);
-                               else
-                                       info->svcapp_info->permission_type = NULL;
-                       } else if (strcmp(colname[i], "app_control") == 0 ) {
-                               __parse_appcontrol(&info->svcapp_info->appcontrol, coltxt[i]);
-                       } else
-                               continue;
-               }
-               break;
-       default:
-               break;
-       }
-
-       return 0;
-}
-
-
-static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
-       int i = 0;
-       for(i = 0; i < ncols; i++)
-       {
-               if (strcmp(colname[i], "app_component") == 0) {
-                       info->app_component = __appcomponent_convert(coltxt[i]);
-               } else if (strcmp(colname[i], "package") == 0) {
-                       info->package = strdup(coltxt[i]);
-               }
-       }
-
-       return 0;
-}
-
 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
 {
        pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
@@ -2286,33 +1086,6 @@ static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
        return 0;
 }
 
-/* get the first locale value*/
-static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
-
-       if (ncols >= 1)
-               info->locale = strdup(coltxt[0]);
-       else
-               info->locale = NULL;
-
-       return 0;
-}
-
-static int __exec_pkginfo_query(char *query, void *data)
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(GET_DB(manifest_db), query, __pkginfo_cb, data, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
 static int __exec_certinfo_query(char *query, void *data)
 {
        char *error_message = NULL;
@@ -2387,118 +1160,6 @@ static int __child_element(xmlTextReaderPtr reader, int depth)
        return ret;
 }
 
-static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       int *p = (int*)data;
-       *p = atoi(coltxt[0]);
-       return 0;
-}
-
-static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
-{
-       int result_query = -1;
-       int ret = 0;
-       char query[MAX_QUERY_LEN];
-
-       snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale='%s')", appid, locale);
-       ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
-       retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
-       return result_query;
-}
-
-static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
-{
-       int result_query = -1;
-       int ret = 0;
-       char wildcard[2] = {'%','\0'};
-       char query[MAX_QUERY_LEN];
-       char lang[3] = {'\0'};
-       strncpy(lang, locale, LANGUAGE_LENGTH);
-
-       snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s')", appid, lang, wildcard);
-       ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
-       retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
-       return result_query;
-}
-
-static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
-{
-       int ret = 0;
-       char wildcard[2] = {'%','\0'};
-       char lang[3] = {'\0'};
-       char query[MAX_QUERY_LEN];
-       char *locale_new = NULL;
-       pkgmgr_locale_x *info = NULL;
-
-       info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
-       if (info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               return NULL;
-       }
-       memset(info, '\0', sizeof(*info));
-
-       strncpy(lang, locale, 2);
-       snprintf(query, MAX_QUERY_LEN, "select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s'", appid, lang, wildcard);
-       ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
-       trym_if(ret == -1, "Exec DB query failed");
-       locale_new = info->locale;
-       free(info);
-       return locale_new;
-catch:
-       if (info) {
-               free(info);
-               info = NULL;
-       }
-       return NULL;
-}
-
-static char* __convert_syslocale_to_manifest_locale(char *syslocale)
-{
-       char *locale = malloc(6);
-       if (!locale) {
-               _LOGE("Malloc Failed\n");
-               return NULL;
-       }
-
-       sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
-       return locale;
-}
-
-static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
-{
-       assert(appid);
-       assert(syslocale);
-
-       char *locale = NULL;
-       char *locale_new = NULL;
-       int check_result = 0;
-
-       locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
-
-       /*check exact matching */
-       check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
-
-       /* Exact found */
-       if (check_result == 1) {
-               _LOGD("%s find exact locale(%s)\n", appid, locale);
-               return locale;
-       }
-
-       /* fallback matching */
-       check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
-       if(check_result == 1) {
-                  locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
-                  free(locale);
-                  if (locale_new == NULL)
-                          locale_new =  strdup(DEFAULT_LOCALE);
-                  return locale_new;
-       }
-
-       /* default locale */
-       free(locale);
-       return  strdup(DEFAULT_LOCALE);
-}
-
 long long _pkgmgr_calculate_dir_size(char *dirname)
 {
        long long total = 0;
@@ -2674,157 +1335,60 @@ static int __get_pkg_location(const char *pkgid)
        return PMINFO_INTERNAL_STORAGE;
 }
 
-API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
+static int _pkginfo_get_filtered_foreach_pkginfo(pkgmgrinfo_filter_x *filter,
+               pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
 {
-       retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
-       char *error_message = NULL;
-       int ret = PMINFO_R_OK;
-       int ret_db = 0;
-
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
        pkgmgr_pkginfo_x *pkginfo = NULL;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
+       pkgmgr_pkginfo_x *next;
+       pkgmgr_pkginfo_x *tmp;
+       char *locale;
+       int stop = 0;
 
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
+       if (__open_manifest_db(uid) < 0)
                return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
+
+       locale = _get_system_locale();
        if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
+               __close_manifest_db();
                return PMINFO_R_ERROR;
        }
 
-       ret_db = __open_manifest_db(uid);
-       if (ret_db == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               free(syslocale);
+       if (_pkginfo_get_pkg(locale, filter, &pkginfo)) {
                free(locale);
+               __close_manifest_db();
                return PMINFO_R_ERROR;
        }
-       pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       pkgmgr_pkginfo_x *node = NULL;
-       pkgmgr_pkginfo_x *temp_node = NULL;
-
-       snprintf(query, MAX_QUERY_LEN, "select * from package_info");
-       if (SQLITE_OK !=
-           sqlite3_exec(GET_DB(manifest_db), query, __pkg_list_cb, (void *)tmphead, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       LISTHEAD(tmphead, node);
 
-       for(node = node->next; node ; node = node->next) {
-               pkginfo = node;
-               pkginfo->locale = strdup(locale);
-               pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
-               if (pkginfo->manifest_info->privileges == NULL) {
-                       _LOGE("Failed to allocate memory for privileges info\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               /*populate manifest_info from DB*/
-               snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               /*populate privilege_info from DB*/
-               snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Privilege Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               /*Also store the values corresponding to default locales*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               if (pkginfo->manifest_info->label) {
-                       LISTHEAD(pkginfo->manifest_info->label, tmp1);
-                       pkginfo->manifest_info->label = tmp1;
-               }
-               if (pkginfo->manifest_info->icon) {
-                       LISTHEAD(pkginfo->manifest_info->icon, tmp2);
-                       pkginfo->manifest_info->icon = tmp2;
-               }
-               if (pkginfo->manifest_info->description) {
-                       LISTHEAD(pkginfo->manifest_info->description, tmp3);
-                       pkginfo->manifest_info->description = tmp3;
-               }
-               if (pkginfo->manifest_info->author) {
-                       LISTHEAD(pkginfo->manifest_info->author, tmp4);
-                       pkginfo->manifest_info->author = tmp4;
-               }
-               if (pkginfo->manifest_info->privileges->privilege) {
-                       LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
-                       pkginfo->manifest_info->privileges->privilege = tmp5;
+       tmp = pkginfo;
+       while (tmp) {
+               next = tmp->next;
+               tmp->uid = uid;
+               tmp->locale = locale;
+               if (stop == 0) {
+                       if (pkg_list_cb(tmp, user_data) < 0)
+                               stop = 1;
                }
+               pkgmgrinfo_basic_free_package(tmp->pkg_info);
+               free(tmp);
+               tmp = next;
        }
 
-       LISTHEAD(tmphead, node);
-
-       for(node = node->next; node ; node = node->next) {
-               pkginfo = node;
-               pkginfo->uid = uid;
-               ret = pkg_list_cb( (void *)pkginfo, user_data);
-               if(ret < 0)
-                       break;
-       }
+       free(locale);
+       __close_manifest_db();
 
-       ret = PMINFO_R_OK;
+       return PMINFO_R_OK;
+}
 
-err:
-       __close_manifest_db();
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       LISTHEAD(tmphead, node);
-       temp_node = node->next;
-       node = temp_node;
-       while (node) {
-               temp_node = node->next;
-               __cleanup_pkginfo(node);
-               node = temp_node;
+API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
+               void *user_data, uid_t uid)
+{
+       if (pkg_list_cb == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
        }
-       __cleanup_pkginfo(tmphead);
-       return ret;
+
+       return _pkginfo_get_filtered_foreach_pkginfo(NULL, pkg_list_cb,
+                       user_data, uid);
 }
 
 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
@@ -2832,118 +1396,516 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
        return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, GLOBAL_USER);
 }
 
-API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle)
+static void _save_column_str(sqlite3_stmt *stmt, int idx, const char **str)
 {
-       retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       pkgmgr_pkginfo_x *pkginfo = NULL;
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
-       int exist = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
-       const char* user_pkg_parser = NULL;
-
-       *handle = NULL;
+       const char *val;
 
-       /*validate pkgid*/
-       user_pkg_parser = getUserPkgParserDBPathUID(uid);
-       ret = __open_manifest_db(uid);
-         retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
+       val = (const char *)sqlite3_column_text(stmt, idx);
+       if (val)
+               *str = strdup(val);
+}
 
-       /*check pkgid exist on db*/
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __validate_cb, (void *)&exist);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
-       tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] for user[%d] is not found in DB", pkgid, uid);
+static int _pkginfo_get_author(const char *pkgid, author_x **author)
+{
+       static const char query_raw[] =
+               "SELECT author_name, author_email, author_href "
+               "FROM package_info WHERE package=%Q";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx = 0;
+       author_x *info;
 
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+       query = sqlite3_mprintf(query_raw, pkgid);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
 
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
+       }
 
-       pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
+       if (sqlite3_step(stmt) == SQLITE_ERROR) {
+               LOGE("step error: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               sqlite3_finalize(stmt);
+               return PMINFO_R_ERROR;
+       }
 
-       pkginfo->locale = strdup(locale);
+       /* one author per one package */
+       info = calloc(1, sizeof(author_x));
+       if (info == NULL) {
+               LOGE("out of memory");
+               sqlite3_finalize(stmt);
+               return PMINFO_R_ERROR;
+       }
 
-       pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
+       _save_column_str(stmt, idx++, &info->text);
+       _save_column_str(stmt, idx++, &info->email);
+       _save_column_str(stmt, idx++, &info->href);
 
-       pkginfo->manifest_info->package = strdup(pkgid);
-       pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
-       tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
+       *author = info;
 
-       /*populate manifest_info from DB*/
-       snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
+       sqlite3_finalize(stmt);
 
-       memset(query, '\0', MAX_QUERY_LEN);
-       /*populate privilege_info from DB*/
-       snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
+       return PMINFO_R_OK;
+}
 
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-               " package='%s' and package_locale='%s'", pkgid, locale);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
+static int _pkginfo_get_label(const char *pkgid, const char *locale,
+               label_x **label)
+{
+       static const char query_raw[] =
+               "SELECT package_label, package_locale "
+               "FROM package_localized_info "
+               "WHERE package=%Q AND package_locale IN (%Q, %Q)";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       label_x *info;
 
-       /*Also store the values corresponding to default locales*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-               " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
+       query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
 
-       if (pkginfo->manifest_info->label) {
-               LISTHEAD(pkginfo->manifest_info->label, tmp1);
-               pkginfo->manifest_info->label = tmp1;
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
        }
-       if (pkginfo->manifest_info->icon) {
-               LISTHEAD(pkginfo->manifest_info->icon, tmp2);
-               pkginfo->manifest_info->icon = tmp2;
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(label_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*label) {
+                               LISTHEAD(*label, info);
+                               *label = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &info->text);
+               _save_column_str(stmt, idx++, &info->lang);
+               LISTADD(*label, info);
        }
-       if (pkginfo->manifest_info->description) {
-               LISTHEAD(pkginfo->manifest_info->description, tmp3);
-               pkginfo->manifest_info->description = tmp3;
+
+       if (*label) {
+               LISTHEAD(*label, info);
+               *label = info;
        }
-       if (pkginfo->manifest_info->author) {
-               LISTHEAD(pkginfo->manifest_info->author, tmp4);
-               pkginfo->manifest_info->author = tmp4;
+
+       return PMINFO_R_OK;
+}
+
+static int _pkginfo_get_icon(const char *pkgid, const char *locale,
+               icon_x **icon)
+{
+       static const char query_raw[] =
+               "SELECT package_icon, package_locale "
+               "FROM package_localized_info "
+               "WHERE package=%Q AND package_locale IN (%Q, %Q)";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       icon_x *info;
+
+       query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
        }
-       if (pkginfo->manifest_info->privileges->privilege) {
-               LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
-               pkginfo->manifest_info->privileges->privilege = tmp5;
+
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
        }
 
-catch:
-       if (ret == PMINFO_R_OK)
-               *handle = (void*)pkginfo;
-       else {
-               *handle = NULL;
-               __cleanup_pkginfo(pkginfo);
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(icon_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*icon) {
+                               LISTHEAD(*icon, info);
+                               *icon = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &info->text);
+               _save_column_str(stmt, idx++, &info->lang);
+               LISTADD(*icon, info);
        }
-       __close_manifest_db();
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
+
+       if (*icon) {
+               LISTHEAD(*icon, info);
+               *icon = info;
        }
-       if (locale) {
+
+       return PMINFO_R_OK;
+}
+
+static int _pkginfo_get_description(const char *pkgid, const char *locale,
+               description_x **description)
+{
+       static const char query_raw[] =
+               "SELECT package_description, package_locale "
+               "FROM package_localized_info "
+               "WHERE package=%Q AND package_locale IN (%Q, %Q)";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       description_x *info;
+
+       query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
+
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
+       }
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(description_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*description) {
+                               LISTHEAD(*description, info);
+                               *description = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &info->text);
+               _save_column_str(stmt, idx++, &info->lang);
+               LISTADD(*description, info);
+       }
+
+       if (*description) {
+               LISTHEAD(*description, info);
+               *description = info;
+       }
+
+       return PMINFO_R_OK;
+}
+
+static int _pkginfo_get_privilege(const char *pkgid, privileges_x **privileges)
+{
+       static const char query_raw[] =
+               "SELECT privilege FROM package_privilege_info WHERE package=%Q";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       privileges_x *p;
+       privilege_x *info;
+
+       /* privilege list should stored in privileges_x... */
+       p = calloc(1, sizeof(privileges_x));
+       if (p == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
+       *privileges = p;
+
+       query = sqlite3_mprintf(query_raw, pkgid);
+       if (query == NULL) {
+               LOGE("out of memory");
+               free(p);
+               return PMINFO_R_ERROR;
+       }
+
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               free(p);
+               return PMINFO_R_ERROR;
+       }
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(privilege_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (p->privilege) {
+                               LISTHEAD(p->privilege, info);
+                               p->privilege = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               _save_column_str(stmt, 0, &info->text);
+               LISTADD(p->privilege, info);
+       }
+
+       if (p->privilege) {
+               LISTHEAD(p->privilege, info);
+               p->privilege = info;
+       }
+
+       return PMINFO_R_OK;
+}
+
+static char *_get_filtered_query(const char *query_raw,
+               pkgmgrinfo_filter_x *filter)
+{
+       char buf[MAX_QUERY_LEN] = { 0, };
+       char *condition;
+       size_t len;
+       GSList *list;
+       GSList *head = NULL;
+
+       if (filter)
+               head = filter->list;
+
+       strncat(buf, query_raw, MAX_QUERY_LEN - 1);
+       len = strlen(buf);
+       for (list = head; list; list = list->next) {
+               /* TODO: revise condition getter function */
+               __get_filter_condition(list->data, &condition);
+               if (condition == NULL)
+                       continue;
+               if (buf[strlen(query_raw)] == '\0') {
+                       len += strlen(" WHERE ");
+                       strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
+               } else {
+                       len += strlen(" AND ");
+                       strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
+               }
+               len += strlen(condition);
+               strncat(buf, condition, sizeof(buf) - len - 1);
+               free(condition);
+               condition = NULL;
+       }
+
+       return strdup(buf);
+}
+
+static int _pkginfo_get_pkg(const char *locale, pkgmgrinfo_filter_x *filter,
+               pkgmgr_pkginfo_x **pkginfo)
+{
+       static const char query_raw[] =
+               "SELECT for_all_users, package, package_version, "
+               "install_location, package_removable, package_preload, "
+               "package_readonly, package_update, package_appsetting, "
+               "package_system, package_type, package_size, installed_time, "
+               "installed_storage, storeclient_id, mainapp_id, package_url, "
+               "root_path, csc_path, package_nodisplay, package_api_version "
+               "FROM package_info";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       pkgmgr_pkginfo_x *info;
+       package_x *pkg;
+
+       query = _get_filtered_query(query_raw, filter);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
+
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
+       }
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               pkg = calloc(1, sizeof(package_x));
+               if (pkg == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &pkg->for_all_users);
+               _save_column_str(stmt, idx++, &pkg->package);
+               _save_column_str(stmt, idx++, &pkg->version);
+               _save_column_str(stmt, idx++, &pkg->installlocation);
+               _save_column_str(stmt, idx++, &pkg->removable);
+               _save_column_str(stmt, idx++, &pkg->preload);
+               _save_column_str(stmt, idx++, &pkg->readonly);
+               _save_column_str(stmt, idx++, &pkg->update);
+               _save_column_str(stmt, idx++, &pkg->appsetting);
+               _save_column_str(stmt, idx++, &pkg->system);
+               _save_column_str(stmt, idx++, &pkg->type);
+               _save_column_str(stmt, idx++, &pkg->package_size);
+               _save_column_str(stmt, idx++, &pkg->installed_time);
+               _save_column_str(stmt, idx++, &pkg->installed_storage);
+               _save_column_str(stmt, idx++, &pkg->storeclient_id);
+               _save_column_str(stmt, idx++, &pkg->mainapp_id);
+               _save_column_str(stmt, idx++, &pkg->package_url);
+               _save_column_str(stmt, idx++, &pkg->root_path);
+               _save_column_str(stmt, idx++, &pkg->csc_path);
+               _save_column_str(stmt, idx++, &pkg->nodisplay_setting);
+               _save_column_str(stmt, idx++, &pkg->api_version);
+
+               if (_pkginfo_get_author(pkg->package, &pkg->author)) {
+                       pkgmgrinfo_basic_free_package(pkg);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+
+               if (_pkginfo_get_label(pkg->package, locale, &pkg->label)) {
+                       pkgmgrinfo_basic_free_package(pkg);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+
+               if (_pkginfo_get_icon(pkg->package, locale, &pkg->icon)) {
+                       pkgmgrinfo_basic_free_package(pkg);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+
+               if (_pkginfo_get_description(pkg->package, locale,
+                                       &pkg->description)) {
+                       pkgmgrinfo_basic_free_package(pkg);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+
+               if (_pkginfo_get_privilege(pkg->package, &pkg->privileges)) {
+                       pkgmgrinfo_basic_free_package(pkg);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+
+               info = calloc(1, sizeof(pkgmgr_pkginfo_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       pkgmgrinfo_basic_free_package(pkg);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+
+               info->pkg_info = pkg;
+               LISTADD(*pkginfo, info);
+       }
+
+       sqlite3_finalize(stmt);
+
+       if (*pkginfo) {
+               LISTHEAD(*pkginfo, info);
+               *pkginfo = info;
+       } else {
+               LOGE("no result");
+               return PMINFO_R_ERROR;
+       }
+
+       return PMINFO_R_OK;
+}
+
+static char *_get_system_locale(void)
+{
+       char *lang;
+       char *locale;
+
+       lang = vconf_get_str(VCONFKEY_LANGSET);
+       if (lang == NULL) {
+               locale = strdup(DEFAULT_LOCALE);
+               if (locale == NULL) {
+                       LOGE("out of memory");
+                       return NULL;
+               }
+               return locale;
+       }
+
+       locale = malloc(sizeof(char *) * 6);
+       if (locale == NULL) {
+               LOGE("out of memory");
+               free(lang);
+               return NULL;
+       }
+
+       strncpy(locale, lang, 2);
+       locale[2] = '-';
+       locale[3] = tolower(lang[3]);
+       locale[4] = tolower(lang[4]);
+       locale[5] = '\0';
+
+       free(lang);
+
+       return locale;
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
+               pkgmgrinfo_pkginfo_h *handle)
+{
+       pkgmgr_pkginfo_x *pkginfo = NULL;
+       pkgmgrinfo_pkginfo_filter_h filter;
+       char *locale;
+
+       if (pkgid == NULL || handle == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
+       }
+
+       if (__open_manifest_db(uid) < 0)
+               return PMINFO_R_ERROR;
+
+
+       locale = _get_system_locale();
+       if (locale == NULL) {
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
+       }
+
+       if (pkgmgrinfo_pkginfo_filter_create(&filter)) {
                free(locale);
-               locale = NULL;
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
        }
-       return ret;
+
+       if (pkgmgrinfo_pkginfo_filter_add_string(filter,
+                       PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid)) {
+               pkgmgrinfo_pkginfo_filter_destroy(filter);
+               free(locale);
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
+       }
+
+       if (_pkginfo_get_pkg(locale, filter, &pkginfo)) {
+               LOGE("failed to get pkginfo of %s for user %d", pkgid, uid);
+               pkgmgrinfo_pkginfo_filter_destroy(filter);
+               free(locale);
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
+       }
+
+       pkginfo->uid = uid;
+       pkginfo->locale = locale;
+       *handle = pkginfo;
+
+       pkgmgrinfo_pkginfo_filter_destroy(filter);
+       __close_manifest_db();
+
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
@@ -2958,10 +1920,10 @@ API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_n
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->package == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->package == NULL)
                return PMINFO_R_ERROR;
 
-       *pkg_name = (char *)info->manifest_info->package;
+       *pkg_name = (char *)info->pkg_info->package;
 
        return PMINFO_R_OK;
 }
@@ -2973,10 +1935,10 @@ API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->package == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->package == NULL)
                return PMINFO_R_ERROR;
 
-       *pkgid = (char *)info->manifest_info->package;
+       *pkgid = (char *)info->pkg_info->package;
 
        return PMINFO_R_OK;
 }
@@ -2988,10 +1950,10 @@ API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->type == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->type == NULL)
                return PMINFO_R_ERROR;
 
-       *type = (char *)info->manifest_info->type;
+       *type = (char *)info->pkg_info->type;
 
        return PMINFO_R_OK;
 }
@@ -3003,10 +1965,10 @@ API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **versi
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->version == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->version == NULL)
                return PMINFO_R_ERROR;
 
-       *version = (char *)info->manifest_info->version;
+       *version = (char *)info->pkg_info->version;
 
        return PMINFO_R_OK;
 }
@@ -3019,10 +1981,10 @@ API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkg
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->installlocation == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->installlocation;
+       val = (char *)info->pkg_info->installlocation;
        if (strcmp(val, "internal-only") == 0)
                *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
        else if (strcmp(val, "prefer-external") == 0)
@@ -3040,10 +2002,10 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->package_size == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->package_size == NULL)
                return PMINFO_R_ERROR;
 
-       *size = atoi((char *)info->manifest_info->package_size);
+       *size = atoi((char *)info->pkg_info->package_size);
 
        return PMINFO_R_OK;
 }
@@ -3218,7 +2180,7 @@ API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-       for (ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->pkg_info->icon; ptr != NULL; ptr = ptr->next) {
                if (ptr->lang == NULL)
                        continue;
 
@@ -3251,7 +2213,7 @@ API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-       for (ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->pkg_info->label; ptr != NULL; ptr = ptr->next) {
                if (ptr->lang == NULL)
                        continue;
 
@@ -3284,7 +2246,7 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-       for (ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->pkg_info->description; ptr != NULL; ptr = ptr->next) {
                if (ptr->lang == NULL)
                        continue;
 
@@ -3317,7 +2279,7 @@ API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **a
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-       for (ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->pkg_info->author; ptr != NULL; ptr = ptr->next) {
                if (ptr->lang == NULL)
                        continue;
 
@@ -3345,11 +2307,11 @@ API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->author == NULL ||
-                       info->manifest_info->author->email == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
+                       info->pkg_info->author->email == NULL)
                return PMINFO_R_ERROR;
 
-       *author_email = (char *)info->manifest_info->author->email;
+       *author_email = (char *)info->pkg_info->author->email;
 
        return PMINFO_R_OK;
 }
@@ -3361,11 +2323,11 @@ API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **a
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->author == NULL ||
-                       info->manifest_info->author->href == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
+                       info->pkg_info->author->href == NULL)
                return PMINFO_R_ERROR;
 
-       *author_href = (char *)info->manifest_info->author->href;
+       *author_href = (char *)info->pkg_info->author->href;
 
        return PMINFO_R_OK;
 }
@@ -3377,12 +2339,12 @@ API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pk
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->installed_storage == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->installed_storage == NULL)
                return PMINFO_R_ERROR;
 
-       if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
+       if (strcmp(info->pkg_info->installed_storage,"installed_internal") == 0)
                *storage = PMINFO_INTERNAL_STORAGE;
-       else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
+       else if (strcmp(info->pkg_info->installed_storage,"installed_external") == 0)
                *storage = PMINFO_EXTERNAL_STORAGE;
        else
                return PMINFO_R_ERROR;
@@ -3397,10 +2359,10 @@ API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->installed_time == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->installed_time == NULL)
                return PMINFO_R_ERROR;
 
-       *installed_time = atoi(info->manifest_info->installed_time);
+       *installed_time = atoi(info->pkg_info->installed_time);
 
        return PMINFO_R_OK;
 }
@@ -3412,10 +2374,10 @@ API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char *
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->storeclient_id == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->storeclient_id == NULL)
                return PMINFO_R_ERROR;
 
-       *storeclientid = (char *)info->manifest_info->storeclient_id;
+       *storeclientid = (char *)info->pkg_info->storeclient_id;
 
        return PMINFO_R_OK;
 }
@@ -3427,10 +2389,10 @@ API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mai
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->mainapp_id == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->mainapp_id == NULL)
                return PMINFO_R_ERROR;
 
-       *mainappid = (char *)info->manifest_info->mainapp_id;
+       *mainappid = (char *)info->pkg_info->mainapp_id;
 
        return PMINFO_R_OK;
 }
@@ -3442,10 +2404,10 @@ API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->package_url == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->package_url == NULL)
                return PMINFO_R_ERROR;
 
-       *url = (char *)info->manifest_info->package_url;
+       *url = (char *)info->pkg_info->package_url;
 
        return PMINFO_R_OK;
 }
@@ -3563,10 +2525,10 @@ API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **pat
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->root_path == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->root_path == NULL)
                return PMINFO_R_ERROR;
 
-       *path = (char *)info->manifest_info->root_path;
+       *path = (char *)info->pkg_info->root_path;
 
        return PMINFO_R_OK;
 }
@@ -3578,10 +2540,10 @@ API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->csc_path == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->csc_path == NULL)
                return PMINFO_R_ERROR;
 
-       *path = (char *)info->manifest_info->csc_path;
+       *path = (char *)info->pkg_info->csc_path;
 
        return PMINFO_R_OK;
 }
@@ -3992,10 +2954,10 @@ API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *remov
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->removable == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->removable == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->removable;
+       val = (char *)info->pkg_info->removable;
        if (strcasecmp(val, "true") == 0)
                *removable = 1;
        else if (strcasecmp(val, "false") == 0)
@@ -4014,10 +2976,10 @@ API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->installlocation == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->installlocation;
+       val = (char *)info->pkg_info->installlocation;
        if (strcmp(val, "internal-only") == 0)
                *movable = 0;
        else if (strcmp(val, "prefer-external") == 0)
@@ -4036,10 +2998,10 @@ API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->preload == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->preload == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->preload;
+       val = (char *)info->pkg_info->preload;
        if (strcasecmp(val, "true") == 0)
                *preload = 1;
        else if (strcasecmp(val, "false") == 0)
@@ -4058,10 +3020,10 @@ API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->system == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->system == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->system;
+       val = (char *)info->pkg_info->system;
        if (strcasecmp(val, "true") == 0)
                *system = 1;
        else if (strcasecmp(val, "false") == 0)
@@ -4080,10 +3042,10 @@ API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readon
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->readonly == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->readonly == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->readonly;
+       val = (char *)info->pkg_info->readonly;
        if (strcasecmp(val, "true") == 0)
                *readonly = 1;
        else if (strcasecmp(val, "false") == 0)
@@ -4102,10 +3064,10 @@ API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->update == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->update == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->update;
+       val = (char *)info->pkg_info->update;
        if (strcasecmp(val, "true") == 0)
                *update = 1;
        else if (strcasecmp(val, "false") == 0)
@@ -4124,10 +3086,10 @@ API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *f
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(for_all_users == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->manifest_info == NULL || info->manifest_info->for_all_users == NULL)
+       if (info->pkg_info == NULL || info->pkg_info->for_all_users == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->manifest_info->for_all_users;
+       val = (char *)info->pkg_info->for_all_users;
        if (strcasecmp(val, "1") == 0)
                *for_all_users = 1;
        else if (strcasecmp(val, "0") == 0)
@@ -4410,170 +3372,17 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int
        return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, GLOBAL_USER);
 }
 
-API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
-                               pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
+API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(
+               pkgmgrinfo_pkginfo_filter_h handle,
+               pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
-       pkgmgr_pkginfo_x *node = NULL;
-       pkgmgr_pkginfo_x *tmphead = NULL;
-       pkgmgr_pkginfo_x *pkginfo = NULL;
-
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
-       }
-
-       ret = __open_manifest_db(uid);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               free(syslocale);
-               free(locale);
-               return PMINFO_R_ERROR;
-       }
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
-
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
-               }
-       }
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
-       }
-       tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (tmphead == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       tmphead->uid = uid;
-       if (SQLITE_OK !=
-           sqlite3_exec(GET_DB(manifest_db), query, __pkg_list_cb, (void *)tmphead, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       LISTHEAD(tmphead, node);
-       for(node = node->next ; node ; node = node->next) {
-               pkginfo = node;
-               pkginfo->locale = strdup(locale);
-               pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
-               if (pkginfo->manifest_info->privileges == NULL) {
-                       _LOGE("Failed to allocate memory for privileges info\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-
-               /*populate manifest_info from DB*/
-               snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               /*Also store the values corresponding to default locales*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               if (pkginfo->manifest_info->label) {
-                       LISTHEAD(pkginfo->manifest_info->label, tmp1);
-                       pkginfo->manifest_info->label = tmp1;
-               }
-               if (pkginfo->manifest_info->icon) {
-                       LISTHEAD(pkginfo->manifest_info->icon, tmp2);
-                       pkginfo->manifest_info->icon = tmp2;
-               }
-               if (pkginfo->manifest_info->description) {
-                       LISTHEAD(pkginfo->manifest_info->description, tmp3);
-                       pkginfo->manifest_info->description = tmp3;
-               }
-               if (pkginfo->manifest_info->author) {
-                       LISTHEAD(pkginfo->manifest_info->author, tmp4);
-                       pkginfo->manifest_info->author = tmp4;
-               }
-               if (pkginfo->manifest_info->privileges->privilege) {
-                       LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
-                       pkginfo->manifest_info->privileges->privilege = tmp5;
-               }
-       }
-
-       LISTHEAD(tmphead, node);
-
-       for(node = node->next ; node ; node = node->next) {
-               pkginfo = node;
-               pkginfo->uid = uid;
-               ret = pkg_cb( (void *)pkginfo, user_data);
-               if(ret < 0)
-                       break;
+       if (handle == NULL || pkg_cb == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
        }
-       ret = PMINFO_R_OK;
 
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       __close_manifest_db();
-       __cleanup_pkginfo(tmphead);
-       return ret;
+       return _pkginfo_get_filtered_foreach_pkginfo(handle, pkg_cb, user_data,
+                       uid);
 }
 
 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
@@ -4590,7 +3399,7 @@ API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
        int ret = -1;
        privilege_x *ptr = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       ptr = info->manifest_info->privileges->privilege;
+       ptr = info->pkg_info->privileges->privilege;
        for (; ptr; ptr = ptr->next) {
                if (ptr->text){
                        ret = privilege_func(ptr->text, user_data);
@@ -4601,379 +3410,101 @@ API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
-                                               pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
+static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
+               pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
+               void *user_data)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
-       retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
-
-       char *syslocale = NULL;
-       char *locale = NULL;
-       int ret = -1;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       pkgmgr_pkginfo_x *allinfo = NULL;
        pkgmgr_appinfo_x *appinfo = NULL;
-       icon_x *ptr1 = NULL;
-       label_x *ptr2 = NULL;
-       category_x *ptr3 = NULL;
-       metadata_x *ptr4 = NULL;
-       permission_x *ptr5 = NULL;
-       image_x *ptr6 = NULL;
-       appcontrol_x *ptr7 = NULL;
-       const char* user_pkg_parser = NULL;
-
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       retvm_if(syslocale == NULL, PMINFO_R_EINVAL, "current locale is NULL");
-
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
-
-       /*calloc allinfo*/
-       allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
-
-       /*calloc manifest_info*/
-       allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
-
-       /*set component type*/
-       if (component == PMINFO_UI_APP)
-               appinfo->app_component = PMINFO_UI_APP;
-       if (component == PMINFO_SVC_APP)
-               appinfo->app_component = PMINFO_SVC_APP;
-       if (component == PMINFO_ALL_APP)
-               appinfo->app_component = PMINFO_ALL_APP;
-
-       /*open db */
-       user_pkg_parser = getUserPkgParserDBPathUID(uid);
-       ret = __open_manifest_db(uid);
-       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
-
-       appinfo->package = strdup(info->manifest_info->package);
-       snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                       "from package_app_info where " \
-                       "package='%s' and app_component='%s'",
-                       info->manifest_info->package,
-                       (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
-
-       switch(component) {
-       case PMINFO_UI_APP:
-               /*Populate ui app info */
-               ret = __exec_db_query(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)info);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
-
-               uiapplication_x *tmp = NULL;
-               if (info->manifest_info->uiapplication) {
-                       LISTHEAD(info->manifest_info->uiapplication, tmp);
-                       info->manifest_info->uiapplication = tmp;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->uiapp_info = tmp;
-                       if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
-                               if (locale) {
-                                       free(locale);
-                               }
-                               locale = __get_app_locale_by_fallback(GET_DB(manifest_db), appinfo->uiapp_info->appid, syslocale);
-                       }
-
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       pkgmgr_appinfo_x *next;
+       pkgmgr_appinfo_x *tmp;
+       char *locale;
+       int stop = 0;
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       if (__open_manifest_db(uid) < 0)
+               return PMINFO_R_ERROR;
 
-                       /*store setting notification icon section*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-                       
-                       /*store app preview image info*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+       locale = _get_system_locale();
+       if (locale == NULL) {
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
+       }
 
-                       /*store app control info*/
-                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+       if (_appinfo_get_app(locale, filter, &appinfo)) {
+               free(locale);
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
+       }
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       if (appinfo->uiapp_info->label) {
-                               LISTHEAD(appinfo->uiapp_info->label, ptr2);
-                               appinfo->uiapp_info->label = ptr2;
-                       }
-                       if (appinfo->uiapp_info->icon) {
-                               LISTHEAD(appinfo->uiapp_info->icon, ptr1);
-                               appinfo->uiapp_info->icon = ptr1;
-                       }
-                       if (appinfo->uiapp_info->category) {
-                               LISTHEAD(appinfo->uiapp_info->category, ptr3);
-                               appinfo->uiapp_info->category = ptr3;
-                       }
-                       if (appinfo->uiapp_info->metadata) {
-                               LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
-                               appinfo->uiapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->uiapp_info->permission) {
-                               LISTHEAD(appinfo->uiapp_info->permission, ptr5);
-                               appinfo->uiapp_info->permission = ptr5;
-                       }
-                       if (appinfo->uiapp_info->image) {
-                               LISTHEAD(appinfo->uiapp_info->image, ptr6);
-                               appinfo->uiapp_info->image = ptr6;
-                       }
-                       if (appinfo->uiapp_info->appcontrol) {
-                               LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
-                               appinfo->uiapp_info->appcontrol = ptr7;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp = tmp->next;
-               }
-               break;
-       case PMINFO_SVC_APP:
-               /*Populate svc app info */
-               ret = __exec_db_query(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)info);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
-
-               serviceapplication_x *tmp1 = NULL;
-               if (info->manifest_info->serviceapplication) {
-                       LISTHEAD(info->manifest_info->serviceapplication, tmp1);
-                       info->manifest_info->serviceapplication = tmp1;
+       tmp = appinfo;
+       while (tmp) {
+               next = tmp->next;
+               tmp->locale = strdup(locale);
+               if (stop == 0) {
+                       if (app_list_cb(tmp, user_data) < 0)
+                               stop = 1;
                }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp1 != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->svcapp_info = tmp1;
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+               __cleanup_appinfo(tmp);
+               tmp = next;
+       }
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       free(locale);
+       __close_manifest_db();
 
-                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+       return PMINFO_R_OK;
+}
 
-                       if (appinfo->svcapp_info->label) {
-                               LISTHEAD(appinfo->svcapp_info->label, ptr2);
-                               appinfo->svcapp_info->label = ptr2;
-                       }
-                       if (appinfo->svcapp_info->icon) {
-                               LISTHEAD(appinfo->svcapp_info->icon, ptr1);
-                               appinfo->svcapp_info->icon = ptr1;
-                       }
-                       if (appinfo->svcapp_info->category) {
-                               LISTHEAD(appinfo->svcapp_info->category, ptr3);
-                               appinfo->svcapp_info->category = ptr3;
-                       }
-                       if (appinfo->svcapp_info->metadata) {
-                               LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
-                               appinfo->svcapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->svcapp_info->permission) {
-                               LISTHEAD(appinfo->svcapp_info->permission, ptr5);
-                               appinfo->svcapp_info->permission = ptr5;
-                       }
-                       if (appinfo->svcapp_info->appcontrol) {
-                               LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
-                               appinfo->svcapp_info->appcontrol = ptr7;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp1 = tmp1->next;
-               }
-               break;
-       case PMINFO_ALL_APP:
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
-
-               /*Populate all app info */
-               ret = __exec_db_query(GET_DB(manifest_db), query, __allapp_list_cb, (void *)allinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
-
-               /*UI Apps*/
-               appinfo->app_component = PMINFO_UI_APP;
-               uiapplication_x *tmp2 = NULL;
-               if (allinfo->manifest_info->uiapplication) {
-                       LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
-                       allinfo->manifest_info->uiapplication = tmp2;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp2 != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->uiapp_info = tmp2;
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
+               pkgmgrinfo_app_component component,
+               pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
+{
+       int ret;
+       pkgmgrinfo_appinfo_filter_h filter;
+       char *pkgid;
+       const char *comp_str = NULL;
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       if (handle == NULL || app_func == NULL) {
+               LOGE("invalied parameter");
+               return PMINFO_R_EINVAL;
+       }
 
-                       /*store setting notification icon section*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-                       
-                       /*store app preview image info*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
-
-                       /*store app control info*/
-                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
-
-                       if (appinfo->uiapp_info->label) {
-                               LISTHEAD(appinfo->uiapp_info->label, ptr2);
-                               appinfo->uiapp_info->label = ptr2;
-                       }
-                       if (appinfo->uiapp_info->icon) {
-                               LISTHEAD(appinfo->uiapp_info->icon, ptr1);
-                               appinfo->uiapp_info->icon = ptr1;
-                       }
-                       if (appinfo->uiapp_info->category) {
-                               LISTHEAD(appinfo->uiapp_info->category, ptr3);
-                               appinfo->uiapp_info->category = ptr3;
-                       }
-                       if (appinfo->uiapp_info->metadata) {
-                               LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
-                               appinfo->uiapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->uiapp_info->permission) {
-                               LISTHEAD(appinfo->uiapp_info->permission, ptr5);
-                               appinfo->uiapp_info->permission = ptr5;
-                       }
-                       if (appinfo->uiapp_info->image) {
-                               LISTHEAD(appinfo->uiapp_info->image, ptr6);
-                               appinfo->uiapp_info->image = ptr6;
-                       }
-                       if (appinfo->uiapp_info->appcontrol) {
-                               LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
-                               appinfo->uiapp_info->appcontrol = ptr7;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp2 = tmp2->next;
-               }
+       if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
+       }
 
-               /*SVC Apps*/
-               appinfo->app_component = PMINFO_SVC_APP;
-               serviceapplication_x *tmp3 = NULL;
-               if (allinfo->manifest_info->serviceapplication) {
-                       LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
-                       allinfo->manifest_info->serviceapplication = tmp3;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp3 != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->svcapp_info = tmp3;
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       if (pkgmgrinfo_appinfo_filter_create(&filter))
+               return PMINFO_R_ERROR;
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       if (pkgmgrinfo_appinfo_filter_add_string(filter,
+                               PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid))
+               return PMINFO_R_ERROR;
 
-                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
-                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
 
-                       if (appinfo->svcapp_info->label) {
-                               LISTHEAD(appinfo->svcapp_info->label, ptr2);
-                               appinfo->svcapp_info->label = ptr2;
-                       }
-                       if (appinfo->svcapp_info->icon) {
-                               LISTHEAD(appinfo->svcapp_info->icon, ptr1);
-                               appinfo->svcapp_info->icon = ptr1;
-                       }
-                       if (appinfo->svcapp_info->category) {
-                               LISTHEAD(appinfo->svcapp_info->category, ptr3);
-                               appinfo->svcapp_info->category = ptr3;
-                       }
-                       if (appinfo->svcapp_info->metadata) {
-                               LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
-                               appinfo->svcapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->svcapp_info->permission) {
-                               LISTHEAD(appinfo->svcapp_info->permission, ptr5);
-                               appinfo->svcapp_info->permission = ptr5;
-                       }
-                       if (appinfo->svcapp_info->appcontrol) {
-                               LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
-                               appinfo->svcapp_info->appcontrol = ptr7;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp3 = tmp3->next;
-               }
-               appinfo->app_component = PMINFO_ALL_APP;
+       switch (component) {
+       case PMINFO_UI_APP:
+               comp_str = PMINFO_APPINFO_UI_APP;
+               break;
+       case PMINFO_SVC_APP:
+               comp_str = PMINFO_APPINFO_SVC_APP;
+               break;
+       default:
                break;
-
        }
 
-       ret = PMINFO_R_OK;
-catch:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       if (appinfo) {
-               if (appinfo->package) {
-                       free((void *)appinfo->package);
-                       appinfo->package = NULL;
+       if (comp_str) {
+               if (pkgmgrinfo_appinfo_filter_add_string(filter,
+                                       PMINFO_APPINFO_PROP_APP_COMPONENT,
+                                       comp_str)) {
+                       pkgmgrinfo_appinfo_filter_destroy(filter);
+                       return PMINFO_R_ERROR;
                }
-               free(appinfo);
-               appinfo = NULL;
        }
-       __cleanup_pkginfo(allinfo);
 
-       __close_manifest_db();
+       ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
+                       user_data);
+
+       pkgmgrinfo_appinfo_filter_destroy(filter);
+
        return ret;
 }
 
@@ -4985,519 +3516,452 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
 
 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
 {
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
+       if (app_func == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
+       }
 
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       const char* user_pkg_parser = NULL;
+       return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
+                       user_data);
+}
 
-       /*open db*/
-       user_pkg_parser = getUserPkgParserDBPathUID(uid);
-       ret = __open_manifest_db(uid);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
+API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+       return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
+}
 
-       /*calloc pkginfo*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
+{
+       if (app_func == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
+       }
 
-       /*calloc manifest_info*/
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+       return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
+                       user_data);
+}
 
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+       return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
+}
 
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(GET_DB(manifest_db), query, __mini_appinfo_cb, (void *)info);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+static int _appinfo_get_label(const char *appid, const char *locale,
+               label_x **label)
+{
+       static const char query_raw[] =
+               "SELECT app_label, app_locale "
+               "FROM package_app_localized_info "
+               "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       label_x *info;
 
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
+       query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
        }
 
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               appinfo->app_component = PMINFO_UI_APP;
-               appinfo->package = strdup(ptr1->package);
-               appinfo->uiapp_info = ptr1;
-
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
        }
-       /*Service Apps*/
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               appinfo->app_component = PMINFO_SVC_APP;
-               appinfo->package = strdup(ptr2->package);
-               appinfo->svcapp_info = ptr2;
 
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(label_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*label) {
+                               LISTHEAD(*label, info);
+                               *label = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &info->text);
+               _save_column_str(stmt, idx++, &info->lang);
+               LISTADD(*label, info);
        }
-       ret = PMINFO_R_OK;
 
-catch:
-       __close_manifest_db();
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
+       if (*label) {
+               LISTHEAD(*label, info);
+               *label = info;
        }
-       __cleanup_pkginfo(info);
-       return ret;
-}
 
-API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
-{
-       return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
+       return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
+static int _appinfo_get_icon(const char *appid, const char *locale,
+               icon_x **icon)
 {
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
-
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       category_x *tmp3 = NULL;
-       metadata_x *tmp4 = NULL;
-       permission_x *tmp5 = NULL;
-       image_x *tmp6 = NULL;
-       appcontrol_x *tmp7 = NULL;
-       const char *user_pkg_parser = NULL;
-       pkgmgr_pkginfo_x *info = NULL;
-
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+       static const char query_raw[] =
+               "SELECT app_icon, app_locale "
+               "FROM package_app_localized_info "
+               "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       icon_x *info;
 
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+       query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
 
-       /*open db*/
-       user_pkg_parser = getUserPkgParserDBPathUID(uid);
-       ret = __open_manifest_db(uid);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
+       }
 
-       /*calloc pkginfo*/
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(icon_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*icon) {
+                               LISTHEAD(*icon, info);
+                               *icon = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &info->text);
+               _save_column_str(stmt, idx++, &info->lang);
+               LISTADD(*icon, info);
+       }
 
-       /*calloc manifest_info*/
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+       if (*icon) {
+               LISTHEAD(*icon, info);
+               *icon = info;
+       }
 
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+       return PMINFO_R_OK;
+}
 
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(GET_DB(manifest_db), query, __app_list_cb, (void *)info);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+static int _appinfo_get_category(const char *appid, category_x **category)
+{
+       static const char query_raw[] =
+               "SELECT category FROM package_app_app_category WHERE app_id=%Q";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       category_x *info;
 
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
+       query = sqlite3_mprintf(query_raw, appid);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
        }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
+
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
        }
 
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->app_component = PMINFO_UI_APP;
-               appinfo->package = strdup(ptr1->package);
-               appinfo->uiapp_info = ptr1;
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_info where " \
-                               "app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
-                       if (locale) {
-                               free(locale);
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(category_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*category) {
+                               LISTHEAD(*category, info);
+                               *category = info;
                        }
-                       locale = __get_app_locale_by_fallback(GET_DB(manifest_db), ptr1->appid, syslocale);
+                       return PMINFO_R_ERROR;
                }
+               _save_column_str(stmt, 0, &info->name);
+               LISTADD(*category, info);
+       }
 
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr1->appid, locale);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+       if (*category) {
+               LISTHEAD(*category, info);
+               *category = info;
+       }
 
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr1->appid, DEFAULT_LOCALE);
+       return PMINFO_R_OK;
+}
 
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+static int _appinfo_get_app_control(const char *appid,
+               appcontrol_x **appcontrol)
+{
+       static const char query_raw[] =
+               "SELECT app_control FROM package_app_app_control "
+               "WHERE app_id=%Q";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       appcontrol_x *info = NULL;
+       char *str;
 
-               /*store setting notification icon section*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+       query = sqlite3_mprintf(query_raw, appid);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
 
-               /*store app preview image info*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
-
-               /*store app control info*/
-               snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
-
-               if (appinfo->uiapp_info->label) {
-                       LISTHEAD(appinfo->uiapp_info->label, tmp1);
-                       appinfo->uiapp_info->label = tmp1;
-               }
-               if (appinfo->uiapp_info->icon) {
-                       LISTHEAD(appinfo->uiapp_info->icon, tmp2);
-                       appinfo->uiapp_info->icon= tmp2;
-               }
-               if (appinfo->uiapp_info->category) {
-                       LISTHEAD(appinfo->uiapp_info->category, tmp3);
-                       appinfo->uiapp_info->category = tmp3;
-               }
-               if (appinfo->uiapp_info->metadata) {
-                       LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
-                       appinfo->uiapp_info->metadata = tmp4;
-               }
-               if (appinfo->uiapp_info->permission) {
-                       LISTHEAD(appinfo->uiapp_info->permission, tmp5);
-                       appinfo->uiapp_info->permission = tmp5;
-               }
-               if (appinfo->uiapp_info->image) {
-                       LISTHEAD(appinfo->uiapp_info->image, tmp6);
-                       appinfo->uiapp_info->image = tmp6;
-               }
-               if (appinfo->uiapp_info->appcontrol) {
-                       LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
-                       appinfo->uiapp_info->appcontrol = tmp7;
-               }
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
        }
-       /*Service Apps*/
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->app_component = PMINFO_SVC_APP;
-               appinfo->package = strdup(ptr2->package);
-               appinfo->svcapp_info = ptr2;
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_info where " \
-                               "app_id='%s'", ptr2->appid);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr2->appid, locale);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               _save_column_str(stmt, 0, (const char **)&str);
+               /* TODO: revise */
+               __parse_appcontrol(&info, str);
+               free(str);
+       }
 
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr2->appid, DEFAULT_LOCALE);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr2->appid);
-               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
-
-               if (appinfo->svcapp_info->label) {
-                       LISTHEAD(appinfo->svcapp_info->label, tmp1);
-                       appinfo->svcapp_info->label = tmp1;
-               }
-               if (appinfo->svcapp_info->icon) {
-                       LISTHEAD(appinfo->svcapp_info->icon, tmp2);
-                       appinfo->svcapp_info->icon= tmp2;
-               }
-               if (appinfo->svcapp_info->category) {
-                       LISTHEAD(appinfo->svcapp_info->category, tmp3);
-                       appinfo->svcapp_info->category = tmp3;
-               }
-               if (appinfo->svcapp_info->metadata) {
-                       LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
-                       appinfo->svcapp_info->metadata = tmp4;
-               }
-               if (appinfo->svcapp_info->permission) {
-                       LISTHEAD(appinfo->svcapp_info->permission, tmp5);
-                       appinfo->svcapp_info->permission = tmp5;
-               }
-               if (appinfo->svcapp_info->appcontrol) {
-                       LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
-                       appinfo->svcapp_info->appcontrol = tmp7;
-               }
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
+       if (*appcontrol) {
+               LISTHEAD(*appcontrol, info);
+               *appcontrol = info;
        }
-       ret = PMINFO_R_OK;
 
-catch:
-       if (locale) {
-               free(locale);
-               locale = NULL;
+       return PMINFO_R_OK;
+}
+
+static int _appinfo_get_data_control(const char *appid,
+               datacontrol_x **datacontrol)
+{
+       static const char query_raw[] =
+               "SELECT providerid, access, type "
+               "FROM package_app_data_control WHERE app_id=%Q";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       datacontrol_x *info;
+
+       query = sqlite3_mprintf(query_raw, appid);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
        }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
+
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
        }
-       __close_manifest_db();
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               info = calloc(1, sizeof(datacontrol_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       if (*datacontrol) {
+                               LISTHEAD(*datacontrol, info);
+                               *datacontrol = info;
+                       }
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &info->providerid);
+               _save_column_str(stmt, idx++, &info->access);
+               _save_column_str(stmt, idx++, &info->type);
+               LISTADD(*datacontrol, info);
        }
-       __cleanup_pkginfo(info);
-       return ret;
-}
 
-API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
-{
-       return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
+       if (*datacontrol) {
+               LISTHEAD(*datacontrol, info);
+               *datacontrol = info;
+       }
+
+       return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
+static int _appinfo_get_app(const char *locale, pkgmgrinfo_filter_x *filter,
+               pkgmgr_appinfo_x **appinfo)
 {
-       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       static const char query_raw[] =
+               "SELECT app_id, app_component, app_exec, app_nodisplay, "
+               "app_type, app_onboot, app_multiple, app_autorestart, "
+               "app_taskmanage, app_enabled, app_hwacceleration, "
+               "app_screenreader, app_mainapp, app_recentimage, "
+               "app_launchcondition, app_indicatordisplay, app_portraitimg, "
+               "app_landscapeimg, app_guestmodevisibility, "
+               "app_permissiontype, app_preload, app_submode, "
+               "app_submode_mainid, app_launch_mode, component_type, package "
+               "FROM package_app_info";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       int idx;
+       pkgmgr_appinfo_x *info;
+       application_x *app;
 
-       pkgmgr_appinfo_x *appinfo = NULL;
-       char *syslocale = NULL;
-       char *locale = NULL;
-       int ret = -1;
-       int exist = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       category_x *tmp3 = NULL;
-       metadata_x *tmp4 = NULL;
-       permission_x *tmp5 = NULL;
-       image_x *tmp6 = NULL;
-       appcontrol_x *tmp7 = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       const char* user_pkg_parser = NULL;
+       query = _get_filtered_query(query_raw, filter);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
 
-       *handle = NULL;
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return PMINFO_R_ERROR;
+       }
 
-       /*open db*/
-       user_pkg_parser = getUserPkgParserDBPathUID(uid);
-       ret = __open_manifest_db(uid);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
-  
-       /*check appid exist on db*/
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __validate_cb, (void *)&exist);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
-       tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] for user[%d] is not found in DB", appid, uid);
-
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               app = calloc(1, sizeof(application_x));
+               if (app == NULL) {
+                       LOGE("out of memory");
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
+               idx = 0;
+               _save_column_str(stmt, idx++, &app->appid);
+               _save_column_str(stmt, idx++, &app->component);
+               _save_column_str(stmt, idx++, &app->exec);
+               _save_column_str(stmt, idx++, &app->nodisplay);
+               _save_column_str(stmt, idx++, &app->type);
+               _save_column_str(stmt, idx++, &app->onboot);
+               _save_column_str(stmt, idx++, &app->multiple);
+               _save_column_str(stmt, idx++, &app->autorestart);
+               _save_column_str(stmt, idx++, &app->taskmanage);
+               _save_column_str(stmt, idx++, &app->enabled);
+               _save_column_str(stmt, idx++, &app->hwacceleration);
+               _save_column_str(stmt, idx++, &app->screenreader);
+               _save_column_str(stmt, idx++, &app->mainapp);
+               _save_column_str(stmt, idx++, &app->recentimage);
+               _save_column_str(stmt, idx++, &app->launchcondition);
+               _save_column_str(stmt, idx++, &app->indicatordisplay);
+               _save_column_str(stmt, idx++, &app->portraitimg);
+               _save_column_str(stmt, idx++, &app->landscapeimg);
+               _save_column_str(stmt, idx++, &app->guestmode_visibility);
+               _save_column_str(stmt, idx++, &app->permission_type);
+               _save_column_str(stmt, idx++, &app->preload);
+               _save_column_str(stmt, idx++, &app->submode);
+               _save_column_str(stmt, idx++, &app->submode_mainid);
+               _save_column_str(stmt, idx++, &app->launch_mode);
+               _save_column_str(stmt, idx++, &app->component_type);
+               _save_column_str(stmt, idx++, &app->package);
+
+               if (_appinfo_get_label(app->appid, locale, &app->label)) {
+                       pkgmgrinfo_basic_free_application(app);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
 
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+               if (_appinfo_get_icon(app->appid, locale, &app->icon)) {
+                       pkgmgrinfo_basic_free_application(app);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
 
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
+               if (_appinfo_get_category(app->appid, &app->category)) {
+                       pkgmgrinfo_basic_free_application(app);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
 
-       /*check app_component from DB*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appcomponent_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       /*calloc app_component*/
-       if (appinfo->app_component == PMINFO_UI_APP) {
-               appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
-               tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
-       } else {
-               appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
-               tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
-       }
-       appinfo->locale = strdup(locale);
+               if (_appinfo_get_app_control(app->appid, &app->appcontrol)) {
+                       pkgmgrinfo_basic_free_application(app);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
 
-       /*populate app_info from DB*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+               if (_appinfo_get_data_control(app->appid, &app->datacontrol)) {
+                       pkgmgrinfo_basic_free_application(app);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
 
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+               info = calloc(1, sizeof(pkgmgr_appinfo_x));
+               if (info == NULL) {
+                       LOGE("out of memory");
+                       pkgmgrinfo_basic_free_application(app);
+                       sqlite3_finalize(stmt);
+                       return PMINFO_R_ERROR;
+               }
 
-       /*Also store the values corresponding to default locales*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+               info->package = strdup(app->package);
+               info->app_info = app;
+               info->locale = strdup(locale);
+               LISTADD(*appinfo, info);
+       }
 
-       /*Populate app category*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
+       sqlite3_finalize(stmt);
 
-       /*Populate app metadata*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
+       if (*appinfo) {
+               LISTHEAD(*appinfo, info);
+               *appinfo = info;
+       } else {
+               LOGE("no result");
+               return PMINFO_R_OK;
+       }
 
-       /*Populate app permission*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
+       return PMINFO_R_OK;
+}
 
-       /*store setting notification icon section*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
+               pkgmgrinfo_appinfo_h *handle)
+{
+       pkgmgr_appinfo_x *appinfo = NULL;
+       pkgmgrinfo_appinfo_filter_h filter;
+       char *locale;
 
-       /*store app preview image info*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+       if (appid == NULL || handle == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
+       }
 
-       /*store app control info*/
-       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
-       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+       if (__open_manifest_db(uid) < 0)
+               return PMINFO_R_ERROR;
 
-       switch (appinfo->app_component) {
-       case PMINFO_UI_APP:
-               if (appinfo->uiapp_info->label) {
-                       LISTHEAD(appinfo->uiapp_info->label, tmp1);
-                       appinfo->uiapp_info->label = tmp1;
-               }
-               if (appinfo->uiapp_info->icon) {
-                       LISTHEAD(appinfo->uiapp_info->icon, tmp2);
-                       appinfo->uiapp_info->icon = tmp2;
-               }
-               if (appinfo->uiapp_info->category) {
-                       LISTHEAD(appinfo->uiapp_info->category, tmp3);
-                       appinfo->uiapp_info->category = tmp3;
-               }
-               if (appinfo->uiapp_info->metadata) {
-                       LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
-                       appinfo->uiapp_info->metadata = tmp4;
-               }
-               if (appinfo->uiapp_info->permission) {
-                       LISTHEAD(appinfo->uiapp_info->permission, tmp5);
-                       appinfo->uiapp_info->permission = tmp5;
-               }
-               if (appinfo->uiapp_info->image) {
-                       LISTHEAD(appinfo->uiapp_info->image, tmp6);
-                       appinfo->uiapp_info->image = tmp6;
-               }
-               if (appinfo->uiapp_info->appcontrol) {
-                       LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
-                       appinfo->uiapp_info->appcontrol = tmp7;
-               }
-               break;
-       case PMINFO_SVC_APP:
-               if (appinfo->svcapp_info->label) {
-                       LISTHEAD(appinfo->svcapp_info->label, tmp1);
-                       appinfo->svcapp_info->label = tmp1;
-               }
-               if (appinfo->svcapp_info->icon) {
-                       LISTHEAD(appinfo->svcapp_info->icon, tmp2);
-                       appinfo->svcapp_info->icon = tmp2;
-               }
-               if (appinfo->svcapp_info->category) {
-                       LISTHEAD(appinfo->svcapp_info->category, tmp3);
-                       appinfo->svcapp_info->category = tmp3;
-               }
-               if (appinfo->svcapp_info->metadata) {
-                       LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
-                       appinfo->svcapp_info->metadata = tmp4;
-               }
-               if (appinfo->svcapp_info->permission) {
-                       LISTHEAD(appinfo->svcapp_info->permission, tmp5);
-                       appinfo->svcapp_info->permission = tmp5;
-               }
-               if (appinfo->svcapp_info->appcontrol) {
-                       LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
-                       appinfo->svcapp_info->appcontrol = tmp7;
-               }
-               break;
-       default:
-               break;
+       locale = _get_system_locale();
+       if (locale == NULL) {
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
        }
 
-       ret = PMINFO_R_OK;
-
-catch:
-       if (ret == PMINFO_R_OK)
-               *handle = (void*)appinfo;
-       else {
-               *handle = NULL;
-               __cleanup_appinfo(appinfo);
+       if (pkgmgrinfo_appinfo_filter_create(&filter)) {
+               free(locale);
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
        }
 
-       __close_manifest_db();
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
+       if (pkgmgrinfo_appinfo_filter_add_string(filter,
+                               PMINFO_APPINFO_PROP_APP_ID, appid)) {
+               pkgmgrinfo_appinfo_filter_destroy(filter);
+               free(locale);
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
        }
-       if (locale) {
+
+       if (_appinfo_get_app(locale, filter, &appinfo)) {
                free(locale);
-               locale = NULL;
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
        }
-       return ret;
+
+       *handle = appinfo;
+
+       pkgmgrinfo_appinfo_filter_destroy(filter);
+       __close_manifest_db();
+
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
@@ -5512,20 +3976,9 @@ API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       switch (info->app_component) {
-       case PMINFO_UI_APP:
-               if (info->uiapp_info == NULL || info->uiapp_info->appid == NULL)
-                       return PMINFO_R_ERROR;
-               *appid = (char *)info->uiapp_info->appid;
-               break;
-       case PMINFO_SVC_APP:
-               if (info->svcapp_info == NULL || info->svcapp_info->appid == NULL)
-                       return PMINFO_R_ERROR;
-               *appid = (char *)info->svcapp_info->appid;
-               break;
-       default:
+       if (info->app_info == NULL || info->app_info->appid == NULL)
                return PMINFO_R_ERROR;
-       }
+       *appid = (char *)info->app_info->appid;
 
        return PMINFO_R_OK;
 }
@@ -5567,20 +4020,9 @@ API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       switch (info->app_component) {
-       case PMINFO_UI_APP:
-               if (info->uiapp_info == NULL || info->uiapp_info->exec == NULL)
-                       return PMINFO_R_ERROR;
-               *exec = (char *)info->uiapp_info->exec;
-               break;
-       case PMINFO_SVC_APP:
-               if (info->svcapp_info == NULL || info->svcapp_info->exec == NULL)
-                       return PMINFO_R_ERROR;
-               *exec = (char *)info->svcapp_info->exec;
-               break;
-       default:
+       if (info->app_info == NULL || info->app_info->exec == NULL)
                return PMINFO_R_ERROR;
-       }
+       *exec = (char *)info->app_info->exec;
 
        return PMINFO_R_OK;
 }
@@ -5599,13 +4041,7 @@ API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-        if (info->app_component == PMINFO_UI_APP)
-                start = info->uiapp_info->icon;
-       else if (info->app_component == PMINFO_SVC_APP)
-                start = info->svcapp_info->icon;
-       else
-               return PMINFO_R_EINVAL;
-
+       start = info->app_info->icon;
        for (ptr = start; ptr != NULL; ptr = ptr->next) {
                if (ptr->lang == NULL)
                        continue;
@@ -5641,13 +4077,7 @@ API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
        locale = info->locale;
        retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
 
-       if (info->app_component == PMINFO_UI_APP)
-               start = info->uiapp_info->label;
-       else if (info->app_component == PMINFO_SVC_APP)
-               start = info->svcapp_info->label;
-       else
-               return PMINFO_R_EINVAL;
-
+       start = info->app_info->label;
        for (ptr = start; ptr != NULL; ptr = ptr->next) {
                if (ptr->lang == NULL)
                        continue;
@@ -5740,17 +4170,20 @@ API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *loca
 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
 {
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       int comp;
 
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->app_component == PMINFO_UI_APP)
-               *component = PMINFO_UI_APP;
-       else if (info->app_component == PMINFO_SVC_APP)
-               *component = PMINFO_SVC_APP;
-       else
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       comp = __appcomponent_convert(info->app_info->component);
+       if (comp < 0)
                return PMINFO_R_ERROR;
 
+       *component = comp;
+
        return PMINFO_R_OK;
 }
 
@@ -5761,20 +4194,9 @@ API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_t
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       switch (info->app_component) {
-       case PMINFO_UI_APP:
-               if (info->uiapp_info == NULL || info->uiapp_info->type == NULL)
-                       return PMINFO_R_ERROR;
-               *app_type = (char *)info->uiapp_info->type;
-               break;
-       case PMINFO_SVC_APP:
-               if (info->svcapp_info == NULL || info->svcapp_info->type == NULL)
-                       return PMINFO_R_ERROR;
-               *app_type = (char *)info->svcapp_info->type;
-               break;
-       default:
+       if (info->app_info == NULL || info->app_info->type == NULL)
                return PMINFO_R_ERROR;
-       }
+       *app_type = (char *)info->app_info->type;
 
        return PMINFO_R_OK;
 }
@@ -5836,7 +4258,7 @@ API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       for (ptr = info->uiapp_info->icon; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->app_info->icon; ptr != NULL; ptr = ptr->next) {
                if (ptr->section == NULL)
                        continue;
 
@@ -5860,7 +4282,7 @@ API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, ch
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       for (ptr = info->uiapp_info->icon; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->app_info->icon; ptr != NULL; ptr = ptr->next) {
                if (ptr->section == NULL)
                        continue;
 
@@ -5882,10 +4304,10 @@ API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pk
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->uiapp_info == NULL || info->uiapp_info->recentimage == NULL)
+       if (info->app_info == NULL || info->app_info->recentimage == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->uiapp_info->recentimage;
+       val = (char *)info->app_info->recentimage;
        if (strcasecmp(val, "capture") == 0)
                *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
        else if (strcasecmp(val, "icon") == 0)
@@ -5905,7 +4327,7 @@ API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char *
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       for (ptr = info->uiapp_info->image; ptr != NULL; ptr = ptr->next) {
+       for (ptr = info->app_info->image; ptr != NULL; ptr = ptr->next) {
                if (ptr->section == NULL)
                        continue;
 
@@ -5927,13 +4349,7 @@ API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgm
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->app_component == PMINFO_UI_APP)
-               val = info->uiapp_info->permission_type;
-       else if (info->app_component == PMINFO_SVC_APP)
-               val = info->svcapp_info->permission_type;
-       else
-               return PMINFO_R_ERROR;
-
+       val = info->app_info->permission_type;
        if (val == NULL)
                return PMINFO_R_ERROR;
 
@@ -5954,10 +4370,10 @@ API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->uiapp_info == NULL || info->uiapp_info->component_type == NULL)
+       if (info->app_info == NULL || info->app_info->component_type == NULL)
                return PMINFO_R_ERROR;
 
-       *component_type = (char *)info->uiapp_info->component_type;
+       *component_type = (char *)info->app_info->component_type;
 
        return PMINFO_R_OK;
 }
@@ -5970,10 +4386,10 @@ API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmg
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->uiapp_info == NULL || info->uiapp_info->hwacceleration == NULL)
+       if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->uiapp_info->hwacceleration;
+       val = (char *)info->app_info->hwacceleration;
        if (strcasecmp(val, "not-use-GL") == 0)
                *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
        else if (strcasecmp(val, "use-GL") == 0)
@@ -5992,10 +4408,10 @@ API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgri
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->uiapp_info == NULL || info->uiapp_info->screenreader == NULL)
+       if (info->app_info == NULL || info->app_info->screenreader == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->uiapp_info->screenreader;
+       val = (char *)info->app_info->screenreader;
        if (strcasecmp(val, "screenreader-off") == 0)
                *screenreader = PMINFO_SCREENREADER_OFF;
        else if (strcasecmp(val, "screenreader-on") == 0)
@@ -6014,12 +4430,12 @@ API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **p
        retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->app_component != PMINFO_UI_APP || info->uiapp_info == NULL ||
-                       info->uiapp_info->portraitimg || info->uiapp_info->landscapeimg == NULL)
+       if (info->app_info == NULL || info->app_info->portraitimg ||
+                       info->app_info->landscapeimg == NULL)
                return PMINFO_R_ERROR;
 
-       *portrait_img = (char *)info->uiapp_info->portraitimg;
-       *landscape_img = (char *)info->uiapp_info->landscapeimg;
+       *portrait_img = (char *)info->app_info->portraitimg;
+       *landscape_img = (char *)info->app_info->landscapeimg;
 
        return PMINFO_R_OK;
 }
@@ -6031,10 +4447,10 @@ API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h  handle, char
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
 
-       if (info->uiapp_info == NULL || info->uiapp_info->submode_mainid == NULL)
+       if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
                return PMINFO_R_ERROR;
 
-       *submode_mainid = (char *)info->uiapp_info->submode_mainid;
+       *submode_mainid = (char *)info->app_info->submode_mainid;
 
        return PMINFO_R_OK;
 }
@@ -6046,13 +4462,10 @@ API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **m
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       if (info->app_component != PMINFO_UI_APP)
-               return PMINFO_R_EINVAL;
-
-       if (info->uiapp_info->launch_mode == NULL)
+       if (info->app_info->launch_mode == NULL)
                return PMINFO_R_ERROR;
 
-       *mode = (char *)(info->uiapp_info->launch_mode);
+       *mode = (char *)(info->app_info->launch_mode);
 
        return PMINFO_R_OK;
 }
@@ -6148,13 +4561,11 @@ API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
        int ret = -1;
        permission_x *ptr = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       if (info->app_component == PMINFO_UI_APP)
-               ptr = info->uiapp_info->permission;
-       else if (info->app_component == PMINFO_SVC_APP)
-               ptr = info->svcapp_info->permission;
-       else
-               return PMINFO_R_EINVAL;
-       for (; ptr; ptr = ptr->next) {
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       for (ptr = info->app_info->permission; ptr; ptr = ptr->next) {
                if (ptr->value) {
                        ret = permission_func(ptr->value, user_data);
                        if (ret < 0)
@@ -6172,13 +4583,11 @@ API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
        int ret = -1;
        category_x *ptr = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       if (info->app_component == PMINFO_UI_APP)
-               ptr = info->uiapp_info->category;
-       else if (info->app_component == PMINFO_SVC_APP)
-               ptr = info->svcapp_info->category;
-       else
-               return PMINFO_R_EINVAL;
-       for (; ptr; ptr = ptr->next) {
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       for (ptr = info->app_info->category; ptr; ptr = ptr->next) {
                if (ptr->name) {
                        ret = category_func(ptr->name, user_data);
                        if (ret < 0)
@@ -6196,13 +4605,11 @@ API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
        int ret = -1;
        metadata_x *ptr = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       if (info->app_component == PMINFO_UI_APP)
-               ptr = info->uiapp_info->metadata;
-       else if (info->app_component == PMINFO_SVC_APP)
-               ptr = info->svcapp_info->metadata;
-       else
-               return PMINFO_R_EINVAL;
-       for (; ptr; ptr = ptr->next) {
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       for (ptr = info->app_info->metadata; ptr; ptr = ptr->next) {
                if (ptr->key) {
                        ret = metadata_func(ptr->key, ptr->value, user_data);
                        if (ret < 0)
@@ -6220,27 +4627,11 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
        int ret;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
        appcontrol_x *appcontrol;
-       pkgmgrinfo_app_component component;
-       ret = pkgmgrinfo_appinfo_get_component(handle, &component);
-       if (ret < 0) {
-               _LOGE("Failed to get app component name\n");
-               return PMINFO_R_ERROR;
-       }
-       switch (component) {
-       case PMINFO_UI_APP:
-               if (info->uiapp_info == NULL)
-                       return PMINFO_R_EINVAL;
-               appcontrol = info->uiapp_info->appcontrol;
-               break;
-       case PMINFO_SVC_APP:
-               if (info->svcapp_info == NULL)
-                       return PMINFO_R_EINVAL;
-               appcontrol = info->svcapp_info->appcontrol;
-               break;
-       default:
-               return PMINFO_R_EINVAL;
-       }
-       for (; appcontrol; appcontrol = appcontrol->next) {
+
+       if (info->uiapp_info == NULL)
+               return PMINFO_R_ERROR;
+
+       for (appcontrol = info->app_info->appcontrol; appcontrol; appcontrol = appcontrol->next) {
                ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
                if (ret < 0)
                        break;
@@ -6249,13 +4640,17 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h  handle, bool *nodisplay)
+API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->nodisplay;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->nodisplay;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *nodisplay = 1;
@@ -6267,13 +4662,17 @@ API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h  handle, bool *nodi
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h  handle, bool *multiple)
+API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->multiple;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->multiple;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *multiple = 1;
@@ -6291,7 +4690,11 @@ API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h han
        retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->indicatordisplay;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->indicatordisplay;
        if (val) {
                if (strcasecmp(val, "true") == 0){
                        *indicator_disp = 1;
@@ -6310,7 +4713,11 @@ API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h  handle, bool *tas
        retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->taskmanage;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->taskmanage;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *taskmanage = 1;
@@ -6328,15 +4735,11 @@ API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h  handle, bool *enable
        retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       if (info->app_component == PMINFO_UI_APP)
-               val = (char *)info->uiapp_info->enabled;
-       else if (info->app_component == PMINFO_SVC_APP)
-               val = (char *)info->uiapp_info->enabled;
-       else {
-               _LOGE("invalid component type\n");
-               return PMINFO_R_EINVAL;
-       }
 
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->enabled;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *enabled = 1;
@@ -6355,7 +4758,11 @@ API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h  handle, bool *onboot)
        retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->svcapp_info->onboot;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->onboot;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *onboot = 1;
@@ -6373,7 +4780,11 @@ API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h  handle, bool *au
        retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->svcapp_info->autorestart;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->autorestart;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *autorestart = 1;
@@ -6391,7 +4802,11 @@ API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainap
        retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->mainapp;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->mainapp;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *mainapp = 1;
@@ -6409,7 +4824,11 @@ API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload
        retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->preload;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->preload;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *preload = 1;
@@ -6427,7 +4846,11 @@ API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode
        retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->submode;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       val = (char *)info->app_info->submode;
        if (val) {
                if (strcasecmp(val, "true") == 0)
                        *submode = 1;
@@ -6448,14 +4871,13 @@ API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const
        category_x *ptr = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
-       *exist = 0;
-
-       ptr = info->uiapp_info->category;
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
 
-       for (; ptr; ptr = ptr->next) {
+       *exist = 0;
+       for (ptr = info->app_info->category; ptr; ptr = ptr->next) {
                if (ptr->name) {
-                       if (strcasecmp(ptr->name, category) == 0)
-                       {
+                       if (strcasecmp(ptr->name, category) == 0) {
                                *exist = 1;
                                break;
                        }
@@ -6732,194 +5154,17 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int
        return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
 }
 
-API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
-                               pkgmgrinfo_app_list_cb app_cb, void * user_data, uid_t uid)
+API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
+               pkgmgrinfo_appinfo_filter_h handle,
+               pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
 {
-       char *syslocale;
-       char *locale;
-       char *condition;
-       char *error_message;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret;
-       uiapplication_x *ptr1;
-       serviceapplication_x *ptr2;
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       pkgmgr_pkginfo_x *info;
-       pkgmgr_pkginfo_x *filtinfo = NULL;
-       pkgmgr_appinfo_x *appinfo = NULL;
-
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
+       if (handle == NULL || app_cb == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
        }
 
-       ret = __open_manifest_db(uid);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               free(syslocale);
-               free(locale);
-               return PMINFO_R_ERROR;
-       }
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
-               }
-       }
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
-       }
-       /*To get filtered list*/
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       if (info->manifest_info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       /*To get detail app info for each member of filtered list*/
-       filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (filtinfo == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       if (filtinfo->manifest_info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       if (appinfo == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       if (SQLITE_OK !=
-           sqlite3_exec(GET_DB(manifest_db), query, __app_list_cb, (void *)info, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       memset(query, '\0', MAX_QUERY_LEN);
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
-       }
-       /*Filtered UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr1->appid, "uiapp");
-               if (SQLITE_OK !=
-               sqlite3_exec(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                              error_message);
-                       sqlite3_free(error_message);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-       }
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr2->appid, "svcapp");
-               if (SQLITE_OK !=
-               sqlite3_exec(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                              error_message);
-                       sqlite3_free(error_message);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-       }
-       if (filtinfo->manifest_info->uiapplication) {
-               LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
-               filtinfo->manifest_info->uiapplication = ptr1;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr1 != NULL)
-       {
-               appinfo->package = strdup(ptr1->package);
-               appinfo->locale = strdup(locale);
-               appinfo->uiapp_info = ptr1;
-               appinfo->app_component = PMINFO_UI_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr1 = ptr1->next;
-       }
-       /*Filtered Service Apps*/
-       if (filtinfo->manifest_info->serviceapplication) {
-               LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
-               filtinfo->manifest_info->serviceapplication = ptr2;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr2 != NULL)
-       {
-               appinfo->package = strdup(ptr2->package);
-               appinfo->locale = strdup(locale);
-               appinfo->svcapp_info = ptr2;
-               appinfo->app_component = PMINFO_SVC_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr2 = ptr2->next;
-       }
-       ret = PMINFO_R_OK;
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       __close_manifest_db();
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       __cleanup_pkginfo(filtinfo);
-       return ret;
+       return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
+                       user_data);
 }
 
 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
@@ -6978,157 +5223,117 @@ catch:
        return ret;
 }
 
-API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
-               pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
+static char *_get_metadata_filtered_query(const char *query_raw,
+               pkgmgrinfo_filter_x *filter)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
-       retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
+       char buf[MAX_QUERY_LEN] = { 0, };
+       char *condition;
+       size_t len;
        GSList *list;
-       int ret = 0;
-       pkgmgr_pkginfo_x *info = NULL;
-       pkgmgr_pkginfo_x *filtinfo = NULL;
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+       GSList *head = NULL;
 
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
+       if (filter)
+               head = filter->list;
 
-       ret = __open_manifest_db(uid);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               free(syslocale);
-               free(locale);
-               return PMINFO_R_ERROR;
-       }
-       /*Start constructing query*/
-       memset(where, '\0', MAX_QUERY_LEN);
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
+       strncat(buf, query_raw, MAX_QUERY_LEN - 1);
+       len = strlen(buf);
+       for (list = head; list; list = list->next) {
+               /* TODO: revise condition getter function */
                __get_metadata_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
+               if (condition == NULL)
+                       continue;
+               if (buf[strlen(query_raw)] == '\0') {
+                       len += strlen(" WHERE ");
+                       strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
+               } else {
+                       len += strlen(" AND ");
+                       strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
                }
+               len += strlen(condition);
+               strncat(buf, condition, sizeof(buf) - len - 1);
+               free(condition);
+               condition = NULL;
        }
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-       }
-       /*To get filtered list*/
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
 
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
-       /*To get detail app info for each member of filtered list*/
-       filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
-       filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+       return strdup(buf);
+}
 
-       ret = sqlite3_exec(GET_DB(manifest_db), query, __app_list_cb, (void *)info, &error_message);
-       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
-       memset(query, '\0', MAX_QUERY_LEN);
+static GSList *_appinfo_get_metadata_filtered_list(pkgmgrinfo_filter_x *filter)
+{
+       static const char query_raw[] =
+               "SELECT app_id FROM package_app_app_metadata";
+       int ret;
+       char *query;
+       sqlite3_stmt *stmt;
+       GSList *list = NULL;
+       char *appid;
 
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
+       query = _get_metadata_filtered_query(query_raw, filter);
+       if (query == NULL) {
+               LOGE("out of memory");
+               return NULL;
        }
 
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr1->appid, "uiapp");
-               ret = sqlite3_exec(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)filtinfo, &error_message);
-               tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
-               memset(query, '\0', MAX_QUERY_LEN);
-       }
-       /*Service Apps*/
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr2->appid, "svcapp");
-               ret = sqlite3_exec(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)filtinfo, &error_message);
-               tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
-               memset(query, '\0', MAX_QUERY_LEN);
-       }
-       /*Filtered UI Apps*/
-       if (filtinfo->manifest_info->uiapplication) {
-               LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
-               filtinfo->manifest_info->uiapplication = ptr1;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr1 != NULL)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->uiapp_info = ptr1;
-               appinfo->app_component = PMINFO_UI_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr1 = ptr1->next;
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+                       &stmt, NULL);
+       free(query);
+       if (ret != SQLITE_OK) {
+               LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+               return NULL;
        }
-       /*Filtered Service Apps*/
-       if (filtinfo->manifest_info->serviceapplication) {
-               LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
-               filtinfo->manifest_info->serviceapplication = ptr2;
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               _save_column_str(stmt, 0, (const char **)&appid);
+               list = g_slist_append(list, appid);
        }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr2 != NULL)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->svcapp_info = ptr2;
-               appinfo->app_component = PMINFO_SVC_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr2 = ptr2->next;
+
+       return list;
+}
+
+API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
+               pkgmgrinfo_appinfo_metadata_filter_h handle,
+               pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
+{
+       GSList *list;
+       GSList *tmp;
+       char *appid;
+       pkgmgrinfo_appinfo_h info;
+       int stop = 0;
+
+       if (handle == NULL || app_cb == NULL) {
+               LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
        }
-       ret = PMINFO_R_OK;
-catch:
-       if (locale) {
-               free(locale);
-               locale = NULL;
+
+       if (__open_manifest_db(uid) < 0)
+               return PMINFO_R_ERROR;
+
+       list = _appinfo_get_metadata_filtered_list(handle);
+       if (list == NULL) {
+               LOGE("no result");
+               __close_manifest_db();
+               return PMINFO_R_ERROR;
        }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
+
+       for (tmp = list; tmp; tmp = tmp->next) {
+               appid = (char *)tmp->data;
+               if (stop == 0) {
+                       if (pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid,
+                                               &info)) {
+                               free(appid);
+                               continue;
+                       }
+                       if (app_cb(info, user_data) < 0)
+                               stop = 1;
+                       pkgmgrinfo_appinfo_destroy_appinfo(info);
+               }
+               free(appid);
        }
-       sqlite3_free(error_message);
+
+       g_slist_free(list);
        __close_manifest_db();
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       __cleanup_pkginfo(filtinfo);
-       return ret;
+
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
@@ -7847,7 +6052,7 @@ API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
 
        retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
 
-       pkgmgr_parser_free_manifest_xml(mfx);
+       pkgmgrinfo_basic_free_package(mfx);
 
        return PMINFO_R_OK;
 }