Fix pkgmgrinfo_appinfo_get_label 90/137090/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 4 Jul 2017 09:59:44 +0000 (18:59 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 4 Jul 2017 10:32:51 +0000 (19:32 +0900)
- Search same localed label text.
- Return empty string if not found.

Change-Id: Ib039d30c4ce605cccd4581645cafc98945a59aed
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/pkgmgrinfo_appinfo.c

index e07bf52..ed529f7 100644 (file)
@@ -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;
 }