Fix bug about resolving appid 95/116195/1
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 23 Feb 2017 07:48:49 +0000 (16:48 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 23 Feb 2017 09:14:41 +0000 (01:14 -0800)
- uris having the same scheme wasn't be saved as scheme type in appsvc db when
  setting default apps

Change-Id: If8b97be4b0a72039a38c19bb4690f7ba4cc9353e
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
(cherry picked from commit 412e2ecac2b3356c632e3e3d5afae3078e6c890f)

src/service.c

index a75c1ab..e0b01d2 100755 (executable)
@@ -834,7 +834,6 @@ API int aul_svc_run_service_for_uid(bundle *b, int request_code,
 
        GSList *pkg_list = NULL;
        char *query = NULL;
-       char *query2 = NULL;
        gchar *checksum;
 
        if (b == NULL) {
@@ -911,26 +910,9 @@ API int aul_svc_run_service_for_uid(bundle *b, int request_code,
                goto end;
        }
 
-       query2 = __make_query_with_collation(info.op, info.uri,
-                       info.mime, info.m_type, info.s_type);
-       if (info.uri_r_info) {
-               query = __make_query(query, info.op, info.uri_r_info,
-                       info.mime, info.m_type, info.s_type);
-       }
-
-       query = __make_query(query, info.op, info.scheme,
-               info.mime, info.m_type, info.s_type);
-
-       query = __make_query(query, info.op, "*",
-               info.mime, info.m_type, info.s_type);
-
-       if (info.scheme && (strcmp(info.scheme, "file") == 0)
-               && info.mime && (strcmp(info.mime, "NULL") != 0)) {
-               query = __make_query(query, info.op, "NULL",
+       query = __make_query_with_collation(info.op, info.uri,
                        info.mime, info.m_type, info.s_type);
-       }
 
-       query = _svc_db_query_builder_or(query2, query);
        query = _svc_db_query_builder_build(query);
        _svc_db_exec_query(query, &pkg_list, uid);
        if (query) {
@@ -938,46 +920,15 @@ API int aul_svc_run_service_for_uid(bundle *b, int request_code,
                query = NULL;
        }
 
-       if (info.category)
-               __get_list_with_category(info.category, &pkg_list, uid);
-
-       __get_list_with_submode(info.op, info.win_id, &pkg_list, uid);
-
        pkg_count = g_slist_length(pkg_list);
-       _D("pkg_count : %d", pkg_count);
-
-       if (pkg_count == 1) {
-               pkgname = (char *)pkg_list->data;
-               if (pkgname != NULL) {
-                       __put_cache(checksum, pkgname, uid);
-                       ret = __run_svc_with_pkgname(pkgname, b, request_code,
-                                       cbfunc, data, uid);
-                       goto end;
-               }
-       } else if (pkg_count > 1) {
-               bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri);
-               __put_cache(checksum, APP_SELECTOR, uid);
-               ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
-                               cbfunc, data, uid);
-               goto end;
-       }
-       __free_pkg_list(pkg_list);
-       pkg_list = NULL;
-
-       /*scheme & host*/
-       if (info.uri_r_info) {
-               pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri_r_info, uid);
-
-               if (pkgname != NULL) {
-                       __put_cache(checksum, pkgname, uid);
-                       ret = __run_svc_with_pkgname(pkgname, b, request_code,
-                                       cbfunc, data, uid);
-                       free(pkgname);
-                       goto end;
+       if (pkg_count > 0) {
+               __free_pkg_list(pkg_list);
+               pkg_list = NULL;
+               if (info.uri_r_info) {
+                       query = __make_query(query, info.op, info.uri_r_info,
+                               info.mime, info.m_type, info.s_type);
                }
 
-               query2 = __make_query(query, info.op, info.uri_r_info,
-                       info.mime, info.m_type, info.s_type);
                query = __make_query(query, info.op, info.scheme,
                        info.mime, info.m_type, info.s_type);
 
@@ -990,7 +941,6 @@ API int aul_svc_run_service_for_uid(bundle *b, int request_code,
                                info.mime, info.m_type, info.s_type);
                }
 
-               query = _svc_db_query_builder_or(query2, query);
                query = _svc_db_query_builder_build(query);
                _svc_db_exec_query(query, &pkg_list, uid);
                if (query) {
@@ -1015,17 +965,84 @@ API int aul_svc_run_service_for_uid(bundle *b, int request_code,
                                goto end;
                        }
                } else if (pkg_count > 1) {
-                       bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri_r_info);
-                       __put_cache(checksum, APP_SELECTOR, uid);
+                       bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri);
                        ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
                                        cbfunc, data, uid);
                        goto end;
                }
-
                __free_pkg_list(pkg_list);
                pkg_list = NULL;
        }
 
+       /*scheme & host*/
+       if (info.uri_r_info) {
+               pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri_r_info, uid);
+
+               if (pkgname != NULL) {
+                       __put_cache(checksum, pkgname, uid);
+                       ret = __run_svc_with_pkgname(pkgname, b, request_code,
+                                       cbfunc, data, uid);
+                       free(pkgname);
+                       goto end;
+               }
+
+               query = __make_query(query, info.op, info.uri_r_info,
+                       info.mime, info.m_type, info.s_type);
+               query = _svc_db_query_builder_build(query);
+               _svc_db_exec_query(query, &pkg_list, uid);
+               if (query) {
+                       free(query);
+                       query = NULL;
+               }
+
+               pkg_count = g_slist_length(pkg_list);
+               if (pkg_count > 0) {
+                       __free_pkg_list(pkg_list);
+                       pkg_list = NULL;
+                       query = __make_query(query, info.op, "*",
+                       info.mime, info.m_type, info.s_type);
+
+                       if (info.scheme && (strcmp(info.scheme, "file") == 0)
+                               && info.mime && (strcmp(info.mime, "NULL") != 0)) {
+                               query = __make_query(query, info.op, "NULL",
+                                       info.mime, info.m_type, info.s_type);
+                       }
+
+                       query = _svc_db_query_builder_build(query);
+                       _svc_db_exec_query(query, &pkg_list, uid);
+                       if (query) {
+                               free(query);
+                               query = NULL;
+                       }
+
+                       if (info.category)
+                               __get_list_with_category(info.category, &pkg_list, uid);
+
+                       __get_list_with_submode(info.op, info.win_id, &pkg_list, uid);
+
+                       pkg_count = g_slist_length(pkg_list);
+                       _D("pkg_count : %d", pkg_count);
+
+                       if (pkg_count == 1) {
+                               pkgname = (char *)pkg_list->data;
+                               if (pkgname != NULL) {
+                                       __put_cache(checksum, pkgname, uid);
+                                       ret = __run_svc_with_pkgname(pkgname, b, request_code,
+                                                       cbfunc, data, uid);
+                                       goto end;
+                               }
+                       } else if (pkg_count > 1) {
+                               bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri_r_info);
+                               ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
+                                       cbfunc, data, uid);
+                               goto end;
+                       }
+
+                       __free_pkg_list(pkg_list);
+                       pkg_list = NULL;
+               }
+       }
+
        /*scheme*/
        pkgname = _svc_db_get_app(info.op, info.origin_mime, info.scheme, uid);
 
@@ -1079,7 +1096,6 @@ API int aul_svc_run_service_for_uid(bundle *b, int request_code,
                return AUL_SVC_RET_ENOMATCH;
        } else {
                bundle_add(b, AUL_SVC_K_URI_R_INFO, info.scheme);
-               __put_cache(checksum, APP_SELECTOR, uid);
                ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
                                cbfunc, data, uid);
        }