From 2a50bb6ad7d34848c9acb0d87469bb92e9e6e133 Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sun, 5 Jul 2020 10:47:09 +0200 Subject: Plain chat messages not working Plain chat messages not working for non-carbon + no OTR support. On master we did some clean-up. The problem is at https://github.com/profanity-im/profanity/blob/0.9.patch/src/event/server_events.c#L625 (0.9.0). The implementation looks like: - HAVE_LIBOTR is set - _sv_ev_incoming_otr - HAVE_LIBOTR is not set - _sv_ev_incoming_plain I think the `_sv_ev_incoming_otr` can handle otr and plain, because I didn't find a `_sv_ev_incoming_plain` if `HAVE_LIBOTR` is set. On master for 0.10.0 the implementation is much better: https://github.com/profanity-im/profanity/blob/master/src/event/server_events.c#L623 But, we just call `_sv_ev_incoming_otr` independent of `HAVE_LIBOTR`. Unfortunately, `_sv_ev_incoming_otr` is doing nothing if `HAVE_LIBOTR` is not set: https://github.com/profanity-im/profanity/blob/master/src/event/server_events.c#L538 I did some more clean-up at sv_ev_incoming_message and changed the implementation of `_sv_ev_incoming_otr`. ``` static void _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message) { // OTR or plain plain } ``` The caller do not take care of `HAVE_LIBOTR`, call `_sv_ev_incoming_plain` if you are sure it's a plain message or call `_sv_ev_incoming_otr`. `_sv_ev_incoming_otr` can be used for otr / plain or for plain only. --- src/event/server_events.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/event/server_events.c b/src/event/server_events.c index 0d42e6c1..303f4fc7 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -73,6 +73,7 @@ #include "ui/ui.h" static void _clean_incoming_message(ProfMessage *message); +static void _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit); void sv_ev_login_account_success(char *account_name, gboolean secured) @@ -555,6 +556,8 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message message->plain = NULL; chatwin->pgp_recv = FALSE; } +#else + _sv_ev_incoming_plain(chatwin, new_win, message, TRUE); #endif } @@ -621,18 +624,20 @@ sv_ev_incoming_message(ProfMessage *message) } if( message->enc == PROF_MSG_ENC_OX) { - _sv_ev_incoming_ox(chatwin, new_win, message, TRUE); - } else if (message->encrypted) { + _sv_ev_incoming_ox(chatwin, new_win, message, TRUE); + } else if (message->enc == PROF_MSG_ENC_OMEMO) { + _sv_ev_incoming_omemo(chatwin, new_win, message, TRUE); + } else if (message->encrypted) { if (chatwin->is_otr) { win_println((ProfWin*)chatwin, THEME_DEFAULT, "-", "PGP encrypted message received whilst in OTR session."); } else { _sv_ev_incoming_pgp(chatwin, new_win, message, TRUE); } - } else if (message->enc == PROF_MSG_ENC_OMEMO) { - _sv_ev_incoming_omemo(chatwin, new_win, message, TRUE); } else { + // otr or plain _sv_ev_incoming_otr(chatwin, new_win, message); } + rosterwin_roster(); return; -- cgit 1.4.1-2-gfad0