INCLUDE(FindPkgConfig)
SET(APPSVC_PKGS_CHECK_MODULES "dlog ecore libprivilege-control aul")
-SET(APPSVC_LIBPKGS_CHECK_MODULES "dlog bundle dbus-glib-1 ail xdgmime aul glib-2.0 ecore libsoup-2.4 iniparser pkgmgr-info libtzplatform-config")
+SET(APPSVC_LIBPKGS_CHECK_MODULES "dlog bundle dbus-glib-1 xdgmime aul glib-2.0 ecore libsoup-2.4 iniparser pkgmgr-info libtzplatform-config")
IF (with_x)
pkg_check_modules(pkgs REQUIRED ${APPSVC_PKGS_CHECK_MODULES} x11)
BuildRequires: pkgconfig(libprivilege-control)
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(ail)
BuildRequires: pkgconfig(xdgmime)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(glib-2.0)
#include <unistd.h>
#include <sys/types.h>
-#include <ail.h>
#include <aul.h>
#include <libsoup/soup.h>
#include <Ecore.h>
#include <iniparser.h>
#include <pkgmgr-info.h>
+#include <tzplatform_config.h>
#include "appsvc.h"
#include "appsvc_db.h"
appsvc_res_fn cbfunc, void *data);
static int __get_resolve_info(bundle *b, appsvc_resolve_info_t *info);
static int __free_resolve_info_data(appsvc_resolve_info_t *info);
-static ail_cb_ret_e __ail_iter_func(const ail_appinfo_h appinfo,
- void *user_data, uid_t uid);
static int __get_list_with_condition(char *op, char *uri,
char *mime, GSList **pkg_list, uid_t uid);
return 0;
}
-static ail_cb_ret_e __ail_iter_func(
- const ail_appinfo_h appinfo, void *user_data, uid_t uid)
-{
- GSList **pkg_list = (GSList **)user_data;
- GSList *iter = NULL;
- char *str = NULL;
- char *pkgname = NULL;
-
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, uid, &str);
-
- _D("Matching application is %s",str);
-
- for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
- pkgname = (char *)iter->data;
- if (strncmp(str, pkgname, MAX_PACKAGE_STR_SIZE-1) == 0)
- return AIL_CB_RET_CONTINUE;
- }
-
- pkgname = strdup(str);
- *pkg_list = g_slist_append(*pkg_list, (void *)pkgname);
- _D("%s is added",pkgname);
-
- return AIL_CB_RET_CONTINUE;
-}
-
-static int __get_list_with_condition(char *op, char *uri, char *mime, GSList **pkg_list, uid_t uid)
-{
- ail_filter_h filter;
- ail_error_e ail_ret;
- char svc_filter[MAX_FILTER_STR_SIZE] = {0,};
-
- ail_ret = ail_filter_new(&filter);
- if (ail_ret != AIL_ERROR_OK)
- return APPSVC_RET_ERROR;
-
- snprintf(svc_filter, MAX_FILTER_STR_SIZE-1, "%s|%s|%s", op, uri, mime);
- _D("svc_filter : %s",svc_filter);
-
- ail_ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_SVC_STR, svc_filter);
- if (ail_ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return APPSVC_RET_ERROR;
- }
-
- ail_filter_list_usr_appinfo_foreach(filter, __ail_iter_func, (void *)pkg_list, uid);
-
- ail_filter_destroy(filter);
-
- return APPSVC_RET_OK;
-}
-
SLPAPI int appsvc_set_operation(bundle *b, const char *operation)
{
if(b == NULL){
tmp = malloc(MAX_MIME_STR_SIZE);
- __get_list_with_condition(op, uri, mime, pkg_list, uid);
+ _svc_db_get_list_with_condition(op, uri, mime, pkg_list, uid);
if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(s_type, "%", 1) != 0)) {
snprintf(tmp, MAX_MIME_STR_SIZE-1, "%s/*", m_type);
- __get_list_with_condition(op, uri, tmp, pkg_list, uid);
+ _svc_db_get_list_with_condition(op, uri, tmp, pkg_list, uid);
}
if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(m_type, "%", 1) != 0)) {
snprintf(tmp, MAX_MIME_STR_SIZE-1, "*/*");
- __get_list_with_condition(op, uri, tmp, pkg_list, uid);
+ _svc_db_get_list_with_condition(op, uri, tmp, pkg_list, uid);
}
free(tmp);
char *appid = NULL;
GSList *find_item = NULL;
char *find_appid = NULL;
- ail_appinfo_h handle;
+ pkgmgrinfo_appinfo_h handle = NULL;
char *submode_mainid = NULL;
#ifndef WAYLAND
find_item = NULL;
submode_mainid = NULL;
appid = (char *)iter->data;
- ret = ail_get_usr_appinfo(appid, uid, &handle);
+ ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle);
SECURE_LOGD("ret %d, %s, %x", ret, appid, handle);
- ret = ail_appinfo_get_usr_str(handle, AIL_PROP_X_SLP_SUBMODEMAINID_STR, uid, &submode_mainid);
+ ret = pkgmgrinfo_appinfo_get_submode_mainid(handle, &submode_mainid);
SECURE_LOGD("appid(%s) submode_mainid(%s) win_id(%s)", appid, submode_mainid, win_id);
if(submode_mainid) {
if(win_id) {
}
}
}
- ail_destroy_appinfo(handle);
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
if(!find_item) {
iter = g_slist_next(iter);
}
#include "internal.h"
#define SVC_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".appsvc.db")
-#define APP_INFO_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".app_info.db")
+#define APP_INFO_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
#define QUERY_MAX_LEN 8192
#define URI_MAX_LEN 4096
if (uid != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
tzplatform_set_user(uid);
- app_info_db = tzplatform_mkpath(TZ_USER_DB, ".app_info.db");
+ app_info_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_parser.db");
db_path = tzplatform_getenv(TZ_USER_DB);
gid = tzplatform_getgid(TZ_USER_NAME);
tzplatform_reset_user();
} else {
- app_info_db = tzplatform_mkpath(TZ_SYS_DB, ".app_info.db");
+ app_info_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
db_path = tzplatform_getenv(TZ_SYS_DB);
}
return 0;
}
- rc = sqlite3_open(getUserSvcDB(uid), &svc_db);
+ rc = sqlite3_open_v2(getUserSvcDB(uid), &svc_db, SQLITE_OPEN_READONLY, NULL);
if(rc) {
_E("Can't open database: %s", sqlite3_errmsg(svc_db));
goto err;
return 0;
}
- rc = sqlite3_open(getUserAppDB(uid), &app_info_db);
+ rc = sqlite3_open_v2(getUserAppDB(uid), &app_info_db, SQLITE_OPEN_READONLY, NULL);
if(rc) {
_E("Can't open database: %s", sqlite3_errmsg(app_info_db));
goto err;
snprintf(query, QUERY_MAX_LEN,
"select count(*) from appsvc where pkg_name = '%s';", pkg_name);
- ret = sqlite3_prepare(svc_db, query, sizeof(query), &stmt, NULL);
+ ret = sqlite3_prepare_v2(svc_db, query, sizeof(query), &stmt, NULL);
if (ret != SQLITE_OK) {
return -1;
}
_D("query : %s\n",query);
- ret = sqlite3_prepare(svc_db, query, strlen(query), &stmt, NULL);
+ ret = sqlite3_prepare_v2(svc_db, query, strlen(query), &stmt, NULL);
if ( ret != SQLITE_OK) {
_E("prepare error(%d)\n", ret);
return ret_val;
}
+int _svc_db_get_list_with_condition(char *op, char *uri, char *mime, GSList **pkg_list, uid_t uid)
+{
+ char query[QUERY_MAX_LEN];
+ sqlite3_stmt* stmt;
+ int ret;
+ GSList *iter = NULL;
+ char *str = NULL;
+ char *pkgname = NULL;
+ int found;
+
+ if(__init_app_info_db(uid)<0)
+ return 0;
+
+ snprintf(query, QUERY_MAX_LEN, "select ac.app_id from package_app_app_control as ac where ac.app_control like '%%%s|%s|%s%%'", op,uri,mime);
+ SECURE_LOGD("query : %s\n",query);
+
+ ret = sqlite3_prepare_v2(app_info_db, query, strlen(query), &stmt, NULL);
+ if ( ret != SQLITE_OK) {
+ _E("prepare error, ret = %d, extended = %d %s\n", ret,
+ sqlite3_extended_errcode(app_info_db), sqlite3_errmsg(app_info_db));
+ return -1;
+ }
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ str = (char *)sqlite3_column_text(stmt, 0);
+ found = 0;
+ for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+ pkgname = (char *)iter->data;
+ if (strncmp(str,pkgname, MAX_PACKAGE_STR_SIZE-1) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ if(found == 0) {
+ pkgname = strdup(str);
+ *pkg_list = g_slist_append(*pkg_list, (void *)pkgname);
+ _D("%s is added",pkgname);
+ }
+ }
+
+ ret = sqlite3_finalize(stmt);
+
+ return 0;
+}
+
int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list, uid_t uid)
{
char query[QUERY_MAX_LEN];
if(__init_app_info_db(uid)<0)
return 0;
- snprintf(query, QUERY_MAX_LEN, "select package from app_info where x_slp_svc like '%%%s|%s|%s%%'", op, uri ? uri : "NULL", mime);
- _D("query : %s\n",query);
+ snprintf(query, QUERY_MAX_LEN, "select ac.app_id from package_app_app_control as ac where ac.app_control='%s|%s|%s' collate appsvc_collation", op,uri,mime);
+ SECURE_LOGD("query : %s\n",query);
- ret = sqlite3_prepare(app_info_db, query, strlen(query), &stmt, NULL);
+ ret = sqlite3_prepare_v2(app_info_db, query, strlen(query), &stmt, NULL);
if ( ret != SQLITE_OK) {
- _E("prepare error\n");
+ _E("prepare error, ret = %d, extended = %d %s\n", ret,
+ sqlite3_extended_errcode(app_info_db), sqlite3_errmsg(app_info_db));
return -1;
}