Merge upstream/master into merge/upstream-full
All checks were successful
CI Code / Check coding style (pull_request) Successful in 32s
CI Code / Check spelling (pull_request) Successful in 15s
CI Code / Linux (debian) (pull_request) Successful in 6m43s
CI Code / Linux (ubuntu) (pull_request) Successful in 6m49s
CI Code / Linux (arch) (pull_request) Successful in 8m52s
CI Code / Code Coverage (pull_request) Successful in 7m19s
All checks were successful
CI Code / Check coding style (pull_request) Successful in 32s
CI Code / Check spelling (pull_request) Successful in 15s
CI Code / Linux (debian) (pull_request) Successful in 6m43s
CI Code / Linux (ubuntu) (pull_request) Successful in 6m49s
CI Code / Linux (arch) (pull_request) Successful in 8m52s
CI Code / Code Coverage (pull_request) Successful in 7m19s
Merge profanity-im/profanity master (373 commits) into cproof fork.
Source changes (manual merge):
- src/command/: cmd_defs, cmd_funcs, cmd_ac — upstream g_new0, auto_gchar,
launch_editor callback; keep our XEP-0308 LMC, force-encryption, CWE-134
- src/config/: preferences, tlscerts, account — upstream UNIQUE dedup,
dynamic pad capacity; keep our db_history_result_t, scroll logic
- src/database.*: upstream g_new0 memory mgmt; keep our return types,
add null-check fix for msg->timestamp
- src/omemo/, src/pgp/: upstream _gpgme_key_get_email, g_new0;
keep our replace_id in omemo_on_message_send
- src/tools/: editor, http_upload, bookmark_ignore — upstream launch_editor
callback API
- src/ui/: console, window, chatwin, mucwin, inputwin, buffer —
upstream win_warn_needed/sent dedup, PAD_MIN_HEIGHT dynamic pads;
keep our y_start_pos scroll, _truncate_datetime_suffix
- src/xmpp/: message, stanza, presence, roster_list, iq, session —
upstream connection_get_available_resources; keep our LMC stanza logic
- src/common.c: fix format-security (cons_show)
Build system:
- Makefile.am: updated test paths to subdirectory structure, added
test_cmd_ac, test_forced_encryption
- Restored autotools files deleted by upstream meson migration:
bootstrap.sh, autogen.sh, m4/ax_valgrind_check.m4, configure-debug
Tests:
- Unit tests: upstream unittests.c base + our forced_encryption tests
(482 passed, 0 failed across all 4 configurations)
- Functional tests: kept our version (93 passed, 0 failed)
upstream version requires stbbr_for_xmlns not yet in our stabber fork
- Updated test stubs: stub_xmpp.c, stub_omemo.c from upstream
Compile fixes:
- src/common.c: cons_show(errmsg) -> cons_show("%s", errmsg)
- src/database.c: null-check before msg->timestamp access
- src/ui/console.c: size_t -> (int) cast for format width
- src/config/tlscerts.c: %d -> %zu for size_t
This commit is contained in:
@@ -3,35 +3,9 @@
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
||||
* Copyright (C) 2019 - 2025 Michael Vetter <jubalh@iodoru.org>
|
||||
*
|
||||
* This file is part of Profanity.
|
||||
*
|
||||
* Profanity is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Profanity is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link the code of portions of this program with the OpenSSL library under
|
||||
* certain conditions as described in each individual source file, and
|
||||
* distribute linked combinations including the two.
|
||||
*
|
||||
* You must obey the GNU General Public License in all respects for all of the
|
||||
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
||||
* may extend this exception to your version of the file(s), but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version. If you delete this exception statement from all
|
||||
* source files in the program, then also delete it here.
|
||||
* Copyright (C) 2019 - 2026 Michael Vetter <jubalh@iodoru.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later WITH OpenSSL-exception
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -49,6 +23,7 @@
|
||||
#include "tools/autocomplete.h"
|
||||
#include "config/files.h"
|
||||
#include "config/conflists.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
// preference groups refer to the sections in .profrc or theme files
|
||||
// for example [ui] but not [colours] which is handled in theme.c
|
||||
@@ -66,6 +41,7 @@
|
||||
#define PREF_GROUP_MUC "muc"
|
||||
#define PREF_GROUP_PLUGINS "plugins"
|
||||
#define PREF_GROUP_EXECUTABLES "executables"
|
||||
#define PREF_GROUP_SPELLCHECK "spellcheck"
|
||||
|
||||
#define INPBLOCK_DEFAULT 1000
|
||||
|
||||
@@ -77,10 +53,10 @@ static Autocomplete boolean_choice_ac;
|
||||
static Autocomplete room_trigger_ac;
|
||||
|
||||
static void _save_prefs(void);
|
||||
static const char* _get_group(preference_t pref);
|
||||
static const char* _get_key(preference_t pref);
|
||||
static const gchar* _get_group(preference_t pref);
|
||||
static const gchar* _get_key(preference_t pref);
|
||||
static gboolean _get_default_boolean(preference_t pref);
|
||||
static char* _get_default_string(preference_t pref);
|
||||
static gchar* _get_default_string(preference_t pref);
|
||||
|
||||
static void
|
||||
_prefs_load(void)
|
||||
@@ -89,7 +65,7 @@ _prefs_load(void)
|
||||
log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err);
|
||||
if (err) {
|
||||
log_maxsize = 0;
|
||||
g_error_free(err);
|
||||
PROF_GERROR_FREE(err);
|
||||
}
|
||||
|
||||
// move pre 0.5.0 autoaway.time to autoaway.awaytime
|
||||
@@ -109,7 +85,7 @@ _prefs_load(void)
|
||||
// migrate pre 0.5.0 time settings
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time", NULL)) {
|
||||
auto_gchar gchar* time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL);
|
||||
char* val = time ? time : "off";
|
||||
gchar* val = time ? time : "off";
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.console", val);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.chat", val);
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.muc", val);
|
||||
@@ -178,7 +154,7 @@ _prefs_load(void)
|
||||
if (values && !g_key_file_has_key(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", NULL)) {
|
||||
// First value in array is `require_save` option -- we ignore that
|
||||
// one as there is no such option anymore.
|
||||
char* executable = values[1];
|
||||
gchar* executable = values[1];
|
||||
|
||||
g_key_file_set_string(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", executable);
|
||||
g_key_file_set_comment(prefs, PREF_GROUP_EXECUTABLES, "url.open.cmd", " Migrated from url.open.cmd[DEF]. `require_save` option has been removed in v0.10 and was discarded.", NULL);
|
||||
@@ -252,7 +228,7 @@ _prefs_load(void)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
autocomplete_add(room_trigger_ac, triggers[i]);
|
||||
}
|
||||
}
|
||||
@@ -274,7 +250,7 @@ prefs_reload(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_load(const char* config_file)
|
||||
prefs_load(const gchar* config_file)
|
||||
{
|
||||
if (config_file == NULL) {
|
||||
load_config_keyfile(&prefs_prof_keyfile, FILE_PROFRC);
|
||||
@@ -286,6 +262,77 @@ prefs_load(const char* config_file)
|
||||
_prefs_load();
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_changes_print(const gchar* key, const gchar* newval, const gchar* oldval, gboolean* banner_shown)
|
||||
{
|
||||
#define PREFS_CHANGES_FORMAT_STRING "%-32s | %-20s | %-20s"
|
||||
if (!*banner_shown) {
|
||||
cons_show(PREFS_CHANGES_FORMAT_STRING, "Key", "New value", "Old value");
|
||||
*banner_shown = TRUE;
|
||||
}
|
||||
cons_show(PREFS_CHANGES_FORMAT_STRING, key, newval, oldval);
|
||||
#undef PREFS_CHANGES_FORMAT_STRING
|
||||
}
|
||||
|
||||
void
|
||||
prefs_changes(void)
|
||||
{
|
||||
const gchar* undef = "";
|
||||
prof_keyfile_t saved;
|
||||
if (!load_custom_keyfile(&saved, g_strdup(prefs_prof_keyfile.filename)))
|
||||
return;
|
||||
gsize ngroups, nsavedgroups, g;
|
||||
auto_gcharv gchar** groups = g_key_file_get_groups(prefs_prof_keyfile.keyfile, &ngroups);
|
||||
gboolean banner_shown = FALSE;
|
||||
for (g = 0; g < ngroups; ++g) {
|
||||
gsize nkeys, k;
|
||||
gboolean saved_has_group = g_key_file_has_group(saved.keyfile, groups[g]);
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(prefs_prof_keyfile.keyfile, groups[g], &nkeys, NULL);
|
||||
for (k = 0; k < nkeys; ++k) {
|
||||
auto_gerror GError* err = NULL;
|
||||
auto_gchar gchar* full_key = g_strdup_printf("%s.%s", groups[g], keys[k]);
|
||||
auto_gchar gchar* new_value = g_key_file_get_value(prefs_prof_keyfile.keyfile, groups[g], keys[k], &err);
|
||||
if (err || !new_value) {
|
||||
cons_show_error("%s: New value (%s) error: %s", full_key, STR_MAYBE_NULL(new_value), PROF_GERROR_MESSAGE(err));
|
||||
continue;
|
||||
}
|
||||
if (!saved_has_group
|
||||
|| !g_key_file_has_key(saved.keyfile, groups[g], keys[k], NULL)) {
|
||||
prefs_changes_print(full_key, new_value, undef, &banner_shown);
|
||||
continue;
|
||||
}
|
||||
auto_gchar gchar* old_value = g_key_file_get_value(saved.keyfile, groups[g], keys[k], &err);
|
||||
if (err || !old_value) {
|
||||
cons_show_error("%s: Old value (%s) error: %s", full_key, STR_MAYBE_NULL(old_value), PROF_GERROR_MESSAGE(err));
|
||||
continue;
|
||||
}
|
||||
if (!g_str_equal(old_value, new_value)) {
|
||||
prefs_changes_print(full_key, new_value, old_value, &banner_shown);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto_gcharv gchar** savedgroups = g_key_file_get_groups(saved.keyfile, &nsavedgroups);
|
||||
for (g = 0; g < nsavedgroups; ++g) {
|
||||
gsize nkeys, k;
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(saved.keyfile, savedgroups[g], &nkeys, NULL);
|
||||
for (k = 0; k < nkeys; ++k) {
|
||||
if (g_key_file_has_key(prefs_prof_keyfile.keyfile, savedgroups[g], keys[k], NULL))
|
||||
continue;
|
||||
auto_gerror GError* err = NULL;
|
||||
auto_gchar gchar* full_key = g_strdup_printf("%s.%s", groups[g], keys[k]);
|
||||
auto_gchar gchar* old_value = g_key_file_get_value(saved.keyfile, groups[g], keys[k], &err);
|
||||
if (err || !old_value) {
|
||||
cons_show_error("%s: Old value (%s) error: %s", full_key, STR_MAYBE_NULL(old_value), PROF_GERROR_MESSAGE(err));
|
||||
continue;
|
||||
}
|
||||
prefs_changes_print(full_key, undef, old_value, &banner_shown);
|
||||
}
|
||||
}
|
||||
free_keyfile(&saved);
|
||||
if (!banner_shown)
|
||||
cons_show("No changes to saved preferences.");
|
||||
}
|
||||
|
||||
void
|
||||
prefs_save(void)
|
||||
{
|
||||
@@ -302,7 +349,7 @@ prefs_close(void)
|
||||
}
|
||||
|
||||
gchar*
|
||||
prefs_autocomplete_boolean_choice(const char* const prefix, gboolean previous, void* context)
|
||||
prefs_autocomplete_boolean_choice(const gchar* const prefix, gboolean previous, void* context)
|
||||
{
|
||||
return autocomplete_complete(boolean_choice_ac, prefix, TRUE, previous);
|
||||
}
|
||||
@@ -314,7 +361,7 @@ prefs_reset_boolean_choice(void)
|
||||
}
|
||||
|
||||
gchar*
|
||||
prefs_autocomplete_room_trigger(const char* const prefix, gboolean previous, void* context)
|
||||
prefs_autocomplete_room_trigger(const gchar* const prefix, gboolean previous, void* context)
|
||||
{
|
||||
return autocomplete_complete(room_trigger_ac, prefix, TRUE, previous);
|
||||
}
|
||||
@@ -340,7 +387,7 @@ prefs_do_chat_notify(gboolean current_win)
|
||||
}
|
||||
|
||||
GList*
|
||||
prefs_message_get_triggers(const char* const message)
|
||||
prefs_message_get_triggers(const gchar* const message)
|
||||
{
|
||||
GList* result = NULL;
|
||||
|
||||
@@ -348,7 +395,7 @@ prefs_message_get_triggers(const char* const message)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
auto_gchar gchar* trigger_lower = g_utf8_strdown(triggers[i], -1);
|
||||
if (g_strrstr(message_lower, trigger_lower)) {
|
||||
result = g_list_append(result, strdup(triggers[i]));
|
||||
@@ -359,8 +406,8 @@ prefs_message_get_triggers(const char* const message)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_do_room_notify(gboolean current_win, const char* const roomjid, const char* const mynick,
|
||||
const char* const theirnick, const char* const message, gboolean mention, gboolean trigger_found)
|
||||
prefs_do_room_notify(gboolean current_win, const gchar* const roomjid, const gchar* const mynick,
|
||||
const gchar* const theirnick, const gchar* const message, gboolean mention, gboolean trigger_found)
|
||||
{
|
||||
if (g_strcmp0(mynick, theirnick) == 0) {
|
||||
return FALSE;
|
||||
@@ -409,7 +456,7 @@ prefs_do_room_notify(gboolean current_win, const char* const roomjid, const char
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_do_room_notify_mention(const char* const roomjid, int unread, gboolean mention, gboolean trigger)
|
||||
prefs_do_room_notify_mention(const gchar* const roomjid, int unread, gboolean mention, gboolean trigger)
|
||||
{
|
||||
gboolean notify_room = FALSE;
|
||||
if (g_key_file_has_key(prefs, roomjid, "notify", NULL)) {
|
||||
@@ -445,61 +492,61 @@ prefs_do_room_notify_mention(const char* const roomjid, int unread, gboolean men
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_room_notify(const char* const roomjid, gboolean value)
|
||||
prefs_set_room_notify(const gchar* const roomjid, gboolean value)
|
||||
{
|
||||
g_key_file_set_boolean(prefs, roomjid, "notify", value);
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_room_notify_mention(const char* const roomjid, gboolean value)
|
||||
prefs_set_room_notify_mention(const gchar* const roomjid, gboolean value)
|
||||
{
|
||||
g_key_file_set_boolean(prefs, roomjid, "notify.mention", value);
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_room_notify_trigger(const char* const roomjid, gboolean value)
|
||||
prefs_set_room_notify_trigger(const gchar* const roomjid, gboolean value)
|
||||
{
|
||||
g_key_file_set_boolean(prefs, roomjid, "notify.trigger", value);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_has_room_notify(const char* const roomjid)
|
||||
prefs_has_room_notify(const gchar* const roomjid)
|
||||
{
|
||||
return g_key_file_has_key(prefs, roomjid, "notify", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_has_room_notify_mention(const char* const roomjid)
|
||||
prefs_has_room_notify_mention(const gchar* const roomjid)
|
||||
{
|
||||
return g_key_file_has_key(prefs, roomjid, "notify.mention", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_has_room_notify_trigger(const char* const roomjid)
|
||||
prefs_has_room_notify_trigger(const gchar* const roomjid)
|
||||
{
|
||||
return g_key_file_has_key(prefs, roomjid, "notify.trigger", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_get_room_notify(const char* const roomjid)
|
||||
prefs_get_room_notify(const gchar* const roomjid)
|
||||
{
|
||||
return g_key_file_get_boolean(prefs, roomjid, "notify", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_get_room_notify_mention(const char* const roomjid)
|
||||
prefs_get_room_notify_mention(const gchar* const roomjid)
|
||||
{
|
||||
return g_key_file_get_boolean(prefs, roomjid, "notify.mention", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_get_room_notify_trigger(const char* const roomjid)
|
||||
prefs_get_room_notify_trigger(const gchar* const roomjid)
|
||||
{
|
||||
return g_key_file_get_boolean(prefs, roomjid, "notify.trigger", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_reset_room_notify(const char* const roomjid)
|
||||
prefs_reset_room_notify(const gchar* const roomjid)
|
||||
{
|
||||
if (g_key_file_has_group(prefs, roomjid)) {
|
||||
g_key_file_remove_group(prefs, roomjid, NULL);
|
||||
@@ -512,8 +559,8 @@ prefs_reset_room_notify(const char* const roomjid)
|
||||
gboolean
|
||||
prefs_get_boolean(preference_t pref)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
gboolean def = _get_default_boolean(pref);
|
||||
|
||||
if (!g_key_file_has_key(prefs, group, key, NULL)) {
|
||||
@@ -526,8 +573,8 @@ prefs_get_boolean(preference_t pref)
|
||||
void
|
||||
prefs_set_boolean(preference_t pref, gboolean value)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
g_key_file_set_boolean(prefs, group, key, value);
|
||||
}
|
||||
|
||||
@@ -542,9 +589,9 @@ prefs_set_boolean(preference_t pref, gboolean value)
|
||||
gchar*
|
||||
prefs_get_string(preference_t pref)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
char* def = _get_default_string(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
gchar* def = _get_default_string(pref);
|
||||
|
||||
gchar* result = g_key_file_get_string(prefs, group, key, NULL);
|
||||
|
||||
@@ -571,9 +618,9 @@ prefs_get_string(preference_t pref)
|
||||
gchar*
|
||||
prefs_get_string_with_locale(preference_t pref, gchar* locale)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
char* def = _get_default_string(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
gchar* def = _get_default_string(pref);
|
||||
|
||||
gchar* result = g_key_file_get_locale_string(prefs, group, key, locale, NULL);
|
||||
|
||||
@@ -602,8 +649,8 @@ prefs_get_string_with_locale(preference_t pref, gchar* locale)
|
||||
void
|
||||
prefs_set_string(preference_t pref, const gchar* new_value)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
if (new_value == NULL) {
|
||||
g_key_file_remove_key(prefs, group, key, NULL);
|
||||
} else {
|
||||
@@ -612,10 +659,10 @@ prefs_set_string(preference_t pref, const gchar* new_value)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_string_with_option(preference_t pref, char* option, char* value)
|
||||
prefs_set_string_with_option(preference_t pref, gchar* option, gchar* value)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
if (value == NULL) {
|
||||
g_key_file_remove_key(prefs, group, key, NULL);
|
||||
} else {
|
||||
@@ -624,10 +671,10 @@ prefs_set_string_with_option(preference_t pref, char* option, char* value)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_string_list_with_option(preference_t pref, char* option, const gchar* const* values)
|
||||
prefs_set_string_list_with_option(preference_t pref, gchar* option, const gchar* const* values)
|
||||
{
|
||||
const char* group = _get_group(pref);
|
||||
const char* key = _get_key(pref);
|
||||
const gchar* group = _get_group(pref);
|
||||
const gchar* key = _get_key(pref);
|
||||
if (values == NULL || *values == NULL) {
|
||||
if (g_strcmp0(option, "*") == 0) {
|
||||
g_key_file_set_string_list(prefs, group, key, NULL, 0);
|
||||
@@ -647,11 +694,11 @@ prefs_set_string_list_with_option(preference_t pref, char* option, const gchar*
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
gchar*
|
||||
prefs_get_tls_certpath(void)
|
||||
{
|
||||
const char* group = _get_group(PREF_TLS_CERTPATH);
|
||||
const char* key = _get_key(PREF_TLS_CERTPATH);
|
||||
const gchar* group = _get_group(PREF_TLS_CERTPATH);
|
||||
const gchar* key = _get_key(PREF_TLS_CERTPATH);
|
||||
|
||||
auto_gchar gchar* setting = g_key_file_get_string(prefs, group, key, NULL);
|
||||
|
||||
@@ -679,7 +726,7 @@ prefs_get_tls_certpath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* result = strdup(setting);
|
||||
gchar* result = g_strdup(setting);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -883,14 +930,14 @@ prefs_get_plugins(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_add_plugin(const char* const name)
|
||||
prefs_add_plugin(const gchar* const name)
|
||||
{
|
||||
conf_string_list_add(prefs, PREF_GROUP_PLUGINS, "load", name);
|
||||
_save_prefs();
|
||||
}
|
||||
|
||||
void
|
||||
prefs_remove_plugin(const char* const name)
|
||||
prefs_remove_plugin(const gchar* const name)
|
||||
{
|
||||
conf_string_list_remove(prefs, PREF_GROUP_PLUGINS, "load", name);
|
||||
_save_prefs();
|
||||
@@ -924,7 +971,7 @@ prefs_get_occupants_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_occupants_char(char* ch)
|
||||
prefs_set_occupants_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.char", ch);
|
||||
@@ -969,7 +1016,7 @@ prefs_get_occupants_header_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_occupants_header_char(char* ch)
|
||||
prefs_set_occupants_header_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.header.char", ch);
|
||||
@@ -1003,7 +1050,7 @@ prefs_get_roster_size(void)
|
||||
}
|
||||
|
||||
static gchar*
|
||||
_prefs_get_encryption_char(const char* const ch, const char* const pref_group, const char* const key)
|
||||
_prefs_get_encryption_char(const gchar* const ch, const gchar* const pref_group, const gchar* const key)
|
||||
{
|
||||
gchar* result = NULL;
|
||||
|
||||
@@ -1018,7 +1065,7 @@ _prefs_get_encryption_char(const char* const ch, const char* const pref_group, c
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_prefs_set_encryption_char(const char* const ch, const char* const pref_group, const char* const key)
|
||||
_prefs_set_encryption_char(const gchar* const ch, const gchar* const pref_group, const gchar* const key)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, pref_group, key, ch);
|
||||
@@ -1036,7 +1083,7 @@ prefs_get_otr_char(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_set_otr_char(char* ch)
|
||||
prefs_set_otr_char(gchar* ch)
|
||||
{
|
||||
return _prefs_set_encryption_char(ch, PREF_GROUP_OTR, "otr.char");
|
||||
}
|
||||
@@ -1048,7 +1095,7 @@ prefs_get_pgp_char(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_set_pgp_char(char* ch)
|
||||
prefs_set_pgp_char(gchar* ch)
|
||||
{
|
||||
return _prefs_set_encryption_char(ch, PREF_GROUP_PGP, "pgp.char");
|
||||
}
|
||||
@@ -1060,7 +1107,7 @@ prefs_get_ox_char(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_set_ox_char(char* ch)
|
||||
prefs_set_ox_char(gchar* ch)
|
||||
{
|
||||
return _prefs_set_encryption_char(ch, PREF_GROUP_OX, "ox.char");
|
||||
}
|
||||
@@ -1072,7 +1119,7 @@ prefs_get_omemo_char(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_set_omemo_char(char* ch)
|
||||
prefs_set_omemo_char(gchar* ch)
|
||||
{
|
||||
return _prefs_set_encryption_char(ch, PREF_GROUP_OMEMO, "omemo.char");
|
||||
}
|
||||
@@ -1084,7 +1131,7 @@ prefs_get_roster_header_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_header_char(char* ch)
|
||||
prefs_set_roster_header_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.header.char", ch);
|
||||
@@ -1106,7 +1153,7 @@ prefs_get_roster_contact_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_contact_char(char* ch)
|
||||
prefs_set_roster_contact_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.contact.char", ch);
|
||||
@@ -1128,7 +1175,7 @@ prefs_get_roster_resource_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_resource_char(char* ch)
|
||||
prefs_set_roster_resource_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.resource.char", ch);
|
||||
@@ -1150,7 +1197,7 @@ prefs_get_roster_private_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_private_char(char* ch)
|
||||
prefs_set_roster_private_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.private.char", ch);
|
||||
@@ -1172,7 +1219,7 @@ prefs_get_roster_room_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_room_char(char* ch)
|
||||
prefs_set_roster_room_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.char", ch);
|
||||
@@ -1194,7 +1241,7 @@ prefs_get_roster_room_private_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_roster_room_private_char(char* ch)
|
||||
prefs_set_roster_room_private_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", ch);
|
||||
@@ -1281,7 +1328,7 @@ prefs_get_correction_char(void)
|
||||
}
|
||||
|
||||
void
|
||||
prefs_set_correction_char(char* ch)
|
||||
prefs_set_correction_char(gchar* ch)
|
||||
{
|
||||
if (g_utf8_strlen(ch, 4) == 1) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, "correction.char", ch);
|
||||
@@ -1291,7 +1338,7 @@ prefs_set_correction_char(char* ch)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_add_room_notify_trigger(const char* const text)
|
||||
prefs_add_room_notify_trigger(const gchar* const text)
|
||||
{
|
||||
gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
|
||||
|
||||
@@ -1303,7 +1350,7 @@ prefs_add_room_notify_trigger(const char* const text)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_remove_room_notify_trigger(const char* const text)
|
||||
prefs_remove_room_notify_trigger(const gchar* const text)
|
||||
{
|
||||
gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
|
||||
_save_prefs();
|
||||
@@ -1322,7 +1369,7 @@ prefs_get_room_notify_triggers(void)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
result = g_list_append(result, strdup(triggers[i]));
|
||||
}
|
||||
|
||||
@@ -1332,7 +1379,7 @@ prefs_get_room_notify_triggers(void)
|
||||
ProfWinPlacement*
|
||||
prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin)
|
||||
{
|
||||
ProfWinPlacement* placement = malloc(sizeof(ProfWinPlacement));
|
||||
ProfWinPlacement* placement = g_new0(ProfWinPlacement, 1);
|
||||
placement->titlebar_pos = titlebar;
|
||||
placement->mainwin_pos = mainwin;
|
||||
placement->statusbar_pos = statusbar;
|
||||
@@ -1623,7 +1670,7 @@ prefs_inputwin_pos_down(void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_add_alias(const char* const name, const char* const value)
|
||||
prefs_add_alias(const gchar* const name, const gchar* const value)
|
||||
{
|
||||
if (g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
|
||||
return FALSE;
|
||||
@@ -1634,13 +1681,13 @@ prefs_add_alias(const char* const name, const char* const value)
|
||||
}
|
||||
|
||||
gchar*
|
||||
prefs_get_alias(const char* const name)
|
||||
prefs_get_alias(const gchar* const name)
|
||||
{
|
||||
return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_remove_alias(const char* const name)
|
||||
prefs_remove_alias(const gchar* const name)
|
||||
{
|
||||
if (!g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
|
||||
return FALSE;
|
||||
@@ -1669,14 +1716,14 @@ prefs_get_aliases(void)
|
||||
gsize len;
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
char* name = keys[i];
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
gchar* name = keys[i];
|
||||
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
||||
|
||||
if (value) {
|
||||
ProfAlias* alias = malloc(sizeof(struct prof_alias_t));
|
||||
alias->name = strdup(name);
|
||||
alias->value = strdup(value);
|
||||
ProfAlias* alias = g_new0(struct prof_alias_t, 1);
|
||||
alias->name = g_strdup(name);
|
||||
alias->value = g_strdup(value);
|
||||
|
||||
result = g_list_insert_sorted(result, alias, (GCompareFunc)_alias_cmp);
|
||||
}
|
||||
@@ -1689,9 +1736,9 @@ prefs_get_aliases(void)
|
||||
void
|
||||
_free_alias(ProfAlias* alias)
|
||||
{
|
||||
FREE_SET_NULL(alias->name);
|
||||
FREE_SET_NULL(alias->value);
|
||||
FREE_SET_NULL(alias);
|
||||
GFREE_SET_NULL(alias->name);
|
||||
GFREE_SET_NULL(alias->value);
|
||||
GFREE_SET_NULL(alias);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1709,7 +1756,7 @@ _save_prefs(void)
|
||||
// get the preference group for a specific preference
|
||||
// for example the PREF_BEEP setting ("beep" in .profrc, see _get_key) belongs
|
||||
// to the [ui] section.
|
||||
static const char*
|
||||
static const gchar*
|
||||
_get_group(preference_t pref)
|
||||
{
|
||||
switch (pref) {
|
||||
@@ -1865,6 +1912,9 @@ _get_group(preference_t pref)
|
||||
return PREF_GROUP_OMEMO;
|
||||
case PREF_OX_LOG:
|
||||
return PREF_GROUP_OX;
|
||||
case PREF_SPELLCHECK_ENABLE:
|
||||
case PREF_SPELLCHECK_LANG:
|
||||
return PREF_GROUP_SPELLCHECK;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -1872,7 +1922,7 @@ _get_group(preference_t pref)
|
||||
|
||||
// get the key used in .profrc for the preference
|
||||
// for example the PREF_AUTOAWAY_MODE maps to "autoaway.mode" in .profrc
|
||||
static const char*
|
||||
static const gchar*
|
||||
_get_key(preference_t pref)
|
||||
{
|
||||
switch (pref) {
|
||||
@@ -2156,6 +2206,10 @@ _get_key(preference_t pref)
|
||||
return "force-encryption.enabled";
|
||||
case PREF_FORCE_ENCRYPTION_MODE:
|
||||
return "force-encryption.policy";
|
||||
case PREF_SPELLCHECK_ENABLE:
|
||||
return "enabled";
|
||||
case PREF_SPELLCHECK_LANG:
|
||||
return "lang";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -2209,6 +2263,7 @@ _get_default_boolean(preference_t pref)
|
||||
case PREF_STROPHE_SM_ENABLED:
|
||||
case PREF_STROPHE_SM_RESEND:
|
||||
return TRUE;
|
||||
case PREF_SPELLCHECK_ENABLE:
|
||||
case PREF_PGP_PUBKEY_AUTOIMPORT:
|
||||
case PREF_FORCE_ENCRYPTION:
|
||||
default:
|
||||
@@ -2218,7 +2273,7 @@ _get_default_boolean(preference_t pref)
|
||||
|
||||
// the default setting for a string type preference
|
||||
// if it is not specified in .profrc
|
||||
static char*
|
||||
static gchar*
|
||||
_get_default_string(preference_t pref)
|
||||
{
|
||||
switch (pref) {
|
||||
@@ -2319,6 +2374,8 @@ _get_default_string(preference_t pref)
|
||||
return "on";
|
||||
case PREF_FORCE_ENCRYPTION_MODE:
|
||||
return "resend-to-confirm";
|
||||
case PREF_SPELLCHECK_LANG:
|
||||
return "en_US";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user