Fix notification translation SMACK issue 12/101112/2 accepted/tizen/3.0/common/20161201.135151 accepted/tizen/3.0/ivi/20161201.031606 accepted/tizen/3.0/mobile/20161201.031536 accepted/tizen/3.0/tv/20161201.031556 accepted/tizen/3.0/wearable/20161201.031603 submit/tizen_3.0/20161130.105137 submit/tizen_3.0/20161130.105146
authorseungha.son <seungha.son@samsung.com>
Wed, 30 Nov 2016 09:05:04 +0000 (18:05 +0900)
committerseungha.son <seungha.son@samsung.com>
Wed, 30 Nov 2016 10:32:25 +0000 (19:32 +0900)
Signed-off-by: seungha.son <seungha.son@samsung.com>
Change-Id: I15f700b2c80d487da509431897847b7ec52fcb95

include/notification_private.h
src/notification.c
src/notification_internal.c
src/notification_ipc.c

index 86866b4ac81341a6220ae8265d20a0a43d38e4a7..06eca1750bf04f2a6471a7f801cf1209794f6b4a 100644 (file)
@@ -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;
 
index c8f950c51864440198e4060d374c53654fe96403..d3a77357245cd4011b0009a40e46629dc9e97185 100755 (executable)
@@ -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;
index 298a0976e3078c81c655b84b59455792e20f4fca..b02b5017799bd35e319627547f019c71cd571e21 100755 (executable)
@@ -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;
 }
 
index 6c5fb5ba3b8605c1a74ce1c01835eb323d19b585..045fdd098b772dbd5af920926c9ff0cec97d7cd1 100755 (executable)
@@ -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", &noti->timeout);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TEXT_INPUT_MAX_LENGTH, "i", &noti->text_input_max_length);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_EVENT_FLAG, "i", &noti->event_flag);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TRANSLATION, "i", &noti->is_translation);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", &noti->uid);
 
        noti->caller_pkgname = _dup_string(caller_pkgname);