1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-30 21:55:24 +00:00
Commit Graph

256 Commits

Author SHA1 Message Date
Michael Vetter
6be5b51a46 message.c: Log invalid message type
So far we logged when we receive a message without a type. Which is
actually quite common and makes no sense.
2020-07-02 17:47:07 +02:00
Michael Vetter
46a00317ee message.c: Check for message type
RFC 6121 allows only few types.
So we can also remove that check in _handle_chat().
2020-07-02 17:40:58 +02:00
Michael Vetter
19d9e80a79 message.c: Remove handled cases form _handle_chat()
Both cases are tested before entering that function.
2020-07-02 17:32:14 +02:00
Michael Vetter
d9cfa2e48a message.c: Break out of _message_handler() after handling code
AFAIK it can only be one.
Except at STANZA_NS_MUC_USER which is used in several cases.
2020-07-02 17:31:56 +02:00
Michael Vetter
b14b711492 message.c: Parse incoming message stanzas according to type 2020-07-02 17:15:42 +02:00
Michael Vetter
728cb55b68 message.c: Add pubsub helper function 2020-07-02 16:48:57 +02:00
Michael Vetter
f2b415079a message.c: Add XEP information 2020-07-02 16:37:20 +02:00
Michael Vetter
1f50647865 message.c: Add my copyright 2020-07-02 15:22:58 +02:00
Michael Vetter
3350139ed0 message.c: Make several functions static 2020-07-02 15:21:54 +02:00
Michael Vetter
10190b5fb0 message.c: Adjust function formatting 2020-07-02 15:20:17 +02:00
Michael Vetter
8de6a7bfb0 And ifdefs around new OX functions
Fix for some build cases introduced in 2c94ee5a88
Fix https://github.com/profanity-im/profanity/issues/1376
2020-06-30 11:10:27 +02:00
DebXWoody
2c94ee5a88 Feature request - XEP-0373: OpenPGP for XMPP (OX)
Basic implementation of XEP-0373: OpenPGP for XMPP.
https://xmpp.org/extensions/xep-0373.html

Command /ox

Issue: #1331
2020-06-29 19:05:41 +02:00
Dmitry Podgorny
409bbd6f2d Fix possible segfault in xmpp/message.c
Check for pointer to be NULL before dereferencing it.
2020-06-16 17:52:01 +03:00
Michael Vetter
d4692b1b2d Fix carbon logging
Regards https://github.com/profanity-im/profanity/issues/1342
2020-05-27 22:06:04 +02:00
Michael Vetter
de8975c008 Add and use connection_get_barejid()
Instead of connection_get_fulljid() and then creating a Jid from it.
2020-05-25 13:04:19 +02:00
Michael Vetter
e41ae21bea Fix typing notification
With d1d0ad8d1a we set a timestamp to now
for all messages upon receival. Even if the original message didn't
contain any timestamp. So we can use the timestamp of retrieval for
logging and displaying and don't get them at each of those location
where they might differ.

This means that timestamp will never be NULL.

I don't see why we would want to check for the chat state only if
timestamp isn't there.

Probably because in XEP-0085 there is not timestamp defined.
So if it thats stanza it's not there and we can parse quicker, but there
is nothing forbidden it to be there.

Related to https://github.com/profanity-im/profanity/issues/1339
2020-05-21 12:24:03 +02:00
Michael Vetter
5ec1b03cbc _handle_carbons(): fix potential memleak 2020-04-21 17:11:04 +02:00
Michael Vetter
dd566d8d56 MAM: Correctly display incoming MAM chat message 2020-04-11 23:56:01 +02:00
Michael Vetter
180ec2b474 Add to_jid field to ProfMessage struct
Is usefult in many cases if we want cleaner code.
Hope this edit didn't break anything though ;-)
2020-04-11 17:11:53 +02:00
Michael Vetter
38273fef5c First test with receiving MAM 2020-04-11 16:05:14 +02:00
Michael Vetter
f3b8cc407d _handle_chat: return if no 'from'
Let's not crash :-)
2020-04-11 16:05:14 +02:00
Michael Vetter
e878b6d266 Don't crash if we get a message without from or type
MAM messages don't have a type nor a from.
If we detect a message without type let's log it and exit without
continuing to try to parse it.

Otherwise we go into _handle_chat() and crash on the no from.
2020-04-11 16:05:14 +02:00
Michael Vetter
3524a53c7c Add type field to ProfMessage
The mucuser boolean is not now needed anymore.
2020-04-06 19:15:02 +02:00
Michael Vetter
a0a4fd0426 db: log all incoming and outgoing messages 2020-04-06 10:50:20 +02:00
Michael Vetter
a4b53550ca Rename PROF_MSG_ENC_PLAIN to PROF_MSG_ENC_NONE 2020-04-06 10:50:20 +02:00
Michael Vetter
d1d0ad8d1a Add timestamp for incoming messages if none is set
Timestamps are only set if a message is delayed.
If none is set let's set it upon recaival so we don't have to set it
when it gets displayed.

This means we will also have it for logs etc in the ProfMessage.
2020-04-06 10:50:20 +02:00
Michael Vetter
56836fb72d Use correct MUC message timestamp
win_println_incoming_muc_msg() always used the current time. Now let's
use whatever is sent int he message struct (from the delay stanza or
the current time that we set now once the message is received).

