1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00
Commit Graph

370 Commits

Author SHA1 Message Date
Michael Vetter
7b49fbdf45 Pass window to functions so we dont have to call twice 2020-07-09 16:11:50 +02:00
Michael Vetter
a2726b6a7d Apply coding style 2020-07-07 14:18:57 +02:00
Michael Vetter
a4cadf78fa Revert "Apply coding style"
This reverts commit 9b55f2dec0.

Sorting the includes creates some problems.
2020-07-07 13:53:30 +02:00
Michael Vetter
9b55f2dec0 Apply coding style
Regards https://github.com/profanity-im/profanity/issues/1396
2020-07-07 09:43:28 +02:00
DebXWoody
2a50bb6ad7 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.
2020-07-06 10:36:03 +02:00
Michael Vetter
e5ac12afa6 Remove prefs_free_string()
It just does a free.
Related to b580b9ef11
2020-07-02 11:34:12 +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
DebXWoody
c81931c35d
Cleanup defines - client_events.c 2020-06-19 22:05:31 +02:00
DebXWoody
fa9ef70037
Clean-up task: clean up feature defines 2020-06-14 12:12:29 +02:00
Dmitry Podgorny
ac410445af Add option for legacy authentication
New options:
  /connect <account> [auth default|legacy]
  /account <account> set auth default|legacy

Fixes #1236.
2020-06-05 11:37:51 +03:00
Michael Vetter
3d7a3134af Fix offline roster contacts
Fix https://github.com/profanity-im/profanity/issues/1280
p_contact_set_presence() is triggered in
(roster_process_pending_presence) to set the presence to online
after the roster is displayed.

This happened to me _every time_ with one certain account on my server.
But not even once with other accounts on my server.

I don't understand why that is the case, but AFAIK the code should be
like it is in this PR anyways.

roster_process_pending_presence() was added there in
973a05d15a to fix
https://github.com/profanity-im/profanity/issues/1050
2020-06-02 14:24:37 +02:00
Michael Vetter
4c047b0cb5
Merge pull request #1344 from DebXWoody/bugfix/1327
Bugfix: Status with PGP shows offline in titlebar
2020-05-28 20:47:48 +02: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
242ffbcf70 Add bookmark ignore functionality for multiple accounts
```
cat ~/.local/share/profanity/bookmark_ignore
[jubalh@iodoru.org]
profanity@rooms.dismail.de=true

[testuser@domain.org]
testr@rooms.domain.org=true
```

Regards https://github.com/profanity-im/profanity/issues/1115
2020-05-24 13:31:24 +02:00
Michael Vetter
d03c953d4a PoC for bookmark ignore
```
~/.local/share/profanity % cat bookmark_ignore
[ignore]
profanity@rooms.dismail.de=
```

Regards https://github.com/profanity-im/profanity/issues/1115
2020-05-24 12:55:43 +02:00
DebXWoody
d3e23ff030
Bugfix: Status with PGP shows offline in titlebar
There is code to redraw the ui, because the user may enter a passphase for the
private key. There was also a ui_init, which shouldn't be called, because it
will set the status to the initial state, which is 'offline' and 'no tls'.

Issue: #1327
2020-05-23 07:09:08 +02:00
Michael Vetter
ee9ca24f87 Log all carbon copied messages
So far we only had the logging in sv_ev_incoming_carbon() not
sv_ev_outgoing_carbon().

Regards https://github.com/profanity-im/profanity/issues/1342
2020-05-22 16:42:20 +02:00
Michael Vetter
88c36745fe Add option to add bookmark name
`/bookmark add|update` got `name` field.
By default localpart of JID is used (like before) but now we can set the
name ourselves.

Regards https://github.com/profanity-im/profanity/issues/697
2020-05-22 14:18:20 +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
444ce95aae Log after displaying the message
Otherwise we print the freshly received message to the window twice.
Once when receiving (and immediately printing), then logging it, and
then again when we print the last 10 log entries.

