1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Refactor mucwin_history()

Just pass ProfMessage.
This commit is contained in:
Michael Vetter 2020-02-19 16:57:37 +01:00
parent cf36a92dcb
commit 6aa793fca6
3 changed files with 9 additions and 8 deletions

View File

@ -286,7 +286,7 @@ sv_ev_room_history(ProfMessage *message)
gboolean younger = g_date_time_compare(mucwin->last_msg_timestamp, message->timestamp) < 0 ? TRUE : FALSE;
if (ev_is_first_connect() || younger ) {
mucwin_history(mucwin, message->jid->resourcepart, message->timestamp, message->plain);
mucwin_history(mucwin, message);
}
}
}

View File

@ -361,28 +361,29 @@ mucwin_nick_change(ProfMucWin *mucwin, const char *const nick)
}
void
mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message)
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, "/me ", 4) == 0) {
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 + 4);
g_string_append(line, message->plain + 4);
} else {
g_string_append(line, nick);
g_string_append(line, ": ");
g_string_append(line, message);
g_string_append(line, message->plain);
}
win_print_history(window, timestamp, line->str);
win_print_history(window, message->timestamp, line->str);
g_string_free(line, TRUE);
plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp);
plugins_on_room_history_message(mucwin->roomjid, nick, message->plain, message->timestamp);
}
static void

View File

@ -156,7 +156,7 @@ void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const ni
void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *const nick,
const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message);
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_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject);