diff options
author | Jiwoong Im <jiwoong.im@samsung.com> | 2015-05-20 19:25:17 +0900 |
---|---|---|
committer | Jiwoong Im <jiwoong.im@samsung.com> | 2015-05-20 19:25:17 +0900 |
commit | 681c60e7e515803465625d4a2290cc925fdad087 (patch) | |
tree | 6074d79f95400714d7e9e5b57b5d37688b357b3a | |
parent | d95dbdd84bb3aa893ea3e5042ce7a4684f85f4e6 (diff) | |
download | app-svc-681c60e7e515803465625d4a2290cc925fdad087.tar.gz app-svc-681c60e7e515803465625d4a2290cc925fdad087.tar.bz2 app-svc-681c60e7e515803465625d4a2290cc925fdad087.zip |
remove ail dependency.
ail and appinfo APIs in package manager info (pkgmgr-info) provides
exactly same function and ail deprecated to remove confusion from those
two APIs with same feature in 2.3.
JIRA ticket : TC-2513
Change-Id: Ic2c459f3a78df94c8737f6e11557f38d1819a605
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | packaging/app-svc.spec | 1 | ||||
-rw-r--r-- | src/appsvc.c | 69 | ||||
-rwxr-xr-x | src/appsvc_db.c | 68 |
4 files changed, 66 insertions, 74 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a31ccc3..5ac3c54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") 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) diff --git a/packaging/app-svc.spec b/packaging/app-svc.spec index a298e7c..ea84239 100644 --- a/packaging/app-svc.spec +++ b/packaging/app-svc.spec @@ -23,7 +23,6 @@ BuildRequires: pkgconfig(ecore-x) 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) diff --git a/src/appsvc.c b/src/appsvc.c index 42d0713..e136732 100644 --- a/src/appsvc.c +++ b/src/appsvc.c @@ -27,7 +27,6 @@ #include <unistd.h> #include <sys/types.h> -#include <ail.h> #include <aul.h> #include <libsoup/soup.h> @@ -38,6 +37,7 @@ #include <Ecore.h> #include <iniparser.h> #include <pkgmgr-info.h> +#include <tzplatform_config.h> #include "appsvc.h" #include "appsvc_db.h" @@ -87,8 +87,6 @@ static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code, 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); @@ -332,57 +330,6 @@ static int __free_resolve_info_data(appsvc_resolve_info_t *info) 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){ @@ -513,14 +460,14 @@ static int __get_list_with_condition_mime_extened(char *op, char *uri, char *mim 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); @@ -614,7 +561,7 @@ static int __get_list_with_submode(char *win_id, GSList **pkg_list, uid_t uid) 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 @@ -622,9 +569,9 @@ static int __get_list_with_submode(char *win_id, GSList **pkg_list, uid_t uid) 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) { @@ -650,7 +597,7 @@ static int __get_list_with_submode(char *win_id, GSList **pkg_list, uid_t uid) } } } - ail_destroy_appinfo(handle); + pkgmgrinfo_appinfo_destroy_appinfo(handle); if(!find_item) { iter = g_slist_next(iter); } diff --git a/src/appsvc_db.c b/src/appsvc_db.c index 1190e06..0d1f6af 100755 --- a/src/appsvc_db.c +++ b/src/appsvc_db.c @@ -32,7 +32,7 @@ #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 @@ -133,12 +133,12 @@ static char* getUserAppDB(uid_t uid) 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); } @@ -160,7 +160,7 @@ static int __init(uid_t uid) 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; @@ -260,7 +260,7 @@ static int __init_app_info_db(uid_t uid) 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; @@ -373,7 +373,7 @@ int _svc_db_is_defapp(const char *pkg_name, uid_t uid) 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; } @@ -426,7 +426,7 @@ char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri, ui _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); @@ -459,6 +459,51 @@ db_fini : 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]; @@ -472,13 +517,14 @@ int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pk 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; } |