about summary refs log tree commit diff stats
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-06-17 06:23:40 +0200
committerPaul Fariello <paul@fariello.eu>2019-06-20 14:30:42 +0200
commit44d16e91411da44a945b0ac44c0253c1dac5e5f3 (patch)
tree7a21bb18db2b611932a3a5c8e6efdb1ae460294e /src/ui/window.c
parent3bb3cc625d1714fd5e81ef0adba61a5172c3212d (diff)
downloadprofani-tty-44d16e91411da44a945b0ac44c0253c1dac5e5f3.tar.gz
Add prof_message_t to wrap all message attributes
Probably missing copy of body to plain in carbon and privmessage.
Only covers the incoming message path because goal is OMEMO decryption
of untrusted message.
Cover some of the log functions but not all.
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 90508917..d4bd3241 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1044,14 +1044,13 @@ win_show_status_string(ProfWin *window, const char *const from,
 }
 
 void
-win_print_incoming(ProfWin *window, GDateTime *timestamp,
-    const char *const from, const char *const message, prof_enc_t enc_mode)
+win_print_incoming(ProfWin *window, const char *const from, prof_message_t *message)
 {
     char enc_char = '-';
     int flags = NO_ME;
 
-    if (!trusted) {
-        flags != NO_TRUST;
+    if (!message->trusted) {
+        flags |= NO_TRUST;
     }
 
     switch (window->type)
@@ -1061,18 +1060,18 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp,
             ProfChatWin *chatwin = (ProfChatWin*)window;
             if (chatwin->incoming_char) {
                 enc_char = chatwin->incoming_char[0];
-            } else if (enc_mode == PROF_MSG_OTR) {
+            } else if (message->enc == PROF_MSG_ENC_OTR) {
                 enc_char = prefs_get_otr_char();
-            } else if (enc_mode == PROF_MSG_PGP) {
+            } else if (message->enc == PROF_MSG_ENC_PGP) {
                 enc_char = prefs_get_pgp_char();
-            } else if (enc_mode == PROF_MSG_OMEMO) {
+            } else if (message->enc == PROF_MSG_ENC_OMEMO) {
                 enc_char = prefs_get_omemo_char();
             }
-            _win_printf(window, enc_char, 0, timestamp, flags, THEME_TEXT_THEM, from, "%s", message);
+            _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, from, "%s", message->plain);
             break;
         }
         case WIN_PRIVATE:
-            _win_printf(window, '-', 0, timestamp, flags, THEME_TEXT_THEM, from, "%s", message);
+            _win_printf(window, '-', 0, message->timestamp, flags, THEME_TEXT_THEM, from, "%s", message->plain);
             break;
         default:
             assert(FALSE);
@@ -1081,13 +1080,13 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp,
 }
 
 void
-win_print_them(ProfWin *window, theme_item_t theme_item, char ch, const char *const them)
+win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags, const char *const them)
 {
-    _win_printf(window, ch, 0, NULL, NO_ME | NO_EOL, theme_item, them, "");
+    _win_printf(window, ch, 0, NULL, flags | NO_ME | NO_EOL, theme_item, them, "");
 }
 
 void
-win_println_them_message(ProfWin *window, char ch, const char *const them, const char *const message, ...)
+win_println_them_message(ProfWin *window, char ch, int flags, const char *const them, const char *const message, ...)
 {
     GDateTime *timestamp = g_date_time_new_now_local();
 
@@ -1096,9 +1095,9 @@ win_println_them_message(ProfWin *window, char ch, const char *const them, const
     GString *fmt_msg = g_string_new(NULL);
     g_string_vprintf(fmt_msg, message, arg);
 
-    buffer_append(window->layout->buffer, ch, 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL);
+    buffer_append(window->layout->buffer, ch, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL);
 
-    _win_print(window, ch, 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL);
+    _win_print(window, ch, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL);
     inp_nonblocking(TRUE);
     g_date_time_unref(timestamp);