1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-08-04 18:44:14 -04:00
Commit Graph

5472 Commits

Author SHA1 Message Date
Michael Vetter
06f300a42c Move message sent by us logic in own function 2019-10-18 14:50:25 +02:00
Michael Vetter
3bd5c9f535 Remove accidentally added file 2019-10-18 12:24:34 +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
33083662d1 Add XEP-0359 to capabilities
We implement </origin-id> from [XEP-0359](https://xmpp.org/extensions/xep-0359.html).
We already had this implemented for OMEMO. And now use it to check
whether MUC messages were sent from us
(https://github.com/profanity-im/profanity/issues/1201).

We don't implement </stanza-id> yet, but probably need to do so for MAM.

Anyways let's flag this as implementing the XEP.

Fix https://github.com/profanity-im/profanity/issues/1207
2019-10-18 10:46:06 +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
53640f6e97 Remove prefix from stanza id
We sent `prof_prefix_uuid` as id. Where the prefix was also optional.
We don't need this at all.
2019-10-17 15:40:40 +02:00
Michael Vetter
827af999b7 Change algo for connection_create_stanza_id() 2019-10-17 15:32:46 +02:00
Michael Vetter
8f5d1751b2 Change connection_create_stanza_id()
To return identifier and uuid together.
We can remove the prefix later on.
2019-10-17 09:23:11 +02:00
Michael Vetter
708bc83870 Calculate identifier upon connect
This will be needed so that we can later detect if messages (origin-in)
was sent by us.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 15:53:28 +02:00
Michael Vetter
ee0541a262 Rename identification file 2019-10-16 10:54:05 +02:00
Michael Vetter
46f0304f89 Use random string for random-bytes identifier
And rename `instance` to `identifier`.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 10:45:41 +02:00
Michael Vetter
f9eb302a59 Move code from jid_random_resource() into own function
Move the code that creates a random string into it's own function
+get_random_string().
2019-10-16 10:39:35 +02:00
Michael Vetter
1e09a055ca Create random-bytes file
So far only with dummy value.
We will need an identifier that we can hash together with a message ID
and put in as the origin-id.
So when we receive message we can unsplit it and see if it was sent from
this client.

Regards https://github.com/profanity-im/profanity/issues/1207
2019-10-16 10:17:34 +02:00
Michael Vetter
d0c3d3fd6b Null-set account struct
Surpresses the valgrind warning about uninit. values.
2019-10-14 11:35:18 +02:00
Dmitry Podgorny
0499c4e0ee Fix memory leak in unittests 2019-10-14 00:23:02 +03:00
Dmitry Podgorny
6d11cd2db3 Fix memory leak in cmd_join()
room is either argv[0] or allocated by GString. We have to free memory
in the 2nd case. Replace argv[0] with g_strdup(argv[0]) in order to
make unconditional g_free().
2019-10-14 00:19:08 +03:00
Michael Vetter
ffd74229fa
Merge pull request #1205 from mdosch/master
Add cmd.wins.unread
2019-10-12 20:19:18 +02:00
Martin Dosch
df25e9c3d9 Add cmd.wins.unread 2019-10-12 13:42:08 +02:00
Michael Vetter
5c53e02d86 Add option to hilight unread rooms in /wins command
In the theme we can now set `cmd.wins.unread` to hvae a special color
for the lines of the `/wins` output that have unread messages.

Fix https://github.com/profanity-im/profanity/issues/895
2019-10-12 13:03:14 +02:00
Michael Vetter
559c143587 travis: show log in case make check failed 2019-10-10 19:10:55 +02:00
Michael Vetter
8e5dafdea5 Fix invalid reads in unit tests 2019-10-10 19:02:23 +02:00
Michael Vetter
2559ad5370 Revert "Free lits in test_cmd_roster unittest"
This reverts commit 5b19ed28ce.

This caused a segfault.
2019-10-10 18:08:24 +02:00
Michael Vetter
87b66d0816 Make cmd_account safer 2019-10-10 18:06:28 +02:00
Michael Vetter
d3dd95963e Sort includes in python_api.c 2019-10-07 15:53:17 +02:00
Michael Vetter
b3ed213668 Improve MUC 1:1 logging
If we get a private message from a user in a MUC profanity shows this
like:
`profanity@roomsASDF.dismail.de/Martin: Hi`

This was so far logged at:
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de/2019_09_04.log` as:

```
10:48:13 - profanity@rooms.dismail.de: Hi
```

So the nickname was not saved anywhere. This is due to us not knowing
whether we got a regular message from user@server.org/resource or a MUC
PM from room@server.org/user.

We now check for `<x xmlns='http://jabber.org/protocol/muc#user' />` and
add the resourcepart to the logging if we get it.

The file will be created at
`~/.local/share/profanity/chatlogs/my-account-at-server/profanity_at_rooms.dismail.de_nick` and look like:

```
23:59:43 - nick: Hi
```

Fix https://github.com/profanity-im/profanity/issues/1184
2019-10-07 00:05:37 +02:00
Michael Vetter
f1d31e024c Fix typo handel -> handle 2019-10-06 23:00:08 +02:00
Michael Vetter
7684cf64f0 Revert "Fix memleak in cmd_join"
This reverts commit 1746f5f8a8.
2019-10-06 22:44:35 +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
7d7997e93c Add account clear example to help
Give example on how to clear pgpkeyig.
2019-10-06 20:46:50 +02:00
Michael Vetter
a10ab4e692 First destroy roster then free list in test_cmd_roster 2019-10-06 19:13:45 +02:00
Michael Vetter
9b3517c21e Free strings in autocomplete_param_no_with_func
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 19:05:27 +02:00
Michael Vetter
94b401ab96 Fix invalid read in muc code
We didn't set the variables to NULL, but the rest of the code depends on
this check.
```
==22201== Invalid read of size 8
==22201==    at 0x44E560: autocomplete_clear (autocomplete.c:69)
==22201==    by 0x427B2C: muc_invites_clear (muc.c:190)
==22201==    by 0x461328: ev_disconnect_cleanup (common.c:59)
==22201==    by 0x463FB5: cl_ev_disconnect (client_events.c:91)
==22201==    by 0x431252: cmd_disconnect (cmd_funcs.c:1234)
==22201==    by 0x47E883: clears_chat_sessions
(test_cmd_disconnect.c:28)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
==22201==  Address 0x814b690 is 0 bytes inside a block of size 24 free'd
==22201==    at 0x48379AB: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22201==    by 0x44E5F7: autocomplete_free (autocomplete.c:90)
==22201==    by 0x4278A0: muc_close (muc.c:97)
==22201==    by 0x47DBAA: cmd_join_uses_password_when_supplied
(test_cmd_join.c:169)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
==22201==  Block was alloc'd at
==22201==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22201==    by 0x44E51B: autocomplete_new (autocomplete.c:57)
==22201==    by 0x427837: muc_init (muc.c:88)
==22201==    by 0x47DA77: cmd_join_uses_password_when_supplied
(test_cmd_join.c:154)
==22201==    by 0x487E9E1: _run_test (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x487ECCC: _run_tests (in /usr/lib64/libcmocka.so.0.7.0)
==22201==    by 0x47F1BE: main (unittests.c:629)
```
2019-10-06 19:00:46 +02:00
Michael Vetter
1746f5f8a8 Fix memleak in cmd_join
Free `room` string in case we allocated it ourselves.

Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:53:16 +02:00
Michael Vetter
3ce27b47ad Free strings in all cases in cmd_rooms
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:51:04 +02:00
Michael Vetter
98676613fd Free strings in test_cmd_alias
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:45:53 +02:00
Michael Vetter
5b19ed28ce Free lits in test_cmd_roster unittest
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:43:27 +02:00
Michael Vetter
1d23d6461d Remove not needed strdupin test_cmd_rooms
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:40:51 +02:00
Michael Vetter
5349b60385 Free autocomplete_complete results in unittest
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:34:28 +02:00
Michael Vetter
2526e396f8 Fix autocomplete memleak in test_autocomplete
autocomplete_free() calls autocomplete_clear() and then frees the struct
itself.

Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:26:34 +02:00
Michael Vetter
b591f0cf2b Free list in error case in parse_options
Fix memleaks.

Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:12:50 +02:00
Michael Vetter
700f97d78c Free lists in test_roster_list
Fix memleaks.
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 18:06:30 +02:00
Michael Vetter
9e6bc99d08 Fix two memleaks in test_parser
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:59:46 +02:00
Michael Vetter
1fabb61b40 Fix memleak in cmd_bookmark_list_shows_bookmarks unittest
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:54:40 +02:00
Michael Vetter
6776e39644 Fix memleak in test_parser unittest
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:50:29 +02:00
Michael Vetter
d2a087145c Fix memleak in test_callbacks unittest
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:47:13 +02:00
Michael Vetter
4f11140bb5 Fix memleak in test_parser unittest
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:43:10 +02:00
Michael Vetter
897dfbb3c1 Fix memleak in get_start()
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:42:44 +02:00
Michael Vetter
57ebb7cfa6 Destroy hash table ein autocompleters_destroy()
Regards https://github.com/profanity-im/profanity/issues/1019
2019-10-06 17:29:35 +02:00