No playing with the time upon display anymore.
2020-03-09 12:22:36 +01:00
Michael Vetter
779c2efc17 Set muc history correctly in _handle_groupchat()
Fix init. mistake introduced in e9c5c1979d
2020-02-25 16:34:43 +01:00
Michael Vetter
e9c5c1979d Fix memleak in _handle_groupchat()
We need to unref the timestamp before setting a new one.
2020-02-25 15:26:33 +01:00
Michael Vetter
8ee2cdadc8 Parse mentions and triggers in muc history if display is 'regular'
Fix https://github.com/profanity-im/profanity/issues/1261
2020-02-20 10:28:24 +01:00
Michael Vetter
e27c414f1f xep-0308: enable for carbon copied messages
If we are connected with another client and send a message, then correct
it. We now display it correctly in Profanity.

Id wasn't saved for carbon copied messages too so far.
2020-02-14 10:17:07 +01:00
Michael Vetter
4ec005e4c3 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.
2020-02-14 10:17:07 +01:00
Michael Vetter
2a7a389cb5 Rename MUC PM handler
Rename from _private_chat_handler() to _handle_muc_private_message() to
be more consistent with other handler names.
2020-02-14 10:17:07 +01:00
Michael Vetter
66d3f572f9 xep-0308: Dont allow to correct MUC PMs
People could change messages of other people if the nick isn't
registered.
2020-02-14 10:17:00 +01:00
Michael Vetter
ed1d49bf0c xep-0308: correct incoming MUC PMs 2020-02-12 13:07:52 +01:00
Michael Vetter
7cd1be36f2 xep-0308: Display corrected incoming MUC messages correctly 2020-02-12 12:56:34 +01:00
Michael Vetter
11b6e1bfa0 xep-0308: enable corrections for outgoing encrypted messages 2020-02-12 08:54:12 +01:00
Michael Vetter
1118110071 xep-0308: Implement /correct to correct the last send message
So far the correction is sent. But the UI in Profanity itself is not
updated.

Also autocompletion for `/correct` with the last sent message is
missing.
2020-02-10 16:17:01 +01:00
Michael Vetter
f16d56a15e xep-0308: Initial support for incoming LMC 2020-02-10 13:19:54 +01:00
Michael Vetter
8a9488245b muc: save oldest timestamp
So far we saved the timestamp which also had the `from`.
But we need this only to find out whether it's MUC history.

For displaying we should use the oldest delay timestamp.

Also in
61f66966dd (diff-4926fd4577a336bd3eb240f8104a5c5bL837)
a error was introduced.

Before we saved the timestamp in all cases. And only if timestamp AND
from was given we went into MUC history case.
Normal timestamp saving was not done anymore only if it also had a from
attribute.

Regards https://github.com/profanity-im/profanity/issues/1254
2020-01-30 11:46:19 +01:00
Michael Vetter
388bae084b Revert "Save first delay tag as timestamp"
This reverts commit ef00b10c90.

According to reply by user in
https://github.com/profanity-im/profanity/issues/1254#issuecomment-578389784
it didn't help.
2020-01-28 11:42:24 +01:00
Michael Vetter
ef00b10c90 Save first delay tag as timestamp
So far we got the first delay with a from that comes from the server.
This way we know it's MUC history.

Now we take the first time stamp we actually find. Which is likely the
one being added first. And should contain the correct time to display.

It would be nicer to actually compare the dates though.

Regards https://github.com/profanity-im/profanity/issues/1254
2020-01-24 21:30:35 +01:00
Michael Vetter
46fd7150e5 Add vim modeline 2019-11-13 12:11:05 +01:00
Michael Vetter
61f66966dd Check for correct delay tag for muc timestamps
https://github.com/profanity-im/profanity/issues/1190 had another issue:
Sometimes servers send multiple </delay> and we just checked the first
one we got and only used it if the 'from' attribute was fitting.
However it could be that we actually wanted the second </delay> element
and there the 'from' would have been right.

So we need to loop through them until we get the one with the fitting
'from'.

Fix https://github.com/profanity-im/profanity/issues/1190
2019-11-13 09:41:19 +01:00
Michael Vetter
68af0aad65 _handle_groupchat(): get correct origin-id stanza
The problem is that in _handle_groupchat() we look for
STANZA_NS_STABLE_ID which will result in origin-id or stanza-id.
It seems like prosody servers send origin-id first, so this worked in
all my tests. But actually we cannot be sure of the order.
So far we stopped after the first element was found.

I only found xmpp_stanza_get_child_by_ns() and
xmpp_stanza_get_child_by_name() in libstrophe. But we need a combination
of both.

So I created stanza_get_child_by_name_and_ns() for Profanity. I need to
remember to upstream this to libstrophe later (if they really don't have
such a function).

Fix https://github.com/profanity-im/profanity/issues/1223
2019-11-08 15:05:49 +01:00
Michael Vetter
f71de61b9d Don't override ProfMessage Id with origin-id
Profanity sends the same value for both. Other clients might not.
Safe both since we could need them later.

Once we implement Last Message Correction we will need the regular id.
If we override it with origin-id and another client chooses to not use
the same value for id and origin-id then we can't interpret the id sent
with the LMC request correctly.
2019-10-31 13:45:44 +01:00
Michael Vetter
7dd747b58d Set mucuser in carbon case
Also we initialize mucuser properly.

Now in case of a carbon of a MUC PM we sv_ev_incoming_carbon() which
calls _sv_ev_incoming_plain() and then we log it via chat_log_msg_in()
in there.
But we also get the sv_ev_incoming_private_message() and call
chat_log_msg_in() in there too. So the incoming message get's logged
twice.
2019-10-29 10:41:07 +01:00
Michael Vetter
22bf281399 Make prof_identifier const 2019-10-22 12:47:32 +02:00
Michael Vetter
ba18752405 Use UUID in origin-id and id
Let's use UUID to have a more random string then just 10 alphanumeric
values.
2019-10-22 11:10:37 +02:00
Michael Vetter
2a4d1b8410 Free hmac and msgid 2019-10-19 08:18:37 +02:00