xep-0308: update the UI upon sending a corrected message

So far we don't do this for encrypted messages. Still needs to be done.
And MUC also needs to be done.
This commit is contained in:
Michael Vetter
2020-02-11 15:26:58 +01:00
parent 1118110071
commit b6b7dd5ad4
8 changed files with 37 additions and 24 deletions

View File

@@ -8716,6 +8716,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args)
*/ */
// speciel send with replace tag // speciel send with replace tag
cl_ev_send_msg_correct(chatwin, args[0], FALSE, TRUE); cl_ev_send_msg_correct(chatwin, args[0], FALSE, TRUE);
return TRUE;
} }
win_println(window, THEME_DEFAULT, '!', "Command /correct only valid in regular chat windows."); win_println(window, THEME_DEFAULT, '!', "Command /correct only valid in regular chat windows.");

View File

@@ -159,7 +159,7 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
if (!handled) { if (!handled) {
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id); char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt, replace_id);
free(id); free(id);
} }
} }
@@ -297,19 +297,19 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
if (chatwin->is_omemo) { if (chatwin->is_omemo) {
char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id);
free(id); free(id);
} else if (chatwin->pgp_send) { } else if (chatwin->pgp_send) {
char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt); char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt, replace_id);
free(id); free(id);
} else { } else {
gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt); gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
if (!handled) { if (!handled) {
char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id); char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
chat_log_msg_out(chatwin->barejid, plugin_msg, NULL); chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt); chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt, replace_id);
free(id); free(id);
} }
} }
@@ -395,7 +395,8 @@ cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg, const char *
message_send_private(privwin->fulljid, plugin_msg, oob_url); message_send_private(privwin->fulljid, plugin_msg, oob_url);
chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart); chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart);
privwin_outgoing_msg(privwin, plugin_msg); // TODO replace_id
privwin_outgoing_msg(privwin, NULL, NULL, plugin_msg);
plugins_post_priv_message_send(privwin->fulljid, plugin_msg); plugins_post_priv_message_send(privwin->fulljid, plugin_msg);

View File

@@ -348,7 +348,8 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
if (encrypted) { if (encrypted) {
id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt); id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt);
chat_log_otr_msg_out(chatwin->barejid, message, NULL); chat_log_otr_msg_out(chatwin->barejid, message, NULL);
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt); // TODO replace_id
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt, NULL);
otr_free_message(encrypted); otr_free_message(encrypted);
free(id); free(id);
return TRUE; return TRUE;
@@ -368,7 +369,8 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) { if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
char *otr_tagged_msg = otr_tag_message(message); char *otr_tagged_msg = otr_tag_message(message);
id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt); id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt);
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_PLAIN, request_receipt); //TODO replace_id
chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_PLAIN, request_receipt, NULL);
chat_log_msg_out(chatwin->barejid, message, NULL); chat_log_msg_out(chatwin->barejid, message, NULL);
free(otr_tagged_msg); free(otr_tagged_msg);
free(id); free(id);

View File

@@ -309,7 +309,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr
void void
chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode,
gboolean request_receipt) gboolean request_receipt, const char *const replace_id)
{ {
assert(chatwin != NULL); assert(chatwin != NULL);
@@ -324,16 +324,17 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
enc_char = prefs_get_omemo_char(); enc_char = prefs_get_omemo_char();
} }
if (request_receipt && id) {
//TODO: replace_id and id
win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id);
} else {
win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, "%s", message);
}
// save last id and message for LMC // save last id and message for LMC
if (id) { if (id) {
_chatwin_set_last_message(chatwin, id, message); _chatwin_set_last_message(chatwin, id, message);
} }
if (request_receipt && id) {
win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id);
} else {
win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message);
}
} }
void void
@@ -350,7 +351,8 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message)
ProfWin *window = (ProfWin*)chatwin; ProfWin *window = (ProfWin*)chatwin;
win_print_outgoing(window, enc_char, "%s", message->plain); // TODO id set?
win_print_outgoing(window, enc_char, message->id, message->replace_id, "%s", message->plain);
int num = wins_get_num(window); int num = wins_get_num(window);
status_bar_active(num, WIN_CHAT, chatwin->barejid); status_bar_active(num, WIN_CHAT, chatwin->barejid);
} }

View File

@@ -91,11 +91,11 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message)
} }
void void
privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const id, const char *const replace_id, const char *const message)
{ {
assert(privwin != NULL); assert(privwin != NULL);
win_print_outgoing((ProfWin*)privwin, '-', "%s", message); win_print_outgoing((ProfWin*)privwin, '-', id, replace_id ,"%s", message);
} }
void void

View File

@@ -124,8 +124,7 @@ ProfChatWin* chatwin_new(const char *const barejid);
void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created); void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created);
void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id); void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
void chatwin_recipient_gone(ProfChatWin *chatwin); void chatwin_recipient_gone(ProfChatWin *chatwin);
void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, gboolean request_receipt, const char *const replace_id);
gboolean request_receipt);
void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message); void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message);
void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity); void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status); void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status);
@@ -198,8 +197,9 @@ void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch);
void mucwin_unset_message_char(ProfMucWin *mucwin); void mucwin_unset_message_char(ProfMucWin *mucwin);
// MUC private chat window // MUC private chat window
// TODO repalce_id?
void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message); void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message);
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message); void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const id, const char *const replace_id, const char *const message);
void privwin_message_occupant_offline(ProfPrivateWin *privwin); void privwin_message_occupant_offline(ProfPrivateWin *privwin);
void privwin_message_left_room(ProfPrivateWin *privwin); void privwin_message_left_room(ProfPrivateWin *privwin);

View File

@@ -1183,7 +1183,7 @@ win_println_me_message(ProfWin *window, char ch, const char *const me, const cha
} }
void void
win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...) win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...)
{ {
GDateTime *timestamp = g_date_time_new_now_local(); GDateTime *timestamp = g_date_time_new_now_local();
@@ -1192,9 +1192,16 @@ win_print_outgoing(ProfWin *window, const char ch, const char *const message, ..
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg); g_string_vprintf(fmt_msg, message, arg);
buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL, NULL); if (replace_id) {
win_correct_incoming(window, fmt_msg->str, id, replace_id);
} else {
//TODO: without this it works.
//buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL, id);
//_win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL);
_win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", fmt_msg->str);
}
_win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL);
inp_nonblocking(TRUE); inp_nonblocking(TRUE);
g_date_time_unref(timestamp); g_date_time_unref(timestamp);

View File

@@ -65,7 +65,7 @@ void win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags
void win_println_them_message(ProfWin *window, char ch, int flags, const char *const them, const char *const message, ...); void win_println_them_message(ProfWin *window, char ch, int flags, const char *const them, const char *const message, ...);
void win_println_me_message(ProfWin *window, char ch, const char *const me, const char *const message, ...); void win_println_me_message(ProfWin *window, char ch, const char *const me, const char *const message, ...);
void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...);
void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message); void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message);
void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...); void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...);