merge: sync upstream profanity-im/profanity
All checks were successful
CI Code / Check spelling (push) Successful in 18s
CI Code / Check coding style (push) Successful in 34s
CI Code / Code Coverage (push) Successful in 2m36s
CI Code / Linux (debian) (push) Successful in 4m41s
CI Code / Linux (ubuntu) (push) Successful in 4m52s
CI Code / Linux (arch) (push) Successful in 5m40s
All checks were successful
CI Code / Check spelling (push) Successful in 18s
CI Code / Check coding style (push) Successful in 34s
CI Code / Code Coverage (push) Successful in 2m36s
CI Code / Linux (debian) (push) Successful in 4m41s
CI Code / Linux (ubuntu) (push) Successful in 4m52s
CI Code / Linux (arch) (push) Successful in 5m40s
Sync with upstream profanity-im/profanity.
Major upstream changes incorporated:
Memory management
- Replace malloc+memset with g_new0 throughout codebase
- Adopt auto_gchar / auto_gcharv / auto_gerror / auto_jid cleanup macros
- Replace free() with g_free() for GAlloc'd memory
Editor rewrite
- Remove pthread-based async editor; use GChildWatch callback API
- New launch_editor(initial_content, callback, user_data) interface
- Proper signal handling (SIGINT, SIGTSTP, SIGPIPE reset in child)
- ui_suspend()/ui_resume() integration for TTY management
OMEMO improvements
- Dual backend support: libsignal-protocol-c and libomemo-c
- Proper pre-key removal after use (XEP-0384 compliance)
- Automatic pre-key regeneration when store drops below threshold
- New functions: omemo_is_device_active(), omemo_is_jid_trusted()
- omemo_get_jid_untrusted_fingerprints() for better error messages
- Fingerprint notifications on new device identity discovery
- Deterministic pre-key ID generation tracking max_pre_key_id
- omemo_trust_changed() UI updates on trust state changes
JID validation
- RFC 6122-compliant validation in jid_is_valid()
- Character-level checks (RFC 6122 forbidden chars: & ' / : < > @)
- Length limits: 1023 per component, 3071 total
- New jid_is_valid_user_jid() for user vs. service JID distinction
Database
- Schema migration v3: UNIQUE constraint on archive_id for deduplication
- Triggers for corrected message tracking (replaces_db_id / replaced_by_db_id)
- db_history_result_t return type, _truncate_datetime_suffix()
UI / console
- win_warn_needed() / win_warn_sent() warning deduplication hash table
- PAD_MIN_HEIGHT dynamic pad sizing with PAD_THRESHOLD auto-cleanup
- Spellcheck integration in input field with Unicode word detection
- cons_spellcheck_setting() for /settings ui output
- /[command]? shortcut for command help
Account config
- Account name sanitization for GKeyFile special chars ([ ] = # \n \r)
- Replace popen() with g_spawn_sync() for eval_password
- TLS policy: add "direct" option alongside legacy
Connection
- Port validation with g_assert (0–65535)
- SHA-256 certificate fingerprint support (XMPP_CERT_PUBKEY_FINGERPRINT_SHA256)
- "direct" TLS policy alias for legacy SSL
Common utilities
- str_xml_sanitize() for XML 1.0 illegal character removal
- string_matches_one_of() with formatted error messages
- valid_tls_policy_option() helper
- prof_date_time_format_iso8601() utility
- Improved strip_arg_quotes() with backslash unescaping
- prof_occurrences() uses g_slist_prepend + reverse for performance
PGP / OX
- Proper GPGME resource cleanup with goto-cleanup pattern
- g_string_free(xmppuri) leak fix in _ox_key_lookup
CSV export
- Use GString + g_file_set_contents instead of raw write() syscalls
Tests
- Restructured into subdirectories: command/, config/, xmpp/, ui/, omemo/, otr/, pgp/
- New test_cmd_ac.c for autocompleter unit tests
- Updated stubs for new UI suspend/resume functions
License headers
- Migrate to SPDX-3.0 identifiers (GPL-3.0-or-later WITH OpenSSL-exception)
────────────────────────────────────────────────────
cproof-specific preservations:
- XEP-0308 LMC: replace_id ?: id logic in message/stanza/omemo
- Force encryption: cmd_force_encryption, test_forced_encryption
- CWE-134: format string protection (cons_show("%s", ...))
- y_start_pos-based paging in window.c
- db_history_result_t return type, _truncate_datetime_suffix()
Merge-time fixes:
- common.c: format-security (-Werror) — cons_show(errmsg) → cons_show("%s", errmsg)
- database.c: null-deref guard — !msg->timestamp → msg && !msg->timestamp
- console.c: implicit size_t → int cast — (int)(maxlen + 1)
- tlscerts.c: %d for size_t — %zu
Build system:
- Kept autotools (Makefile.am, configure.ac); upstream uses Meson
- Restored deleted files: bootstrap.sh, autogen.sh, ax_valgrind_check.m4, configure-debug
- Updated Makefile.am test paths for subdirectory structure
- Added test_cmd_ac, test_forced_encryption to test sources
Functional tests:
- Use cproof version; upstream requires stbbr_for_xmlns from updated stabber
- Not yet available in devs/stabber fork
Closes #64
Merge author: jabber.developer2
Commits authors:
Michael Vetter <jubalh@iodoru.org>
& Steffen Jaeckel <s@jaeckel.eu>
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 PREF_GROUP_AI "ai"
|
||||
#define PREF_GROUP_AI_PREFIX "ai/" /* per-provider subsection prefix: [ai/<provider>] */
|
||||
#define PREF_AI_SETTING_PREFIX "setting." /* per-provider custom setting key prefix */
|
||||
@@ -80,10 +56,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)
|
||||
@@ -92,7 +68,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
|
||||
@@ -112,7 +88,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);
|
||||
@@ -181,7 +157,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);
|
||||
@@ -318,7 +294,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]);
|
||||
}
|
||||
}
|
||||
@@ -340,7 +316,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);
|
||||
@@ -352,6 +328,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)
|
||||
{
|
||||
@@ -368,7 +415,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);
|
||||
}
|
||||
@@ -380,7 +427,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);
|
||||
}
|
||||
@@ -406,7 +453,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;
|
||||
|
||||
@@ -414,7 +461,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]));
|
||||
@@ -425,8 +472,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;
|
||||
@@ -475,7 +522,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)) {
|
||||
@@ -511,61 +558,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);
|
||||
@@ -578,8 +625,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)) {
|
||||
@@ -592,8 +639,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);
|
||||
}
|
||||
|
||||
@@ -608,9 +655,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);
|
||||
|
||||
@@ -637,9 +684,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);
|
||||
|
||||
@@ -668,8 +715,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 {
|
||||
@@ -678,10 +725,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 {
|
||||
@@ -690,10 +737,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);
|
||||
@@ -713,11 +760,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);
|
||||
|
||||
@@ -745,7 +792,7 @@ prefs_get_tls_certpath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* result = strdup(setting);
|
||||
gchar* result = g_strdup(setting);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -949,14 +996,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();
|
||||
@@ -990,7 +1037,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);
|
||||
@@ -1035,7 +1082,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);
|
||||
@@ -1069,7 +1116,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;
|
||||
|
||||
@@ -1084,7 +1131,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);
|
||||
@@ -1102,7 +1149,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");
|
||||
}
|
||||
@@ -1114,7 +1161,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");
|
||||
}
|
||||
@@ -1126,7 +1173,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");
|
||||
}
|
||||
@@ -1138,7 +1185,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");
|
||||
}
|
||||
@@ -1150,7 +1197,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);
|
||||
@@ -1172,7 +1219,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);
|
||||
@@ -1194,7 +1241,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);
|
||||
@@ -1216,7 +1263,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);
|
||||
@@ -1238,7 +1285,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);
|
||||
@@ -1260,7 +1307,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);
|
||||
@@ -1347,7 +1394,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);
|
||||
@@ -1357,7 +1404,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);
|
||||
|
||||
@@ -1369,7 +1416,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();
|
||||
@@ -1388,7 +1435,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]));
|
||||
}
|
||||
|
||||
@@ -1398,7 +1445,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;
|
||||
@@ -1689,7 +1736,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;
|
||||
@@ -1700,13 +1747,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;
|
||||
@@ -1735,14 +1782,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);
|
||||
}
|
||||
@@ -1755,9 +1802,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
|
||||
@@ -2135,7 +2182,7 @@ prefs_free_ai_settings(GList* settings)
|
||||
// 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) {
|
||||
@@ -2292,6 +2339,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;
|
||||
case PREF_AI_PROVIDER:
|
||||
case PREF_AI_API_KEY:
|
||||
return PREF_GROUP_AI;
|
||||
@@ -2302,7 +2352,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) {
|
||||
@@ -2592,6 +2642,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;
|
||||
}
|
||||
@@ -2646,6 +2700,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:
|
||||
@@ -2655,7 +2710,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) {
|
||||
@@ -2756,6 +2811,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";
|
||||
case PREF_AI_PROVIDER:
|
||||
return "openai";
|
||||
case PREF_AI_API_KEY:
|
||||
|
||||
Reference in New Issue
Block a user