summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2016-05-02 15:09:31 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2016-05-03 10:42:31 +0900
commitf0a8fb9006ef9e623e3fd621eba3714cc5eeeaa4 (patch)
tree8545cbfb54f47465cd04cf5a086e130ae3578c63
parent6ac04adac33123d8da12ec10b9b48900fb59a59f (diff)
downloadnotification-f0a8fb9006ef9e623e3fd621eba3714cc5eeeaa4.tar.gz
notification-f0a8fb9006ef9e623e3fd621eba3714cc5eeeaa4.tar.bz2
notification-f0a8fb9006ef9e623e3fd621eba3714cc5eeeaa4.zip
Change-Id: Icd05fb258df7598f52c2e61b619f38404fb4b78f Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rw-r--r--include/notification_internal.h10
-rwxr-xr-xinclude/notification_ipc.h2
-rwxr-xr-xsrc/notification_internal.c41
-rwxr-xr-xsrc/notification_ipc.c11
4 files changed, 58 insertions, 6 deletions
diff --git a/include/notification_internal.h b/include/notification_internal.h
index c63f8b7..e16e443 100644
--- a/include/notification_internal.h
+++ b/include/notification_internal.h
@@ -703,10 +703,18 @@ int notification_register_detailed_changed_cb(
int notification_unregister_detailed_changed_cb(
void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
void *user_data);
+
/**
- * @}
+ * @brief This function translate localized texts
+ * @param[in] noti The notification handle that is created by notification_create()
+ * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
+ * @see notification_create()
*/
+int notification_translate_localized_text(notification_h noti);
+/**
+ * @}
+ */
#ifdef __cplusplus
}
#endif
diff --git a/include/notification_ipc.h b/include/notification_ipc.h
index fc31c04..1451a70 100755
--- a/include/notification_ipc.h
+++ b/include/notification_ipc.h
@@ -27,7 +27,7 @@
extern "C" {
#endif
-GVariant *notification_ipc_make_gvariant_from_noti(notification_h noti);
+GVariant *notification_ipc_make_gvariant_from_noti(notification_h noti, bool translate);
int notification_ipc_make_noti_from_gvariant(notification_h noti,
GVariant *variant);
diff --git a/src/notification_internal.c b/src/notification_internal.c
index a519d28..f29e618 100755
--- a/src/notification_internal.c
+++ b/src/notification_internal.c
@@ -350,6 +350,47 @@ EXPORT_API int notification_get_icon(notification_h noti,
return ret_err;
}
+EXPORT_API int notification_translate_localized_text(notification_h noti)
+{
+ int noti_err = NOTIFICATION_ERROR_NONE;
+ char *ret_text = NULL;
+ char buf_key[32];
+ char *bundle_val = NULL;
+ char *new_text;
+ bundle *b;
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_TITLE;
+
+ for (; type < NOTIFICATION_TEXT_TYPE_MAX; type++) {
+ noti_err = notification_get_text(noti, type, &ret_text);
+ if (noti_err == NOTIFICATION_ERROR_NONE && ret_text) {
+ b = noti->b_text;
+ if (b == NULL)
+ b = bundle_create();
+
+ new_text = strdup(ret_text);
+
+ snprintf(buf_key, sizeof(buf_key), "%d", type);
+ bundle_get_str(b, buf_key, &bundle_val);
+ if (bundle_val != NULL)
+ bundle_del(b, buf_key);
+
+ bundle_add_str(b, buf_key, new_text);
+ free(new_text);
+ new_text = NULL;
+
+ noti->num_format_args = 0;
+ bundle_val = NULL;
+ }
+ }
+
+ if (noti->b_key) {
+ bundle_free(noti->b_key);
+ noti->b_key = NULL;
+ }
+
+ return noti_err;
+}
+
EXPORT_API int notification_set_title(notification_h noti,
const char *title,
const char *loc_title)
diff --git a/src/notification_ipc.c b/src/notification_ipc.c
index 92f6484..9062ac6 100755
--- a/src/notification_ipc.c
+++ b/src/notification_ipc.c
@@ -669,7 +669,7 @@ int notification_ipc_request_insert(notification_h noti, int *priv_id)
noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
_print_noti(noti);
- body = notification_ipc_make_gvariant_from_noti(noti);
+ body = notification_ipc_make_gvariant_from_noti(noti, false);
if (body == NULL) {
NOTIFICATION_ERR("cannot make gvariant");
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
@@ -708,7 +708,7 @@ int notification_ipc_request_update(notification_h noti)
return result;
}
- body = notification_ipc_make_gvariant_from_noti(noti);
+ body = notification_ipc_make_gvariant_from_noti(noti, false);
if (body == NULL) {
NOTIFICATION_ERR("cannot make gvariant");
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
@@ -747,7 +747,7 @@ int notification_ipc_request_update_async(notification_h noti,
cb_item->result_cb = result_cb;
cb_item->data = user_data;
- body = notification_ipc_make_gvariant_from_noti(noti);
+ body = notification_ipc_make_gvariant_from_noti(noti, false);
if (body == NULL) {
NOTIFICATION_ERR("cannot make gvariant");
free(cb_item);
@@ -1234,7 +1234,7 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
return result;
}
-EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h noti)
+EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h noti, bool translate)
{
NOTIFICATION_DBG("make gvariant from noti");
int i = 0;
@@ -1254,6 +1254,9 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
GVariant *result_body = NULL;
GVariantBuilder builder;
+ if (translate)
+ notification_translate_localized_text(noti);
+
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{iv}"));
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_NOTI_TYPE, g_variant_new_int32(noti->type));
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_LAYOUT, g_variant_new_int32(noti->layout));