Fix widget list duplication check bug 03/139103/3 accepted/tizen/3.0/common/20170719.081640 accepted/tizen/3.0/ivi/20170719.003734 accepted/tizen/3.0/mobile/20170719.003655 accepted/tizen/3.0/tv/20170719.003708 accepted/tizen/3.0/wearable/20170719.003720 submit/tizen_3.0/20170717.101133
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 17 Jul 2017 09:33:40 +0000 (18:33 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Mon, 17 Jul 2017 10:40:46 +0000 (10:40 +0000)
If root user try to get widget list, it returns duplicate widget list

Change-Id: I63197d2ecccf102610e3afd8888d2d823fdc4476
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/widget_service.c

index da15ede..2ebf6df 100644 (file)
@@ -781,7 +781,7 @@ EAPI int widget_service_get_widget_list(widget_list_cb cb, void *data)
                return WIDGET_ERROR_PERMISSION_DENIED;
 
        ret = _get_widget_list(NULL, getuid(), &list);
-       if (ret == WIDGET_ERROR_NONE)
+       if (ret == WIDGET_ERROR_NONE && !_is_global(getuid()))
                ret = _get_widget_list(NULL, GLOBALAPP_USER, &list);
 
        for (tmp = list; tmp; tmp = tmp->next) {
@@ -823,7 +823,7 @@ EAPI int widget_service_get_widget_list_by_pkgid(const char *pkgid,
                return WIDGET_ERROR_PERMISSION_DENIED;
 
        ret = _get_widget_list(pkgid, getuid(), &list);
-       if (ret == WIDGET_ERROR_NONE)
+       if (ret == WIDGET_ERROR_NONE && !_is_global(getuid()))
                ret = _get_widget_list(pkgid, GLOBALAPP_USER, &list);
 
        for (tmp = list; tmp; tmp = tmp->next) {
@@ -931,7 +931,8 @@ EAPI char *widget_service_get_main_app_id(const char *widget_id)
        }
 
        appid = _get_main_app_id(widget_id, getuid());
-       if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                appid = _get_main_app_id(widget_id, GLOBALAPP_USER);
 
        return appid;
@@ -961,7 +962,7 @@ EAPI int widget_service_get_supported_size_types(const char *widget_id,
 
        ret = _get_widget_supported_info(widget_id, getuid(), cnt,
                        &width, &height, types);
-       if (ret == WIDGET_ERROR_NOT_EXIST)
+       if (ret == WIDGET_ERROR_NOT_EXIST && !_is_global(getuid()))
                ret = _get_widget_supported_info(widget_id, GLOBALAPP_USER,
                                cnt, &width, &height, types);
 
@@ -1050,7 +1051,8 @@ EAPI char *widget_service_get_app_id_of_setup_app(const char *widget_id)
        }
 
        appid = _get_app_id_of_setup_app(widget_id, getuid());
-       if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (appid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                appid = _get_app_id_of_setup_app(widget_id, GLOBALAPP_USER);
 
        return appid;
@@ -1125,7 +1127,8 @@ EAPI int widget_service_get_nodisplay(const char *widget_id)
        }
 
        nodisplay = _get_nodisplay(widget_id, getuid());
-       if (get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                nodisplay = _get_nodisplay(widget_id, GLOBALAPP_USER);
 
        return nodisplay;
@@ -1326,7 +1329,8 @@ EAPI char *widget_service_get_preview_image_path(const char *widget_id,
 
        _convert_type_to_support_size_ratio(size_type, &w, &h);
        path = _get_preview_image_path(widget_id, w, h, getuid());
-       if (path == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (path == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                path = _get_preview_image_path(widget_id, w, h, GLOBALAPP_USER);
 
        if (path == NULL) {
@@ -1501,11 +1505,13 @@ EAPI char *widget_service_get_icon(const char *pkgid, const char *lang)
        }
 
        widget_id = _get_main_widget_id(pkgid, getuid());
-       if (widget_id == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (widget_id == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                widget_id = _get_main_widget_id(pkgid, GLOBALAPP_USER);
 
        icon = _get_icon(widget_id, lang, getuid());
-       if (icon == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (icon == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                icon = _get_icon(widget_id, lang, GLOBALAPP_USER);
 
        return icon;
@@ -1631,7 +1637,8 @@ EAPI char *widget_service_get_name(const char *widget_id, const char *lang)
        }
 
        name = _get_name(widget_id, language, getuid());
-       if (name == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (name == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                name = _get_name(widget_id, language, GLOBALAPP_USER);
 
        free(language);
@@ -1658,7 +1665,8 @@ EAPI int widget_service_get_supported_sizes(const char *widget_id, int *cnt,
                return WIDGET_ERROR_PERMISSION_DENIED;
 
        ret = _get_widget_supported_sizes(widget_id, getuid(), cnt, w, h);
-       if (ret == WIDGET_ERROR_NOT_EXIST)
+       if (ret == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                ret = _get_widget_supported_sizes(widget_id, GLOBALAPP_USER,
                                cnt, w, h);
 
@@ -1760,7 +1768,8 @@ static char *__get_widget_main_appid_from_pkgid_or_appid(const char *id)
        }
 
        ret = _get_widget_list(id, getuid(), &widget_list);
-       if (ret != WIDGET_ERROR_NONE || widget_list == NULL)
+       if ((ret != WIDGET_ERROR_NONE || widget_list == NULL)
+                       && !_is_global(getuid()))
                ret = _get_widget_list(id, GLOBALAPP_USER, &widget_list);
 
        if (widget_list == NULL)
@@ -1818,7 +1827,8 @@ EAPI char *widget_service_get_widget_id(const char *appid)
        }
 
        classid = _get_widget_id(appid, getuid());
-       if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                classid = _get_widget_id(appid, GLOBALAPP_USER);
 
        if (classid)
@@ -1833,7 +1843,8 @@ EAPI char *widget_service_get_widget_id(const char *appid)
        }
 
        classid = _get_widget_id(widget_id, getuid());
-       if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (classid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                classid = _get_widget_id(widget_id, GLOBALAPP_USER);
 
        free(widget_id);
@@ -1911,7 +1922,8 @@ EAPI char *widget_service_get_package_id(const char *widget_id)
        }
 
        pkgid = _get_package_id(widget_id, getuid());
-       if (pkgid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST)
+       if (pkgid == NULL && get_last_result() == WIDGET_ERROR_NOT_EXIST
+                       && !_is_global(getuid()))
                pkgid = _get_package_id(widget_id, GLOBALAPP_USER);
 
        return pkgid;
@@ -2215,7 +2227,7 @@ EAPI int widget_service_get_widget_max_count(const char *widget_id)
                return WIDGET_ERROR_PERMISSION_DENIED;
 
        ret = __get_max_instance(widget_id, getuid());
-       if (ret == WIDGET_ERROR_NOT_EXIST)
+       if (ret == WIDGET_ERROR_NOT_EXIST && !_is_global(getuid()))
                ret = __get_max_instance(widget_id, GLOBALAPP_USER);
 
        return ret;