about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-11 15:26:58 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-11 15:26:58 +0100
commitb6b7dd5ad497a71e250b8b3cef0bb987314b141d (patch)
tree150adcde6b07ad55f6bfb5a9db8db10c239bc6ac /src
parent11181100712fc2a1c2f310b4470d752488e8961e (diff)
downloadprofani-tty-b6b7dd5ad497a71e250b8b3cef0bb987314b141d.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_funcs.c1
-rw-r--r--src/event/client_events.c11
-rw-r--r--src/otr/otr.c6
-rw-r--r--src/ui/chatwin.c18
-rw-r--r--src/ui/privwin.c4
-rw-r--r--src/ui/ui.h6
-rw-r--r--src/ui/window.c13
-rw-r--r--src/ui/window.h2
8 files changed, 37 insertions, 24 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 9620f0d7..08a3554c 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -8716,6 +8716,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args)
         */
         // speciel send with replace tag
         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.");
diff --git a/src/event/client_events.c b/src/event/client_events.c
index 50a46ccc..a9b7b46b 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -159,7 +159,7 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
         if (!handled) {
             char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
             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);
         }
     }
@@ -297,19 +297,19 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
     if (chatwin->is_omemo) {
         char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
         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);
     } else if (chatwin->pgp_send) {
         char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
         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);
     } else {
         gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
         if (!handled) {
             char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt, replace_id);
             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);
         }
     }
@@ -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);
         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);
 
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 40684857..bd88ae0b 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -348,7 +348,8 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
         if (encrypted) {
             id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt);
             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);
             free(id);
             return TRUE;
@@ -368,7 +369,8 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
     if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
         char *otr_tagged_msg = otr_tag_message(message);
         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);
         free(otr_tagged_msg);
         free(id);
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index d7906815..55d20135 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -309,7 +309,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr
 
 void
 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);
 
@@ -324,15 +324,16 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
         enc_char = prefs_get_omemo_char();
     }
 
-    // save last id and message for LMC
-    if (id) {
-        _chatwin_set_last_message(chatwin, id, message);
-    }
-
     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, "%s", message);
+        win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, "%s", message);
+    }
+
+    // save last id and message for LMC
+    if (id) {
+        _chatwin_set_last_message(chatwin, id, message);
     }
 }
 
@@ -350,7 +351,8 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message)
 
     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);
     status_bar_active(num, WIN_CHAT, chatwin->barejid);
 }
diff --git a/src/ui/privwin.c b/src/ui/privwin.c
index 4befc325..9a64cd13 100644
--- a/src/ui/privwin.c
+++ b/src/ui/privwin.c
@@ -91,11 +91,11 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message)
 }
 
 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);
 
-    win_print_outgoing((ProfWin*)privwin, '-', "%s", message);
+    win_print_outgoing((ProfWin*)privwin, '-', id, replace_id ,"%s", message);
 }
 
 void
diff --git a/src/ui/ui.h b/src/ui/ui.h
index e8d42410..6cafd13a 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -124,8 +124,7 @@ ProfChatWin* chatwin_new(const char *const barejid);
 void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created);
 void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
 void chatwin_recipient_gone(ProfChatWin *chatwin);
-void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode,
-    gboolean request_receipt);
+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);
 void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message);
 void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity);
 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);
 
 // MUC private chat window
+// TODO repalce_id?
 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_left_room(ProfPrivateWin *privwin);
diff --git a/src/ui/window.c b/src/ui/window.c
index c668bd34..1218b177 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1183,7 +1183,7 @@ win_println_me_message(ProfWin *window, char ch, const char *const me, const cha
 }
 
 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();
 
@@ -1192,9 +1192,16 @@ win_print_outgoing(ProfWin *window, const char ch, const char *const message, ..
     GString *fmt_msg = g_string_new(NULL);
     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);
     g_date_time_unref(timestamp);
 
diff --git a/src/ui/window.h b/src/ui/window.h
index b1f9a4af..40e58d7a 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -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_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_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...);