about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/chatwin.c3
-rw-r--r--src/ui/mucwin.c17
-rw-r--r--src/ui/window.c28
-rw-r--r--src/ui/window.h2
-rw-r--r--src/xmpp/xmpp.h1
5 files changed, 27 insertions, 24 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 93cc9525..34bf3902 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -486,8 +486,7 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid)
 
         while (curr) {
             ProfMessage *msg = curr->data;
-            // TODO: sender is lost right now
-            win_print_history((ProfWin*)chatwin, msg->timestamp, msg->plain);
+            win_print_history((ProfWin*)chatwin, msg, FALSE);
             curr = g_slist_next(curr);
         }
         chatwin->history_shown = TRUE;
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 79a82a61..620ac704 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -373,22 +373,7 @@ mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message)
     char *muc_history_color = prefs_get_string(PREF_HISTORY_COLOR_MUC);
 
     if (g_strcmp0(muc_history_color, "unanimous") == 0) {
-        GString *line = g_string_new("");
-
-        if (strncmp(message->plain, "/me ", 4) == 0) {
-            g_string_append(line, "*");
-            g_string_append(line, nick);
-            g_string_append(line, " ");
-            g_string_append(line, message->plain + 4);
-        } else {
-            g_string_append(line, nick);
-            g_string_append(line, ": ");
-            g_string_append(line, message->plain);
-        }
-
-        win_print_history(window, message->timestamp, line->str);
-
-        g_string_free(line, TRUE);
+        win_print_history(window, message, TRUE);
     } else {
         char *mynick = muc_nick(mucwin->roomjid);
         GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick);
diff --git a/src/ui/window.c b/src/ui/window.c
index fdf5d3f9..21f0f724 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1218,15 +1218,33 @@ win_print_outgoing(ProfWin *window, const char *show_char, const char *const id,
 }
 
 void
-win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message)
+win_print_history(ProfWin *window, const ProfMessage *const message, gboolean is_muc)
 {
-    g_date_time_ref(timestamp);
+    g_date_time_ref(message->timestamp);
 
-    buffer_append(window->layout->buffer, "-", 0, timestamp, 0, THEME_TEXT_HISTORY, "", NULL, message, NULL, NULL);
-    _win_print_internal(window, "-", 0, timestamp, 0, THEME_TEXT_HISTORY, "", message, NULL);
+    int flags = 0;
+
+    // TODO: ProfMessage needs a 'type' field like we have in sql db. then we can know whether each message is a chat, muc, mucpm
+    char *display_name;
+    if (is_muc) {
+        display_name = strdup(message->jid->resourcepart);
+
+        char *muc_history_color = prefs_get_string(PREF_HISTORY_COLOR_MUC);
+        if (g_strcmp0(muc_history_color, "unanimous") == 0) {
+            flags = NO_COLOUR_FROM;
+        }
+        g_free(muc_history_color);
+    } else {
+        display_name = roster_get_msg_display_name(message->jid->barejid, message->jid->resourcepart);
+    }
+
+    buffer_append(window->layout->buffer, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
+    _win_print_internal(window, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, message->plain, NULL);
+
+    free(display_name);
 
     inp_nonblocking(TRUE);
-    g_date_time_unref(timestamp);
+    g_date_time_unref(message->timestamp);
 }
 
 void
diff --git a/src/ui/window.h b/src/ui/window.h
index d17560bc..378dae24 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -68,7 +68,7 @@ void win_print_outgoing(ProfWin *window, const char *show_char, const char *cons
 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_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const ProfMessage *const message);
 void win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message);
-void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message);
+void win_print_history(ProfWin *window, const ProfMessage *const message, gboolean is_muc);
 
 void win_print_http_upload(ProfWin *window, const char *const message, char *url);
 
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 4d5d8279..02d62d01 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -126,6 +126,7 @@ typedef enum {
     PROF_MSG_ENC_OMEMO
 } prof_enc_t;
 
+// TODO: ProfMessage needs a 'type' field like we have in sql db. then we can know whether each message is a chat, muc, mucpm
 typedef struct prof_message_t {
    Jid *jid;
    char *id;