summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyuho Jo <kyuho.jo@samsung.com>2016-03-18 11:19:08 (GMT)
committerKyuho Jo <kyuho.jo@samsung.com>2016-03-18 11:24:04 (GMT)
commitff47085ef33f952fde702e8042ca6c5312dc3c9a (patch)
tree1cbe355d726e0456362f75251c08dfaee64c69ac
parent9b3685a0f37595527c34eb518deabb8ed3b90937 (diff)
downloadair_mediahub-ff47085ef33f952fde702e8042ca6c5312dc3c9a.zip
air_mediahub-ff47085ef33f952fde702e8042ca6c5312dc3c9a.tar.gz
air_mediahub-ff47085ef33f952fde702e8042ca6c5312dc3c9a.tar.bz2
Change-Id: I304baabe1063ccb115cf63745451e1c7b94ae135 Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
-rw-r--r--src/data/mediadata.c125
1 files changed, 88 insertions, 37 deletions
diff --git a/src/data/mediadata.c b/src/data/mediadata.c
index 89618b7..d4dcc41 100644
--- a/src/data/mediadata.c
+++ b/src/data/mediadata.c
@@ -142,12 +142,89 @@ static char *_get_date_string(struct tm *tm)
return strdup(buf);
}
+static i18n_uchar* _convert_to_UTF16_string(const char *source_string)
+{
+ int buffer_length = 0;
+ i18n_error_code_e error_from_i18n;
+ i18n_uchar *converted_string = NULL;
+
+ /* Calc buffer size for converted UTF16 string */
+ i18n_ustring_from_UTF8(NULL, 0, &buffer_length, source_string, -1, &error_from_i18n);
+
+ converted_string = malloc((buffer_length + 2) * sizeof(i18n_uchar));
+ if (converted_string == NULL) {
+ _ERR("malloc failed");
+ goto OUT;
+ }
+
+ /* Convert to i18n(UTF16) string */
+ i18n_ustring_from_UTF8(converted_string, buffer_length + 1, &buffer_length, source_string, -1, &error_from_i18n);
+ if (error_from_i18n != I18N_ERROR_NONE) {
+ _ERR("i18n_ustring_from_UTF8 returns [%d]", error_from_i18n);
+ free(converted_string);
+ goto OUT;
+ }
+ converted_string[buffer_length] = (i18n_uchar)0;
+
+OUT:
+
+ return converted_string;
+}
+
+static char* _convert_to_UTF8_string(i18n_uchar *sourct_string)
+{
+ int buffer_length = 0;
+ i18n_error_code_e error_from_i18n;
+ char *converted_string = NULL;
+
+ i18n_ustring_to_UTF8(NULL, 0, &buffer_length, sourct_string, -1, &error_from_i18n);
+
+ converted_string = malloc((buffer_length + 2) * sizeof(char));
+ if (converted_string == NULL) {
+ _ERR("malloc failed");
+ goto OUT;
+ }
+
+ /* Convert to UTF8 */
+ i18n_ustring_to_UTF8(converted_string, buffer_length + 1, &buffer_length, sourct_string, -1, &error_from_i18n);
+ if (error_from_i18n != I18N_ERROR_NONE) {
+ _ERR("i18n_ustring_to_UTF8 returns [%d]", error_from_i18n);
+ free(converted_string);
+ converted_string = NULL;
+ goto OUT;
+ }
+ converted_string[buffer_length] = '\0';
+
+OUT:
+
+ return converted_string;
+}
+
static int _compare_title(struct group_info *gi, app_media_info *info)
{
if (!gi->data || !info->title)
return -1;
- return strncasecmp(gi->data, info->title, 1);
+ int32_t result = -1;
+ i18n_uchar *converted_group_name = NULL;
+ i18n_uchar *converted_media_title = NULL;
+
+ converted_group_name = _convert_to_UTF16_string(gi->data);
+ converted_media_title = _convert_to_UTF16_string(info->title);
+
+ if (converted_group_name && converted_media_title) {
+ result = i18n_ustring_case_compare_n(converted_group_name, converted_media_title, 1, I18N_USTRING_U_FOLD_CASE_DEFAULT);
+ }
+
+ if (converted_group_name) {
+ free(converted_group_name);
+ }
+
+ if (converted_media_title) {
+ free(converted_media_title);
+ }
+
+ return result;
}
static void *_get_data_title(app_media_info *info)
@@ -163,52 +240,26 @@ static char *_get_title(app_media_info *info)
if (!info->title)
return NULL;
- int buffer_length = 0;
- i18n_error_code_e error_from_i18n;
char *result_str = NULL;
- i18n_uchar *converted_str = NULL;
+ i18n_uchar *converted_string = NULL;
i18n_uchar sub_string[10] = { 0, };
- /* Calc buffer size for converted UTF16 string */
- i18n_ustring_from_UTF8(NULL, 0, &buffer_length, info->title, -1, &error_from_i18n);
+ converted_string = _convert_to_UTF16_string(info->title);
- converted_str = malloc((buffer_length + 2) * sizeof(i18n_uchar));
- if (converted_str == NULL) {
- _ERR("malloc failed");
+ if (converted_string == NULL) {
+ _ERR("_convert_to_UTF16_string failed");
goto OUT;
}
- /* Convert to i18n(UTF16) string */
- i18n_ustring_from_UTF8(converted_str, buffer_length + 1, &buffer_length, info->title, -1, &error_from_i18n);
- if (error_from_i18n != I18N_ERROR_NONE) {
- _ERR("i18n_ustring_from_UTF8 returns [%d]", error_from_i18n);
- goto OUT;
- }
- converted_str[buffer_length] = (i18n_uchar)0;
-
/* Get a character (not a byte) from left */
- i18n_ustring_copy_n(sub_string, converted_str, 1);
- i18n_ustring_to_UTF8(NULL, 0, &buffer_length, sub_string, -1, &error_from_i18n);
-
- result_str = malloc((buffer_length + 2) * sizeof(char));
- if (result_str == NULL) {
- _ERR("malloc failed");
- goto OUT;
- }
+ i18n_ustring_copy_n(sub_string, converted_string, 1);
- /* Convert to UTF8 */
- i18n_ustring_to_UTF8(result_str, buffer_length + 1, &buffer_length, sub_string, -1, &error_from_i18n);
- if (error_from_i18n != I18N_ERROR_NONE) {
- _ERR("i18n_ustring_to_UTF8 returns [%d]", error_from_i18n);
- free(result_str);
- result_str = NULL;
- goto OUT;
- }
- result_str[buffer_length] = '\0';
+ result_str = _convert_to_UTF8_string(sub_string);
OUT:
- if (converted_str)
- free(converted_str);
+
+ if (converted_string)
+ free(converted_string);
return result_str;
}
@@ -433,7 +484,7 @@ static int _compare_cb_name(const void *data1, const void *data2)
if (!info1 || !info2 || !info1->display_name || !info2->display_name)
return -1;
- return strcasecmp(info1->display_name, info2->display_name);
+ return strcasecmp(info1->title, info2->title);
}
static int _compare_cb_genre(const void *data1, const void *data2)