Skip to content

Some improvements#2033

Merged
jubalh merged 6 commits intomasterfrom
some-improvements
Apr 16, 2025
Merged

Some improvements#2033
jubalh merged 6 commits intomasterfrom
some-improvements

Conversation

@sjaeckel
Copy link
Member

@sjaeckel sjaeckel commented Apr 2, 2025

Check commit messages for details.

  • I ran valgrind when using my new feature

sjaeckel added 4 commits April 2, 2025 13:07
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Instead of c&p'ing the same code again and again, put everything in a
struct and loop over it.

This also fixes `vcard` not being in included in `all`.

Fixes: f934c5b ("Add vCard support")

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Instead of manually typing the format-string, one can now simply use
`iso8601`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
`end_date` only gets free'd if `chatwin_db_history()` is called, which is
not always the case.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
@sjaeckel sjaeckel force-pushed the some-improvements branch from 811c11d to c4b2aca Compare April 9, 2025 15:09
@sjaeckel sjaeckel added this to the next milestone Apr 9, 2025
@sjaeckel sjaeckel linked an issue Apr 9, 2025 that may be closed by this pull request
> The returned data is valid until changes to the hash release those keys.
As of the doc of `g_hash_table_get_keys()` [0].

> The returned data is valid until hash_table is modified.
As of the doc of `g_hash_table_get_values()` [1].

Use this property and create the lists when modifying the hashtable.
The `keys` list is most of the time used sorted, so sort it immediately. In
the cases where it was not used sorted, it does not matter.

This started off by looking into whether this can be improved.
`g_hash_table_foreach()` is discouraged to be used and proposes to use
a `GHashTableIter`. Since our lists are not modified very often it does not
really make sense, so I decided to keep using lists, but allocating
those lists statically instead of per invocation.

Instead of using a list, we could maybe use the `GArray` version, but
I am not sure whether it wouldn't be even better to replace the
`GHashTable` all along to store the `windows` instead.

[0] https://docs.gtk.org/glib/type_func.HashTable.get_keys.html
[1] https://docs.gtk.org/glib/type_func.HashTable.get_values.html

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
We must only return early in cases where we received a roster push with
1. a `from` attribute
2. that `from` is not our bare JID

The server sends roster pushes without `from` attribute and we must accept
them.

Fixes #2035
Fixes: bac2460 ("Introduce `equals_our_barejid()`")

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
@sjaeckel sjaeckel force-pushed the some-improvements branch from c4b2aca to ed44d7a Compare April 11, 2025 16:55
@jubalh jubalh merged commit 0b767d3 into master Apr 16, 2025
6 checks passed
@jubalh jubalh deleted the some-improvements branch April 16, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Roster pushes from server ignored

2 participants