From 3a80dfdcb0dfd7bbafb98ab3329e935e6270c9ef Mon Sep 17 00:00:00 2001 From: Daehyeon Jung Date: Mon, 2 May 2016 20:41:16 +0900 Subject: [PATCH] Fix appinfo filter for component type Change-Id: I49a6cb8854cbc74d2d38c6edb18268e41bd6b705 --- include/pkgmgrinfo_type.h | 10 ---------- src/pkgmgrinfo_appinfo.c | 35 ++++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/include/pkgmgrinfo_type.h b/include/pkgmgrinfo_type.h index 433b3c3..1e1591c 100644 --- a/include/pkgmgrinfo_type.h +++ b/include/pkgmgrinfo_type.h @@ -107,16 +107,6 @@ enum { */ #define PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL "LOCATION_EXTERNAL" -/** - * @brief Value to be used when filtering based on app-component - */ -#define PMINFO_APPINFO_UI_APP "UI_APP" - -/** - * @brief Value to be used when filtering based on app-component - */ -#define PMINFO_APPINFO_SVC_APP "SVC_APP" - typedef enum { PMINFO_HWACCELERATION_NOT_USE_GL = 0, /**< Don't use hardware acceleration*/ PMINFO_HWACCELERATION_USE_GL = 1, /**< Use hardware acceleration*/ diff --git a/src/pkgmgrinfo_appinfo.c b/src/pkgmgrinfo_appinfo.c index 4092952..1c6c2c2 100644 --- a/src/pkgmgrinfo_appinfo.c +++ b/src/pkgmgrinfo_appinfo.c @@ -1369,6 +1369,8 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid, return PMINFO_R_OK; } +static const char *__appcomponent_str(pkgmgrinfo_app_component comp); + API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component, pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid) @@ -1405,16 +1407,7 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, } } - switch (component) { - case PMINFO_UI_APP: - comp_str = PMINFO_APPINFO_UI_APP; - break; - case PMINFO_SVC_APP: - comp_str = PMINFO_APPINFO_SVC_APP; - break; - default: - break; - } + comp_str = __appcomponent_str(component); if (comp_str) { if (pkgmgrinfo_appinfo_filter_add_string(filter, @@ -1768,6 +1761,22 @@ static pkgmgrinfo_app_component __appcomponent_convert(const char *comp) return -1; } +static const char *__appcomponent_str(pkgmgrinfo_app_component comp) +{ + switch (comp) { + case PMINFO_UI_APP: + return "uiapp"; + case PMINFO_SVC_APP: + return "svcapp"; + case PMINFO_WIDGET_APP: + return "widgetapp"; + case PMINFO_WATCH_APP: + return "watchapp"; + default: + return NULL; + } +} + API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component) { pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; @@ -2848,11 +2857,7 @@ API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle, node->prop = prop; switch (prop) { case E_PMINFO_APPINFO_PROP_APP_COMPONENT: - if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0) - val = strndup("uiapp", PKG_STRING_LEN_MAX - 1); - else - val = strndup("svcapp", PKG_STRING_LEN_MAX - 1); - node->value = val; + node->value = strdup(value); link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func); if (link) filter->list = g_slist_delete_link(filter->list, link); -- 2.7.4