Fix https://github.com/profanity-im/profanity/issues/1305
2020-04-08 12:21:07 +02:00
Michael Vetter
3b2976c9cb db: Use type from message struct instead of having individual functions 2020-04-06 19:15:06 +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
9224331df3 Fix copy paste error 2020-04-06 10:50:20 +02:00
Michael Vetter
58bef8e592 db: dont log reflected MUC messages 2020-04-06 10:50:20 +02:00
Michael Vetter
a0a4fd0426 db: log all incoming and outgoing messages 2020-04-06 10:50:20 +02:00
Michael Vetter
def2123216 db: log outgoing message in one case
Not all cases covered yet.
2020-04-06 10:50:20 +02:00
Michael Vetter
628b86f57e db: add dedicated chat, muc, muc pm logging functions 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
af2630a289 db: insert message type 2020-04-06 10:50:20 +02:00
Michael Vetter
4a7a0f3e76 db: move includes 2020-04-06 10:50:20 +02:00
Michael Vetter
11663625cc db: Have one database per account 2020-04-06 10:50:20 +02:00
Michael Vetter
71e872c5b8 database: dont log muc pms 2020-04-06 10:50:20 +02:00
Michael Vetter
5cc3b469a8 database: log stanza_id and whether it is a muc message 2020-04-06 10:50:20 +02:00
Michael Vetter
8045a32c4a database: log incoming messages
First trial. Not covering all cases yet.
2020-04-06 10:50:20 +02:00
Michael Vetter
eb2fbdba2e Dont filter out own MUC messages if muc history is set to 'regular'
We use the same incoming function as for regular incoming text here. But
don't want to filter out our own messages since we didn't print them
during sending.

Follow up to 8ee2cdadc8
2020-02-21 18:46:09 +01:00
Michael Vetter
c13553bfcb Fix missing change from last commit 2020-02-20 23:43:35 +01:00
Michael Vetter
1f8b1eb740 Allow utf8 symbols as omemo/pgp/otr indicator char
Fix https://github.com/profanity-im/profanity/issues/1264
2020-02-20 23:36:10 +01:00
Michael Vetter
1ddac7b9c6 Put getting mentions in own function
So we can use it somewhere else too.

Regards https://github.com/profanity-im/profanity/issues/1261
2020-02-20 10:03:36 +01:00
Michael Vetter
6aa793fca6 Refactor mucwin_history()
Just pass ProfMessage.
2020-02-19 16:57:37 +01:00
Michael Vetter
3aad0523d7 Always send delivery receipts if enabled
So far receipts are only send if we have enabled it and the other client
supports it.
But it could be that the other person is connected with several clients.
One supporting it and the other which doesn't. If the not supporting one
is active and we send to a fulljid, then we won't get receipts.

Probably it's best to just always send them if they are enabled in
Profanity. And not try to find out the capabilities of the other client.

