Merge branch private
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 8 Apr 2013 09:10:38 +0000 (18:10 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 8 Apr 2013 09:10:42 +0000 (18:10 +0900)
1. Implemented privilege API
2. Fixed SEGFAULT in pkg filter API
3. removed gcc warning
4. code cleanup
5. fixed Prevent Issues

Change-Id: I7f791ce5956c3dae3d8bfa63e7cc06695fa289b8
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
include/pkgmgr-info.h
packaging/pkgmgr-info.spec
parser/manifest.xsd.in
parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c
src/pkgmgr-info.c

index 01745d6..683a87a 100755 (executable)
@@ -237,6 +237,21 @@ typedef int (*pkgmgrinfo_app_category_list_cb ) (const char *category_name,
                                                        void *user_data);
 
 /**
+ * @fn int (*pkgmgrinfo_pkg_privilege_list_cb ) (const char *privilege_name, void *user_data)
+ *
+ * @brief Specifies the type of function passed to pkgmgrinfo_pkginfo_foreach_privilege()
+ *
+ * @param[in] privilege_name the name of the privilege
+ * @param[in] user_data user data passed to pkgmgrinfo_pkginfo_foreach_privilege()
+ *
+ * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.\n
+ *
+ * @see  pkgmgrinfo_pkginfo_foreach_privilege()
+ */
+typedef int (*pkgmgrinfo_pkg_privilege_list_cb ) (const char *privilege_name,
+                                                       void *user_data);
+
+/**
  * @fn int (*pkgmgrinfo_app_metadata_list_cb ) (const char *metadata_key, const char *metadata_value, void *user_data)
  *
  * @brief Specifies the type of function passed to pkgmgrinfo_appinfo_foreach_metadata()
@@ -1903,6 +1918,51 @@ static int get_rpm_pkg_count()
 int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count);
 
 /**
+ * @fn int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+                       pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data);
+ * @brief      This API gets the list of privilege for a particular package
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ * @param[in]  handle          pointer to the package info handle.
+ * @param[in]  privilege_func          callback function for list
+ * @param[in] user_data        user data to be passed to callback function
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ERROR  internal error
+ * @pre                pkgmgrinfo_pkginfo_get_pkginfo()
+ * @post               pkgmgrinfo_pkginfo_destroy_pkginfo()
+ * @code
+int privilege_func(const char *name, void *user_data)
+{
+       if (strcmp(name, (char *)user_data) == 0)
+               return -1;
+       else
+               return 0;
+}
+
+static int list_privilege(const char *package, char *privilege)
+{
+       int ret = 0;
+       pkgmgrinfo_pkginfo_h handle;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_func, (void *)privilege);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+                       pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data);
+
+/**
  * @fn int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
  pkgmgrinfo_app_list_cb app_func, void *user_data)
  * @brief      This API gets list of installed applications for a particular package
index bbcc495..d183d0b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       pkgmgr-info
 Summary:    Packager Manager infomation api for package
-Version:    0.0.92
+Version:    0.0.95
 Release:    1
 Group:      Application Framework/Package Management
 License:    Apache-2.0
@@ -43,7 +43,7 @@ Dev package for libpkgmgr-parser
 %setup -q
 
 %build
-%cmake . 
+%cmake .
 make %{?jobs:-j%jobs}
 
 %install
index 10bec60..d0630cc 100755 (executable)
   <xs:element name="ime">
   </xs:element>
   <xs:element name="privileges">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:choice maxOccurs="unbounded" minOccurs="0">
+          <xs:element ref="packages:privilege"/>
+        </xs:choice>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="privilege">
   </xs:element>
   <xs:element name="font">
     <xs:complexType>
index c8bf1a5..92097b9 100755 (executable)
  * limitations under the License.
  *
  */
-
+#define _GNU_SOURCE
 #include <dlfcn.h>
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <time.h>
+#include <string.h>
 #include <libxml/parser.h>
 #include <libxml/xmlreader.h>
 #include <libxml/xmlschemas.h>
@@ -48,9 +52,11 @@ typedef enum {
        ACTION_MAX
 } ACTION_TYPE;
 
-char *package;
+const char *package;
 
 static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
+static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
+static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
 static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
 static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
 static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
@@ -66,12 +72,9 @@ static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *
 static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
 static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
 static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
-static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry);
-static int __ps_process_database(xmlTextReaderPtr reader, database_x *database);
 static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
 static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
-static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout);
 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
 static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
 static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
@@ -86,6 +89,8 @@ 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);
@@ -101,12 +106,9 @@ static void __ps_free_compatibility(compatibility_x *compatibility);
 static void __ps_free_resolution(resolution_x *resolution);
 static void __ps_free_request(request_x *request);
 static void __ps_free_define(define_x *define);
-static void __ps_free_registry(registry_x *registry);
-static void __ps_free_database(database_x *database);
 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_layout(layout_x *layout);
 static void __ps_free_icon(icon_x *icon);
 static void __ps_free_author(author_x *author);
 static void __ps_free_description(description_x *description);
@@ -404,9 +406,8 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con
        if (temp == NULL)
                return -1;
        xmlNode *next_node = NULL;
