mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Adapt win_print_history() to work with muc too
This commit is contained in:
parent
0942d98c61
commit
067bc690f2
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user