summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaeho Lee <jaeho81.lee@samsung.com>2013-09-10 18:29:10 +0900
committerJaeho Lee <jaeho81.lee@samsung.com>2013-09-10 18:29:10 +0900
commite06be4ffca07cf786f7ba99a23a9efbe62cd307c (patch)
treea0807da58d2a5832f612a00b1180845ff9a21aea
parent9aade27fa6e030b8afcf62c06786ec301e981fe6 (diff)
downloadapp-svc-e06be4ffca07cf786f7ba99a23a9efbe62cd307c.tar.gz
app-svc-e06be4ffca07cf786f7ba99a23a9efbe62cd307c.tar.bz2
app-svc-e06be4ffca07cf786f7ba99a23a9efbe62cd307c.zip
Apply submodemainid feature
Signed-off-by: Jaeho Lee <jaeho81.lee@samsung.com>
-rw-r--r--packaging/app-svc.spec2
-rwxr-xr-xsrc/appsvc.c73
-rwxr-xr-xsrc/appsvc_db.c53
3 files changed, 104 insertions, 24 deletions
diff --git a/packaging/app-svc.spec b/packaging/app-svc.spec
index c5a79e4..96f597a 100644
--- a/packaging/app-svc.spec
+++ b/packaging/app-svc.spec
@@ -1,6 +1,6 @@
Name: app-svc
Summary: App svc
-Version: 0.1.51
+Version: 0.1.53
Release: 1
Group: System/Libraries
License: Apache License, Version 2.0
diff --git a/src/appsvc.c b/src/appsvc.c
index 905870c..a94ff2d 100755
--- a/src/appsvc.c
+++ b/src/appsvc.c
@@ -227,6 +227,7 @@ static int __get_resolve_info(bundle *b, appsvc_resolve_info_t *info)
info->origin_mime = info->mime = (char *)appsvc_get_mime(b);
info->pkgname = (char *)appsvc_get_pkgname(b);
info->category = (char *)appsvc_get_category(b);
+ info->win_id = (char *)bundle_get_val(b, APP_SVC_K_WIN_ID);
if(info->uri) {
if(strncmp(info->uri,"/",1) == 0){
@@ -571,7 +572,6 @@ static int __get_list_with_category(char *category, GSList **pkg_list)
GSList *app_list = NULL;
GSList *iter = NULL;
char *list_item = NULL;
- int match;
ret = pkgmgrinfo_appinfo_filter_create(&handle);
ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, category);
@@ -595,6 +595,69 @@ static int __get_list_with_category(char *category, GSList **pkg_list)
return 0;
}
+static int __appid_compare(gconstpointer data1, gconstpointer data2)
+{
+ char *a = (char *)data1;
+ char *b = (char *)data2;
+ return strcmp(a,b);
+}
+
+static int __get_list_with_submode(char *win_id, GSList **pkg_list)
+{
+ int ret;
+ GSList *iter = NULL;
+ char *appid = NULL;
+ GSList *find_item = NULL;
+ char *find_appid = NULL;
+ ail_appinfo_h handle;
+ char *submode_mainid = NULL;
+
+ for (iter = *pkg_list; iter != NULL; ) {
+ find_item = NULL;
+ submode_mainid = NULL;
+ appid = (char *)iter->data;
+ ret = ail_get_appinfo(appid, &handle);
+ SECURE_LOGD("ret %d, %s, %x", ret, appid, handle);
+ ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_SUBMODEMAINID_STR, &submode_mainid);
+ SECURE_LOGD("appid(%s) submode_mainid(%s) win_id(%s)", appid, submode_mainid, win_id);
+ if(submode_mainid) {
+ if(win_id) {
+ find_item = g_slist_find_custom(*pkg_list, submode_mainid, __appid_compare);
+ if(find_item) {
+ find_appid = find_item->data;
+ if(find_item == g_slist_next(iter)) {
+ iter = g_slist_next(find_item);
+ *pkg_list = g_slist_remove(*pkg_list, find_appid);
+ free(find_appid);
+ } else {
+ iter = g_slist_next(iter);
+ *pkg_list = g_slist_remove(*pkg_list, find_appid);
+ free(find_appid);
+ }
+ }
+ } else {
+ find_item = g_slist_find_custom(*pkg_list, submode_mainid, __appid_compare);
+ if(find_item) {
+ iter = g_slist_next(iter);
+ *pkg_list = g_slist_remove(*pkg_list, appid);
+ free(appid);
+ }
+ }
+ }
+ ail_destroy_appinfo(handle);
+ if(!find_item) {
+ iter = g_slist_next(iter);
+ }
+ }
+
+ for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+ appid = (char *)iter->data;
+ SECURE_LOGD("appid(%s)", appid);
+ }
+
+ return 0;
+}
+
SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data)
{
appsvc_resolve_info_t info;
@@ -651,6 +714,8 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc,
__get_list_with_category(info.category, &pkg_list);
}
+ __get_list_with_submode(info.win_id, &pkg_list);
+
pkg_count = g_slist_length(pkg_list);
_D("pkg_count : %d", pkg_count);
@@ -697,6 +762,8 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc,
__get_list_with_category(info.category, &pkg_list);
}
+ __get_list_with_submode(info.win_id, &pkg_list);
+
pkg_count = g_slist_length(pkg_list);
_D("pkg_count : %d", pkg_count);
@@ -739,6 +806,8 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc,
__get_list_with_category(info.category, &pkg_list);
}
+ __get_list_with_submode(info.win_id, &pkg_list);
+
pkg_count = g_slist_length(pkg_list);
_D("pkg_count : %d", pkg_count);
@@ -814,6 +883,8 @@ SLPAPI int appsvc_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data)
__get_list_with_category(info.category, &pkg_list);
}
+ __get_list_with_submode(info.win_id, &pkg_list);
+
pkg_count = g_slist_length(pkg_list);
if (pkg_count == 0) {
_E("Cannot find associated application");
diff --git a/src/appsvc_db.c b/src/appsvc_db.c
index 5b5361b..4cc184b 100755
--- a/src/appsvc_db.c
+++ b/src/appsvc_db.c
@@ -49,7 +49,7 @@ static sqlite3 *app_info_db = NULL;
static int __init(void)
{
int rc;
-
+
if (svc_db) {
_D("Already initialized\n");
return 0;
@@ -198,12 +198,12 @@ int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, cons
if(mime_type==NULL)
strncpy(m,"NULL",BUF_MAX_LEN-1);
- else
+ else
strncpy(m,mime_type,BUF_MAX_LEN-1);
if(uri==NULL)
strncpy(u,"NULL",URI_MAX_LEN-1);
- else
+ else
strncpy(u,uri,URI_MAX_LEN-1);
snprintf(query, QUERY_MAX_LEN, "insert into appsvc( operation, mime_type, uri, pkg_name) \
@@ -214,7 +214,7 @@ int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, cons
_E("Don't execute query = %s, error message = %s\n", query, error_message);
return -1;
}
-
+
__fini();
return 0;
}
@@ -223,7 +223,7 @@ int _svc_db_delete_with_pkgname(const char *pkg_name)
{
char query[QUERY_MAX_LEN];
char* error_message = NULL;
-
+
if(pkg_name == NULL) {
_E("Invalid argument: data to delete is NULL\n");
return -1;
@@ -239,7 +239,7 @@ int _svc_db_delete_with_pkgname(const char *pkg_name)
_E("Don't execute query = %s, error message = %s\n", query, error_message);
return -1;
}
-
+
__fini();
return 0;
@@ -251,7 +251,7 @@ int _svc_db_is_defapp(const char *pkg_name)
sqlite3_stmt *stmt;
int cnt = 0;
int ret = -1;
-
+
if(pkg_name == NULL) {
_E("Invalid argument: data to delete is NULL\n");
return 0;
@@ -273,7 +273,7 @@ int _svc_db_is_defapp(const char *pkg_name)
cnt = sqlite3_column_int(stmt, 0);
}
sqlite3_finalize(stmt);
-
+
__fini();
if(cnt < 1) return 0;
@@ -289,27 +289,28 @@ char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri)
sqlite3_stmt* stmt;
int ret;
char* pkgname;
+ char* ret_val = NULL;
if(op == NULL )
return NULL;
if(mime_type==NULL)
strncpy(m,"NULL",BUF_MAX_LEN-1);
- else
+ else
strncpy(m,mime_type,BUF_MAX_LEN-1);
if(uri==NULL)
strncpy(u,"NULL",URI_MAX_LEN-1);
- else
+ else
strncpy(u,uri,URI_MAX_LEN-1);
// if(doubt_sql_injection(mime_type))
// return NULL;
-
+
if(__init() < 0)
return NULL;
-
-
+
+
snprintf(query, QUERY_MAX_LEN, "select pkg_name from appsvc where operation='%s' and mime_type='%s' and uri='%s'",\
op,m,u);
@@ -318,26 +319,34 @@ char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri)
ret = sqlite3_prepare(svc_db, query, strlen(query), &stmt, NULL);
if ( ret != SQLITE_OK) {
- _E("prepare error\n");
- return NULL;
+ _E("prepare error(%d)\n", ret);
+ goto db_fini;
}
ret = sqlite3_step(stmt);
- if (ret == SQLITE_DONE) {
- return NULL;
+ if (ret != SQLITE_ROW) {
+ _D("no result");
+ goto stmt_finialize;
}
- pkgname = malloc(BUF_MAX_LEN);
- strncpy(pkgname, (const char *)sqlite3_column_text(stmt, 0),BUF_MAX_LEN-1);
- //pkgname = (char*) sqlite3_column_text(stmt, 0);
+ pkgname = (char*) sqlite3_column_text(stmt, 0);
+ if(pkgname) {
+ ret_val = malloc(BUF_MAX_LEN);
+ strncpy(ret_val, (const char *)sqlite3_column_text(stmt, 0),BUF_MAX_LEN-1);
+ }
_D("pkgname : %s\n",pkgname);
-
+
+stmt_finialize :
ret = sqlite3_finalize(stmt);
+ if ( ret != SQLITE_OK) {
+ _D("finalize error(%d)", ret);
+ }
+db_fini :
__fini();
- return pkgname;
+ return ret_val;
}
int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list)