Merge pull request #2041 from profanity-im/some-improvements
All checks were successful
CI / Linux (debian) (pull_request) Successful in 13m45s
CI / Linux (arch) (pull_request) Successful in 16m48s
CI / Linux (fedora) (pull_request) Successful in 15m11s
CI / Check coding style (pull_request) Successful in 29s
CI / Check spelling (pull_request) Successful in 15s
CI / Linux (ubuntu) (pull_request) Successful in 13m50s
CI / Linux (debian) (push) Successful in 11m36s
CI / Linux (arch) (push) Successful in 14m0s
CI / Linux (fedora) (push) Successful in 12m25s
CI / Check coding style (push) Successful in 30s
CI / Check spelling (push) Successful in 16s
CI / Linux (ubuntu) (push) Successful in 11m55s

Summary:
- Print the final storage location when successfully decrypting a file with `aesgcm://` source.
- Less GString
- Re-factor cmd_presence()
- Improve const correctness
- Use correct free function. Fixes: 75d7663 ("Free wins summary list")

Pull Request Source: https://github.com/profanity-im/profanity/pull/2041

Author: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Michael Vetter
2025-07-02 21:33:21 +02:00
committed by Jabber Developer
parent b7afea7ec3
commit 091ff41c06
8 changed files with 52 additions and 73 deletions

View File

@@ -258,22 +258,20 @@ GList*
wins_get_private_chats(const char* const roomjid)
{
GList* result = NULL;
GString* prefix = g_string_new(roomjid);
g_string_append(prefix, "/");
auto_gchar gchar* prefix = g_strdup_printf("%s/", roomjid);
GList* curr = values;
while (curr) {
ProfWin* window = curr->data;
if (window->type == WIN_PRIVATE) {
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) {
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix)) {
result = g_list_append(result, privatewin);
}
}
curr = g_list_next(curr);
}
g_string_free(prefix, TRUE);
return result;
}
@@ -1067,19 +1065,13 @@ wins_create_summary(gboolean unread)
while (curr) {
ProfWin* window = g_hash_table_lookup(windows, curr->data);
if (!unread || (unread && win_unread(window) > 0)) {
GString* line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data);
auto_gchar gchar* winstring = win_to_string(window);
if (!winstring) {
g_string_free(line, TRUE);
continue;
}
g_string_append_printf(line, "%d: %s", ui_index, winstring);
result = g_slist_append(result, strdup(line->str));
g_string_free(line, TRUE);
gchar* line = g_strdup_printf("%d: %s", ui_index, winstring);
result = g_slist_append(result, line);
}
curr = g_list_next(curr);
@@ -1108,19 +1100,13 @@ wins_create_summary_attention()
has_attention = mucwin->has_attention;
}
if (has_attention) {
GString* line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data);
auto_gchar gchar* winstring = win_to_string(window);
if (!winstring) {
g_string_free(line, TRUE);
continue;
}
g_string_append_printf(line, "%d: %s", ui_index, winstring);
result = g_slist_append(result, strdup(line->str));
g_string_free(line, TRUE);
gchar* line = g_strdup_printf("%d: %s", ui_index, winstring);
result = g_slist_append(result, line);
}
curr = g_list_next(curr);
}