Fix https://github.com/profanity-im/profanity/issues/1268
2020-02-14 10:17:07 +01:00
Michael Vetter
c614cc288a Fix tests 2020-02-14 10:17:07 +01:00
Michael Vetter
50271493b7 xep-0308: remove replace_id from privwin signature
No `/correct` allowed in privwins
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
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
11b6e1bfa0 xep-0308: enable corrections for outgoing encrypted messages 2020-02-12 08:54:12 +01:00
Michael Vetter
b6b7dd5ad4 xep-0308: update the UI upon sending a corrected message
So far we don't do this for encrypted messages. Still needs to be done.
And MUC also needs to be done.
2020-02-11 15:26:58 +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
Paul Fariello
84506cbaeb Use OMEMO for offline MUC members (#1242) 2020-01-20 14:28:13 +01:00
Michael Vetter
be13e98fe7 Update my Copyright to 2020 2020-01-03 19:52:31 +01:00
Michael Vetter
771dfab123 Start implementing XEP-0084
So far we just subscribe and get the IDs.
2019-12-18 10:17:10 +01:00
Michael Vetter
3bb2e07c1e Use helper function to clean incoming messages
We might want to use utf8proc or something to normalize utf8 strings
later?
2019-12-13 13:42:43 +01:00
Michael Vetter
46fd7150e5 Add vim modeline 2019-11-13 12:11:05 +01:00
Michael Vetter
87f9bacffa Filter RTL unicode characters out
Gajim sends \u200E and \u200F for RTL.
It is planned that Gajim stops doing this and uses some GTK feature to
get the same result.

However users expressed the whish that we filter out such characters in
incoming messages before displaying them to make Profanity more robust.

I'm still not sure whether I like the solution because it means a lot of
allocating/deallocating upon every new message.

Fix https://github.com/profanity-im/profanity/issues/1220
2019-11-13 09:39:07 +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
aa0c638394 Update chat_log_pgp_msg_out() usage
Fix build
2019-10-29 15:20:24 +01:00
Michael Vetter
5a0a6c97e2 Two carbon logging changes
Add resourcepart to the outgoing carbon that is logged, so we use the
correct filenames for MUC PMs.

Dont log incoming carbons of MUC PMs as a workaround to faulty server
behaviour.

See https://wiki.xmpp.org/web/Multi-Session_Nicks#Private_Messages under
'Client-side workaround behavior'.

Regards https://github.com/profanity-im/profanity/issues/1214
2019-10-29 11:46:01 +01:00
Michael Vetter
9788410aaf Also log sv_ev_delayed_private_message 2019-10-29 10:52:11 +01:00
Michael Vetter
8c8c18c6fd Actually log MUC PM messages
If I'm not mistaken MUC PMs have not been logged at all if there was no
other client sending carbons.
This should add MUC PM logging functionality.

We still need to make sure carbons log to the same file.

Regards https://github.com/profanity-im/profanity/issues/1214
2019-10-28 23:36:42 +01:00
Michael Vetter
31014b5e51 Fix which message we want to log 2019-10-19 23:24:33 +02:00
Michael Vetter
06f300a42c Move message sent by us logic in own function 2019-10-18 14:50:25 +02:00
Michael Vetter
dfead6415f sv_ev_room_message: log in all cases if not our client
Forgot to check what happens if the length is <= 10.
2019-10-18 11:59:39 +02:00
Michael Vetter
f7474cd72c sv_ev_room_message: check if message->id is not NULL 2019-10-18 11:43:30 +02:00
Michael Vetter
5c6f5ba0f7 Add connection_get_profanity_identifier stub
And move defintion to xmpp.h
2019-10-18 11:23:30 +02:00
Michael Vetter
430b2eaa0d Log incoming MUC messages if origin-id sais they dont come from us
Regards https://github.com/profanity-im/profanity/issues/1201
2019-10-18 10:40:24 +02:00
Michael Vetter
147be3afdf Don't log own messages on incoming MUC
`sv_ev_room_message()` called `groupchat_log_msg_in()` to log all
incoming MUC messages.

`cl_ev_send_muc_msg()` calls `groupchat_log_msg_out()`.

So messages sent by the user himself was logged two times.

Filter the incoming messages and only log the ones not from our occupant
jid/nick.

Fix https://github.com/profanity-im/profanity/issues/1201
2019-10-06 22:32:58 +02:00
Michael Vetter
523681a642 Log outgoing carbons instead of incoming
Incoming carbons are logged as normal message already.
So we had this logged twice but didn't log outgoing carbons,
send from our account but by another client, at all.

Fix https://github.com/profanity-im/profanity/issues/1181
2019-10-04 13:22:14 +02:00
Michael Vetter
09b6fc9aaa Log 1:1 messages from other clients also to file
Carbons where not logged so far.

Fix https://github.com/profanity-im/profanity/issues/1181
2019-09-04 10:28:52 +02:00
Michael Vetter
25501a5d8a Improve sv_ev_roster_received() last activity check
We don't need to do all the timing stuff if last activity is disabled
anyways.
2019-08-02 15:52:49 +02:00
Michael Vetter
53c3115976 Don't print subscribed message if contact is already in roster
This occured with a user running Cisco Jabber. It seems this server
sends repeated presence subscribed stanzas. And although I find this
strange according to RFC this seems to be ok.

So let's filter them and only display in the console output and to the
log. But don't open seperate windows.

Fix https://github.com/profanity-im/profanity/issues/1165
2019-08-01 20:48:23 +02:00
Michael Vetter
ad9263520e Show MUC history on intentional reconnect
Small bug caused by 13675fb and ce5a4ed.
Fix https://github.com/profanity-im/profanity/issues/1142
2019-07-03 09:19:24 +02:00
Paul Fariello
db8f32c049 Fix handling of encrypted carbons 2019-06-21 15:52:24 +02:00
Paul Fariello
f831f65737 Rename prof_message_t into ProfMessage 2019-06-20 14:30:45 +02:00
Paul Fariello
44d16e9141 Add prof_message_t to wrap all message attributes
Probably missing copy of body to plain in carbon and privmessage.
Only covers the incoming message path because goal is OMEMO decryption
of untrusted message.
Cover some of the log functions but not all.
2019-06-20 14:30:42 +02:00
Paul Fariello
3bb3cc625d Use flags in xmmp/message.c for encryption and trust 2019-06-20 14:30:37 +02:00
Michael Vetter
40b72ffe55 Add myself to copyright
Like discussed with James.
2019-06-17 10:44:08 +02:00
Michael Vetter
5dd6ba73f4
Merge pull request #1110 from profanity-im/feature/704-ui-behaviour-reconnect
Feature/704 ui behaviour reconnect
2019-06-11 07:00:34 +02:00
Michael Vetter
47e55cc112 Safe last MUC message timestamp per MUC
After pasis review of my code he thinks it's better to safe the
timestamp per MUC so we can account for some problems that could occur
with timing.
2019-06-11 06:35:03 +02:00
Michael Vetter
ff6038fe32 Rejoin all MUCs on reconnect
Should fix https://github.com/profanity-im/profanity/issues/1120
2019-06-10 23:18:43 +02:00
Michael Vetter
ce5a4ed77c Only show MUC subject on first connect
For #704 we don't show the room history upon reconnect.
Now we also don't show the room subject in the channel
upon re-established connection.
2019-06-05 10:05:12 +02:00
Michael Vetter
d53c477e4e Reduce timestamp call when saving last muc message
Let's test for mucwin earlier.
2019-06-05 09:56:00 +02:00
Michael Vetter
13675fbf06 Only print room history for new messages upon reconnect
If re-establish a connection don't print the room history again.
In case there there happened nothing at all since we got the room
history on the last connection.
And in case there were no new messages during the time we have been
disconnected.

Instead of printing the room history again we now print 'Re-established
Connection'.

This adds a bit of overhead since we save the timestamp upon every MUC
message.

See: https://github.com/profanity-im/profanity/issues/704
2019-06-05 09:49:50 +02:00
Dmitry Podgorny
6138a5f79b Cancel autoping timer on disconnect or connection loss
If Profanity is disconnected in any way before ping response is
received, the autoping timer will expire after the next connection
is established. As result, user will be disconnected immediately.

Cancel autoping timer in ev_disconnect_cleanup(), so it is done
for all kind of disconnections.
2019-06-03 13:28:00 +03:00
Michael Vetter
bfa4a2ef1f Close windows on connection loss not general disc.
Call `ui_close_all_wins();` only if we disconnect on purpose not when
connection is lost.

Otherwise users might miss messages.

This partly reverts 6ac73db876.
Regards https://github.com/profanity-im/profanity/issues/1083
2019-05-27 12:52:04 +02:00
Michael Vetter
883dbe1911 Create seperate function for disconnect cleanup
Duplicate code in client_events.c and server_events.c. Let's have
events/common.c and a function containing that code.
2019-05-19 22:57:51 +02:00
Michael Vetter
c94f3d0b4a Fix ifdef guard (should have been OMEMO) 2019-05-06 16:11:22 +02:00
Michael Vetter
6ac73db876 Reset things on connection loss
Remove the windows, clear tls certs, clean omemo.
Regards https://github.com/profanity-im/profanity/issues/1089
2019-05-06 12:30:33 +02:00
Michael Vetter
199e8752ca
Merge pull request #1063 from paulfariello/hotfix/presence-before-roster
Handle presence received before roster
2019-04-17 20:47:54 +02:00
Paul Fariello
db55e01dce Follow OMEMO policy even when opening window on message and carbon reception
This should close #1052
2019-04-17 15:54:15 +02:00
Paul Fariello
973a05d15a Handle presence received before roster
Presence of contact not found in roster are filtered out.
But sometimes roster is received after a first few presences.

We choose to store presences until we receive roster and then process
this presences.

Fixes #1050
2019-04-17 14:19:31 +02:00
Paul Fariello
df648ba959 Try to start sessions with every jid in roster 2019-04-10 17:24:56 +02:00
Paul Fariello
4ad6904216 Wait for discovery end to publish omemo devicelist and bundle
Add sv_ev_connection_features_received for that purpose
2019-04-10 17:23:46 +02:00
Paul Fariello
e69f947547 Rework MUC reflected message filtering
Reflected messages can't be filtered by nick only otherwise you might
ignore messages comming from you on another devices.

Consequently we maintain a list of sent messages id in mucwin.
To be sure the id will be correctly reflected we use the origin-id
stanza.
2019-04-10 17:23:46 +02:00
Paul Fariello
2015ba201d Ensure encrypted carbon of own message are marked as encrypted 2019-04-10 17:23:45 +02:00
Paul Fariello
91ee289c77 Add support for disconnect in OMEMO 2019-04-10 17:12:31 +02:00
Paul Fariello
4e1ffa6bdb Log and print outgoing encrypted message 2019-04-10 17:12:31 +02:00
Paul Fariello
a9d55dec92 Add support for sending encrypted message in MUC 2019-04-10 17:12:31 +02:00
Paul Fariello
319fb856e0 Handle decrypted OMEMO messages as such 2019-04-10 17:12:31 +02:00