From: Sangyoon Jang Date: Tue, 4 Jul 2017 09:59:44 +0000 (+0900) Subject: Fix pkgmgrinfo_appinfo_get_label X-Git-Tag: submit/tizen/20170705.114632~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F137090%2F3;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Fix pkgmgrinfo_appinfo_get_label - Search same localed label text. - Return empty string if not found. Change-Id: Ib039d30c4ce605cccd4581645cafc98945a59aed Signed-off-by: Sangyoon Jang --- diff --git a/src/pkgmgrinfo_appinfo.c b/src/pkgmgrinfo_appinfo.c index e07bf52..ed529f7 100644 --- a/src/pkgmgrinfo_appinfo.c +++ b/src/pkgmgrinfo_appinfo.c @@ -1539,21 +1539,42 @@ API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label) { label_x *ptr; pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + char *lbl = NULL; + const char *locale; + GList *tmp; retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL"); retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); - if (info->app_info == NULL || info->app_info->label == NULL) + if (info->app_info == NULL) return PMINFO_R_ERROR; - ptr = (label_x *)info->app_info->label->data; - if (ptr == NULL) - return PMINFO_R_ERROR; + locale = info->locale; + if (locale == NULL) + locale = DEFAULT_LOCALE; - if (ptr->text == NULL) - return PMINFO_R_ERROR; - else - *label = ptr->text; + for (tmp = info->app_info->label; tmp; tmp = tmp->next) { + ptr = (label_x *)tmp->data; + if (ptr == NULL || strcmp(locale, ptr->lang) != 0) + continue; + lbl = ptr->text; + break; + } + + if (lbl != NULL) { + *label = lbl; + return PMINFO_R_OK; + } + + for (tmp = info->app_info->label; tmp; tmp = tmp->next) { + ptr = (label_x *)tmp->data; + if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0) + continue; + lbl = ptr->text; + break; + } + + *label = lbl ? lbl : ""; return PMINFO_R_OK; }