Move files from src/ to common/
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 4 Feb 2021 06:05:38 +0000 (15:05 +0900)
committer연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Thu, 4 Feb 2021 09:35:21 +0000 (18:35 +0900)
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
CMakeLists.txt
packaging/pkgmgr-info.spec
src/CMakeLists.txt
src/common/CMakeLists.txt
src/common/pkgmgrinfo_debug.h [new file with mode: 0644]
src/common/pkgmgrinfo_private.c [new file with mode: 0644]
src/common/pkgmgrinfo_private.h [new file with mode: 0644]

index e77f335..73f2980 100644 (file)
@@ -10,7 +10,7 @@ SET(INCLUDEDIR "\${prefix}/include")
 SET(CMAKE_SKIP_BUILD_RPATH true)
 
 ### Local include directories
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/parser/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/parser/include ${CMAKE_SOURCE_DIR}/src/common)
 
 ### Required packages
 INCLUDE(FindPkgConfig)
index cb9f8d5..b38c13b 100644 (file)
@@ -128,10 +128,11 @@ ln -sf ../pkg-db-recovery.service %{buildroot}%{_unitdir}/basic.target.wants/pkg
 %license LICENSE
 %defattr(-,root,root,-)
 %{_libdir}/libpkgmgr_common.so*
+%{_includedir}/pkgmgr-common/*.hh
+%{_includedir}/pkgmgr-common/*.h
 
 %files common-devel
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
-%{_includedir}/pkgmgr-common/*.hh
 %{_libdir}/pkgconfig/pkgmgr-common.pc
 %{_libdir}/libpkgmgr_common.so
index 409d756..86f57e3 100644 (file)
@@ -4,7 +4,7 @@ ADD_LIBRARY(pkgmgr-info SHARED ${SRCS})
 
 SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES SOVERSION ${MAJORVER})
 SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES VERSION ${FULLVER})
-TARGET_LINK_LIBRARIES(pkgmgr-info pkgmgr_parser ${libpkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(pkgmgr-info pkgmgr_parser pkgmgr_common ${libpkgs_LDFLAGS})
 
 INSTALL(TARGETS pkgmgr-info DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
 
index 87924ee..ad25b05 100644 (file)
@@ -1,7 +1,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED libsystemd)
+pkg_check_modules(pkgs REQUIRED libsystemd dlog glib-2.0 sqlite3 minizip libtzplatform-config vconf )
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -16,7 +16,9 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14")
 SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
 
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-ldl -Wl,--as-needed")
 
 ## Target
 SET(TARGET_COMMON "pkgmgr_common")
@@ -40,6 +42,8 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_COMMON} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}/database/
 )
 
+TARGET_LINK_LIBRARIES(${TARGET_COMMON} ${pkgs_LDFLAGS} "-ldl")
+
 SET_TARGET_PROPERTIES(${TARGET_COMMON} PROPERTIES SOVERSION ${MAJORVER})
 SET_TARGET_PROPERTIES(${TARGET_COMMON} PROPERTIES VERSION ${FULLVER})
 
@@ -62,3 +66,7 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/parcel/  DESTINATION include/pkgmg
   PATTERN "*.hh"
 )
 
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/  DESTINATION include/pkgmgr-common
+  FILES_MATCHING
+  PATTERN "pkgmgrinfo_private.h"
+)
\ No newline at end of file
diff --git a/src/common/pkgmgrinfo_debug.h b/src/common/pkgmgrinfo_debug.h
new file mode 100644 (file)
index 0000000..3f24c3a
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * pkgmgrinfo_debug
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+  * Contact: junsuk. oh <junsuk77.oh@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __PKGMGR_INFO_DEBUG_H__
+#define __PKGMGR_INFO_DEBUG_H__
+
+#include <dlog.h>
+
+#define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define _LOGI(fmt, arg...) LOGI(fmt, ##arg)
+#define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
+
+#define PKGMGR_INFO_ENABLE_DLOG
+
+#define COLOR_RED              "\033[0;31m"
+#define COLOR_BLUE             "\033[0;34m"
+#define COLOR_END              "\033[0;m"
+
+#ifdef PKGMGR_INFO_ENABLE_DLOG
+#define PKGMGR_INFO_DEBUG(fmt, ...) \
+       do { \
+               LOGD(fmt, ##__VA_ARGS__); \
+       } while (0)
+
+#define PKGMGR_INFO_DEBUG_ERR(fmt, ...) \
+       do { \
+               LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
+       } while (0)
+
+#define PKGMGR_INFO_BEGIN() \
+       do { \
+               LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END); \
+       } while (0)
+
+#define PKGMGR_INFO_END() \
+       do { \
+               LOGD(COLOR_BLUE"END <<<<"COLOR_END); \
+       } while (0)
+
+#else
+#define PKGMGR_INFO_DEBUG(fmt, ...) \
+       do { \
+               printf("\n [%s: %s(): %d] " fmt"\n",  rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+       } while (0)
+
+#define PKGMGR_INFO_BEGIN() \
+       do { \
+               printf("\n [%s: %d] : BEGIN >>>> %s() \n", rindex(__FILE__, '/')+1,  __LINE__ , __FUNCTION__); \
+       } while (0)
+
+#define PKGMGR_INFO_END() \
+       do { \
+               printf("\n [%s: %d]: END   <<<< %s()\n", rindex(__FILE__, '/')+1,  __LINE__ , __FUNCTION__); \
+       } while (0)
+#endif
+
+
+#define ret_if(expr) do { \
+       if (expr) { \
+               PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
+               return; \
+       } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+       if (expr) { \
+               PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+               return; \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if (expr) { \
+               PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
+               return (val); \
+       } \
+} while (0)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+               return (val); \
+       } \
+} while (0)
+
+#define trym_if(expr, fmt, arg...) do { \
+       if (expr) { \
+               PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+               goto catch; \
+       } \
+} while (0)
+
+#define tryvm_if(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+               val; \
+               goto catch; \
+       } \
+} while (0)
+
+#endif  /* __PKGMGR_INFO_DEBUG_H__ */
diff --git a/src/common/pkgmgrinfo_private.c b/src/common/pkgmgrinfo_private.c
new file mode 100644 (file)
index 0000000..68f6f36
--- /dev/null
@@ -0,0 +1,732 @@
+/*
+ * pkgmgr-info
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <dlfcn.h>
+
+#include <vconf.h>
+#include <sqlite3.h>
+#include <glib.h>
+#include <unzip.h>
+
+#include "pkgmgr-info.h"
+#include "pkgmgrinfo_debug.h"
+#include "pkgmgrinfo_private.h"
+#include "pkgmgr_parser.h"
+
+static GHashTable *plugin_set_list;
+
+struct _pkginfo_str_map_t {
+       pkgmgrinfo_pkginfo_filter_prop_str prop;
+       const char *property;
+};
+
+static struct _pkginfo_str_map_t pkginfo_str_prop_map[] = {
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_ID,      PMINFO_PKGINFO_PROP_PACKAGE_ID},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE,    PMINFO_PKGINFO_PROP_PACKAGE_TYPE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION, PMINFO_PKGINFO_PROP_PACKAGE_VERSION},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,        PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,       PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,     PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,    PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,     PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,       PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE}
+};
+
+struct _pkginfo_int_map_t {
+       pkgmgrinfo_pkginfo_filter_prop_int prop;
+       const char *property;
+};
+
+static struct _pkginfo_int_map_t pkginfo_int_prop_map[] = {
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE,    PMINFO_PKGINFO_PROP_PACKAGE_SIZE}
+};
+
+struct _pkginfo_bool_map_t {
+       pkgmgrinfo_pkginfo_filter_prop_bool prop;
+       const char *property;
+};
+
+static struct _pkginfo_bool_map_t pkginfo_bool_prop_map[] = {
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE,       PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD,         PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY,        PMINFO_PKGINFO_PROP_PACKAGE_READONLY},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE,          PMINFO_PKGINFO_PROP_PACKAGE_UPDATE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,      PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,       PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE,   PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM,          PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM}
+};
+
+struct _appinfo_str_map_t {
+       pkgmgrinfo_appinfo_filter_prop_str prop;
+       const char *property;
+};
+
+static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
+       {E_PMINFO_APPINFO_PROP_APP_ID,          PMINFO_APPINFO_PROP_APP_ID},
+       {E_PMINFO_APPINFO_PROP_APP_COMPONENT,   PMINFO_APPINFO_PROP_APP_COMPONENT},
+       {E_PMINFO_APPINFO_PROP_APP_EXEC,        PMINFO_APPINFO_PROP_APP_EXEC},
+       {E_PMINFO_APPINFO_PROP_APP_ICON,        PMINFO_APPINFO_PROP_APP_ICON},
+       {E_PMINFO_APPINFO_PROP_APP_TYPE,        PMINFO_APPINFO_PROP_APP_TYPE},
+       {E_PMINFO_APPINFO_PROP_APP_OPERATION,   PMINFO_APPINFO_PROP_APP_OPERATION},
+       {E_PMINFO_APPINFO_PROP_APP_URI, PMINFO_APPINFO_PROP_APP_URI},
+       {E_PMINFO_APPINFO_PROP_APP_MIME,        PMINFO_APPINFO_PROP_APP_MIME},
+       {E_PMINFO_APPINFO_PROP_APP_CATEGORY,    PMINFO_APPINFO_PROP_APP_CATEGORY},
+       {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,      PMINFO_APPINFO_PROP_APP_HWACCELERATION},
+       {E_PMINFO_APPINFO_PROP_APP_SCREENREADER,        PMINFO_APPINFO_PROP_APP_SCREENREADER},
+       {E_PMINFO_APPINFO_PROP_APP_PACKAGE,     PMINFO_APPINFO_PROP_APP_PACKAGE},
+       {E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,   PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE},
+       {E_PMINFO_APPINFO_PROP_PRIVILEGE,       PMINFO_APPINFO_PROP_PRIVILEGE}
+};
+
+struct _appinfo_int_map_t {
+       pkgmgrinfo_appinfo_filter_prop_int prop;
+       const char *property;
+};
+
+static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
+       {E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE,        PMINFO_APPINFO_PROP_APP_SUPPORT_MODE}
+};
+
+struct _appinfo_bool_map_t {
+       pkgmgrinfo_appinfo_filter_prop_bool prop;
+       const char *property;
+};
+
+static struct _appinfo_bool_map_t appinfo_bool_prop_map[] = {
+       {E_PMINFO_APPINFO_PROP_APP_NODISPLAY,           PMINFO_APPINFO_PROP_APP_NODISPLAY},
+       {E_PMINFO_APPINFO_PROP_APP_MULTIPLE,            PMINFO_APPINFO_PROP_APP_MULTIPLE},
+       {E_PMINFO_APPINFO_PROP_APP_ONBOOT,              PMINFO_APPINFO_PROP_APP_ONBOOT},
+       {E_PMINFO_APPINFO_PROP_APP_AUTORESTART,         PMINFO_APPINFO_PROP_APP_AUTORESTART},
+       {E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,          PMINFO_APPINFO_PROP_APP_TASKMANAGE},
+       {E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,             PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION},
+       {E_PMINFO_APPINFO_PROP_APP_UI_GADGET,           PMINFO_APPINFO_PROP_APP_UI_GADGET},
+       {E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,             PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE},
+       {E_PMINFO_APPINFO_PROP_APP_DISABLE,             PMINFO_APPINFO_PROP_APP_DISABLE},
+       {E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE,               PMINFO_APPINFO_PROP_APP_CHECK_STORAGE},
+       {E_PMINFO_APPINFO_PROP_PKG_DISABLE,             PMINFO_APPINFO_PROP_PKG_DISABLE}
+};
+
+inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
+{
+       int i = 0;
+       int max = 0;
+       pkgmgrinfo_pkginfo_filter_prop_str prop = -1;
+
+       if (property == NULL)
+               return -1;
+       max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR + 1;
+       for (i = 0 ; i < max; i++) {
+               if (strcmp(property, pkginfo_str_prop_map[i].property) == 0) {
+                       prop =  pkginfo_str_prop_map[i].prop;
+                       break;
+               }
+       }
+       return prop;
+}
+
+inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
+{
+       int i = 0;
+       int max = 0;
+       pkgmgrinfo_pkginfo_filter_prop_int prop = -1;
+
+       if (property == NULL)
+               return -1;
+       max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT + 1;
+       for (i = 0 ; i < max; i++) {
+               if (strcmp(property, pkginfo_int_prop_map[i].property) == 0) {
+                       prop =  pkginfo_int_prop_map[i].prop;
+                       break;
+               }
+       }
+       return prop;
+}
+
+inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
+{
+       int i = 0;
+       int max = 0;
+       pkgmgrinfo_pkginfo_filter_prop_bool prop = -1;
+
+       if (property == NULL)
+               return -1;
+       max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL + 1;
+       for (i = 0 ; i < max; i++) {
+               if (strcmp(property, pkginfo_bool_prop_map[i].property) == 0) {
+                       prop =  pkginfo_bool_prop_map[i].prop;
+                       break;
+               }
+       }
+       return prop;
+}
+
+inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
+{
+       int i = 0;
+       int max = 0;
+       pkgmgrinfo_appinfo_filter_prop_str prop = -1;
+
+       if (property == NULL)
+               return -1;
+       max = E_PMINFO_APPINFO_PROP_APP_MAX_STR - E_PMINFO_APPINFO_PROP_APP_MIN_STR + 1;
+       for (i = 0 ; i < max; i++) {
+               if (strcmp(property, appinfo_str_prop_map[i].property) == 0) {
+                       prop =  appinfo_str_prop_map[i].prop;
+                       break;
+               }
+       }
+       return prop;
+}
+
+inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
+{
+       int i = 0;
+       int max = 0;
+       pkgmgrinfo_appinfo_filter_prop_int prop = -1;
+
+       if (property == NULL)
+               return -1;
+       max = E_PMINFO_APPINFO_PROP_APP_MAX_INT - E_PMINFO_APPINFO_PROP_APP_MIN_INT + 1;
+       for (i = 0 ; i < max; i++) {
+               if (strcmp(property, appinfo_int_prop_map[i].property) == 0) {
+                       prop =  appinfo_int_prop_map[i].prop;
+                       break;
+               }
+       }
+       return prop;
+}
+
+inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
+{
+       int i = 0;
+       int max = 0;
+       pkgmgrinfo_appinfo_filter_prop_bool prop = -1;
+
+       if (property == NULL)
+               return -1;
+       max = E_PMINFO_APPINFO_PROP_APP_MAX_BOOL - E_PMINFO_APPINFO_PROP_APP_MIN_BOOL + 1;
+       for (i = 0 ; i < max; i++) {
+               if (strcmp(property, appinfo_bool_prop_map[i].property) == 0) {
+                       prop =  appinfo_bool_prop_map[i].prop;
+                       break;
+               }
+       }
+       return prop;
+}
+
+int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **params)
+{
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data;
+       char buf[MAX_QUERY_LEN] = {'\0'};
+       int flag = 0;
+       char *value;
+       char *ptr = NULL;
+       char *saveptr = NULL;
+
+       switch (node->prop) {
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
+               snprintf(buf, sizeof(buf), "pi.package=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
+               snprintf(buf, sizeof(buf), "pi.package_type=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
+               snprintf(buf, sizeof(buf), "pi.package_version=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
+               snprintf(buf, sizeof(buf), "pi.install_location=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
+               snprintf(buf, sizeof(buf), "pi.installed_storage=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
+               snprintf(buf, sizeof(buf), "pi.author_name=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
+               snprintf(buf, sizeof(buf), "pi.author_href=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
+               snprintf(buf, sizeof(buf), "pi.author_email=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE:
+               snprintf(buf, sizeof(buf), "package_privilege_info.privilege=?");
+               flag = E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO;
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
+               snprintf(buf, sizeof(buf), "pi.package_size=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
+               snprintf(buf, sizeof(buf), "pi.package_removable=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
+               snprintf(buf, sizeof(buf), "pi.package_preload=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
+               snprintf(buf, sizeof(buf), "pi.package_readonly=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
+               snprintf(buf, sizeof(buf), "pi.package_update=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
+               snprintf(buf, sizeof(buf), "pi.package_appsetting=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
+               snprintf(buf, sizeof(buf), "pi.package_nodisplay=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE:
+               snprintf(buf, sizeof(buf), "pi.package_support_disable=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE:
+               snprintf(buf, sizeof(buf), "pi.package_disable=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM:
+               snprintf(buf, sizeof(buf), "pi.package_system=? COLLATE NOCASE");
+               break;
+
+       case E_PMINFO_APPINFO_PROP_APP_ID:
+               snprintf(buf, sizeof(buf), "ai.app_id=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
+               snprintf(buf, sizeof(buf), "ai.app_component=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_EXEC:
+               snprintf(buf, sizeof(buf), "ai.app_exec=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_ICON:
+               snprintf(buf, sizeof(buf), "package_app_localized_info.app_icon=?");
+               flag = E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO;
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_TYPE:
+               snprintf(buf, sizeof(buf), "ai.app_type=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_OPERATION:
+               snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE ?||'|%%%%|%%%%'");
+               flag = E_PMINFO_APPINFO_JOIN_APP_CONTROL;
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_URI:
+               snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE '%%%%|'||?||'|%%%%'");
+               flag = E_PMINFO_APPINFO_JOIN_APP_CONTROL;
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_MIME:
+               snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE '%%%%|%%%%|'||?");
+               flag = E_PMINFO_APPINFO_JOIN_APP_CONTROL;
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
+               snprintf(buf, sizeof(buf), "package_app_app_category.category IN (");
+               value = strdup(node->value);
+               if (value == NULL) {
+                       _LOGE("out of memeory");
+                       return 0;
+               }
+               ptr = strtok_r(value, ",", &saveptr);
+               if (ptr == NULL) {
+                       free(value);
+                       return 0;
+               }
+               strncat(buf, "?", sizeof(buf) - strlen(buf) - 1);
+               *params = g_list_append(*params, strdup(ptr));
+               while ((ptr = strtok_r(NULL, ",", &saveptr))) {
+                       strncat(buf, ", ?", sizeof(buf) - strlen(buf) - 1);
+                       *params = g_list_append(*params, strdup(ptr));
+               }
+               strncat(buf, ")", sizeof(buf) - strlen(buf) - 1);
+               *condition = strdup(buf);
+               flag = E_PMINFO_APPINFO_JOIN_CATEGORY;
+               free(value);
+
+               return flag;
+       case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
+               snprintf(buf, sizeof(buf), "ai.app_nodisplay=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
+               snprintf(buf, sizeof(buf), "ai.app_multiple=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
+               snprintf(buf, sizeof(buf), "ai.app_onboot=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
+               snprintf(buf, sizeof(buf), "ai.app_autorestart=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
+               snprintf(buf, sizeof(buf), "ai.app_taskmanage=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
+               snprintf(buf, sizeof(buf), "ai.app_hwacceleration=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
+               snprintf(buf, sizeof(buf), "ai.app_screenreader=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
+               snprintf(buf, sizeof(buf), "ai.app_launchcondition=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
+               snprintf(buf, sizeof(buf), "ai.package=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE:
+               snprintf(buf, sizeof(buf), "ai.app_installed_storage=?");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
+               snprintf(buf, sizeof(buf), "ai.app_ui_gadget=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_DISABLE:
+               if (strcasecmp(node->value, "true") == 0)
+                       snprintf(buf, MAX_QUERY_LEN, "(ai.app_disable=? COLLATE NOCASE " \
+                                       "OR ui.is_disabled='true' COLLATE NOCASE)");
+               else
+                       snprintf(buf, MAX_QUERY_LEN, "(ai.app_disable=? COLLATE NOCASE " \
+                                       "AND (ui.is_disabled='false' COLLATE NOCASE " \
+                                       "OR ui.is_disabled IS NULL))");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE:
+               snprintf(buf, MAX_QUERY_LEN, "ai.app_support_disable=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_APPINFO_PROP_PKG_DISABLE:
+               snprintf(buf, MAX_QUERY_LEN,
+                               "ai.package IN (SELECT package FROM " \
+                               "package_info WHERE package_disable=?)");
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE:
+               snprintf(buf, sizeof(buf), "ai.app_support_mode=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE:
+       case E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE:
+               *condition = NULL;
+               return 0;
+       case E_PMINFO_APPINFO_PROP_PRIVILEGE:
+               snprintf(buf, sizeof(buf), "package_privilege_info.privilege=?");
+               flag = E_PMINFO_APPINFO_JOIN_PRIVILEGE;
+               break;
+       default:
+               _LOGE("Invalid Property Type\n");
+               *condition = NULL;
+               return 0;
+       }
+       *condition = strdup(buf);
+       *params = g_list_append(*params, strdup(node->value));
+       return flag;
+}
+
+int __get_metadata_filter_condition(gpointer data, char **condition,
+               GList **params)
+{
+       pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data;
+       char buf[MAX_QUERY_LEN];
+
+       snprintf(buf, sizeof(buf), "(package_app_app_metadata.md_key=?");
+       if (node->value)
+               strncat(buf, " AND package_app_app_metadata.md_value=?",
+                               sizeof(buf) - strlen(buf) - 1);
+       strncat(buf, ")", sizeof(buf) - strlen(buf) - 1);
+
+       *condition = strdup(buf);
+       *params = g_list_append(*params, strdup(node->key));
+       if (node->value)
+               *params = g_list_append(*params, strdup(node->value));
+
+       return E_PMINFO_APPINFO_JOIN_METADATA;
+}
+
+int _add_icon_info_into_list(const char *locale, char *value, GList **icon)
+{
+       icon_x *info;
+
+       info = calloc(1, sizeof(icon_x));
+       if (info == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
+       info->text = value;
+       info->lang = strdup(locale);
+       *icon = g_list_prepend(*icon, info);
+
+       return PMINFO_R_OK;
+}
+
+int _add_label_info_into_list(const char *locale, char *value, GList **label)
+{
+       label_x *info;
+
+       info = calloc(1, sizeof(label_x));
+       if (info == NULL) {
+               LOGE("out of memory");
+               return PMINFO_R_ERROR;
+       }
+       info->text = value;
+       info->lang = strdup(locale);
+       *label = g_list_prepend(*label, info);
+
+       return PMINFO_R_OK;
+}
+
+char *_get_system_locale(void)
+{
+       char *lang;
+       char *locale;
+
+       lang = vconf_get_str(VCONFKEY_LANGSET);
+       if (lang == NULL) {
+               locale = strdup(DEFAULT_LOCALE);
+               if (locale == NULL) {
+                       LOGE("out of memory");
+                       return NULL;
+               }
+               return locale;
+       }
+
+       locale = malloc(sizeof(char) * 6);
+       if (locale == NULL) {
+               LOGE("out of memory");
+               free(lang);
+               return NULL;
+       }
+
+       strncpy(locale, lang, 2);
+       locale[2] = '-';
+       locale[3] = tolower(lang[3]);
+       locale[4] = tolower(lang[4]);
+       locale[5] = '\0';
+
+       free(lang);
+
+       return locale;
+}
+
+int __pkginfo_check_installed_storage(package_x *pkginfo)
+{
+       char buf[MAX_QUERY_LEN] = {'\0'};
+       int ret;
+
+       retvm_if(pkginfo->package == NULL, PMINFO_R_OK, "pkgid is NULL\n");
+       retvm_if(pkginfo->installed_storage == NULL, PMINFO_R_ERROR,
+                       "installed_storage is NULL\n");
+
+       if (strcmp(pkginfo->installed_storage, "installed_external") == 0) {
+               snprintf(buf, MAX_QUERY_LEN - 1, "%s", pkginfo->external_path);
+               ret = access(buf, R_OK);
+               if (ret != 0) {
+                       _LOGE("can not access [%s] - %d", buf, ret);
+                       return PMINFO_R_ERROR;
+               }
+       }
+
+       return PMINFO_R_OK;
+}
+
+int __appinfo_check_installed_storage(application_x *appinfo)
+{
+       retvm_if(appinfo->installed_storage == NULL, PMINFO_R_ERROR,
+                       "installed_storage is NULL\n");
+
+       if (strcmp(appinfo->installed_storage, "installed_external") == 0) {
+               retvm_if(appinfo->external_path == NULL, PMINFO_R_ERROR,
+                               "external path is NULL\n");
+               if (access(appinfo->external_path, R_OK) != 0) {
+                       _LOGE("can not access [%s]", appinfo->external_path);
+                       return PMINFO_R_ERROR;
+               }
+       }
+
+       return PMINFO_R_OK;
+}
+
+#define BUSY_WAITING_USEC (1000000 / 10 / 2) /* 0.05 sec */
+#define BUSY_WAITING_MAX 100 /* wait for max 5 sec */
+static int __db_busy_handler(void *data, int count)
+{
+       if (count < BUSY_WAITING_MAX) {
+               usleep(BUSY_WAITING_USEC);
+               return 1;
+       } else {
+               /* sqlite3_prepare_v2 will return SQLITE_BUSY */
+               return 0;
+       }
+}
+
+int __open_db(const char *path, sqlite3 **db, int flags)
+{
+       int ret;
+
+       ret = sqlite3_open_v2(path, db, flags, NULL);
+       if (ret != SQLITE_OK) {
+               sqlite3_close_v2(*db);
+               return ret;
+       }
+
+       ret = sqlite3_busy_handler(*db, __db_busy_handler, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("failed to register busy handler: %s",
+                               sqlite3_errmsg(*db));
+               sqlite3_close_v2(*db);
+               return ret;
+       }
+
+       return ret;
+}
+
+struct type_map {
+       const char *manifest;
+       const char *type;
+};
+
+struct type_map type_map[] = {
+       { "res/wgt/config.xml", "wgt" },
+       { "config.xml", "wgt" },
+       { "tizen-manifest.xml", "tpk" },
+       { NULL, NULL}
+};
+
+char *__get_type_from_path(const char *pkg_path)
+{
+       const char *type = NULL;
+       unzFile uf;
+       int i;
+
+       uf = unzOpen(pkg_path);
+       if (uf == NULL) {
+               _LOGE("failed to open zip file %s", pkg_path);
+               return NULL;
+       }
+
+       for (i = 0; type_map[i].manifest != NULL; i++) {
+               if (unzLocateFile(uf, type_map[i].manifest, 0) == UNZ_OK) {
+                       _LOGD("pkgtype of %s: [%s]", pkg_path,
+                                       type_map[i].type);
+                       type = type_map[i].type;
+                       break;
+               }
+       }
+       unzClose(uf);
+
+       if (type == NULL) {
+               _LOGE("cannot get pkg type of file %s", pkg_path);
+               return NULL;
+       }
+
+       return strdup(type);
+}
+
+static const char *__get_library_path(const char *pkg_type)
+{
+       char buf[64];
+       const char *path;
+
+       snprintf(buf, sizeof(buf), "package-manager/backendlib/lib%s.so",
+                       pkg_type);
+       path = tzplatform_mkpath(TZ_SYS_RO_ETC, buf);
+
+       return path;
+}
+
+pkg_plugin_set *__load_library(const char *pkg_type)
+{
+       void *library_handle;
+       pkg_plugin_set *plugin_set;
+       bool (*on_load)(pkg_plugin_set *plugin);
+       const char *library_path;
+
+       library_path = __get_library_path(pkg_type);
+       if (library_path == NULL) {
+               _LOGE("cannot get library path for %s", pkg_type);
+               return NULL;
+       }
+
+       if (plugin_set_list == NULL) {
+               plugin_set_list = g_hash_table_new_full(g_str_hash,
+                               g_str_equal, free, free);
+               if (plugin_set_list == NULL) {
+                       _LOGE("out of memory");
+                       return NULL;
+               }
+       }
+
+       plugin_set = (pkg_plugin_set *)g_hash_table_lookup(plugin_set_list,
+                       (gconstpointer)pkg_type);
+       if (plugin_set) {
+               _LOGD("already loaded [%s]", library_path);
+               return plugin_set;
+       }
+
+       if ((library_handle = dlopen(library_path, RTLD_LAZY)) == NULL) {
+               _LOGE("dlopen is failed library_path[%s]", library_path);
+               return NULL;
+       }
+
+       if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL ||
+                       dlerror() != NULL) {
+               _LOGE("cannot find symbol");
+               dlclose(library_handle);
+               return NULL;
+       }
+
+       plugin_set = (pkg_plugin_set *)calloc(1, sizeof(pkg_plugin_set));
+       if (plugin_set == NULL) {
+               _LOGE("out of memory");
+               dlclose(library_handle);
+               return NULL;
+       }
+
+       if (on_load(plugin_set) != 0) {
+               _LOGE("pkg_plugin_on_load failed");
+               free(plugin_set);
+               dlclose(library_handle);
+               plugin_set = NULL;
+               return NULL;
+       }
+
+       plugin_set->plugin_handle = library_handle;
+       snprintf(plugin_set->pkg_type,
+                       sizeof(plugin_set->pkg_type), "%s", pkg_type);
+
+       g_hash_table_insert(plugin_set_list, (gpointer)strdup(pkg_type),
+                       (gpointer)plugin_set);
+
+       _LOGD("library [%s] is loaded", library_path);
+
+       return plugin_set;
+}
+
+void __unload_library(const char *pkg_type)
+{
+       pkg_plugin_set *plugin_set;
+
+       if (plugin_set_list == NULL)
+               return;
+
+       plugin_set = (pkg_plugin_set *)g_hash_table_lookup(plugin_set_list,
+                       (gconstpointer)pkg_type);
+
+       if (plugin_set == NULL) {
+               _LOGE("pkg plugin for %s is not loaded", pkg_type);
+               return;
+       }
+
+       plugin_set->plugin_on_unload();
+       dlclose(plugin_set->plugin_handle);
+       g_hash_table_remove(plugin_set_list, (gconstpointer)pkg_type);
+}
diff --git a/src/common/pkgmgrinfo_private.h b/src/common/pkgmgrinfo_private.h
new file mode 100644 (file)
index 0000000..47d4dc3
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * pkgmgr-info
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#ifndef __PKGMGRINFO_PRIVATE_H__
+#define __PKGMGRINFO_PRIVATE_H__
+
+#include <stdbool.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <sqlite3.h>
+#include <glib.h>
+#include <tzplatform_config.h>
+
+#include "pkgmgrinfo_type.h"
+#include "pkgmgrinfo_basic.h"
+
+#ifndef DEPRECATED
+#define DEPRECATED     __attribute__ ((__deprecated__))
+#endif
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "PKGMGR_INFO"
+
+#define ASC_CHAR(s) (const char *)s
+#define XML_CHAR(s) (const xmlChar *)s
+
+#define MANIFEST_DB    tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
+#define MAX_QUERY_LEN  4096
+#define MAX_CERT_TYPE  9
+#define CERT_DB                tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
+#define PKG_STRING_LEN_MAX 1024
+#define PKG_TYPE_STRING_LEN_MAX                128
+#define PKG_VERSION_STRING_LEN_MAX     128
+#define PKG_VALUE_STRING_LEN_MAX               512
+#define PKG_RW_PATH tzplatform_mkpath(TZ_USER_APP, "")
+#define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
+#define BLOCK_SIZE      4096 /*in bytes*/
+#define BUFSIZE 4096
+#define ROOT_UID 0
+#define APPFW_UID 301
+
+#define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
+#define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
+
+#define SERVICE_NAME "org.tizen.system.deviced"
+#define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
+#define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
+#define METHOD_NAME "RequestMountApp2ext"
+
+/*String properties for filtering based on package info*/
+typedef enum _pkgmgrinfo_pkginfo_filter_prop_str {
+       E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR = 101,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_ID = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR = E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE
+} pkgmgrinfo_pkginfo_filter_prop_str;
+
+/*Boolean properties for filtering based on package info*/
+typedef enum _pkgmgrinfo_pkginfo_filter_prop_bool {
+       E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL = 201,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL = E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM
+} pkgmgrinfo_pkginfo_filter_prop_bool;
+
+/*Integer properties for filtering based on package info*/
+typedef enum _pkgmgrinfo_pkginfo_filter_prop_int {
+       E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT = 301,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT,
+       E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT = E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE
+} pkgmgrinfo_pkginfo_filter_prop_int;
+
+/*String properties for filtering based on app info*/
+typedef enum _pkgmgrinfo_appinfo_filter_prop_str {
+       E_PMINFO_APPINFO_PROP_APP_MIN_STR = 401,
+       E_PMINFO_APPINFO_PROP_APP_ID = E_PMINFO_APPINFO_PROP_APP_MIN_STR,
+       E_PMINFO_APPINFO_PROP_APP_COMPONENT,
+       E_PMINFO_APPINFO_PROP_APP_EXEC,
+       E_PMINFO_APPINFO_PROP_APP_ICON,
+       E_PMINFO_APPINFO_PROP_APP_TYPE,
+       E_PMINFO_APPINFO_PROP_APP_OPERATION,
+       E_PMINFO_APPINFO_PROP_APP_URI,
+       E_PMINFO_APPINFO_PROP_APP_MIME,
+       E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
+       E_PMINFO_APPINFO_PROP_APP_CATEGORY,
+       E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
+       E_PMINFO_APPINFO_PROP_APP_PACKAGE,
+       E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,
+       E_PMINFO_APPINFO_PROP_PRIVILEGE,
+       E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_PRIVILEGE
+} pkgmgrinfo_appinfo_filter_prop_str;
+
+/*Boolean properties for filtering based on app info*/
+typedef enum _pkgmgrinfo_appinfo_filter_prop_bool {
+       E_PMINFO_APPINFO_PROP_APP_MIN_BOOL = 501,
+       E_PMINFO_APPINFO_PROP_APP_NODISPLAY = E_PMINFO_APPINFO_PROP_APP_MIN_BOOL,
+       E_PMINFO_APPINFO_PROP_APP_MULTIPLE,
+       E_PMINFO_APPINFO_PROP_APP_ONBOOT,
+       E_PMINFO_APPINFO_PROP_APP_AUTORESTART,
+       E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,
+       E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,
+       E_PMINFO_APPINFO_PROP_APP_UI_GADGET,
+       E_PMINFO_APPINFO_PROP_APP_DISABLE,
+       E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,
+       E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE,
+       E_PMINFO_APPINFO_PROP_PKG_DISABLE,
+       E_PMINFO_APPINFO_PROP_APP_MAX_BOOL = E_PMINFO_APPINFO_PROP_PKG_DISABLE
+} pkgmgrinfo_appinfo_filter_prop_bool;
+
+/*Integer properties for filtering based on app info*/
+typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
+       /*Currently No Fields*/
+       E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
+       E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE = E_PMINFO_APPINFO_PROP_APP_MIN_INT,
+       E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE
+} pkgmgrinfo_appinfo_filter_prop_int;
+
+/*Integer properties for filtering based on app info*/
+typedef enum _pkgmgrinfo_pkginfo_filter_prop_range {
+       /*Currently No Fields*/
+       E_PMINFO_PKGINFO_PROP_RANGE_MIN_INT = 701,
+       E_PMINFO_PKGINFO_PROP_RANGE_BASIC,
+       E_PMINFO_PKGINFO_PROP_RANGE_MAX_INT = E_PMINFO_PKGINFO_PROP_RANGE_BASIC
+} pkgmgrinfo_pkginfo_filter_prop_range;
+
+typedef enum _pkgmgrinfo_pkginfo_join_flag {
+       E_PMINFO_PKGINFO_JOIN_LOCALIZED_INFO = 0x0001,
+       E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO = 0x0002,
+} pkgmgrinfo_pkginfo_join_flag;
+
+typedef enum _pkgmgrinfo_appinfo_join_flag {
+       E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO = 0x0001,
+       E_PMINFO_APPINFO_JOIN_CATEGORY = 0x0002,
+       E_PMINFO_APPINFO_JOIN_APP_CONTROL = 0x0004,
+       E_PMINFO_APPINFO_JOIN_METADATA = 0x0008,
+       E_PMINFO_APPINFO_JOIN_PRIVILEGE = 0x0010,
+} pkgmgrinfo_appinfo_join_flag;
+
+typedef enum _pkgmgrinfo_appinfo_disable_type {
+       E_APPINFO_DISABLE_TYPE_PKG = 0,
+       E_APPINFO_DISABLE_TYPE_APP
+} pkgmgrinfo_appinfo_disable_type;
+
+typedef struct _pkgmgr_pkginfo_x {
+       uid_t uid;
+       package_x *pkg_info;
+       char *locale;
+} pkgmgr_pkginfo_x;
+
+typedef struct _pkgmgr_appinfo_x {
+       const char *package;
+       char *locale;
+       pkgmgrinfo_app_component app_component;
+       application_x *app_info;
+} pkgmgr_appinfo_x;
+
+/*For filter APIs*/
+typedef struct _pkgmgrinfo_filter_x {
+       uid_t uid;
+       GSList *list;
+       GSList *list_metadata;
+} pkgmgrinfo_filter_x;
+
+typedef struct _pkgmgrinfo_node_x {
+       int prop;
+       char *key;
+       char *value;
+} pkgmgrinfo_node_x;
+
+typedef struct _pkgmgrinfo_metadata_node_x {
+       char *key;
+       char *value;
+} pkgmgrinfo_metadata_node_x;
+
+typedef struct _pkgmgrinfo_appcontrol_x {
+       int operation_count;
+       int uri_count;
+       int mime_count;
+       int subapp_count;
+       char **operation;
+       char **uri;
+       char **mime;
+       char **subapp;
+} pkgmgrinfo_appcontrol_x;
+
+typedef struct _pkgmgr_certinfo_x {
+       int for_all_users;
+       char *pkgid;
+       char *cert_value;
+       char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
+       int cert_id[MAX_CERT_TYPE];             /*certificate ID in index table*/
+} pkgmgr_certinfo_x;
+
+typedef struct _db_handle {
+       sqlite3 *dbHandle;
+       int ref;
+} db_handle;
+
+/* TODO: refine below structures */
+#define PKG_TYPE_STRING_LEN_MAX        128
+#define PKG_NAME_STRING_LEN_MAX        128
+#define PKG_VERSION_STRING_LEN_MAX     128
+#define PKG_VALUE_STRING_LEN_MAX 512
+#define PKG_URL_STRING_LEN_MAX 1024
+#define PKG_LABEL_STRING_LEN_MAX 128
+#define PKG_PATH_STRING_LEN_MAX 512
+#define PKG_DEP_TYPE_STRING_LEN_MAX 128
+
+typedef struct _package_manager_pkg_info_t {
+       char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+       char pkg_name[PKG_NAME_STRING_LEN_MAX];
+       char pkgid[PKG_NAME_STRING_LEN_MAX];
+       char version[PKG_VERSION_STRING_LEN_MAX];
+       struct _package_manager_pkg_info_t *next;
+} package_manager_pkg_info_t;
+
+typedef struct _package_manager_pkg_dependency_info_t {
+       char pkgid[PKG_NAME_STRING_LEN_MAX];
+       char type[PKG_DEP_TYPE_STRING_LEN_MAX];
+       char required_version[PKG_VERSION_STRING_LEN_MAX];
+} pkg_dependency_info_t;
+
+typedef struct _package_manager_pkg_detail_info_t {
+       char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+       char pkg_name[PKG_NAME_STRING_LEN_MAX];
+       char pkgid[PKG_NAME_STRING_LEN_MAX];
+       char version[PKG_VERSION_STRING_LEN_MAX];
+       char api_version[PKG_VERSION_STRING_LEN_MAX];
+       char pkg_description[PKG_VALUE_STRING_LEN_MAX];
+       char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
+       time_t installed_time;  /* installed time it must be GMT+0 time */
+       int installed_size;             /* installed total size */
+       int app_size;                   /* installed app size */
+       int data_size;                  /* data size which is made on run time */
+       char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
+       void *pkg_optional_info;
+       char label[PKG_LABEL_STRING_LEN_MAX];
+       char author[PKG_VALUE_STRING_LEN_MAX];
+       char *icon_buf;
+       int icon_size;
+       GList *privilege_list;
+       GList *dependency_list;
+} package_manager_pkg_detail_info_t;
+
+typedef void (*_pkg_plugin_unload)(void);
+typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkgid);
+typedef int (*_pkg_plugin_get_installed_pkg_list)(
+               const char *category, const char *option,
+               package_manager_pkg_info_t **list, int *count);
+typedef int (*_pkg_plugin_get_pkg_detail_info)(const char *pkgid,
+               package_manager_pkg_detail_info_t *pkg_detail_info);
+typedef int (*_pkg_plugin_get_pkg_detail_info_from_package)(
+               const char *pkg_path,
+               package_manager_pkg_detail_info_t *pkg_detail_info);
+
+typedef struct _pkg_plugin_set {
+       char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+       void *plugin_handle;
+       _pkg_plugin_unload plugin_on_unload;
+       _pkg_plugin_pkg_is_installed pkg_is_installed;
+       _pkg_plugin_get_installed_pkg_list get_installed_pkg_list;
+       _pkg_plugin_get_pkg_detail_info get_pkg_detail_info;
+       _pkg_plugin_get_pkg_detail_info_from_package
+       get_pkg_detail_info_from_package;
+} pkg_plugin_set;
+
+pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
+pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
+pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
+
+pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
+pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
+pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
+
+pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
+
+int _check_create_cert_db(void);
+void _save_column_int(sqlite3_stmt *stmt, int idx, int *i);
+void _save_column_str(sqlite3_stmt *stmt, int idx, char **str);
+char *_get_system_locale(void);
+int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **param);
+int __get_metadata_filter_condition(gpointer data, char **condition, GList **param);
+int _add_icon_info_into_list(const char *locale, char *value, GList **icon);
+int _add_label_info_into_list(const char *locale, char *value, GList **label);
+int __pkginfo_check_installed_storage(package_x *pkginfo);
+int __appinfo_check_installed_storage(application_x *appinfo);
+int __open_db(const char *path, sqlite3 **db, int flags);
+char *__get_type_from_path(const char *pkg_path);
+pkg_plugin_set *__load_library(const char *pkg_type);
+void __unload_library(const char *pkg_type);
+
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+#define REGULAR_USER 5000
+static inline uid_t _getuid(void)
+{
+       uid_t uid = getuid();
+
+       if (uid < REGULAR_USER)
+               return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+       else
+               return uid;
+}
+
+#endif  /* __PKGMGRINFO_PRIVATE_H__ */