-       while(cur_node != NULL)
-       {
-               if ( (strcmp(temp->name, cur_node->name) == 0) &&
+       while(cur_node != NULL) {
+               if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
                        (temp->line == cur_node->line) ) {
                        break;
                }
@@ -447,7 +448,7 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con
        fclose(fp);
 #endif
 
-       ret = __ps_run_parser(copyDocPtr, name, action, pkgid);
+       ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
  END:
 
        return ret;
@@ -495,7 +496,7 @@ __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], c
                        else {
                                i = 0;
                                for (tag = tagv[0]; tag; tag = tagv[++i])
-                                       if (strcmp(tag, elementName) == 0) {
+                                       if (strcmp(tag, ASCII(elementName)) == 0) {
                                                DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
                                                __run_parser_prestep(reader,
                                                                     action, pkgid);
@@ -597,6 +598,36 @@ static void __ps_free_category(category_x *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)
@@ -809,8 +840,7 @@ static void __ps_free_capability(capability_x *capability)
        if (capability->resolution) {
                resolution_x *resolution = capability->resolution;
                resolution_x *tmp = NULL;
-               while(resolution != NULL)
-               {
+               while(resolution != NULL) {
                        tmp = resolution->next;
                        __ps_free_resolution(resolution);
                        resolution = tmp;
@@ -860,8 +890,7 @@ static void __ps_free_datacontrol(datacontrol_x *datacontrol)
        if (datacontrol->capability) {
                capability_x *capability = datacontrol->capability;
                capability_x *tmp = NULL;
-               while(capability != NULL)
-               {
+               while(capability != NULL) {
                        tmp = capability->next;
                        __ps_free_capability(capability);
                        capability = tmp;
@@ -883,8 +912,7 @@ static void __ps_free_launchconditions(launchconditions_x *launchconditions)
        if (launchconditions->condition) {
                condition_x *condition = launchconditions->condition;
                condition_x *tmp = NULL;
-               while(condition != NULL)
-               {
+               while(condition != NULL) {
                        tmp = condition->next;
                        __ps_free_condition(condition);
                        condition = tmp;
@@ -906,8 +934,7 @@ static void __ps_free_appcontrol(appcontrol_x *appcontrol)
        if (appcontrol->operation) {
                operation_x *operation = appcontrol->operation;
                operation_x *tmp = NULL;
-               while(operation != NULL)
-               {
+               while(operation != NULL) {
                        tmp = operation->next;
                        __ps_free_operation(operation);
                        operation = tmp;
@@ -917,8 +944,7 @@ static void __ps_free_appcontrol(appcontrol_x *appcontrol)
        if (appcontrol->uri) {
                uri_x *uri = appcontrol->uri;
                uri_x *tmp = NULL;
-               while(uri != NULL)
-               {
+               while(uri != NULL) {
                        tmp = uri->next;
                        __ps_free_uri(uri);
                        uri = tmp;
@@ -928,8 +954,7 @@ static void __ps_free_appcontrol(appcontrol_x *appcontrol)
        if (appcontrol->mime) {
                mime_x *mime = appcontrol->mime;
                mime_x *tmp = NULL;
-               while(mime != NULL)
-               {
+               while(mime != NULL) {
                        tmp = mime->next;
                        __ps_free_mime(mime);
                        mime = tmp;
@@ -939,8 +964,7 @@ static void __ps_free_appcontrol(appcontrol_x *appcontrol)
        if (appcontrol->subapp) {
                subapp_x *subapp = appcontrol->subapp;
                subapp_x *tmp = NULL;
-               while(subapp != NULL)
-               {
+               while(subapp != NULL) {
                        tmp = subapp->next;
                        __ps_free_subapp(subapp);
                        subapp = tmp;
@@ -962,8 +986,7 @@ static void __ps_free_appsvc(appsvc_x *appsvc)
        if (appsvc->operation) {
                operation_x *operation = appsvc->operation;
                operation_x *tmp = NULL;
-               while(operation != NULL)
-               {
+               while(operation != NULL) {
                        tmp = operation->next;
                        __ps_free_operation(operation);
                        operation = tmp;
@@ -973,8 +996,7 @@ static void __ps_free_appsvc(appsvc_x *appsvc)
        if (appsvc->uri) {
                uri_x *uri = appsvc->uri;
                uri_x *tmp = NULL;
-               while(uri != NULL)
-               {
+               while(uri != NULL) {
                        tmp = uri->next;
                        __ps_free_uri(uri);
                        uri = tmp;
@@ -984,8 +1006,7 @@ static void __ps_free_appsvc(appsvc_x *appsvc)
        if (appsvc->mime) {
                mime_x *mime = appsvc->mime;
                mime_x *tmp = NULL;
-               while(mime != NULL)
-               {
+               while(mime != NULL) {
                        tmp = mime->next;
                        __ps_free_mime(mime);
                        mime = tmp;
@@ -995,8 +1016,7 @@ static void __ps_free_appsvc(appsvc_x *appsvc)
        if (appsvc->subapp) {
                subapp_x *subapp = appsvc->subapp;
                subapp_x *tmp = NULL;
-               while(subapp != NULL)
-               {
+               while(subapp != NULL) {
                        tmp = subapp->next;
                        __ps_free_subapp(subapp);
                        subapp = tmp;
@@ -1023,8 +1043,7 @@ static void __ps_free_define(define_x *define)
        if (define->request) {
                request_x *request = define->request;
                request_x *tmp = NULL;
-               while(request != NULL)
-               {
+               while(request != NULL) {
                        tmp = request->next;
                        __ps_free_request(request);
                        request = tmp;
@@ -1034,8 +1053,7 @@ static void __ps_free_define(define_x *define)
        if (define->allowed) {
                allowed_x *allowed = define->allowed;
                allowed_x *tmp = NULL;
-               while(allowed != NULL)
-               {
+               while(allowed != NULL) {
                        tmp = allowed->next;
                        __ps_free_allowed(allowed);
                        allowed = tmp;
@@ -1045,38 +1063,6 @@ static void __ps_free_define(define_x *define)
        define = NULL;
 }
 
-static void __ps_free_registry(registry_x *registry)
-{
-       if (registry == NULL)
-               return;
-       if (registry->name) {
-               free((void *)registry->name);
-               registry->name = NULL;
-       }
-       if (registry->text) {
-               free((void *)registry->text);
-               registry->text = NULL;
-       }
-       free((void*)registry);
-       registry = NULL;
-}
-
-static void __ps_free_database(database_x *database)
-{
-       if (database == NULL)
-               return;
-       if (database->name) {
-               free((void *)database->name);
-               database->name = NULL;
-       }
-       if (database->text) {
-               free((void *)database->text);
-               database->text = NULL;
-       }
-       free((void*)database);
-       database = NULL;
-}
-
 static void __ps_free_datashare(datashare_x *datashare)
 {
        if (datashare == NULL)
@@ -1085,8 +1071,7 @@ static void __ps_free_datashare(datashare_x *datashare)
        if (datashare->define) {
                define_x *define =  datashare->define;
                define_x *tmp = NULL;
-               while(define != NULL)
-               {
+               while(define != NULL) {
                        tmp = define->next;
                        __ps_free_define(define);
                        define = tmp;
@@ -1096,8 +1081,7 @@ static void __ps_free_datashare(datashare_x *datashare)
        if (datashare->request) {
                request_x *request = datashare->request;
                request_x *tmp = NULL;
-               while(request != NULL)
-               {
+               while(request != NULL) {
                        tmp = request->next;
                        __ps_free_request(request);
                        request = tmp;
@@ -1107,22 +1091,6 @@ static void __ps_free_datashare(datashare_x *datashare)
        datashare = NULL;
 }
 
-static void __ps_free_layout(layout_x *layout)
-{
-       if (layout == NULL)
-               return;
-       if (layout->name) {
-               free((void *)layout->name);
-               layout->name = NULL;
-       }
-       if (layout->text) {
-               free((void *)layout->text);
-               layout->text = NULL;
-       }
-       free((void*)layout);
-       layout = NULL;
-}
-
 static void __ps_free_label(label_x *label)
 {
        if (label == NULL)
@@ -1263,8 +1231,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->label) {
                label_x *label = uiapplication->label;
                label_x *tmp = NULL;
-               while(label != NULL)
-               {
+               while(label != NULL) {
                        tmp = label->next;
                        __ps_free_label(label);
                        label = tmp;
@@ -1274,8 +1241,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->icon) {
                icon_x *icon = uiapplication->icon;
                icon_x *tmp = NULL;
-               while(icon != NULL)
-               {
+               while(icon != NULL) {
                        tmp = icon->next;
                        __ps_free_icon(icon);
                        icon = tmp;
@@ -1285,8 +1251,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->image) {
                image_x *image = uiapplication->image;
                image_x *tmp = NULL;
-               while(image != NULL)
-               {
+               while(image != NULL) {
                        tmp = image->next;
                        __ps_free_image(image);
                        image = tmp;
@@ -1296,8 +1261,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->appcontrol) {
                appcontrol_x *appcontrol = uiapplication->appcontrol;
                appcontrol_x *tmp = NULL;
-               while(appcontrol != NULL)
-               {
+               while(appcontrol != NULL) {
                        tmp = appcontrol->next;
                        __ps_free_appcontrol(appcontrol);
                        appcontrol = tmp;
@@ -1307,8 +1271,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->launchconditions) {
                launchconditions_x *launchconditions = uiapplication->launchconditions;
                launchconditions_x *tmp = NULL;
-               while(launchconditions != NULL)
-               {
+               while(launchconditions != NULL) {
                        tmp = launchconditions->next;
                        __ps_free_launchconditions(launchconditions);
                        launchconditions = tmp;
@@ -1318,8 +1281,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->notification) {
                notification_x *notification = uiapplication->notification;
                notification_x *tmp = NULL;
-               while(notification != NULL)
-               {
+               while(notification != NULL) {
                        tmp = notification->next;
                        __ps_free_notification(notification);
                        notification = tmp;
@@ -1329,8 +1291,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->datashare) {
                datashare_x *datashare = uiapplication->datashare;
                datashare_x *tmp = NULL;
-               while(datashare != NULL)
-               {
+               while(datashare != NULL) {
                        tmp = datashare->next;
                        __ps_free_datashare(datashare);
                        datashare = tmp;
@@ -1340,8 +1301,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->appsvc) {
                appsvc_x *appsvc = uiapplication->appsvc;
                appsvc_x *tmp = NULL;
-               while(appsvc != NULL)
-               {
+               while(appsvc != NULL) {
                        tmp = appsvc->next;
                        __ps_free_appsvc(appsvc);
                        appsvc = tmp;
@@ -1351,8 +1311,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->category) {
                category_x *category = uiapplication->category;
                category_x *tmp = NULL;
-               while(category != NULL)
-               {
+               while(category != NULL) {
                        tmp = category->next;
                        __ps_free_category(category);
                        category = tmp;
@@ -1362,8 +1321,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->metadata) {
                metadata_x *metadata = uiapplication->metadata;
                metadata_x *tmp = NULL;
-               while(metadata != NULL)
-               {
+               while(metadata != NULL) {
                        tmp = metadata->next;
                        __ps_free_metadata(metadata);
                        metadata = tmp;
@@ -1373,8 +1331,7 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
        if (uiapplication->permission) {
                permission_x *permission = uiapplication->permission;
                permission_x *tmp = NULL;
-               while(permission != NULL)
-               {
+               while(permission != NULL) {
                        tmp = permission->next;
                        __ps_free_permission(permission);
                        permission = tmp;
@@ -1438,8 +1395,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->label) {
                label_x *label = serviceapplication->label;
                label_x *tmp = NULL;
-               while(label != NULL)
-               {
+               while(label != NULL) {
                        tmp = label->next;
                        __ps_free_label(label);
                        label = tmp;
@@ -1449,8 +1405,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->icon) {
                icon_x *icon = serviceapplication->icon;
                icon_x *tmp = NULL;
-               while(icon != NULL)
-               {
+               while(icon != NULL) {
                        tmp = icon->next;
                        __ps_free_icon(icon);
                        icon = tmp;
@@ -1460,8 +1415,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->appcontrol) {
                appcontrol_x *appcontrol = serviceapplication->appcontrol;
                appcontrol_x *tmp = NULL;
-               while(appcontrol != NULL)
-               {
+               while(appcontrol != NULL) {
                        tmp = appcontrol->next;
                        __ps_free_appcontrol(appcontrol);
                        appcontrol = tmp;
@@ -1471,8 +1425,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->datacontrol) {
                datacontrol_x *datacontrol = serviceapplication->datacontrol;
                datacontrol_x *tmp = NULL;
-               while(datacontrol != NULL)
-               {
+               while(datacontrol != NULL) {
                        tmp = datacontrol->next;
                        __ps_free_datacontrol(datacontrol);
                        datacontrol = tmp;
@@ -1482,8 +1435,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->launchconditions) {
                launchconditions_x *launchconditions = serviceapplication->launchconditions;
                launchconditions_x *tmp = NULL;
-               while(launchconditions != NULL)
-               {
+               while(launchconditions != NULL) {
                        tmp = launchconditions->next;
                        __ps_free_launchconditions(launchconditions);
                        launchconditions = tmp;
@@ -1493,8 +1445,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->notification) {
                notification_x *notification = serviceapplication->notification;
                notification_x *tmp = NULL;
-               while(notification != NULL)
-               {
+               while(notification != NULL) {
                        tmp = notification->next;
                        __ps_free_notification(notification);
                        notification = tmp;
@@ -1504,8 +1455,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->datashare) {
                datashare_x *datashare = serviceapplication->datashare;
                datashare_x *tmp = NULL;
-               while(datashare != NULL)
-               {
+               while(datashare != NULL) {
                        tmp = datashare->next;
                        __ps_free_datashare(datashare);
                        datashare = tmp;
@@ -1515,8 +1465,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->appsvc) {
                appsvc_x *appsvc = serviceapplication->appsvc;
                appsvc_x *tmp = NULL;
-               while(appsvc != NULL)
-               {
+               while(appsvc != NULL) {
                        tmp = appsvc->next;
                        __ps_free_appsvc(appsvc);
                        appsvc = tmp;
@@ -1526,8 +1475,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->category) {
                category_x *category = serviceapplication->category;
                category_x *tmp = NULL;
-               while(category != NULL)
-               {
+               while(category != NULL) {
                        tmp = category->next;
                        __ps_free_category(category);
                        category = tmp;
@@ -1537,8 +1485,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->metadata) {
                metadata_x *metadata = serviceapplication->metadata;
                metadata_x *tmp = NULL;
-               while(metadata != NULL)
-               {
+               while(metadata != NULL) {
                        tmp = metadata->next;
                        __ps_free_metadata(metadata);
                        metadata = tmp;
@@ -1548,8 +1495,7 @@ static void __ps_free_serviceapplication(serviceapplication_x *serviceapplicatio
        if (serviceapplication->permission) {
                permission_x *permission = serviceapplication->permission;
                permission_x *tmp = NULL;
-               while(permission != NULL)
-               {
+               while(permission != NULL) {
                        tmp = permission->next;
                        __ps_free_permission(permission);
                        permission = tmp;
@@ -1707,6 +1653,15 @@ static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
        return 0;
 }
 
+static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
+{
+       xmlTextReaderRead(reader);
+       if (xmlTextReaderValue(reader)) {
+               privilege->text = ASCII(xmlTextReaderValue(reader));
+       }
+       return 0;
+}
+
 static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
 {
        if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
@@ -1724,7 +1679,7 @@ static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permis
        xmlTextReaderRead(reader);
        if (xmlTextReaderValue(reader))
                permission->value = ASCII(xmlTextReaderValue(reader));
-
+       return 0;
 }
 
 static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
@@ -1809,18 +1764,6 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define)
        return ret;
 }
 
-static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
-static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
 static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
 {
        const xmlChar *node;
@@ -1999,6 +1942,45 @@ static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc)
        return ret;
 }
 
+
+static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
+{
+       const xmlChar *node;
+       int ret = -1;
+       int depth = -1;
+       privilege_x *tmp1 = NULL;
+
+       depth = xmlTextReaderDepth(reader);
+       while ((ret = __next_child_element(reader, depth))) {
+               node = xmlTextReaderConstName(reader);
+               if (!node) {
+                       DBG("xmlTextReaderConstName value is NULL\n");
+                       return -1;
+               }
+
+               if (strcmp(ASCII(node), "privilege") == 0) {
+                       privilege_x *privilege = malloc(sizeof(privilege_x));
+                       if (privilege == NULL) {
+                               DBG("Malloc Failed\n");
+                               return -1;
+                       }
+                       memset(privilege, '\0', sizeof(privilege_x));
+                       LISTADD(privileges->privilege, privilege);
+                       ret = __ps_process_privilege(reader, privilege);
+               } else
+                       return -1;
+               if (ret < 0) {
+                       DBG("Processing privileges failed\n");
+                       return ret;
+               }
+       }
+       if (privileges->privilege) {
+               LISTHEAD(privileges->privilege, tmp1);
+               privileges->privilege = tmp1;
+       }
+       return ret;
+}
+
 static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
 {
        const xmlChar *node;
@@ -2093,14 +2075,8 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar
        return ret;
 }
 
-static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
-{
-       /*TODO: once policy is set*/
-       return 0;
-}
-
 static char*
-__get_icon_with_path(char* icon)
+__get_icon_with_path(const char* icon)
 {
        if (!icon)
                return NULL;
@@ -2190,10 +2166,10 @@ static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
                icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
        xmlTextReaderRead(reader);
        if (xmlTextReaderValue(reader)) {
-               char *text  = ASCII(xmlTextReaderValue(reader));
+               const char *text  = ASCII(xmlTextReaderValue(reader));
                if(text) {
-                       icon->text = __get_icon_with_path(text);
-                       free(text);
+                       icon->text = (const char *)__get_icon_with_path(text);
+                       free((void *)text);
                }
        }
 
@@ -2926,6 +2902,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
        icon_x *tmp11 = NULL;
        compatibility_x *tmp12 = NULL;
        deviceprofile_x *tmp13 = NULL;
+       privileges_x *tmp14 = NULL;
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -2971,6 +2948,15 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
                        memset(license, '\0', sizeof(license_x));
                        LISTADD(mfx->license, license);
                        ret = __ps_process_license(reader, license);
+               } else if (!strcmp(ASCII(node), "privileges")) {
+                       privileges_x *privileges = malloc(sizeof(privileges_x));
+                       if (privileges == NULL) {
+                               DBG("Malloc Failed\n");
+                               return -1;
+                       }
+                       memset(privileges, '\0', sizeof(privileges_x));
+                       LISTADD(mfx->privileges, privileges);
+                       ret = __ps_process_privileges(reader, privileges);
                } else if (!strcmp(ASCII(node), "ui-application")) {
                        uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
                        if (uiapplication == NULL) {
@@ -3060,8 +3046,6 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
                        continue;
                } else if (!strcmp(ASCII(node), "notifications")) {
                        continue;
-               } else if (!strcmp(ASCII(node), "privileges")) {
-                       continue;
                } else if (!strcmp(ASCII(node), "ime")) {
                        continue;
                } else
@@ -3124,7 +3108,10 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
                LISTHEAD(mfx->deviceprofile, tmp13);
                mfx->deviceprofile= tmp13;
        }
-
+       if (mfx->privileges) {
+               LISTHEAD(mfx->privileges, tmp14);
+               mfx->privileges = tmp14;
+       }
        return ret;
 }
 
@@ -3432,19 +3419,17 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
                        mime_x *mi = NULL;
                        uri_x *ui = NULL;
                        subapp_x *sub = NULL;
-                       char *operation = NULL;
-                       char *mime = NULL;
-                       char *uri = NULL;
-                       char *subapp = NULL;
+                       const char *operation = NULL;
+                       const char *mime = NULL;
+                       const char *uri = NULL;
+                       const char *subapp = NULL;
                        int i = 0;
 
 
                        asvc = up->appsvc;
-                       while(asvc != NULL)
-                       {
+                       while(asvc != NULL) {
                                op = asvc->operation;
-                               while(op != NULL)
-                               {
+                               while(op != NULL) {
                                        if (op)
                                                operation = op->name;
                                        mi = asvc->mime;
@@ -3511,18 +3496,16 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
                        mime_x *mi = NULL;
                        uri_x *ui = NULL;
                        subapp_x *sub = NULL;
-                       char *operation = NULL;
-                       char *mime = NULL;
-                       char *uri = NULL;
-                       char *subapp = NULL;
+                       const char *operation = NULL;
+                       const char *mime = NULL;
+                       const char *uri = NULL;
+                       const char *subapp = NULL;
                        int i = 0;
 
                        acontrol = up->appcontrol;
-                       while(acontrol != NULL)
-                       {
+                       while(acontrol != NULL) {
                                op = acontrol->operation;
-                               while(op != NULL)
-                               {
+                               while(op != NULL) {
                                        if (op)
                                                operation = op->name;
                                        mi = acontrol->mime;
@@ -3622,13 +3605,13 @@ static int __add_preload_info(manifest_x * mfx, const char *manifest)
        int state = 0;
 
        if(strstr(manifest, MANIFEST_RO_PREFIX)) {
-               free(mfx->readonly);
+               free((void *)mfx->readonly);
                mfx->readonly = strdup("True");
 
-               free(mfx->preload);
+               free((void *)mfx->preload);
                mfx->preload = strdup("True");
 
-               free(mfx->removable);
+               free((void *)mfx->removable);
                mfx->removable = strdup("False");
 
                return 0;
@@ -3653,17 +3636,17 @@ static int __add_preload_info(manifest_x * mfx, const char *manifest)
                __str_trim(buffer);
 
                if(!strcmp(mfx->package, buffer)) {
-                       free(mfx->preload);
+                       free((void *)mfx->preload);
                        mfx->preload = strdup("True");
                        if(state == 2){
-                               free(mfx->readonly);
+                               free((void *)mfx->readonly);
                                mfx->readonly = strdup("False");
-                               free(mfx->removable);
+                               free((void *)mfx->removable);
                                mfx->removable = strdup("False");
                        } else if(state == 3){
-                               free(mfx->readonly);
+                               free((void *)mfx->readonly);
                                mfx->readonly = strdup("False");
-                               free(mfx->removable);
+                               free((void *)mfx->removable);
                                mfx->removable = strdup("True");
                        }
                }
@@ -3755,8 +3738,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->icon) {
                icon_x *icon = mfx->icon;
                icon_x *tmp = NULL;
-               while(icon != NULL)
-               {
+               while(icon != NULL) {
                        tmp = icon->next;
                        __ps_free_icon(icon);
                        icon = tmp;
@@ -3766,8 +3748,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->label) {
                label_x *label = mfx->label;
                label_x *tmp = NULL;
-               while(label != NULL)
-               {
+               while(label != NULL) {
                        tmp = label->next;
                        __ps_free_label(label);
                        label = tmp;
@@ -3777,8 +3758,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->author) {
                author_x *author = mfx->author;
                author_x *tmp = NULL;
-               while(author != NULL)
-               {
+               while(author != NULL) {
                        tmp = author->next;
                        __ps_free_author(author);
                        author = tmp;
@@ -3788,8 +3768,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->description) {
                description_x *description = mfx->description;
                description_x *tmp = NULL;
-               while(description != NULL)
-               {
+               while(description != NULL) {
                        tmp = description->next;
                        __ps_free_description(description);
                        description = tmp;
@@ -3799,19 +3778,27 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->license) {
                license_x *license = mfx->license;
                license_x *tmp = NULL;
-               while(license != 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)
-               {
+               while(uiapplication != NULL) {
                        tmp = uiapplication->next;
                        __ps_free_uiapplication(uiapplication);
                        uiapplication = tmp;
@@ -3821,8 +3808,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->serviceapplication) {
                serviceapplication_x *serviceapplication = mfx->serviceapplication;
                serviceapplication_x *tmp = NULL;
-               while(serviceapplication != NULL)
-               {
+               while(serviceapplication != NULL) {
                        tmp = serviceapplication->next;
                        __ps_free_serviceapplication(serviceapplication);
                        serviceapplication = tmp;
@@ -3832,8 +3818,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->daemon) {
                daemon_x *daemon = mfx->daemon;
                daemon_x *tmp = NULL;
-               while(daemon != NULL)
-               {
+               while(daemon != NULL) {
                        tmp = daemon->next;
                        __ps_free_daemon(daemon);
                        daemon = tmp;
@@ -3843,8 +3828,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->theme) {
                theme_x *theme = mfx->theme;
                theme_x *tmp = NULL;
-               while(theme != NULL)
-               {
+               while(theme != NULL) {
                        tmp = theme->next;
                        __ps_free_theme(theme);
                        theme = tmp;
@@ -3854,8 +3838,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->font) {
                font_x *font = mfx->font;
                font_x *tmp = NULL;
-               while(font != NULL)
-               {
+               while(font != NULL) {
                        tmp = font->next;
                        __ps_free_font(font);
                        font = tmp;
@@ -3865,8 +3848,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->ime) {
                ime_x *ime = mfx->ime;
                ime_x *tmp = NULL;
-               while(ime != NULL)
-               {
+               while(ime != NULL) {
                        tmp = ime->next;
                        __ps_free_ime(ime);
                        ime = tmp;
@@ -3876,8 +3858,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->compatibility) {
                compatibility_x *compatibility = mfx->compatibility;
                compatibility_x *tmp = NULL;
-               while(compatibility != NULL)
-               {
+               while(compatibility != NULL) {
                        tmp = compatibility->next;
                        __ps_free_compatibility(compatibility);
                        compatibility = tmp;
@@ -3887,8 +3868,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
        if (mfx->deviceprofile) {
                deviceprofile_x *deviceprofile = mfx->deviceprofile;
                deviceprofile_x *tmp = NULL;
-               while(deviceprofile != NULL)
-               {
+               while(deviceprofile != NULL) {
                        tmp = deviceprofile->next;
                        __ps_free_deviceprofile(deviceprofile);
                        deviceprofile = tmp;
index 45d9997..58cbe1a 100755 (executable)
@@ -122,6 +122,18 @@ typedef struct metadata_x {
        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;
@@ -145,8 +157,8 @@ typedef struct image_x {
        const char *text;
        const char *lang;
        const char *section;
-       struct icon_x *prev;
-       struct icon_x *next;
+       struct image_x *prev;
+       struct image_x *next;
 } image_x;
 
 typedef struct allowed_x {
@@ -448,6 +460,7 @@ typedef struct manifest_x {
        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*/
index 3ccf12a..a7d9c20 100755 (executable)
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <db-util.h>
 #include <glib.h>
+#include "pkgmgr-info.h"
 #include "pkgmgr_parser_internal.h"
 #include "pkgmgr_parser_db.h"
 
@@ -76,6 +77,14 @@ char *prev = NULL;
                                                "REFERENCES package_info(package) " \
                                                "ON DELETE CASCADE)"
 
+#define QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO "create table if not exists package_privilege_info " \
+                                               "(package text not null, " \
+                                               "privilege text not null, " \
+                                               "PRIMARY KEY(package, privilege) " \
+                                               "FOREIGN KEY(package) " \
+                                               "REFERENCES package_info(package) " \
+                                               "ON DELETE CASCADE)"
+
 #define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \
                                                "(app_id text primary key not null, " \
                                                "app_component text, " \
@@ -231,32 +240,49 @@ static void __insert_serviceapplication_locale_info(gpointer data, gpointer user
 static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
 static void __insert_pkglocale_info(gpointer data, gpointer userdata);
 static int __insert_manifest_info_in_db(manifest_x *mfx);
-static int __update_manifest_info_in_db(manifest_x *mfx);
 static int __delete_manifest_info_from_db(manifest_x *mfx);
-static int __initialize_package_info_db();
-static int __initialize_package_localized_info_db();
-static int __initialize_package_app_info_db();
-static int __initialize_package_cert_info_db();
-static int __initialize_package_cert_index_info_db();
-static int __initialize_package_app_localized_info_db();
-static int __initialize_package_app_icon_section_info_db();
-static int __initialize_package_app_image_info_db();
-static int __initialize_package_app_app_svc_db();
-static int __initialize_package_app_app_category_db();
-static int __initialize_package_app_app_control_db();
-static int __initialize_package_app_app_metadata_db();
-static int __initialize_package_app_share_allowed_db();
-static int __initialize_package_app_share_request_db();
+static int __delete_appinfo_from_db(char *db_table, const char *appid);
+static int __initialize_db(sqlite3 *db_handle, const char *db_query);
 static int __exec_query(char *query);
 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
                char **label, char **license, char **icon, char **description, char **author);
-
 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
 static void __trimfunc1(gpointer data, gpointer userdata);
 static void __trimfunc2(gpointer data, gpointer userdata);
 static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
 static void __preserve_guestmode_visibility_value(manifest_x *mfx);
 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname);
+static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
+
+static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path)
+{
+       int ret = -1;
+       sqlite3 *handle;
+       if (access(db_path, F_OK) == 0) {
+               ret =
+                   db_util_open(db_path, &handle,
+                                DB_UTIL_REGISTER_HOOK_METHOD);
+               if (ret != SQLITE_OK) {
+                       DBG("connect db [%s] failed!\n",
+                              db_path);
+                       return -1;
+               }
+               *db_handle = handle;
+               return 0;
+       }
+       DBG("%s DB does not exists. Create one!!\n", db_path);
+
+       ret =
+           db_util_open(db_path, &handle,
+                        DB_UTIL_REGISTER_HOOK_METHOD);
+
+       if (ret != SQLITE_OK) {
+               DBG("connect db [%s] failed!\n", db_path);
+               return -1;
+       }
+       *db_handle = handle;
+       return 0;
+}
 
 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname)
 {
@@ -311,278 +337,14 @@ static void __preserve_guestmode_visibility_value(manifest_x *mfx)
        return;
 }
 
-static int __initialize_package_info_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO,
-                        NULL, NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_INFO, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __pkgmgr_parser_cert_create_db()
-{
-       int ret = -1;
-       if (access(PKGMGR_CERT_DB_FILE, F_OK) == 0) {
-               ret =
-                   db_util_open(PKGMGR_CERT_DB_FILE, &pkgmgr_cert_db,
-                                DB_UTIL_REGISTER_HOOK_METHOD);
-               if (ret != SQLITE_OK) {
-                       DBG("connect db [%s] failed!\n",
-                              PKGMGR_CERT_DB_FILE);
-                       return -1;
-               }
-               return 0;
-       }
-       DBG("Pkgmgr DB does not exists. Create one!!\n");
-
-       ret =
-           db_util_open(PKGMGR_CERT_DB_FILE, &pkgmgr_cert_db,
-                        DB_UTIL_REGISTER_HOOK_METHOD);
-
-       if (ret != SQLITE_OK) {
-               DBG("connect db [%s] failed!\n", PKGMGR_CERT_DB_FILE);
-               return -1;
-       }
-       return 0;
-}
-
-static int __initialize_package_cert_info_db()
-{
-       char *error_message = NULL;
-       int ret = -1;
-       ret = __pkgmgr_parser_cert_create_db();
-       if (ret == -1) {
-               DBG("Failed to open DB\n");
-               return ret;
-       }
-
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO,
-                        NULL, NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_CERT_INFO, error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(pkgmgr_cert_db);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_cert_index_info_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO,
-                        NULL, NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO, error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(pkgmgr_cert_db);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       sqlite3_close(pkgmgr_cert_db);
-       return 0;
-}
-
-static int __initialize_package_localized_info_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO, NULL, NULL,
-                        &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO,
-                      error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_info_db()
+static int __initialize_db(sqlite3 *db_handle, const char *db_query)
 {
        char *error_message = NULL;
        if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO,
+           sqlite3_exec(db_handle, db_query,
                         NULL, NULL, &error_message)) {
                DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_INFO, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_localized_info_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO, NULL,
-                        NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO,
-                      error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_icon_section_info_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO, NULL,
-                        NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO,
-                      error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_image_info_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO, NULL,
-                        NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO,
-                      error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_app_control_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL, NULL, NULL,
-                        &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_app_category_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY, NULL, NULL,
-                        &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_app_metadata_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA, NULL, NULL,
-                        &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_app_permission_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION, NULL, NULL,
-                        &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_app_svc_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, NULL, NULL,
-                        &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_share_allowed_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED, NULL,
-                        NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED,
-                      error_message);
-               sqlite3_free(error_message);
-               return -1;
-       }
-       sqlite3_free(error_message);
-       return 0;
-}
-
-static int __initialize_package_app_share_request_db()
-{
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(pkgmgr_parser_db,
-                        QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST, NULL,
-                        NULL, &error_message)) {
-               DBG("Don't execute query = %s error message = %s\n",
-                      QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST,
-                      error_message);
+                      db_query, error_message);
                sqlite3_free(error_message);
                return -1;
        }
@@ -725,6 +487,7 @@ static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
                return -1;
        if (strcmp((char*)a, (char*)b) > 0)
                return 1;
+       return 0;
 }
 
 static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
@@ -798,7 +561,7 @@ static void __extract_icon_data(gpointer data, icon_x *icn, char **icon, char **
        }
 }
 
-static void __extract_image_data(gpointer data, icon_x *image, char **lang, char **img)
+static void __extract_image_data(gpointer data, image_x*image, char **lang, char **img)
 {
        while(image != NULL)
        {
@@ -1119,10 +882,10 @@ static int __insert_uiapplication_appcontrol_info(manifest_x *mfx)
        subapp_x *sub = NULL;
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
-       char *operation = NULL;
-       char *mime = NULL;
-       char *uri = NULL;
-       char *subapp = NULL;
+       const char *operation = NULL;
+       const char *mime = NULL;
+       const char *uri = NULL;
+       const char *subapp = NULL;
        while(up != NULL)
        {
                acontrol = up->appcontrol;
@@ -1193,10 +956,10 @@ static int __insert_uiapplication_appsvc_info(manifest_x *mfx)
        subapp_x *sub = NULL;
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
-       char *operation = NULL;
-       char *mime = NULL;
-       char *uri = NULL;
-       char *subapp = NULL;
+       const char *operation = NULL;
+       const char *mime = NULL;
+       const char *uri = NULL;
+       const char *subapp = NULL;
        while(up != NULL)
        {
                asvc = up->appsvc;
@@ -1451,10 +1214,10 @@ static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx)
        mime_x *mi = NULL;
        uri_x *ui = NULL;
        subapp_x *sub = NULL;
-       char *operation = NULL;
-       char *mime = NULL;
-       char *uri = NULL;
-       char *subapp = NULL;
+       const char *operation = NULL;
+       const char *mime = NULL;
+       const char *uri = NULL;
+       const char *subapp = NULL;
        while(sp != NULL)
        {
                acontrol = sp->appcontrol;
@@ -1523,10 +1286,10 @@ static int __insert_serviceapplication_appsvc_info(manifest_x *mfx)
        mime_x *mi = NULL;
        uri_x *ui = NULL;
        subapp_x *sub = NULL;
-       char *operation = NULL;
-       char *mime = NULL;
-       char *uri = NULL;
-       char *subapp = NULL;
+       const char *operation = NULL;
+       const char *mime = NULL;
+       const char *uri = NULL;
+       const char *subapp = NULL;
        while(sp != NULL)
        {
                asvc = sp->appsvc;
@@ -1674,13 +1437,15 @@ static int __insert_manifest_info_in_db(manifest_x *mfx)
        uiapplication_x *up_icn = mfx->uiapplication;
        uiapplication_x *up_image = mfx->uiapplication;
        serviceapplication_x *sp = mfx->serviceapplication;
+       privileges_x *pvs = NULL;
+       privilege_x *pv = NULL;
        char query[MAX_QUERY_LEN] = { '\0' };
        int ret = -1;
        char *type = NULL;
        char *path = NULL;
-       char *auth_name = NULL;
-       char *auth_email = NULL;
-       char *auth_href = NULL;
+       const char *auth_name = NULL;
+       const char *auth_email = NULL;
+       const char *auth_href = NULL;
        if (ath) {
                if (ath->text)
                        auth_name = ath->text;
@@ -1731,6 +1496,27 @@ static int __insert_manifest_info_in_db(manifest_x *mfx)
                free(path);
                path = NULL;
        }
+
+       /*Insert in the package_privilege_info DB*/
+       pvs = mfx->privileges;
+       while (pvs != NULL) {
+               pv = pvs->privilege;
+               while (pv != NULL) {
+                       memset(query, '\0', MAX_QUERY_LEN);
+                       snprintf(query, MAX_QUERY_LEN,
+                               "insert into package_privilege_info(package, privilege) " \
+                               "values('%s','%s')",\
+                                mfx->package, pv->text);
+                       ret = __exec_query(query);
+                       if (ret == -1) {
+                               DBG("Package Privilege Info DB Insert Failed\n");
+                               return -1;
+                       }
+                       pv = pv->next;
+               }
+               pvs = pvs->next;
+       }
+
        /*Insert the package locale and app locale info */
        pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
        g_list_foreach(pkglocale, __trimfunc1, NULL);
@@ -1885,13 +1671,27 @@ static int __insert_manifest_info_in_db(manifest_x *mfx)
 
 }
 
+static int __delete_appinfo_from_db(char *db_table, const char *appid)
+{
+       char query[MAX_QUERY_LEN] = { '\0' };
+       int ret = -1;
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN,
+                "delete from %s where app_id='%s'", db_table, appid);
+       ret = __exec_query(query);
+       if (ret == -1) {
+               DBG("DB Deletion from table (%s) Failed\n", db_table);
+               return -1;
+       }
+       return 0;
+}
+
 static int __delete_manifest_info_from_db(manifest_x *mfx)
 {
        char query[MAX_QUERY_LEN] = { '\0' };
        int ret = -1;
        uiapplication_x *up = mfx->uiapplication;
        serviceapplication_x *sp = mfx->serviceapplication;
-
        /*Delete from cert table*/
        ret = pkgmgrinfo_delete_certinfo(mfx->package);
        if (ret) {
@@ -1917,285 +1717,87 @@ static int __delete_manifest_info_from_db(manifest_x *mfx)
                DBG("Package Localized Info DB Delete Failed\n");
                return -1;
        }
-       memset(query, '\0', MAX_QUERY_LEN);
 
-       /*Delete from Package App Info*/
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_info where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Info DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
+       /*Delete from Package Privilege Info*/
+       snprintf(query, MAX_QUERY_LEN,
+                "delete from package_privilege_info where package='%s'", mfx->package);
+       ret = __exec_query(query);
+       if (ret == -1) {
+               DBG("Package Privilege Info DB Delete Failed\n");
+               return -1;
+       }
+
+       while (up != NULL) {
+               ret = __delete_appinfo_from_db("package_app_info", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_localized_info", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_icon_section_info", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_image_info", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_svc", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_control", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_category", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_metadata", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_permission", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_share_allowed", up->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_share_request", up->appid);
+               if (ret < 0)
+                       return ret;
                up = up->next;
        }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_info where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Info DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
 
-       /*Delete from Package App Localized Info*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_localized_info where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Localized Info DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_localized_info where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Localized Info DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from  App icon localized Info*/
-       up = mfx->uiapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_icon_section_info where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App image Info DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-
-       /*Delete from  App image Info*/
-       up = mfx->uiapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_image_info where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App image Info DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-
-       /*Delete from Package App App-Svc*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_svc where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Svc DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_svc where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Svc DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from Package App App-Control*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_control where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Control DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_control where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Control DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from Package App App-Category*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_category where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Category DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_category where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Category DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from Package App App-Metadata*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_metadata where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Metadata DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_metadata where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-Metadata DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from Package App App-permission*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_permission where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-permission DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_app_permission where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App App-permission DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from Package App Share Allowed*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_share_allowed where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Share Allowed DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_share_allowed where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Share Allowed DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               sp = sp->next;
-       }
-
-       /*Delete from Package App Share Request*/
-       up = mfx->uiapplication;
-       sp = mfx->serviceapplication;
-       while(up != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_share_request where app_id='%s'", up->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Share Request DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               up = up->next;
-       }
-       while(sp != NULL)
-       {
-               snprintf(query, MAX_QUERY_LEN,
-                        "delete from package_app_share_request where app_id='%s'", sp->appid);
-               ret = __exec_query(query);
-               if (ret == -1) {
-                       DBG("Package App Share Request DB Delete Failed\n");
-                       return -1;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
+       while (sp != NULL) {
+               ret = __delete_appinfo_from_db("package_app_info", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_localized_info", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_icon_section_info", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_image_info", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_svc", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_control", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_category", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_metadata", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_app_permission", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_share_allowed", sp->appid);
+               if (ret < 0)
+                       return ret;
+               ret = __delete_appinfo_from_db("package_app_share_request", sp->appid);
+               if (ret < 0)
+                       return ret;
                sp = sp->next;
        }
        return 0;
@@ -2205,114 +1807,106 @@ static int __delete_manifest_info_from_db(manifest_x *mfx)
 int pkgmgr_parser_initialize_db()
 {
        int ret = -1;
-       ret = __initialize_package_info_db();
+       /*Manifest DB*/
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
        if (ret == -1) {
                DBG("package info DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_localized_info_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO);
        if (ret == -1) {
                DBG("package localized info DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_cert_info_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO);
        if (ret == -1) {
-               DBG("package cert info DB initialization failed\n");
+               DBG("package app app privilege DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_cert_index_info_db();
-       if (ret == -1) {
-               DBG("package cert index info DB initialization failed\n");
-               return ret;
-       }
-       ret = __initialize_package_app_info_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO);
        if (ret == -1) {
                DBG("package app info DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_localized_info_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO);
        if (ret == -1) {
                DBG("package app localized info DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_icon_section_info_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO);
        if (ret == -1) {
                DBG("package app icon localized info DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_image_info_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO);
        if (ret == -1) {
                DBG("package app image info DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_app_control_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL);
        if (ret == -1) {
                DBG("package app app control DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_app_category_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY);
        if (ret == -1) {
                DBG("package app app category DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_app_metadata_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA);
        if (ret == -1) {
                DBG("package app app category DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_app_permission_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION);
        if (ret == -1) {
                DBG("package app app permission DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_app_svc_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC);
        if (ret == -1) {
                DBG("package app app svc DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_share_allowed_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
        if (ret == -1) {
                DBG("package app share allowed DB initialization failed\n");
                return ret;
        }
-       ret = __initialize_package_app_share_request_db();
+       ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST);
        if (ret == -1) {
                DBG("package app share request DB initialization failed\n");
                return ret;
        }
+       /*Cert DB*/
+       ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
+       if (ret == -1) {
+               DBG("package cert info DB initialization failed\n");
+               return ret;
+       }
+       ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO);
+       if (ret == -1) {
+               DBG("package cert index info DB initialization failed\n");
+               return ret;
+       }
        return 0;
 }
 
 int pkgmgr_parser_check_and_create_db()
 {
        int ret = -1;
-       if (access(PKGMGR_PARSER_DB_FILE, F_OK) == 0) {
-               ret =
-                   db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
-                                DB_UTIL_REGISTER_HOOK_METHOD);
-               if (ret != SQLITE_OK) {
-                       DBG("connect db [%s] failed!\n",
-                              PKGMGR_PARSER_DB_FILE);
-                       return -1;
-               }
-               ret = chmod(PKGMGR_PARSER_DB_FILE, 0664);
-               if (ret)
-                       DBG("Failed to change mode of manifest DB\n");
-               return 0;
+       /*Manifest DB*/
+       ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE);
+       if (ret) {
+               DBG("Manifest DB creation Failed\n");
+               return -1;
        }
-       DBG("Pkgmgr DB does not exists. Create one!!\n");
-
-       ret =
-           db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
-                        DB_UTIL_REGISTER_HOOK_METHOD);
-
-       if (ret != SQLITE_OK) {
-               DBG("connect db [%s] failed!\n", PKGMGR_PARSER_DB_FILE);
+       /*Cert DB*/
+       ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE);
+       if (ret) {
+               DBG("Cert DB creation Failed\n");
                return -1;
        }
-       ret = chmod(PKGMGR_PARSER_DB_FILE, 0664);
-       if (ret)
-               DBG("Failed to change mode of manifest DB\n");
        return 0;
 }
 
@@ -2322,7 +1916,7 @@ API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
                DBG("manifest pointer is NULL\n");
                return -1;
        }
-       int ret = -1;
+       int ret = 0;
        ret = pkgmgr_parser_check_and_create_db();
        if (ret == -1) {
                DBG("Failed to open DB\n");
@@ -2330,33 +1924,34 @@ API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
        }
        ret = pkgmgr_parser_initialize_db();
        if (ret == -1)
-               return ret;
+               goto err;
        /*Begin transaction*/
        ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                DBG("Failed to begin transaction\n");
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               ret = -1;
+               goto err;
        }
        DBG("Transaction Begin\n");
        ret = __insert_manifest_info_in_db(mfx);
        if (ret == -1) {
                DBG("Insert into DB failed. Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               goto err;
        }
        /*Commit transaction*/
        ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                DBG("Failed to commit transaction. Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               ret = -1;
+               goto err;
        }
        DBG("Transaction Commit and End\n");
+err:
        sqlite3_close(pkgmgr_parser_db);
-       return 0;
+       sqlite3_close(pkgmgr_cert_db);
+       return ret;
 }
 
 API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
@@ -2365,7 +1960,7 @@ API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
                DBG("manifest pointer is NULL\n");
                return -1;
        }
-       int ret = -1;
+       int ret = 0;
        ret = pkgmgr_parser_check_and_create_db();
        if (ret == -1) {
                DBG("Failed to open DB\n");
@@ -2373,30 +1968,28 @@ API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
        }
        ret = pkgmgr_parser_initialize_db();
        if (ret == -1)
-               return ret;
+               goto err;
        /*Preserve guest mode visibility*/
        __preserve_guestmode_visibility_value( mfx);
        /*Begin transaction*/
        ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                DBG("Failed to begin transaction\n");
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               ret = -1;
+               goto err;
        }
        DBG("Transaction Begin\n");
        ret = __delete_manifest_info_from_db(mfx);
        if (ret == -1) {
                DBG("Delete from DB failed. Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               goto err;
        }
        ret = __insert_manifest_info_in_db(mfx);
        if (ret == -1) {
                DBG("Insert into DB failed. Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               goto err;
        }
 
        /*Commit transaction*/
@@ -2404,12 +1997,14 @@ API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
        if (ret != SQLITE_OK) {
                DBG("Failed to commit transaction. Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               ret = -1;
+               goto err;
        }
        DBG("Transaction Commit and End\n");
+err:
        sqlite3_close(pkgmgr_parser_db);
-       return 0;
+       sqlite3_close(pkgmgr_cert_db);
+       return ret;
 }
 
 API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
@@ -2418,7 +2013,7 @@ API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
                DBG("manifest pointer is NULL\n");
                return -1;
        }
-       int ret = -1;
+       int ret = 0;
        ret = pkgmgr_parser_check_and_create_db();
        if (ret == -1) {
                DBG("Failed to open DB\n");
@@ -2428,26 +2023,28 @@ API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
        ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                DBG("Failed to begin transaction\n");
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               ret = -1;
+               goto err;
        }
        DBG("Transaction Begin\n");
        ret = __delete_manifest_info_from_db(mfx);
        if (ret == -1) {
                DBG("Delete from DB failed. Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               goto err;
        }
        /*Commit transaction*/
        ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                DBG("Failed to commit transaction, Rollback now\n");
                sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(pkgmgr_parser_db);
-               return -1;
+               ret = -1;
+               goto err;
        }
        DBG("Transaction Commit and End\n");
        sqlite3_close(pkgmgr_parser_db);
-       return 0;
+err:
+       sqlite3_close(pkgmgr_parser_db);
+       sqlite3_close(pkgmgr_cert_db);
+       return ret;
 }
index b1eca4b..7079d57 100755 (executable)
@@ -28,6 +28,7 @@
 #include <sqlite3.h>
 #include <vconf.h>
 #include <glib.h>
+#include <ctype.h>
 #include <assert.h>
 
 #include <libxml/parser.h>
@@ -37,6 +38,7 @@
 #include "pkgmgr_parser.h"
 #include "pkgmgr-info-internal.h"
 #include "pkgmgr-info.h"
+#include "pkgmgr_parser_db.h"
 #include <dirent.h>
 #include <sys/stat.h>
 
@@ -201,8 +203,6 @@ 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 int __pkgmgr_appinfo_new_handle_id();
-static int __pkgmgr_pkginfo_new_handle_id();
 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);
@@ -921,6 +921,7 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
        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);
@@ -930,6 +931,8 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
        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) {
@@ -1022,7 +1025,11 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->root_path = strdup(coltxt[i]);
                        else
                                info->manifest_info->root_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]);
@@ -1737,30 +1744,33 @@ static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt,
 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);
-       __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
-
+       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);
-       __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
-
+       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];
@@ -1772,15 +1782,21 @@ static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, c
                _LOGE("Out of Memory!!!\n");
                return NULL;
        }
-       memset(info, NULL, sizeof(*info));
+       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);
-       __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
+       ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
+       tryvm_if(ret == -1, PMINFO_R_ERROR, "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)
@@ -1804,7 +1820,7 @@ static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const
        char *locale_new = NULL;
        int check_result = 0;
 
-       locale = __convert_syslocale_to_manifest_locale(syslocale);
+       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);
@@ -1987,10 +2003,7 @@ err:
 
 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
 {
-       if (pkg_list_cb == NULL) {
-               _LOGE("callback function is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
        char *error_message = NULL;
        int ret = PMINFO_R_OK;
        char query[MAX_QUERY_LEN] = {'\0'};
@@ -2001,6 +2014,7 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
        icon_x *tmp2 = NULL;
        description_x *tmp3 = NULL;
        author_x *tmp4 = NULL;
+       privilege_x *tmp5 = NULL;
 
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
        if (syslocale == NULL) {
@@ -2021,7 +2035,7 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
                ret = PMINFO_R_ERROR;
                goto err;
        }
-       pkgmgr_pkginfo_x *tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
+       pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
        pkgmgr_pkginfo_x *node = NULL;
        pkgmgr_pkginfo_x *temp_node = NULL;
 
@@ -2040,7 +2054,12 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
 
        for(node = node->next; node ; node = node->next) {
                pkginfo = node;
-
+               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);
@@ -2050,6 +2069,15 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
                        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);
@@ -2084,6 +2112,10 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
                        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);
@@ -2122,14 +2154,8 @@ err:
 
 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
 {
-       if (pkgid == NULL) {
-               _LOGE("package name is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (handle == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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;
        char *error_message = NULL;
        int ret = PMINFO_R_OK;
@@ -2141,6 +2167,7 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
        icon_x *tmp2 = NULL;
        description_x *tmp3 = NULL;
        author_x *tmp4 = NULL;
+       privilege_x *tmp5 = NULL;
 
        /*validate pkgid*/
        ret = __open_manifest_db();
@@ -2191,6 +2218,12 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
                goto err;
        }
        pkginfo->manifest_info->package = strdup(pkgid);
+       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' ", pkgid);
        ret = __exec_pkginfo_query(query, (void *)pkginfo);
@@ -2200,6 +2233,15 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
                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' ", pkgid);
+       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'", pkgid, locale);
        ret = __exec_pkginfo_query(query, (void *)pkginfo);
@@ -2234,6 +2276,10 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
                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;
+       }
        *handle = (void *)pkginfo;
        sqlite3_close(manifest_db);
        if (syslocale) {
@@ -2264,17 +2310,11 @@ err:
 
 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (pkg_name == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        if (info->manifest_info->package)
-               *pkg_name = info->manifest_info->package;
+               *pkg_name = (char *)info->manifest_info->package;
        else
                return PMINFO_R_ERROR;
 
@@ -2283,17 +2323,11 @@ API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_n
 
 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (pkgid == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        if (info->manifest_info->package)
-               *pkgid = info->manifest_info->package;
+               *pkgid = (char *)info->manifest_info->package;
        else
                return PMINFO_R_ERROR;
 
@@ -2302,17 +2336,11 @@ API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
 
 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (type == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        if (info->manifest_info->type)
-               *type = info->manifest_info->type;
+               *type = (char *)info->manifest_info->type;
        else
                *type = pkgtype;
        return PMINFO_R_OK;
@@ -2320,14 +2348,8 @@ API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
 
 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (version == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        *version = (char *)info->manifest_info->version;
        return PMINFO_R_OK;
@@ -2335,14 +2357,8 @@ API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **versi
 
 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (location == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        val = (char *)info->manifest_info->installlocation;
@@ -2359,14 +2375,8 @@ API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkg
 
 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (size == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        char *location = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
@@ -2389,14 +2399,8 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si
 
 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (size == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
 
        char *pkgid = NULL;
        char device_path[PKG_STRING_LEN_MAX] = { '\0', };
@@ -2530,14 +2534,8 @@ API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size
 
 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (size == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
 
        char *pkgid = NULL;
        char device_path[PKG_STRING_LEN_MAX] = { '\0', };
@@ -2678,14 +2676,8 @@ catch:
 
 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (description == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        char *locale = NULL;
        description_x *ptr = NULL;
        *description = NULL;
@@ -2713,14 +2705,8 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d
 
 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (author_name == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        char *locale = NULL;
        author_x *ptr = NULL;
        *author_name = NULL;
@@ -2748,14 +2734,8 @@ API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **a
 
 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (author_email == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        *author_email = (char *)info->manifest_info->author->email;
        return PMINFO_R_OK;
@@ -2763,14 +2743,8 @@ API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **
 
 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (author_href == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        *author_href = (char *)info->manifest_info->author->href;
        return PMINFO_R_OK;
@@ -2778,8 +2752,10 @@ API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **a
 
 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
 {
-       char *pkgid;
+       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");
 
+       char *pkgid = NULL;
        pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
        if (pkgid == NULL){
                 _LOGE("invalid func parameters\n");
@@ -2832,14 +2808,8 @@ API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pk
 
 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (installed_time == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        if (info->manifest_info->installed_time)
                *installed_time = atoi(info->manifest_info->installed_time);
@@ -2851,14 +2821,8 @@ API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *
 
 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (storeclientid == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        *storeclientid = (char *)info->manifest_info->storeclient_id;
        return PMINFO_R_OK;
@@ -2866,14 +2830,8 @@ API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char *
 
 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (mainappid == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        *mainappid = (char *)info->manifest_info->mainapp_id;
        return PMINFO_R_OK;
@@ -2881,14 +2839,8 @@ API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mai
 
 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (url == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        *url = (char *)info->manifest_info->package_url;
        return PMINFO_R_OK;
@@ -2896,19 +2848,11 @@ API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
 
 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
 {
-       char *val = NULL;
+       const char *val = NULL;
        const xmlChar *node;
        xmlTextReaderPtr reader;
-
-       if (manifest == NULL) {
-               _LOGE("input argument is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-
-       if (size == NULL) {
-               _LOGE("output argument is NULL\n");
-               return PMINFO_R_ERROR;
-       }
+       retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
+       retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
        xmlInitParser();
        reader = xmlReaderForFile(manifest, NULL, 0);
@@ -2957,19 +2901,11 @@ API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
 
 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
 {
-       char *val = NULL;
+       const char *val = NULL;
        const xmlChar *node;
        xmlTextReaderPtr reader;
-
-       if (manifest == NULL) {
-               _LOGE("input argument is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-
-       if (location == NULL) {
-               _LOGE("output argument is NULL\n");
-               return PMINFO_R_ERROR;
-       }
+       retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
+       retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
        xmlInitParser();
        reader = xmlReaderForFile(manifest, NULL, 0);
@@ -3018,18 +2954,12 @@ API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinf
 
 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (path == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
 
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        if (info->manifest_info->root_path)
-               *path = info->manifest_info->root_path;
+               *path = (char *)info->manifest_info->root_path;
        else
                return PMINFO_R_ERROR;
 
@@ -3247,8 +3177,9 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c
 
 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
 {
-       char *pkgid;
-
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       char *pkgid = NULL;
        pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
        if (pkgid == NULL){
                 _LOGD("invalid func parameters\n");
@@ -3305,14 +3236,8 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce
 
 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (removable == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        val = (char *)info->manifest_info->removable;
@@ -3350,14 +3275,8 @@ API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable
 
 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (preload == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        val = (char *)info->manifest_info->preload;
@@ -3374,14 +3293,8 @@ API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload
 
 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (readonly == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        val = (char *)info->manifest_info->readonly;
@@ -3417,10 +3330,7 @@ API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
 
 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
 {
-       if (handle == NULL) {
-               _LOGE("pkginfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        __cleanup_pkginfo(info);
        return PMINFO_R_OK;
@@ -3428,10 +3338,7 @@ API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
 
 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
 {
-       if (handle == NULL) {
-               _LOGE("Filter handle output parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
        *handle = NULL;
        pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
        if (filter == NULL) {
@@ -3444,10 +3351,7 @@ API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
 
 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
 {
-       if (handle == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
        if (filter->list){
                g_slist_foreach(filter->list, __destroy_each_node, NULL);
@@ -3461,10 +3365,8 @@ API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
                                const char *property, const int value)
 {
-       if (handle == NULL || property == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
        char *val = NULL;
        GSList *link = NULL;
@@ -3504,10 +3406,8 @@ API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
                                const char *property, const bool value)
 {
-       if (handle == NULL || property == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *val = NULL;
        GSList *link = NULL;
        int prop = -1;
@@ -3548,10 +3448,9 @@ API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
                                const char *property, const char *value)
 {
-       if (handle == NULL || property == NULL || value == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *val = NULL;
        GSList *link = NULL;
        int prop = -1;
@@ -3599,10 +3498,8 @@ API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
 
 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
 {
-       if (handle == NULL || count == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *syslocale = NULL;
        char *locale = NULL;
        char *condition = NULL;
@@ -3685,10 +3582,8 @@ err:
 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
                                pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
 {
-       if (handle == NULL || pkg_cb == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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;
@@ -3701,6 +3596,7 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
        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;
@@ -3768,6 +3664,12 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
        LISTHEAD(tmphead, node);
        for(node = node->next ; node ; node = node->next) {
                pkginfo = node;
+               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);
@@ -3812,6 +3714,10 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
                        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);
@@ -3838,6 +3744,23 @@ err:
        return ret;
 }
 
+API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+                       pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+       retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+       int ret = -1;
+       privilege_x *ptr = NULL;
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       ptr = info->manifest_info->privileges->privilege;
+       for (; ptr; ptr = ptr->next) {
+               ret = privilege_func(ptr->text, user_data);
+               if (ret < 0)
+                       break;
+       }
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
                                                pkgmgrinfo_app_list_cb app_func, void *user_data)
 {
@@ -3854,10 +3777,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
        pkgmgr_appinfo_x *appinfo = NULL;
        icon_x *ptr1 = NULL;
        label_x *ptr2 = NULL;
-       category_x *tmp3 = NULL;
-       metadata_x *tmp4 = NULL;
-       permission_x *tmp5 = NULL;
-       image_x *tmp6 = NULL;
+       category_x *ptr3 = NULL;
+       metadata_x *ptr4 = NULL;
+       permission_x *ptr5 = NULL;
+       image_x *ptr6 = NULL;
        sqlite3 *appinfo_db = NULL;
 
        /*get system locale*/
@@ -3870,7 +3793,7 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
 
        /*calloc allinfo*/
        strncpy(glocale, locale, PKG_LOCALE_STRING_LEN_MAX  - 1);
-       allinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+       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*/
@@ -3954,20 +3877,20 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                appinfo->uiapp_info->icon = ptr1;
                        }
                        if (appinfo->uiapp_info->category) {
-                               LISTHEAD(appinfo->uiapp_info->category, tmp3);
-                               appinfo->uiapp_info->category = tmp3;
+                               LISTHEAD(appinfo->uiapp_info->category, ptr3);
+                               appinfo->uiapp_info->category = ptr3;
                        }
                        if (appinfo->uiapp_info->metadata) {
-                               LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
-                               appinfo->uiapp_info->metadata = tmp4;
+                               LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
+                               appinfo->uiapp_info->metadata = ptr4;
                        }
                        if (appinfo->uiapp_info->permission) {
-                               LISTHEAD(appinfo->uiapp_info->permission, tmp5);
-                               appinfo->uiapp_info->permission = tmp5;
+                               LISTHEAD(appinfo->uiapp_info->permission, ptr5);
+                               appinfo->uiapp_info->permission = ptr5;
                        }
                        if (appinfo->uiapp_info->image) {
-                               LISTHEAD(appinfo->uiapp_info->image, tmp6);
-                               appinfo->uiapp_info->image = tmp6;
+                               LISTHEAD(appinfo->uiapp_info->image, ptr6);
+                               appinfo->uiapp_info->image = ptr6;
                        }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
@@ -4009,16 +3932,16 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                appinfo->svcapp_info->icon = ptr1;
                        }
                        if (appinfo->svcapp_info->category) {
-                               LISTHEAD(appinfo->svcapp_info->category, tmp3);
-                               appinfo->svcapp_info->category = tmp3;
+                               LISTHEAD(appinfo->svcapp_info->category, ptr3);
+                               appinfo->svcapp_info->category = ptr3;
                        }
                        if (appinfo->svcapp_info->metadata) {
-                               LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
-                               appinfo->svcapp_info->metadata = tmp4;
+                               LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
+                               appinfo->svcapp_info->metadata = ptr4;
                        }
                        if (appinfo->svcapp_info->permission) {
-                               LISTHEAD(appinfo->svcapp_info->permission, tmp5);
-                               appinfo->svcapp_info->permission = tmp5;
+                               LISTHEAD(appinfo->svcapp_info->permission, ptr5);
+                               appinfo->svcapp_info->permission = ptr5;
                        }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
@@ -4077,20 +4000,20 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                appinfo->uiapp_info->icon = ptr1;
                        }
                        if (appinfo->uiapp_info->category) {
-                               LISTHEAD(appinfo->uiapp_info->category, tmp3);
-                               appinfo->uiapp_info->category = tmp3;
+                               LISTHEAD(appinfo->uiapp_info->category, ptr3);
+                               appinfo->uiapp_info->category = ptr3;
                        }
                        if (appinfo->uiapp_info->metadata) {
-                               LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
-                               appinfo->uiapp_info->metadata = tmp4;
+                               LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
+                               appinfo->uiapp_info->metadata = ptr4;
                        }
                        if (appinfo->uiapp_info->permission) {
-                               LISTHEAD(appinfo->uiapp_info->permission, tmp5);
-                               appinfo->uiapp_info->permission = tmp5;
+                               LISTHEAD(appinfo->uiapp_info->permission, ptr5);
+                               appinfo->uiapp_info->permission = ptr5;
                        }
                        if (appinfo->uiapp_info->image) {
-                               LISTHEAD(appinfo->uiapp_info->image, tmp6);
-                               appinfo->uiapp_info->image = tmp6;
+                               LISTHEAD(appinfo->uiapp_info->image, ptr6);
+                               appinfo->uiapp_info->image = ptr6;
                        }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
@@ -4129,16 +4052,16 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                appinfo->svcapp_info->icon = ptr1;
                        }
                        if (appinfo->svcapp_info->category) {
-                               LISTHEAD(appinfo->svcapp_info->category, tmp3);
-                               appinfo->svcapp_info->category = tmp3;
+                               LISTHEAD(appinfo->svcapp_info->category, ptr3);
+                               appinfo->svcapp_info->category = ptr3;
                        }
                        if (appinfo->svcapp_info->metadata) {
-                               LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
-                               appinfo->svcapp_info->metadata = tmp4;
+                               LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
+                               appinfo->svcapp_info->metadata = ptr4;
                        }
                        if (appinfo->svcapp_info->permission) {
-                               LISTHEAD(appinfo->svcapp_info->permission, tmp5);
-                               appinfo->svcapp_info->permission = tmp5;
+                               LISTHEAD(appinfo->svcapp_info->permission, ptr5);
+                               appinfo->svcapp_info->permission = ptr5;
                        }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
@@ -4162,7 +4085,7 @@ catch:
        }
        if (appinfo) {
                if (appinfo->package) {
-                       free(appinfo->package);
+                       free((void *)appinfo->package);
                        appinfo->package = NULL;
                }
                free(appinfo);
@@ -4307,7 +4230,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                ret = app_func((void *)appinfo, user_data);
                if (ret < 0)
                        break;
-               free(appinfo->package);
+               free((void *)appinfo->package);
                appinfo->package = NULL;
        }
        /*Service Apps*/
@@ -4362,7 +4285,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                ret = app_func((void *)appinfo, user_data);
                if (ret < 0)
                        break;
-               free(appinfo->package);
+               free((void *)appinfo->package);
                appinfo->package = NULL;
        }
        ret = PMINFO_R_OK;
@@ -4567,14 +4490,8 @@ catch:
 
 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h  handle, char **appid)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (appid == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_component == PMINFO_UI_APP)
@@ -4587,14 +4504,8 @@ API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h  handle, char **appid)
 
 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h  handle, char **pkg_name)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (pkg_name == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        *pkg_name = (char *)info->package;
@@ -4604,14 +4515,8 @@ API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h  handle, char **pkg_
 
 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h  handle, char **pkgid)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (pkgid == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        *pkgid = (char *)info->package;
@@ -4621,14 +4526,8 @@ API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h  handle, char **pkgid)
 
 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h  handle, char **exec)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (exec == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_component == PMINFO_UI_APP)
@@ -4642,14 +4541,8 @@ API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h  handle, char **exec)
 
 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h  handle, char **icon)
 {
-        if (handle == NULL) {
-                _LOGE("appinfo handle is NULL\n");
-                return PMINFO_R_EINVAL;
-        }
-        if (icon == NULL) {
-                _LOGE("Argument supplied to hold return value is NULL\n");
-                return PMINFO_R_EINVAL;
-        }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
         char *locale = NULL;
         icon_x *ptr = NULL;
         icon_x *start = NULL;
@@ -4683,14 +4576,8 @@ API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h  handle, char **icon)
 
 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h  handle, char **label)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (label == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *locale = NULL;
        label_x *ptr = NULL;
        label_x *start = NULL;
@@ -4731,14 +4618,8 @@ API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h  handle, char **label)
 
 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h  handle, pkgmgrinfo_app_component *component)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (component == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_component == PMINFO_UI_APP)
@@ -4753,14 +4634,8 @@ API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h  handle, pkgmgrinf
 
 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h  handle, char **app_type)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (app_type == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_component == PMINFO_UI_APP)
@@ -4774,14 +4649,9 @@ API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h  handle, char **app_
 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h  handle,
                                        int *operation_count, char ***operation)
 {
-       if (handle == NULL) {
-               _LOGE("appcontrol handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (operation_count == NULL || operation == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
        *operation_count = data->operation_count;
        *operation = data->operation;
@@ -4791,14 +4661,9 @@ API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h  handle,
 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h  handle,
                                        int *uri_count, char ***uri)
 {
-       if (handle == NULL) {
-               _LOGE("appcontrol handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (uri_count == NULL || uri == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
        *uri_count = data->uri_count;
        *uri = data->uri;
@@ -4808,14 +4673,9 @@ API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h  handle,
 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h  handle,
                                        int *mime_count, char ***mime)
 {
-       if (handle == NULL) {
-               _LOGE("appcontrol handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (mime_count == NULL || mime == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
        *mime_count = data->mime_count;
        *mime = data->mime;
@@ -4877,14 +4737,8 @@ API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h  handle, c
 
 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h  handle, pkgmgrinfo_app_recentimage *type)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (type == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
        val = (char *)info->uiapp_info->recentimage;
@@ -4964,14 +4818,8 @@ API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h  handle, pkg
 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_category_list_cb category_func, void *user_data)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (category_func == NULL) {
-               _LOGE("Callback function is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
        int ret = -1;
        category_x *ptr = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
@@ -4992,14 +4840,8 @@ API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (metadata_func == NULL) {
-               _LOGE("Callback function is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
        int ret = -1;
        metadata_x *ptr = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
@@ -5020,14 +4862,8 @@ API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (appcontrol_func == NULL) {
-               _LOGE("Callback function is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
        int i = 0;
        int ret = -1;
        int oc = 0;
@@ -5180,14 +5016,8 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
 
 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h  handle, bool *nodisplay)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (nodisplay == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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;
@@ -5204,14 +5034,8 @@ API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h  handle, bool *nodi
 
 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h  handle, bool *multiple)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (multiple == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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;
@@ -5228,14 +5052,8 @@ API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h  handle, bool *multi
 
 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (indicator_disp == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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;
@@ -5254,18 +5072,9 @@ API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h han
 
 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h  handle, char **portrait_img, char **landscape_img)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (portrait_img == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (landscape_img == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_component == PMINFO_UI_APP){
@@ -5278,14 +5087,8 @@ API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h  handle, char **
 
 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h  handle, bool *taskmanage)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (taskmanage == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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;
@@ -5302,14 +5105,8 @@ API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h  handle, bool *tas
 
 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h  handle, bool *enabled)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (enabled == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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)
@@ -5335,14 +5132,8 @@ API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h  handle, bool *enable
 
 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h  handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (hwacceleration == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
        val = (char *)info->uiapp_info->hwacceleration;
@@ -5359,14 +5150,8 @@ API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h  handle, pkgm
 
 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h  handle, bool *onboot)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (onboot == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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;
@@ -5383,14 +5168,8 @@ API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h  handle, bool *onboot)
 
 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h  handle, bool *autorestart)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (autorestart == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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;
@@ -5407,14 +5186,8 @@ API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h  handle, bool *au
 
 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainapp)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (mainapp == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       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;
@@ -5431,10 +5204,7 @@ API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainap
 
 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h  handle)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
        __cleanup_appinfo(info);
        return PMINFO_R_OK;
@@ -5453,10 +5223,8 @@ API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
                                const char *property, const int value)
 {
-       if (handle == NULL || property == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
        char *val = NULL;
        GSList *link = NULL;
@@ -5496,10 +5264,8 @@ API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
                                const char *property, const bool value)
 {
-       if (handle == NULL || property == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *val = NULL;
        GSList *link = NULL;
        int prop = -1;
@@ -5540,10 +5306,9 @@ API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
                                const char *property, const char *value)
 {
-       if (handle == NULL || property == NULL || value == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *val = NULL;
        pkgmgrinfo_node_x *ptr = NULL;
        char prev[PKG_STRING_LEN_MAX] = {'\0'};
@@ -5620,10 +5385,8 @@ API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
 
 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
 {
-       if (handle == NULL || count == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *syslocale = NULL;
        char *locale = NULL;
        char *condition = NULL;
@@ -5706,10 +5469,8 @@ err:
 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
                                pkgmgrinfo_app_list_cb app_cb, void * user_data)
 {
-       if (handle == NULL || app_cb == NULL) {
-               _LOGE("Filter handle input parameter is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       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");
        char *syslocale = NULL;
        char *locale = NULL;
        char *condition = NULL;
@@ -6555,9 +6316,9 @@ API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h hand
                }
        }
        if (location == INSTALL_INTERNAL) {
-               strcpy(mfx->installlocation, "internal-only");
+               strcpy((char *)mfx->installlocation, "internal-only");
        } else if (location == INSTALL_EXTERNAL) {
-               strcpy(mfx->installlocation, "prefer-external");
+               strcpy((char *)mfx->installlocation, "prefer-external");
        } else {
                _LOGE("Invalid location type\n");
                return PMINFO_R_ERROR;
@@ -6718,9 +6479,9 @@ API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int
                }
        }
        if (removable == 0) {
-               strcpy(mfx->removable, "false");
+               strcpy((char *)mfx->removable, "false");
        } else if (removable == 1) {
-               strcpy(mfx->removable, "true");
+               strcpy((char *)mfx->removable, "true");
        } else {
                _LOGE("Invalid removable type\n");
                return PMINFO_R_ERROR;
@@ -6747,9 +6508,9 @@ API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int p
                }
        }
        if (preload == 0) {
-               strcpy(mfx->preload, "false");
+               strcpy((char *)mfx->preload, "false");
        } else if (preload == 1) {
-               strcpy(mfx->preload, "true");
+               strcpy((char *)mfx->preload, "true");
        } else {
                _LOGE("Invalid preload type\n");
                return PMINFO_R_ERROR;
@@ -6817,10 +6578,7 @@ API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
 
 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
 {
-       if (appid == NULL) {
-               _LOGE("appid is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
        ret = __open_manifest_db();
@@ -6874,23 +6632,10 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
 
 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
 {
-       if (providerid == NULL) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (type == NULL) {
-               _LOGE("Argument supplied is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (appid == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (access == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-
+       retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+       retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+       retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        int ret = PMINFO_R_OK;
        char query[MAX_QUERY_LEN] = {'\0'};
        char *error_message = NULL;
@@ -6932,10 +6677,7 @@ API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * typ
 
 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
 {
-       if (appid == NULL) {
-               _LOGE("appid is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
        char *error_message = NULL;
@@ -6987,14 +6729,8 @@ API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *labe
 
 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
-       if (status == NULL) {
-               _LOGE("Argument supplied to hold return value is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       retvm_if(status == 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->guestmode_visibility;
@@ -7012,10 +6748,7 @@ API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
 
 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
 {
-       if (handle == NULL) {
-               _LOGE("appinfo handle is NULL\n");
-               return PMINFO_R_EINVAL;
-       }
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        char *val = NULL;
        int ret = 0;
        char *noti_string = NULL;