1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

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.
This commit is contained in:
DebXWoody 2020-07-05 10:47:09 +02:00 committed by Michael Vetter
parent d2c3aa566b
commit 2a50bb6ad7

View File

@ -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;