diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-16 01:12:30 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-16 01:12:30 +0900 |
commit | 70ed9ed4ed8e4858d3a9b8e9ca8ebf0cb366b5c1 (patch) | |
tree | 1eb53d297187befa7c9fa0bdf319a772fe848e9e | |
parent | e739f01bde2b821ac6b82990fe79c22f714b7eed (diff) | |
download | app-svc-70ed9ed4ed8e4858d3a9b8e9ca8ebf0cb366b5c1.tar.gz app-svc-70ed9ed4ed8e4858d3a9b8e9ca8ebf0cb366b5c1.tar.bz2 app-svc-70ed9ed4ed8e4858d3a9b8e9ca8ebf0cb366b5c1.zip |
merge with master
-rwxr-xr-x | CMakeLists.txt | 4 | ||||
-rwxr-xr-x | include/appsvc.h | 1 | ||||
-rw-r--r-- | packaging/app-svc.spec | 16 | ||||
-rwxr-xr-x | src/appsvc.c | 46 | ||||
-rwxr-xr-x | src/appsvc_db.c | 37 |
5 files changed, 62 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd300c..9f68f83 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,11 +79,11 @@ CONFIGURE_FILE(appsvc.pc.in appsvc.pc @ONLY) ### Install ### -INSTALL(TARGETS appsvc DESTINATION lib COMPONENT RuntimeLibraries) +INSTALL(TARGETS appsvc DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) INSTALL(TARGETS ${AVATAR_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/appsvc.h DESTINATION include/appsvc) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/appsvc.pc DESTINATION lib/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/appsvc.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/appsvc_db.sql DESTINATION /opt/share ) diff --git a/include/appsvc.h b/include/appsvc.h index 4a98f39..d01aaa5 100755 --- a/include/appsvc.h +++ b/include/appsvc.h @@ -102,6 +102,7 @@ extern "C" { * @brief Return values in appsvc. */ typedef enum _appsvc_return_val { + APPSVC_RET_EILLACC = -5, /**< Illegal Access */ APPSVC_RET_ELAUNCH = -4, /**< Failure on launching the app */ APPSVC_RET_ENOMATCH = -3, /**< No matching result Error */ APPSVC_RET_EINVAL = -2, /**< Invalid argument */ diff --git a/packaging/app-svc.spec b/packaging/app-svc.spec index ab21033..d62c6f2 100644 --- a/packaging/app-svc.spec +++ b/packaging/app-svc.spec @@ -1,7 +1,6 @@ -#sbs-git:slp/pkgs/a/app-svc app-svc 0.1.19 de68cdc468eaded317b4f5be9cdafebb01639aa0 Name: app-svc Summary: App svc -Version: 0.1.42 +Version: 0.1.48 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 @@ -43,13 +42,10 @@ App svc (developement files) %build - -CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=/usr - +%cmake . make %{?jobs:-j%jobs} %install -rm -rf %{buildroot} %make_install @@ -74,13 +70,13 @@ chsmack -a 'app-svc::db' /opt/dbspace/.appsvc.db-journal %defattr(-,root,root,-) /opt/share/appsvc_db.sql /usr/bin/appsvc_test -/usr/lib/libappsvc.so.0 -/usr/lib/libappsvc.so.0.1.0 +%{_libdir}/libappsvc.so.0 +%{_libdir}/libappsvc.so.0.1.0 %files devel %defattr(-,root,root,-) -/usr/lib/pkgconfig/appsvc.pc -/usr/lib/libappsvc.so +%{_libdir}/pkgconfig/appsvc.pc +%{_libdir}/libappsvc.so /usr/include/appsvc/appsvc.h diff --git a/src/appsvc.c b/src/appsvc.c index db1d4da..f2c17b9 100755 --- a/src/appsvc.c +++ b/src/appsvc.c @@ -196,8 +196,11 @@ static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code, ap cb_info = __create_rescb(request_code, cbfunc, data); ret = aul_launch_app_with_result(pkgname, b, __aul_cb, cb_info); - if(ret < 0) + if(ret == AUL_R_EILLACC) { + ret = APPSVC_RET_EILLACC; + } else if(ret < 0) { ret = APPSVC_RET_ELAUNCH; + } } else { _D("pkg_name : %s - no result", pkgname); ret = aul_launch_app(pkgname, b); @@ -499,17 +502,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); - 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); } - 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); } - free(tmp); return 0; @@ -518,7 +518,20 @@ static int __get_list_with_condition_mime_extened(char *op, char *uri, char *mim static int __get_list_with_condition_mime_extened_with_collation(char *op, char *uri, char *mime, char *m_type, char *s_type, GSList **pkg_list) { + char *tmp; + + tmp = malloc(MAX_MIME_STR_SIZE); + _svc_db_get_list_with_collation(op, uri, mime, pkg_list); + if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(s_type, "%", 1) != 0)) { + snprintf(tmp, MAX_MIME_STR_SIZE-1, "%s/*", m_type); + _svc_db_get_list_with_collation(op, uri, tmp, pkg_list); + } + if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(m_type, "%", 1) != 0)) { + snprintf(tmp, MAX_MIME_STR_SIZE-1, "*/*"); + _svc_db_get_list_with_collation(op, uri, tmp, pkg_list); + } + free(tmp); return 0; } @@ -592,23 +605,23 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, return APPSVC_RET_EINVAL; } - memset(&info, 0, sizeof(appsvc_resolve_info_t)); - ret = __get_resolve_info(b, &info); - if(ret < 0) - return ret; - - pkgname = info.pkgname; - _D("op - %s / mime - %s / shceme - %s\n", info.op, info.origin_mime, info.scheme); + pkgname = (char *)appsvc_get_pkgname(b); /* explict*/ if(pkgname) { if(appsvc_get_operation(b) == NULL) appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT); ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data); - __free_resolve_info_data(&info); return ret; } + memset(&info, 0, sizeof(appsvc_resolve_info_t)); + ret = __get_resolve_info(b, &info); + if(ret < 0) + return ret; + + _D("op - %s / mime - %s / shceme - %s\n", info.op, info.origin_mime, info.scheme); + /*uri*/ pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri); if(pkgname==NULL){ @@ -625,6 +638,9 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, __get_list_with_condition_mime_extened(info.op, info.scheme, info.mime, info.m_type, info.s_type, &pkg_list); + __get_list_with_condition_mime_extened(info.op, "*", + info.mime, info.m_type, info.s_type, &pkg_list); + if(info.category) { __get_list_with_category(info.category, &pkg_list); } @@ -668,6 +684,9 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, __get_list_with_condition_mime_extened(info.op, info.scheme, info.mime, info.m_type, info.s_type, &pkg_list); + __get_list_with_condition_mime_extened(info.op, "*", + info.mime, info.m_type, info.s_type, &pkg_list); + if(info.category) { __get_list_with_category(info.category, &pkg_list); } @@ -707,6 +726,9 @@ SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, __get_list_with_condition_mime_extened(info.op, info.scheme, info.mime, info.m_type, info.s_type, &pkg_list); + __get_list_with_condition_mime_extened(info.op, "*", + info.mime, info.m_type, info.s_type, &pkg_list); + if(info.category) { __get_list_with_category(info.category, &pkg_list); } diff --git a/src/appsvc_db.c b/src/appsvc_db.c index b523441..5b5361b 100755 --- a/src/appsvc_db.c +++ b/src/appsvc_db.c @@ -32,7 +32,8 @@ #define SVC_DB_PATH "/opt/dbspace/.appsvc.db" #define APP_INFO_DB_PATH "/opt/dbspace/.app_info.db" -#define QUERY_MAXLEN 4096 +#define QUERY_MAX_LEN 8192 +#define URI_MAX_LEN 4096 #define BUF_MAX_LEN 1024 #define APPSVC_COLLATION "appsvc_collation" @@ -185,8 +186,8 @@ static int __fini(void) int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, const char *pkg_name) { char m[BUF_MAX_LEN]; - char u[BUF_MAX_LEN]; - char query[BUF_MAX_LEN]; + char u[URI_MAX_LEN]; + char query[QUERY_MAX_LEN]; char* error_message = NULL; if(__init()<0) @@ -201,11 +202,11 @@ int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, cons strncpy(m,mime_type,BUF_MAX_LEN-1); if(uri==NULL) - strncpy(u,"NULL",BUF_MAX_LEN-1); + strncpy(u,"NULL",URI_MAX_LEN-1); else - strncpy(u,uri,BUF_MAX_LEN-1); - - sprintf(query,"insert into appsvc( operation, mime_type, uri, pkg_name) \ + strncpy(u,uri,URI_MAX_LEN-1); + + snprintf(query, QUERY_MAX_LEN, "insert into appsvc( operation, mime_type, uri, pkg_name) \ values('%s','%s','%s','%s')",op,m,u,pkg_name); if (SQLITE_OK != sqlite3_exec(svc_db, query, NULL, NULL, &error_message)) @@ -220,7 +221,7 @@ int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, cons int _svc_db_delete_with_pkgname(const char *pkg_name) { - char query[BUF_MAX_LEN]; + char query[QUERY_MAX_LEN]; char* error_message = NULL; if(pkg_name == NULL) { @@ -231,7 +232,7 @@ int _svc_db_delete_with_pkgname(const char *pkg_name) if(__init()<0) return -1; - snprintf(query, BUF_MAX_LEN, "delete from appsvc where pkg_name = '%s';", pkg_name); + snprintf(query, QUERY_MAX_LEN, "delete from appsvc where pkg_name = '%s';", pkg_name); if (SQLITE_OK != sqlite3_exec(svc_db, query, NULL, NULL, &error_message)) { @@ -246,7 +247,7 @@ int _svc_db_delete_with_pkgname(const char *pkg_name) int _svc_db_is_defapp(const char *pkg_name) { - char query[BUF_MAX_LEN]; + char query[QUERY_MAX_LEN]; sqlite3_stmt *stmt; int cnt = 0; int ret = -1; @@ -259,7 +260,7 @@ int _svc_db_is_defapp(const char *pkg_name) if(__init()<0) return 0; - snprintf(query, BUF_MAX_LEN, + 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); @@ -283,8 +284,8 @@ int _svc_db_is_defapp(const char *pkg_name) char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri) { char m[BUF_MAX_LEN]; - char u[BUF_MAX_LEN]; - char query[BUF_MAX_LEN]; + char u[URI_MAX_LEN]; + char query[QUERY_MAX_LEN]; sqlite3_stmt* stmt; int ret; char* pkgname; @@ -298,9 +299,9 @@ char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri) strncpy(m,mime_type,BUF_MAX_LEN-1); if(uri==NULL) - strncpy(u,"NULL",BUF_MAX_LEN-1); + strncpy(u,"NULL",URI_MAX_LEN-1); else - strncpy(u,uri,BUF_MAX_LEN-1); + strncpy(u,uri,URI_MAX_LEN-1); // if(doubt_sql_injection(mime_type)) // return NULL; @@ -309,7 +310,7 @@ char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri) return NULL; - sprintf(query,"select pkg_name from appsvc where operation='%s' and mime_type='%s' and uri='%s'",\ + snprintf(query, QUERY_MAX_LEN, "select pkg_name from appsvc where operation='%s' and mime_type='%s' and uri='%s'",\ op,m,u); _D("query : %s\n",query); @@ -341,7 +342,7 @@ char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri) int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list) { - char query[BUF_MAX_LEN]; + char query[QUERY_MAX_LEN]; sqlite3_stmt* stmt; int ret; GSList *iter = NULL; @@ -352,7 +353,7 @@ int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pk if(__init_app_info_db()<0) return 0; - sprintf(query,"select package from app_info where x_slp_svc='%s|%s|%s' collate appsvc_collation", op,uri,mime); + snprintf(query, QUERY_MAX_LEN, "select package from app_info where x_slp_svc='%s|%s|%s' collate appsvc_collation", op,uri,mime); _D("query : %s\n",query); ret = sqlite3_prepare(app_info_db, query, strlen(query), &stmt, NULL); |