about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-10 16:17:01 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-10 16:17:01 +0100
commit11181100712fc2a1c2f310b4470d752488e8961e (patch)
treecd5b5341d86e48e7df09c6bfc9414dfc296144ca /src/ui
parent83b61e5160b6624eb0b2898c1321d33341e6510c (diff)
downloadprofani-tty-11181100712fc2a1c2f310b4470d752488e8961e.tar.gz
xep-0308: Implement `/correct` to correct the last send message
So far the correction is sent. But the UI in Profanity itself is not
updated.

Also autocompletion for `/correct` with the last sent message is
missing.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c16
-rw-r--r--src/ui/win_types.h3
-rw-r--r--src/ui/window.c4
3 files changed, 23 insertions, 0 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 8faf4934..d7906815 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -56,6 +56,7 @@
 #endif
 
 static void _chatwin_history(ProfChatWin *chatwin, const char *const contact);
+static void _chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message);
 
 ProfChatWin*
 chatwin_new(const char *const barejid)
@@ -323,6 +324,11 @@ 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) {
         win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id);
     } else {
@@ -496,3 +502,13 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact)
         g_slist_free_full(history, free);
     }
 }
+
+static void
+_chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message)
+{
+    free(chatwin->last_message);
+    chatwin->last_message = strdup(message);
+
+    free(chatwin->last_msg_id);
+    chatwin->last_msg_id = strdup(id);
+}
diff --git a/src/ui/win_types.h b/src/ui/win_types.h
index 68ed719e..0a0545bd 100644
--- a/src/ui/win_types.h
+++ b/src/ui/win_types.h
@@ -160,6 +160,9 @@ typedef struct prof_chat_win_t {
     char *enctext;
     char *incoming_char;
     char *outgoing_char;
+    // For LMC
+    char *last_message;
+    char *last_msg_id;
 } ProfChatWin;
 
 typedef struct prof_muc_win_t {
diff --git a/src/ui/window.c b/src/ui/window.c
index 339f4456..c668bd34 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -152,6 +152,8 @@ win_create_chat(const char *const barejid)
     new_win->enctext = NULL;
     new_win->incoming_char = NULL;
     new_win->outgoing_char = NULL;
+    new_win->last_message = NULL;
+    new_win->last_msg_id = NULL;
 
     new_win->memcheck = PROFCHATWIN_MEMCHECK;
 
@@ -488,6 +490,8 @@ win_free(ProfWin* window)
         free(chatwin->enctext);
         free(chatwin->incoming_char);
         free(chatwin->outgoing_char);
+        free(chatwin->last_message);
+        free(chatwin->last_msg_id);
         chat_state_free(chatwin->state);
         break;
     }