diff options
author | seungha.son <seungha.son@samsung.com> | 2016-11-30 18:05:04 +0900 |
---|---|---|
committer | seungha.son <seungha.son@samsung.com> | 2016-11-30 19:32:25 +0900 |
commit | 4e834fcf17d69005828f3aea8f46be55bc337bbe (patch) | |
tree | 16f37ac369fafc9656dcd1c57a70484ddd73bd4f | |
parent | 5eb83544e46b793f7e83bea800764bbed79ee15e (diff) | |
download | notification-4e834fcf17d69005828f3aea8f46be55bc337bbe.tar.gz notification-4e834fcf17d69005828f3aea8f46be55bc337bbe.tar.bz2 notification-4e834fcf17d69005828f3aea8f46be55bc337bbe.zip |
Fix notification translation SMACK issuesubmit/tizen_3.0/20161130.105146submit/tizen_3.0/20161130.105137accepted/tizen/3.0/wearable/20161201.031603accepted/tizen/3.0/tv/20161201.031556accepted/tizen/3.0/mobile/20161201.031536accepted/tizen/3.0/ivi/20161201.031606accepted/tizen/3.0/common/20161201.135151
Signed-off-by: seungha.son <seungha.son@samsung.com>
Change-Id: I15f700b2c80d487da509431897847b7ec52fcb95
-rw-r--r-- | include/notification_private.h | 2 | ||||
-rwxr-xr-x | src/notification.c | 34 | ||||
-rwxr-xr-x | src/notification_internal.c | 4 | ||||
-rwxr-xr-x | src/notification_ipc.c | 2 |
4 files changed, 28 insertions, 14 deletions
diff --git a/include/notification_private.h b/include/notification_private.h index 86866b4..06eca17 100644 --- a/include/notification_private.h +++ b/include/notification_private.h @@ -97,6 +97,7 @@ struct _notification { int timeout; int text_input_max_length; bool event_flag; + bool is_translation; uid_t uid; }; @@ -158,6 +159,7 @@ typedef enum notification_data_type { NOTIFICATION_DATA_TYPE_TIMEOUT, NOTIFICATION_DATA_TYPE_TEXT_INPUT_MAX_LENGTH, NOTIFICATION_DATA_TYPE_EVENT_FLAG, + NOTIFICATION_DATA_TYPE_TRANSLATION, NOTIFICATION_DATA_TYPE_UID, } notification_data_type_e; diff --git a/src/notification.c b/src/notification.c index c8f950c..d3a7735 100755 --- a/src/notification.c +++ b/src/notification.c @@ -462,21 +462,24 @@ EXPORT_API int notification_get_text(notification_h noti, snprintf(buf_key, sizeof(buf_key), "%d", type); bundle_get_str(b, buf_key, &ret_val); - if (ret_val != NULL && noti->domain != NULL - && noti->dir != NULL) { - /* Get application string */ - bindtextdomain(noti->domain, noti->dir); - get_str = dgettext(noti->domain, ret_val); - if (get_str == ret_val) /* not found */ - get_str = NULL; - } else if (ret_val != NULL) { - /* Get system string */ - get_str = dgettext("sys_string", ret_val); - if (get_str == ret_val) /* not found */ + if (noti->is_translation == false) { + if (ret_val != NULL && noti->domain != NULL + && noti->dir != NULL) { + /* Get application string */ + bindtextdomain(noti->domain, noti->dir); + + get_str = dgettext(noti->domain, ret_val); + if (get_str == ret_val) /* not found */ + get_str = NULL; + } else if (ret_val != NULL) { + /* Get system string */ + get_str = dgettext("sys_string", ret_val); + if (get_str == ret_val) /* not found */ + get_str = NULL; + } else { get_str = NULL; - } else { - get_str = NULL; + } } } @@ -505,7 +508,7 @@ EXPORT_API int notification_get_text(notification_h noti, noti->num_format_args = atoi(ret_val); } - if (noti->num_format_args == 0) { + if (noti->num_format_args == 0 || noti->is_translation == true) { *text = (char *)get_str; } else { /* Check first variable is count, LEFT pos */ @@ -1436,6 +1439,7 @@ static notification_h _notification_create(notification_type_e type) noti->ongoing_value_type = NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT; noti->timeout = 0; noti->event_flag = false; + noti->is_translation = false; if (getuid() >= REGULAR_UID_MIN) { noti->caller_pkgname = notification_get_pkgname_by_pid(); @@ -1654,6 +1658,8 @@ EXPORT_API int notification_clone(notification_h noti, notification_h *clone) new_noti->temp_title = NULL; new_noti->temp_content = NULL; + new_noti->is_translation = noti->is_translation; + *clone = new_noti; return NOTIFICATION_ERROR_NONE; diff --git a/src/notification_internal.c b/src/notification_internal.c index 298a097..b02b501 100755 --- a/src/notification_internal.c +++ b/src/notification_internal.c @@ -447,6 +447,8 @@ EXPORT_API int notification_translate_localized_text(notification_h noti) bundle *b; notification_text_type_e type = NOTIFICATION_TEXT_TYPE_TITLE; + noti->is_translation = false; + for (; type < NOTIFICATION_TEXT_TYPE_MAX; type++) { ret = notification_get_text(noti, type, &ret_text); if (ret == NOTIFICATION_ERROR_NONE && ret_text) { @@ -474,6 +476,8 @@ EXPORT_API int notification_translate_localized_text(notification_h noti) } } + noti->is_translation = true; + return ret; } diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 6c5fb5b..045fdd0 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -1830,6 +1830,7 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TIMEOUT, g_variant_new_int32(noti->timeout)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TEXT_INPUT_MAX_LENGTH, g_variant_new_int32(noti->text_input_max_length)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_EVENT_FLAG, g_variant_new_int32(noti->event_flag)); + g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TRANSLATION, g_variant_new_int32(noti->is_translation)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_UID, g_variant_new_int32(noti->uid)); result_body = g_variant_builder_end(&builder); @@ -1985,6 +1986,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti, _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TIMEOUT, "i", ¬i->timeout); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TEXT_INPUT_MAX_LENGTH, "i", ¬i->text_input_max_length); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_EVENT_FLAG, "i", ¬i->event_flag); + _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TRANSLATION, "i", ¬i->is_translation); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", ¬i->uid); noti->caller_pkgname = _dup_string(caller_pkgname); |