From 9b3593bdf9e00bb042de80f250899d201eccb091 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 13 Feb 2020 12:24:12 +0100 Subject: xep-0308: enable correction in outgoing messages with delivery receipts --- src/ui/chatwin.c | 3 +-- src/ui/window.c | 12 ++++++++---- src/ui/window.h | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/ui') diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index bb651e5f..859921b9 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -326,8 +326,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, } if (request_receipt && id) { - //TODO: replace_id and id - win_print_outgoing_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id); + win_print_outgoing_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id, replace_id); } else { win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, "%s", message); } diff --git a/src/ui/window.c b/src/ui/window.c index 4d369c3a..4f6ceb2e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1381,19 +1381,23 @@ win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *con void win_print_http_upload(ProfWin *window, const char *const message, char *url) { - win_print_outgoing_with_receipt(window, '!', NULL, message, url); + win_print_outgoing_with_receipt(window, '!', NULL, message, url, NULL); } void -win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id) +win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id) { GDateTime *time = g_date_time_new_now_local(); DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t)); receipt->received = FALSE; - buffer_append(window->layout->buffer, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt, id); - _win_print_internal(window, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); + if (replace_id) { + _win_correct(window, message, id, replace_id); + } else { + buffer_append(window->layout->buffer, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt, id); + _win_print_internal(window, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); + } // TODO: cross-reference.. this should be replaced by a real event-based system inp_nonblocking(TRUE); diff --git a/src/ui/window.h b/src/ui/window.h index 8bec554d..2bd11621 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -72,8 +72,7 @@ void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const void win_print_http_upload(ProfWin *window, const char *const message, char *url); -void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, - char *id); +void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id); void win_newline(ProfWin *window); void win_redraw(ProfWin *window); -- cgit 1.4.1-2-gfad0