about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorDebXWoody <stefan@debxwoody.de>2020-07-05 10:47:09 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-06 10:36:03 +0200
commit2a50bb6ad7d34848c9acb0d87469bb92e9e6e133 (patch)
treed0e5295699c2634c1bbe6c5ffaaec8e04216031d /src/event
parentd2c3aa566b81a03b112f0192cf10681c523bbfe9 (diff)
downloadprofani-tty-2a50bb6ad7d34848c9acb0d87469bb92e9e6e133.tar.gz
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.
Diffstat (limited to 'src/event')
-rw-r--r--src/event/server_events.c13
1 files changed, 9 insertions, 4 deletions
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;