summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorKyuho Jo <kyuho.jo@samsung.com>2016-06-01 13:53:44 +0900
committerKyuho Jo <kyuho.jo@samsung.com>2016-06-01 14:04:39 +0900
commit02c513f007bb20edcc88199d3e4e13fb058d4c76 (patch)
treec4f1f5701fc995c6705004cdd4bb368434ac7ede /src/util
parentcf2ddf69a4487f2c0f9590add9dca90c20e1d6a5 (diff)
downloadair_mediahub-02c513f007bb20edcc88199d3e4e13fb058d4c76.tar.gz
air_mediahub-02c513f007bb20edcc88199d3e4e13fb058d4c76.tar.bz2
air_mediahub-02c513f007bb20edcc88199d3e4e13fb058d4c76.zip
Changes for supporting myfiles
1. Accept requests for opening media files from myfiles. 2. Place base-i18n with ICU library. 3. maps-service can be removed from dependencies. Change-Id: I444f03761f59ffca06da3129a4ebb7853c986b92 Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/util/util.c b/src/util/util.c
index cb84c9e..5c0f282 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -19,6 +19,7 @@
#include <app_control.h>
#include <app_debug.h>
#include <app_contents.h>
+#include <unicode/ustring.h>
#include "define.h"
#include "util/util.h"
@@ -456,42 +457,64 @@ Elm_Image_Orient util_get_orient(media_content_orientation_e orient)
return o;
}
-i18n_uchar* util_convert_to_UTF16_string(const char *source_string)
+UChar* util_convert_to_UTF16_string(const char *source_string)
{
int buffer_length = 0;
- i18n_error_code_e error_from_i18n;
- i18n_uchar *converted_string = NULL;
+ UErrorCode error_from_icu = 0;
+ 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));
+ u_strFromUTF8(NULL, 0, &buffer_length, source_string, -1, &error_from_icu);
+ if (buffer_length == 0) {
+ _ERR("error form icu[%d][%s]", error_from_icu, u_errorName(error_from_icu));
+ goto OUT;
+ }
+ /* NOTE:
+ * Calling u_strFromUTF8 with 0 capacity always causes U_BUFFER_OVERFLOW_ERROR.
+ * When u_strFromUTF8 is succeeded, u_strFromUTF8 doesn't change error_from_icu.
+ * It means error_from_icu have U_BUFFER_OVERFLOW_ERROR even though there is no problem.
+ * So, error_from_icu should be reset as U_ZERO_ERROR here*/
+ error_from_icu = U_ZERO_ERROR;
+
+ converted_string = malloc((buffer_length + 2) * sizeof(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);
+ u_strFromUTF8(converted_string, buffer_length + 1, &buffer_length, source_string, -1, &error_from_icu);
+ if (U_FAILURE(error_from_icu)) {
+ _ERR("error form icu[%d][%s]", error_from_icu, u_errorName(error_from_icu));
free(converted_string);
+ converted_string = NULL;
goto OUT;
}
- converted_string[buffer_length] = (i18n_uchar)0;
+
+ converted_string[buffer_length] = (UChar)0;
OUT:
return converted_string;
}
-char* util_convert_to_UTF8_string(i18n_uchar *sourct_string)
+char* util_convert_to_UTF8_string(UChar *source_string)
{
int buffer_length = 0;
- i18n_error_code_e error_from_i18n;
+ UErrorCode error_from_icu;
char *converted_string = NULL;
- i18n_ustring_to_UTF8(NULL, 0, &buffer_length, sourct_string, -1, &error_from_i18n);
+ u_strToUTF8(NULL, 0, &buffer_length, source_string, -1, &error_from_icu);
+ if (buffer_length == 0) {
+ _ERR("error form icu[%d][%s]", error_from_icu, u_errorName(error_from_icu));
+ goto OUT;
+ }
+ /* NOTE:
+ * Calling u_strToUTF8 with 0 capacity always causes U_BUFFER_OVERFLOW_ERROR.
+ * When u_strFromUTF8 is succeeded, u_strFromUTF8 doesn't change error_from_icu.
+ * It means error_from_icu have U_BUFFER_OVERFLOW_ERROR even though there is no problem.
+ * So, error_from_icu should be reset as U_ZERO_ERROR here */
+ error_from_icu = U_ZERO_ERROR;
converted_string = malloc((buffer_length + 2) * sizeof(char));
if (converted_string == NULL) {
@@ -500,13 +523,14 @@ char* util_convert_to_UTF8_string(i18n_uchar *sourct_string)
}
/* 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);
+ u_strToUTF8(converted_string, buffer_length + 1, &buffer_length, source_string, -1, &error_from_icu);
+ if (U_FAILURE(error_from_icu)) {
+ _ERR("error form icu[%d][%s]", error_from_icu, u_errorName(error_from_icu));
free(converted_string);
converted_string = NULL;
goto OUT;
}
+
converted_string[buffer_length] = '\0';
OUT: