#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}
+ {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},
+ {E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE, PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE}
};
struct _pkginfo_int_map_t {
{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_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 {
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_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_METADATA_KEY, PMINFO_APPINFO_PROP_APP_METADATA_KEY},
- {E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE, PMINFO_APPINFO_PROP_APP_METADATA_VALUE},
- {E_PMINFO_APPINFO_PROP_APP_PACKAGE, PMINFO_APPINFO_PROP_APP_PACKAGE}
+ {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 {
};
static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
- {E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER}
+ {E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE, PMINFO_APPINFO_PROP_APP_SUPPORT_MODE}
};
struct _appinfo_bool_map_t {
{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_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)
+API pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
{
int i = 0;
int max = 0;
return prop;
}
-inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
+API pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
{
int i = 0;
int max = 0;
return prop;
}
-inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
+API pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
{
int i = 0;
int max = 0;
return prop;
}
-inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
+API pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
{
int i = 0;
int max = 0;
return prop;
}
-inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
+API pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
{
int i = 0;
int max = 0;
return prop;
}
-inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
+API pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
{
int i = 0;
int max = 0;
return prop;
}
-void __get_filter_condition(gpointer data, char **condition)
+void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node)
{
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
+ if (node == NULL)
+ return;
+
+ free(node->value);
+ free(node->key);
+ free(node);
+}
+
+API 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'};
- char temp[PKG_STRING_LEN_MAX] = {'\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), "package_info.package='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.package=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
- snprintf(buf, sizeof(buf), "package_info.package_type='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_type=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
- snprintf(buf, sizeof(buf), "package_info.package_version='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_version=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
- snprintf(buf, sizeof(buf), "package_info.install_location='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.install_location=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
- snprintf(buf, sizeof(buf), "package_info.installed_storage='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.installed_storage=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
- snprintf(buf, sizeof(buf), "package_info.author_name='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.author_name=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
- snprintf(buf, sizeof(buf), "package_info.author_href='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.author_href=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
- snprintf(buf, sizeof(buf), "package_info.author_email='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.author_email=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE:
- snprintf(buf, sizeof(buf), "package_privilege_info.privilege='%s'", node->value);
+ 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), "package_info.package_size='%s'", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_size=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
- snprintf(buf, sizeof(buf), "package_info.package_removable IN %s", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_removable=? COLLATE NOCASE");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
- snprintf(buf, sizeof(buf), "package_info.package_preload IN %s", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_preload=? COLLATE NOCASE");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
- snprintf(buf, sizeof(buf), "package_info.package_readonly IN %s", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_readonly=? COLLATE NOCASE");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
- snprintf(buf, sizeof(buf), "package_info.package_update IN %s", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_update=? COLLATE NOCASE");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
- snprintf(buf, sizeof(buf), "package_info.package_appsetting IN %s", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_appsetting=? COLLATE NOCASE");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
- snprintf(buf, sizeof(buf), "package_info.package_nodisplay IN %s", node->value);
+ snprintf(buf, sizeof(buf), "pi.package_nodisplay=? COLLATE NOCASE");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE:
- snprintf(buf, sizeof(buf), "package_info.package_support_disable IN %s", node->value);
- break;
-
+ 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_PKGINFO_PROP_PACKAGE_RES_TYPE:
+ if (node->value == NULL || strlen(node->value) == 0) {
+ *condition = strdup("package_res_info.res_type IS NOT NULL COLLATE NOCASE");
+ if (*condition == NULL) {
+ _LOGE("out of memeory");
+ return 0;
+ }
+ return E_PMINFO_PKGINFO_JOIN_RES_INFO;
+ } else {
+ snprintf(buf, sizeof(buf), "package_res_info.res_type=? COLLATE NOCASE");
+ flag = E_PMINFO_PKGINFO_JOIN_RES_INFO;
+ break;
+ }
case E_PMINFO_APPINFO_PROP_APP_ID:
- snprintf(buf, sizeof(buf), "package_app_info.app_id='%s'", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_id=?");
break;
case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
- snprintf(buf, sizeof(buf), "package_app_info.app_component='%s'", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_component=?");
break;
case E_PMINFO_APPINFO_PROP_APP_EXEC:
- snprintf(buf, sizeof(buf), "package_app_info.app_exec='%s'", node->value);
+ 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='%s'", node->value);
+ 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), "package_app_info.app_type='%s'", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_type=?");
break;
case E_PMINFO_APPINFO_PROP_APP_OPERATION:
- snprintf(temp, sizeof(temp), "(%s)", node->value);
- snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE %s|%%|%%", temp);
+ 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(temp, sizeof(temp), "(%s)", node->value);
- snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE %%|%s|%%", temp);
+ 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(temp, sizeof(temp), "(%s)", node->value);
- snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE %%|%%|%s", temp);
+ 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(temp, sizeof(temp), "(%s)", node->value);
- snprintf(buf, sizeof(buf), "package_app_app_category.category IN %s", temp);
- break;
+ 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), "package_app_info.app_nodisplay IN %s", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_nodisplay=? COLLATE NOCASE");
break;
case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
- snprintf(buf, sizeof(buf), "package_app_info.app_multiple IN %s", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_multiple=? COLLATE NOCASE");
break;
case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
- snprintf(buf, sizeof(buf), "package_app_info.app_onboot IN %s", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_onboot=? COLLATE NOCASE");
break;
case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
- snprintf(buf, sizeof(buf), "package_app_info.app_autorestart IN %s", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_autorestart=? COLLATE NOCASE");
break;
case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
- snprintf(buf, sizeof(buf), "package_app_info.app_taskmanage IN %s", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_taskmanage=? COLLATE NOCASE");
break;
case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
- snprintf(buf, sizeof(buf), "package_app_info.app_hwacceleration='%s'", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_hwacceleration=?");
break;
case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
- snprintf(buf, sizeof(buf), "package_app_info.app_screenreader='%s'", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_screenreader=?");
break;
case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
- snprintf(buf, sizeof(buf), "package_app_info.app_launchcondition IN %s", node->value);
+ snprintf(buf, sizeof(buf), "ai.app_launchcondition=? COLLATE NOCASE");
break;
case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
- snprintf(buf, sizeof(buf), "package_app_info.package='%s'", node->value);
+ snprintf(buf, sizeof(buf), "ai.package=?");
break;
- case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
- snprintf(buf, sizeof(buf), "package_app_info.app_ui_gadget IN %s", node->value);
+ case E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE:
+ snprintf(buf, sizeof(buf), "ai.app_installed_storage=?");
break;
- case E_PMINFO_APPINFO_PROP_APP_METADATA_KEY:
- snprintf(buf, sizeof(buf), "package_app_app_metadata.md_key='%s'", node->value);
+ 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_METADATA_VALUE:
- snprintf(buf, sizeof(buf), "package_app_app_metadata.md_value='%s'", node->value);
+ 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, "package_app_info.app_support_disable IN %s", node->value);
+ 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_DISABLE_FOR_USER:
- snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id NOT IN "
- "(SELECT app_id from package_app_disable_for_user WHERE uid='%s')", node->value);
+ 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;
+ return 0;
}
*condition = strdup(buf);
- return;
+ *params = g_list_append(*params, strdup(node->value));
+ return flag;
+}
+
+API 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;
+}
+
+API 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;
+}
+
+API 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;
+}
+
+API 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;
+}
+
+API 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;
+}
+
+struct type_map {
+ const char *manifest;
+ const char *type;
+};
+
+const struct type_map type_map[] = {
+ { "res/wgt/config.xml", "wgt" },
+ { "config.xml", "wgt" },
+ { "tizen-manifest.xml", "tpk" },
+ { NULL, NULL}
+};
+
+API 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 void __get_library_path(const char *pkg_type, const char **path)
+{
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "package-manager/backendlib/lib%s.so",
+ pkg_type);
+
+ *path = tzplatform_mkpath(TZ_SYS_RO_ETC, buf);
}
-char *_get_system_locale(void)
+API pkg_plugin_set *__load_library(const char *pkg_type)
{
- char *lang;
- char *locale;
-
- lang = vconf_get_str(VCONFKEY_LANGSET);
- if (lang == NULL) {
- locale = strdup(DEFAULT_LOCALE);
- if (locale == NULL) {
- LOGE("out of memory");
+ void *library_handle;
+ pkg_plugin_set *plugin_set;
+ bool (*on_load)(pkg_plugin_set *plugin);
+ const char *library_path;
+
+ __get_library_path(pkg_type, &library_path);
+ 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;
}
- return locale;
}
- locale = malloc(sizeof(char) * 6);
- if (locale == NULL) {
- LOGE("out of memory");
- free(lang);
+ 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;
+ }
+
+ library_handle = dlopen(library_path, RTLD_LAZY);
+ if (library_handle == NULL) {
+ _LOGE("dlopen is failed library_path[%s]", library_path);
+ return NULL;
+ }
+
+ on_load = dlsym(library_handle, "pkg_plugin_on_load");
+ if (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;
}
- strncpy(locale, lang, 2);
- locale[2] = '-';
- locale[3] = tolower(lang[3]);
- locale[4] = tolower(lang[4]);
- locale[5] = '\0';
+ 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);
- free(lang);
+ _LOGD("library [%s] is loaded", library_path);
- return locale;
+ return plugin_set;
}
+API 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);
+}