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
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);
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)
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;
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;
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);
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;
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));