aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-20 10:17:17 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-20 10:28:24 +0100
commit8ee2cdadc88978ea26e6b6eb56f2aaa1fd5a81df (patch)
tree3f909fac44a21f612cc3c077c3eea8293ac4ca6c /src
parent1ddac7b9c6327e52845aacae6f83ad5d1899c0e6 (diff)
downloadprofani-tty-8ee2cdadc88978ea26e6b6eb56f2aaa1fd5a81df.tar.gz
Parse mentions and triggers in muc history if display is 'regular'
Fix https://github.com/profanity-im/profanity/issues/1261
Diffstat (limited to 'src')
-rw-r--r--src/ui/mucwin.c45
-rw-r--r--src/ui/ui.h3
-rw-r--r--src/xmpp/message.c2
-rw-r--r--src/xmpp/xmpp.h2
4 files changed, 30 insertions, 22 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 7f177f37..2005ce28 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -366,34 +366,41 @@ mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message)
assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin;
- GString *line = g_string_new("");
char *nick = message->jid->resourcepart;
- 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);
- }
-
// 'unanimous' all in one color (like always was)
// 'regular' colored like new messages too
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);
} else {
- // TODO: actually should call mucwin_incoming_msg() so that mentions and triggers are highlighted too.
- // so should put code from sv_ev_room_message() in own function. so that we get the triggers etc.
- win_println_incoming_muc_msg(window, '-', 0, message->jid->resourcepart, message->id, message->replace_id, message->plain);
- }
- g_free(muc_history_color);
+ 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);
+ GList *triggers = prefs_message_get_triggers(message->plain);
- g_string_free(line, TRUE);
+ mucwin_incoming_msg(mucwin, message, mentions, triggers);
+ g_slist_free(mentions);
+ g_list_free_full(triggers, free);
+ }
+
+ g_free(muc_history_color);
plugins_on_room_history_message(mucwin->roomjid, nick, message->plain, message->timestamp);
}
@@ -542,7 +549,7 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *c
}
void
-mucwin_incoming_msg(ProfMucWin *mucwin, ProfMessage *message, GSList *mentions, GList *triggers)
+mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers)
{
assert(mucwin != NULL);
int flags = 0;
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 16feda7b..8790e464 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -3,6 +3,7 @@
* vim: expandtab:ts=4:sts=4:sw=4
*
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2019 - 2020 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
@@ -158,7 +159,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
void mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message);
void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id);
-void mucwin_incoming_msg(ProfMucWin *mucwin, ProfMessage *message, GSList *mentions, GList *triggers);
+void mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers);
void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject);
void mucwin_requires_config(ProfMucWin *mucwin);
void mucwin_info(ProfMucWin *mucwin);
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 0caef0f6..a5c6c33f 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1256,7 +1256,7 @@ _send_message_stanza(xmpp_stanza_t *const stanza)
* checkOID = false: check regular id
*/
bool
-message_is_sent_by_us(ProfMessage *message, bool checkOID) {
+message_is_sent_by_us(const ProfMessage *const message, bool checkOID) {
bool ret = FALSE;
// we check the </origin-id> for this we calculate a hash into it so we can detect
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 0563948a..85c49e03 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -184,7 +184,7 @@ void message_send_paused(const char *const jid);
void message_send_gone(const char *const jid);
void message_send_invite(const char *const room, const char *const contact, const char *const reason);
-bool message_is_sent_by_us(ProfMessage *message, bool checkOID);
+bool message_is_sent_by_us(const ProfMessage *const message, bool checkOID);
void presence_subscription(const char *const jid, const jabber_subscr_t action);
GList* presence_get_subscription_requests(void);