xep-0308: Implement LMC for outgoing MUC messages
Including OMEMO encrypted ones. Also rename `win_println_me_message()` to `win_print_outgoing_muc_msg() as I think it's a more descriptive name.
This commit is contained in:
@@ -50,6 +50,8 @@
|
||||
#include "omemo/omemo.h"
|
||||
#endif
|
||||
|
||||
static void _mucwin_set_last_message(ProfMucWin *mucwin, const char *const id, const char *const message);
|
||||
|
||||
ProfMucWin*
|
||||
mucwin_new(const char *const barejid)
|
||||
{
|
||||
@@ -501,7 +503,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
|
||||
}
|
||||
|
||||
void
|
||||
mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode)
|
||||
mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id)
|
||||
{
|
||||
assert(mucwin != NULL);
|
||||
|
||||
@@ -519,7 +521,12 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *c
|
||||
ch = prefs_get_omemo_char();
|
||||
}
|
||||
|
||||
win_println_me_message(window, ch, mynick, "%s", message);
|
||||
win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, "%s", message);
|
||||
|
||||
// save last id and message for LMC
|
||||
if (id) {
|
||||
_mucwin_set_last_message(mucwin, id, message);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -951,3 +958,13 @@ mucwin_unset_message_char(ProfMucWin *mucwin)
|
||||
mucwin->message_char = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_mucwin_set_last_message(ProfMucWin *mucwin, const char *const id, const char *const message)
|
||||
{
|
||||
free(mucwin->last_message);
|
||||
mucwin->last_message = strdup(message);
|
||||
|
||||
free(mucwin->last_msg_id);
|
||||
mucwin->last_msg_id = strdup(id);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
|
||||
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_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode);
|
||||
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);
|
||||
void mucwin_requires_config(ProfMucWin *mucwin);
|
||||
|
||||
@@ -178,6 +178,9 @@ typedef struct prof_muc_win_t {
|
||||
char *enctext;
|
||||
char *message_char;
|
||||
GDateTime *last_msg_timestamp;
|
||||
// For LMC
|
||||
char *last_message;
|
||||
char *last_msg_id;
|
||||
} ProfMucWin;
|
||||
|
||||
typedef struct prof_conf_win_t ProfConfWin;
|
||||
|
||||
@@ -203,6 +203,8 @@ win_create_muc(const char *const roomjid)
|
||||
new_win->enctext = NULL;
|
||||
new_win->message_char = NULL;
|
||||
new_win->is_omemo = FALSE;
|
||||
new_win->last_message = NULL;
|
||||
new_win->last_msg_id = NULL;
|
||||
|
||||
new_win->memcheck = PROFMUCWIN_MEMCHECK;
|
||||
|
||||
@@ -1169,7 +1171,7 @@ win_println_them_message(ProfWin *window, char ch, int flags, const char *const
|
||||
}
|
||||
|
||||
void
|
||||
win_println_me_message(ProfWin *window, char ch, const char *const me, const char *const message, ...)
|
||||
win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const char *const id, const char *const replace_id, const char *const message, ...)
|
||||
{
|
||||
GDateTime *timestamp = g_date_time_new_now_local();
|
||||
|
||||
@@ -1178,8 +1180,13 @@ win_println_me_message(ProfWin *window, char ch, const char *const me, const cha
|
||||
GString *fmt_msg = g_string_new(NULL);
|
||||
g_string_vprintf(fmt_msg, message, arg);
|
||||
|
||||
buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL, NULL);
|
||||
_win_print_internal(window, ch, 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL);
|
||||
if (replace_id) {
|
||||
_win_correct(window, fmt_msg->str, id, replace_id);
|
||||
} else {
|
||||
_win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_ME, me, id, "%s", fmt_msg->str);
|
||||
}
|
||||
// buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL, NULL);
|
||||
// _win_print_internal(window, ch, 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL);
|
||||
|
||||
inp_nonblocking(TRUE);
|
||||
g_date_time_unref(timestamp);
|
||||
|
||||
@@ -63,7 +63,7 @@ void win_show_status_string(ProfWin *window, const char *const from,
|
||||
|
||||
void win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags, const char *const them);
|
||||
void win_println_them_message(ProfWin *window, char ch, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message, ...);
|
||||
void win_println_me_message(ProfWin *window, char ch, const char *const me, const char *const message, ...);
|
||||
void win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const char *const id, const char *const replace_id, const char *const message, ...);
|
||||
|
||||
void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...);
|
||||
void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message);
|
||||
|
||||
Reference in New Issue
Block a user