2012-10-21 15:02:20 -04:00
|
|
|
/*
|
2012-05-09 22:29:48 -04:00
|
|
|
* preferences.c
|
2019-11-13 06:11:05 -05:00
|
|
|
* vim: expandtab:ts=4:sts=4:sw=4
|
2012-05-09 22:29:48 -04:00
|
|
|
*
|
2019-01-22 05:31:45 -05:00
|
|
|
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
2020-01-03 13:52:31 -05:00
|
|
|
* Copyright (C) 2019 - 2020 Michael Vetter <jubalh@iodoru.org>
|
2012-10-21 15:02:20 -04:00
|
|
|
*
|
2012-05-09 22:29:48 -04:00
|
|
|
* 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
|
2016-07-23 20:14:49 -04:00
|
|
|
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
2012-05-09 22:29:48 -04:00
|
|
|
*
|
2014-08-24 15:57:39 -04:00
|
|
|
* 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.
|
|
|
|
*
|
2012-05-09 22:29:48 -04:00
|
|
|
*/
|
|
|
|
|
2016-03-31 16:05:02 -04:00
|
|
|
#include "config.h"
|
2013-02-02 15:55:58 -05:00
|
|
|
|
2012-05-09 22:37:24 -04:00
|
|
|
#include <stdlib.h>
|
2014-01-20 13:40:48 -05:00
|
|
|
#include <stdio.h>
|
2012-05-10 17:18:08 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-05-09 22:29:48 -04:00
|
|
|
#include <glib.h>
|
2014-10-18 16:26:38 -04:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2013-02-02 17:18:08 -05:00
|
|
|
#include "common.h"
|
2013-02-02 15:55:58 -05:00
|
|
|
#include "log.h"
|
2013-02-02 17:18:08 -05:00
|
|
|
#include "preferences.h"
|
2013-02-02 16:43:59 -05:00
|
|
|
#include "tools/autocomplete.h"
|
2016-07-24 11:22:15 -04:00
|
|
|
#include "config/files.h"
|
2015-11-23 19:38:33 -05:00
|
|
|
#include "config/conflists.h"
|
2012-05-10 18:51:06 -04:00
|
|
|
|
2020-01-29 05:50:04 -05:00
|
|
|
// preference groups refer to the sections in .profrc or theme files
|
|
|
|
// for example [ui] but not [colours] which is handled in theme.c
|
2013-02-02 21:35:04 -05:00
|
|
|
#define PREF_GROUP_LOGGING "logging"
|
|
|
|
#define PREF_GROUP_CHATSTATES "chatstates"
|
|
|
|
#define PREF_GROUP_UI "ui"
|
|
|
|
#define PREF_GROUP_NOTIFICATIONS "notifications"
|
|
|
|
#define PREF_GROUP_PRESENCE "presence"
|
|
|
|
#define PREF_GROUP_CONNECTION "connection"
|
2014-01-23 17:29:53 -05:00
|
|
|
#define PREF_GROUP_ALIAS "alias"
|
2014-05-11 08:13:25 -04:00
|
|
|
#define PREF_GROUP_OTR "otr"
|
2015-06-21 16:42:58 -04:00
|
|
|
#define PREF_GROUP_PGP "pgp"
|
2019-02-26 13:53:06 -05:00
|
|
|
#define PREF_GROUP_OMEMO "omemo"
|
2016-05-23 18:53:44 -04:00
|
|
|
#define PREF_GROUP_MUC "muc"
|
2017-02-05 17:37:48 -05:00
|
|
|
#define PREF_GROUP_PLUGINS "plugins"
|
2013-02-02 21:35:04 -05:00
|
|
|
|
2015-02-10 18:40:23 -05:00
|
|
|
#define INPBLOCK_DEFAULT 1000
|
2014-12-21 13:15:29 -05:00
|
|
|
|
2016-07-24 16:35:12 -04:00
|
|
|
static char *prefs_loc;
|
2012-05-10 04:55:55 -04:00
|
|
|
static GKeyFile *prefs;
|
2012-11-12 04:13:03 -05:00
|
|
|
gint log_maxsize = 0;
|
2012-05-09 22:29:48 -04:00
|
|
|
|
2013-01-24 20:11:49 -05:00
|
|
|
static Autocomplete boolean_choice_ac;
|
2015-11-23 20:34:06 -05:00
|
|
|
static Autocomplete room_trigger_ac;
|
2012-05-10 17:44:23 -04:00
|
|
|
|
2012-05-10 05:12:02 -04:00
|
|
|
static void _save_prefs(void);
|
2015-10-25 18:23:38 -04:00
|
|
|
static const char* _get_group(preference_t pref);
|
|
|
|
static const char* _get_key(preference_t pref);
|
2013-02-02 21:51:15 -05:00
|
|
|
static gboolean _get_default_boolean(preference_t pref);
|
2015-10-25 18:23:38 -04:00
|
|
|
static char* _get_default_string(preference_t pref);
|
2012-05-10 05:02:03 -04:00
|
|
|
|
2019-10-04 08:06:25 -04:00
|
|
|
void _prefs_load(void)
|
2012-05-09 22:29:48 -04:00
|
|
|
{
|
2019-10-04 08:06:25 -04:00
|
|
|
GError *err = NULL;
|
2013-02-02 21:35:04 -05:00
|
|
|
log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err);
|
2015-05-04 17:33:19 -04:00
|
|
|
if (err) {
|
2012-11-12 04:13:03 -05:00
|
|
|
log_maxsize = 0;
|
|
|
|
g_error_free(err);
|
|
|
|
}
|
|
|
|
|
2015-12-01 19:34:27 -05:00
|
|
|
// move pre 0.5.0 autoaway.time to autoaway.awaytime
|
2015-09-27 18:08:30 -04:00
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL)) {
|
|
|
|
gint time = g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL);
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.awaytime", time);
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL);
|
|
|
|
}
|
|
|
|
|
2015-12-01 19:34:27 -05:00
|
|
|
// move pre 0.5.0 autoaway.message to autoaway.awaymessage
|
2015-09-27 18:08:30 -04:00
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL)) {
|
|
|
|
char *message = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_PRESENCE, "autoaway.awaymessage", message);
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
|
|
|
|
prefs_free_string(message);
|
|
|
|
}
|
|
|
|
|
2015-12-01 19:34:27 -05:00
|
|
|
// migrate pre 0.5.0 time settings
|
2015-07-02 11:31:09 -04:00
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time", NULL)) {
|
|
|
|
char *time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL);
|
2015-09-30 17:34:27 -04:00
|
|
|
char *val = NULL;
|
|
|
|
if (time) {
|
|
|
|
val = time;
|
|
|
|
} else {
|
|
|
|
val = "off";
|
2015-07-02 11:31:09 -04:00
|
|
|
}
|
2015-09-30 17:34:27 -04:00
|
|
|
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);
|
2018-04-11 12:57:50 -04:00
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.config", val);
|
2015-09-30 17:34:27 -04:00
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.private", val);
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "time.xmlconsole", val);
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "time", NULL);
|
2015-08-08 19:20:17 -04:00
|
|
|
prefs_free_string(time);
|
2015-07-02 11:31:09 -04:00
|
|
|
}
|
|
|
|
|
2015-12-01 19:34:27 -05:00
|
|
|
// move pre 0.5.0 notify settings
|
2015-11-25 16:24:21 -05:00
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL)) {
|
|
|
|
char *value = g_key_file_get_string(prefs, PREF_GROUP_NOTIFICATIONS, "room", NULL);
|
|
|
|
if (g_strcmp0(value, "on") == 0) {
|
|
|
|
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room", TRUE);
|
|
|
|
} else if (g_strcmp0(value, "off") == 0) {
|
|
|
|
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room", FALSE);
|
|
|
|
} else if (g_strcmp0(value, "mention") == 0) {
|
|
|
|
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room", FALSE);
|
|
|
|
g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "room.mention", TRUE);
|
|
|
|
}
|
2016-02-13 20:34:34 -05:00
|
|
|
prefs_free_string(value);
|
2015-11-25 16:24:21 -05:00
|
|
|
}
|
|
|
|
|
2016-09-22 19:56:53 -04:00
|
|
|
// move pre 0.6.0 titlebar settings to wintitle
|
2016-09-22 16:42:00 -04:00
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.show", NULL)) {
|
|
|
|
gboolean show = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.show", NULL);
|
|
|
|
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "wintitle.show", show);
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.show", NULL);
|
|
|
|
}
|
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL)) {
|
|
|
|
gboolean goodbye = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL);
|
|
|
|
g_key_file_set_boolean(prefs, PREF_GROUP_UI, "wintitle.goodbye", goodbye);
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL);
|
|
|
|
}
|
|
|
|
|
2014-05-11 08:13:25 -04:00
|
|
|
_save_prefs();
|
|
|
|
|
2013-01-24 20:11:49 -05:00
|
|
|
boolean_choice_ac = autocomplete_new();
|
2013-08-25 20:29:50 -04:00
|
|
|
autocomplete_add(boolean_choice_ac, "on");
|
|
|
|
autocomplete_add(boolean_choice_ac, "off");
|
2015-11-23 20:34:06 -05:00
|
|
|
|
|
|
|
room_trigger_ac = autocomplete_new();
|
2015-11-28 18:43:02 -05:00
|
|
|
gsize len = 0;
|
|
|
|
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
2015-11-23 20:34:06 -05:00
|
|
|
|
2015-11-28 18:43:02 -05:00
|
|
|
int i = 0;
|
2015-11-23 20:34:06 -05:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
autocomplete_add(room_trigger_ac, triggers[i]);
|
|
|
|
}
|
|
|
|
g_strfreev(triggers);
|
2012-06-18 17:16:57 -04:00
|
|
|
}
|
|
|
|
|
2019-10-04 08:06:25 -04:00
|
|
|
void
|
|
|
|
prefs_reload(void)
|
|
|
|
{
|
|
|
|
g_key_file_free(prefs);
|
|
|
|
prefs = NULL;
|
|
|
|
|
|
|
|
prefs = g_key_file_new();
|
|
|
|
g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
|
|
|
|
|
|
_prefs_load();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_load(char *config_file)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (config_file == NULL) {
|
|
|
|
prefs_loc = files_get_config_path(FILE_PROFRC);
|
|
|
|
} else {
|
|
|
|
prefs_loc = config_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_file_test(prefs_loc, G_FILE_TEST_EXISTS)) {
|
|
|
|
g_chmod(prefs_loc, S_IRUSR | S_IWUSR);
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs = g_key_file_new();
|
|
|
|
g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
|
|
|
|
|
|
_prefs_load();
|
|
|
|
}
|
|
|
|
|
2019-08-02 04:23:13 -04:00
|
|
|
void
|
|
|
|
prefs_save(void)
|
|
|
|
{
|
|
|
|
_save_prefs();
|
|
|
|
}
|
|
|
|
|
2012-07-31 18:01:15 -04:00
|
|
|
void
|
|
|
|
prefs_close(void)
|
|
|
|
{
|
2013-01-24 20:11:49 -05:00
|
|
|
autocomplete_free(boolean_choice_ac);
|
2015-11-23 20:34:06 -05:00
|
|
|
autocomplete_free(room_trigger_ac);
|
2019-10-05 14:45:07 -04:00
|
|
|
|
2012-07-31 18:01:15 -04:00
|
|
|
g_key_file_free(prefs);
|
2014-01-20 13:40:48 -05:00
|
|
|
prefs = NULL;
|
2019-10-05 14:45:07 -04:00
|
|
|
|
|
|
|
free(prefs_loc);
|
|
|
|
prefs_loc = NULL;
|
2012-07-31 18:01:15 -04:00
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
char*
|
2020-01-30 17:44:43 -05:00
|
|
|
prefs_autocomplete_boolean_choice(const char *const prefix, gboolean previous, void *context)
|
2012-10-22 17:15:06 -04:00
|
|
|
{
|
2017-03-31 19:27:11 -04:00
|
|
|
return autocomplete_complete(boolean_choice_ac, prefix, TRUE, previous);
|
2012-10-22 17:15:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_reset_boolean_choice(void)
|
|
|
|
{
|
2013-01-24 20:11:49 -05:00
|
|
|
autocomplete_reset(boolean_choice_ac);
|
2012-05-09 22:29:48 -04:00
|
|
|
}
|
2012-05-10 04:55:55 -04:00
|
|
|
|
2015-11-23 20:34:06 -05:00
|
|
|
char*
|
2020-01-30 17:44:43 -05:00
|
|
|
prefs_autocomplete_room_trigger(const char *const prefix, gboolean previous, void *context)
|
2015-11-23 20:34:06 -05:00
|
|
|
{
|
2017-03-31 19:27:11 -04:00
|
|
|
return autocomplete_complete(room_trigger_ac, prefix, TRUE, previous);
|
2015-11-23 20:34:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_reset_room_trigger_ac(void)
|
|
|
|
{
|
|
|
|
autocomplete_reset(room_trigger_ac);
|
|
|
|
}
|
|
|
|
|
2015-11-24 18:03:52 -05:00
|
|
|
gboolean
|
2016-02-03 19:21:38 -05:00
|
|
|
prefs_do_chat_notify(gboolean current_win)
|
2015-11-24 18:03:52 -05:00
|
|
|
{
|
2016-02-03 19:35:10 -05:00
|
|
|
if (prefs_get_boolean(PREF_NOTIFY_CHAT) == FALSE) {
|
2015-11-24 20:42:27 -05:00
|
|
|
return FALSE;
|
2016-02-03 19:35:10 -05:00
|
|
|
} else {
|
|
|
|
if ((current_win == FALSE) || ((current_win == TRUE) && prefs_get_boolean(PREF_NOTIFY_CHAT_CURRENT))) {
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-11-24 20:42:27 -05:00
|
|
|
}
|
2015-11-24 18:03:52 -05:00
|
|
|
}
|
|
|
|
|
2016-01-24 18:06:22 -05:00
|
|
|
GList*
|
|
|
|
prefs_message_get_triggers(const char *const message)
|
2016-01-24 12:33:26 -05:00
|
|
|
{
|
2016-01-24 18:06:22 -05:00
|
|
|
GList *result = NULL;
|
|
|
|
|
2016-01-24 12:33:26 -05:00
|
|
|
char *message_lower = g_utf8_strdown(message, -1);
|
|
|
|
gsize len = 0;
|
|
|
|
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
char *trigger_lower = g_utf8_strdown(triggers[i], -1);
|
|
|
|
if (g_strrstr(message_lower, trigger_lower)) {
|
2016-01-24 18:06:22 -05:00
|
|
|
result = g_list_append(result, strdup(triggers[i]));
|
2016-01-24 12:33:26 -05:00
|
|
|
}
|
|
|
|
g_free(trigger_lower);
|
|
|
|
}
|
|
|
|
g_strfreev(triggers);
|
|
|
|
g_free(message_lower);
|
|
|
|
|
2016-01-24 18:06:22 -05:00
|
|
|
return result;
|
2016-01-24 12:33:26 -05:00
|
|
|
}
|
|
|
|
|
2015-11-24 18:03:52 -05:00
|
|
|
gboolean
|
2016-02-03 20:24:37 -05:00
|
|
|
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)
|
2015-11-24 18:03:52 -05:00
|
|
|
{
|
2016-02-03 20:24:37 -05:00
|
|
|
if (g_strcmp0(mynick, theirnick) == 0) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-25 16:24:21 -05:00
|
|
|
gboolean notify_current = prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT);
|
2015-11-24 18:03:52 -05:00
|
|
|
gboolean notify_window = FALSE;
|
2015-11-25 16:24:21 -05:00
|
|
|
if (!current_win || (current_win && notify_current) ) {
|
|
|
|
notify_window = TRUE;
|
|
|
|
}
|
|
|
|
if (!notify_window) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-11-24 18:03:52 -05:00
|
|
|
|
2015-11-27 19:15:53 -05:00
|
|
|
gboolean notify_room = FALSE;
|
|
|
|
if (g_key_file_has_key(prefs, roomjid, "notify", NULL)) {
|
|
|
|
notify_room = g_key_file_get_boolean(prefs, roomjid, "notify", NULL);
|
|
|
|
} else {
|
|
|
|
notify_room = prefs_get_boolean(PREF_NOTIFY_ROOM);
|
|
|
|
}
|
2015-11-25 16:24:21 -05:00
|
|
|
if (notify_room) {
|
|
|
|
return TRUE;
|
2015-11-24 18:03:52 -05:00
|
|
|
}
|
2015-11-25 16:24:21 -05:00
|
|
|
|
2015-11-27 19:15:53 -05:00
|
|
|
gboolean notify_mention = FALSE;
|
|
|
|
if (g_key_file_has_key(prefs, roomjid, "notify.mention", NULL)) {
|
|
|
|
notify_mention = g_key_file_get_boolean(prefs, roomjid, "notify.mention", NULL);
|
|
|
|
} else {
|
|
|
|
notify_mention = prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION);
|
|
|
|
}
|
2016-01-24 18:06:22 -05:00
|
|
|
if (notify_mention && mention) {
|
|
|
|
return TRUE;
|
2015-11-24 18:03:52 -05:00
|
|
|
}
|
|
|
|
|
2015-11-27 19:15:53 -05:00
|
|
|
gboolean notify_trigger = FALSE;
|
|
|
|
if (g_key_file_has_key(prefs, roomjid, "notify.trigger", NULL)) {
|
|
|
|
notify_trigger = g_key_file_get_boolean(prefs, roomjid, "notify.trigger", NULL);
|
|
|
|
} else {
|
|
|
|
notify_trigger = prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER);
|
2015-11-25 16:24:21 -05:00
|
|
|
}
|
2016-01-24 18:06:22 -05:00
|
|
|
if (notify_trigger && trigger_found) {
|
2016-01-24 12:33:26 -05:00
|
|
|
return TRUE;
|
2015-11-24 18:03:52 -05:00
|
|
|
}
|
|
|
|
|
2015-11-27 19:15:53 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-02-06 20:15:40 -05:00
|
|
|
gboolean
|
|
|
|
prefs_do_room_notify_mention(const char *const roomjid, int unread, gboolean mention, gboolean trigger)
|
|
|
|
{
|
|
|
|
gboolean notify_room = FALSE;
|
|
|
|
if (g_key_file_has_key(prefs, roomjid, "notify", NULL)) {
|
|
|
|
notify_room = g_key_file_get_boolean(prefs, roomjid, "notify", NULL);
|
|
|
|
} else {
|
|
|
|
notify_room = prefs_get_boolean(PREF_NOTIFY_ROOM);
|
|
|
|
}
|
|
|
|
if (notify_room && unread > 0) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean notify_mention = FALSE;
|
|
|
|
if (g_key_file_has_key(prefs, roomjid, "notify.mention", NULL)) {
|
|
|
|
notify_mention = g_key_file_get_boolean(prefs, roomjid, "notify.mention", NULL);
|
|
|
|
} else {
|
|
|
|
notify_mention = prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION);
|
|
|
|
}
|
|
|
|
if (notify_mention && mention) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean notify_trigger = FALSE;
|
|
|
|
if (g_key_file_has_key(prefs, roomjid, "notify.trigger", NULL)) {
|
|
|
|
notify_trigger = g_key_file_get_boolean(prefs, roomjid, "notify.trigger", NULL);
|
|
|
|
} else {
|
|
|
|
notify_trigger = prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER);
|
|
|
|
}
|
|
|
|
if (notify_trigger && trigger) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-27 19:15:53 -05:00
|
|
|
void
|
|
|
|
prefs_set_room_notify(const char *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)
|
|
|
|
{
|
|
|
|
g_key_file_set_boolean(prefs, roomjid, "notify.mention", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_room_notify_trigger(const char *const roomjid, gboolean value)
|
|
|
|
{
|
|
|
|
g_key_file_set_boolean(prefs, roomjid, "notify.trigger", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_has_room_notify(const char *const roomjid)
|
|
|
|
{
|
|
|
|
return g_key_file_has_key(prefs, roomjid, "notify", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_has_room_notify_mention(const char *const roomjid)
|
|
|
|
{
|
|
|
|
return g_key_file_has_key(prefs, roomjid, "notify.mention", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_has_room_notify_trigger(const char *const roomjid)
|
|
|
|
{
|
|
|
|
return g_key_file_has_key(prefs, roomjid, "notify.trigger", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_get_room_notify(const char *const roomjid)
|
|
|
|
{
|
|
|
|
return g_key_file_get_boolean(prefs, roomjid, "notify", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_get_room_notify_mention(const char *const roomjid)
|
|
|
|
{
|
|
|
|
return g_key_file_get_boolean(prefs, roomjid, "notify.mention", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_get_room_notify_trigger(const char *const roomjid)
|
|
|
|
{
|
|
|
|
return g_key_file_get_boolean(prefs, roomjid, "notify.trigger", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_reset_room_notify(const char *const roomjid)
|
|
|
|
{
|
|
|
|
if (g_key_file_has_group(prefs, roomjid)) {
|
|
|
|
g_key_file_remove_group(prefs, roomjid, NULL);
|
2015-11-25 16:24:21 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2015-11-24 18:03:52 -05:00
|
|
|
}
|
|
|
|
|
2012-07-24 18:19:48 -04:00
|
|
|
gboolean
|
2013-02-02 21:35:04 -05:00
|
|
|
prefs_get_boolean(preference_t pref)
|
2012-05-10 04:55:55 -04:00
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
const char *group = _get_group(pref);
|
|
|
|
const char *key = _get_key(pref);
|
|
|
|
gboolean def = _get_default_boolean(pref);
|
|
|
|
|
|
|
|
if (!g_key_file_has_key(prefs, group, key, NULL)) {
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_key_file_get_boolean(prefs, group, key, NULL);
|
2012-05-10 04:55:55 -04:00
|
|
|
}
|
|
|
|
|
2012-07-24 18:19:48 -04:00
|
|
|
void
|
2013-02-02 21:51:15 -05:00
|
|
|
prefs_set_boolean(preference_t pref, gboolean value)
|
2012-05-10 04:55:55 -04:00
|
|
|
{
|
2013-02-02 21:51:15 -05:00
|
|
|
const char *group = _get_group(pref);
|
|
|
|
const char *key = _get_key(pref);
|
|
|
|
g_key_file_set_boolean(prefs, group, key, value);
|
2012-05-10 04:55:55 -04:00
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
char*
|
2013-02-02 22:24:13 -05:00
|
|
|
prefs_get_string(preference_t pref)
|
2012-11-21 16:24:10 -05:00
|
|
|
{
|
2013-02-02 22:24:13 -05:00
|
|
|
const char *group = _get_group(pref);
|
|
|
|
const char *key = _get_key(pref);
|
|
|
|
char *def = _get_default_string(pref);
|
|
|
|
|
|
|
|
char *result = g_key_file_get_string(prefs, group, key, NULL);
|
|
|
|
|
|
|
|
if (result == NULL) {
|
2015-05-04 17:33:19 -04:00
|
|
|
if (def) {
|
2015-06-24 08:50:04 -04:00
|
|
|
return g_strdup(def);
|
2014-06-17 19:32:36 -04:00
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-02-02 22:24:13 -05:00
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
2012-11-21 16:24:10 -05:00
|
|
|
}
|
|
|
|
|
2014-06-17 19:32:36 -04:00
|
|
|
void
|
|
|
|
prefs_free_string(char *pref)
|
|
|
|
{
|
2015-05-04 17:33:19 -04:00
|
|
|
if (pref) {
|
2015-06-24 08:50:04 -04:00
|
|
|
g_free(pref);
|
2014-06-17 19:32:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-21 16:24:10 -05:00
|
|
|
void
|
2013-02-02 22:24:13 -05:00
|
|
|
prefs_set_string(preference_t pref, char *value)
|
2012-11-21 16:24:10 -05:00
|
|
|
{
|
2013-02-02 22:24:13 -05:00
|
|
|
const char *group = _get_group(pref);
|
|
|
|
const char *key = _get_key(pref);
|
|
|
|
if (value == NULL) {
|
|
|
|
g_key_file_remove_key(prefs, group, key, NULL);
|
|
|
|
} else {
|
|
|
|
g_key_file_set_string(prefs, group, key, value);
|
|
|
|
}
|
2012-11-21 16:24:10 -05:00
|
|
|
}
|
|
|
|
|
2016-10-17 18:48:03 -04:00
|
|
|
char*
|
|
|
|
prefs_get_tls_certpath(void)
|
|
|
|
{
|
|
|
|
const char *group = _get_group(PREF_TLS_CERTPATH);
|
|
|
|
const char *key = _get_key(PREF_TLS_CERTPATH);
|
|
|
|
|
|
|
|
char *setting = g_key_file_get_string(prefs, group, key, NULL);
|
|
|
|
|
|
|
|
if (g_strcmp0(setting, "none") == 0) {
|
|
|
|
prefs_free_string(setting);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setting == NULL) {
|
|
|
|
if (g_file_test("/etc/ssl/certs", G_FILE_TEST_IS_DIR)) {
|
|
|
|
return strdup("/etc/ssl/certs");
|
|
|
|
}
|
|
|
|
if (g_file_test("/etc/pki/tls/certs", G_FILE_TEST_IS_DIR)) {
|
|
|
|
return strdup("/etc/pki/tls/certs");
|
|
|
|
}
|
|
|
|
if (g_file_test("/etc/ssl", G_FILE_TEST_IS_DIR)) {
|
|
|
|
return strdup("/etc/ssl");
|
|
|
|
}
|
|
|
|
if (g_file_test("/etc/pki/tls", G_FILE_TEST_IS_DIR)) {
|
|
|
|
return strdup("/etc/pki/tls");
|
|
|
|
}
|
|
|
|
if (g_file_test("/system/etc/security/cacerts", G_FILE_TEST_IS_DIR)) {
|
|
|
|
return strdup("/system/etc/security/cacerts");
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *result = strdup(setting);
|
|
|
|
prefs_free_string(setting);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-19 18:31:25 -05:00
|
|
|
gint
|
|
|
|
prefs_get_gone(void)
|
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_CHATSTATES, "gone", NULL);
|
2012-12-19 18:31:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_gone(gint value)
|
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_CHATSTATES, "gone", value);
|
2012-12-19 18:31:25 -05:00
|
|
|
}
|
|
|
|
|
2012-10-27 17:05:08 -04:00
|
|
|
gint
|
|
|
|
prefs_get_notify_remind(void)
|
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_NOTIFICATIONS, "remind", NULL);
|
2012-10-27 17:05:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_notify_remind(gint value)
|
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_NOTIFICATIONS, "remind", value);
|
2012-08-15 19:50:32 -04:00
|
|
|
}
|
|
|
|
|
2012-11-11 16:44:55 -05:00
|
|
|
gint
|
|
|
|
prefs_get_max_log_size(void)
|
|
|
|
{
|
2012-11-12 04:13:03 -05:00
|
|
|
if (log_maxsize < PREFS_MIN_LOG_SIZE)
|
|
|
|
return PREFS_MAX_LOG_SIZE;
|
|
|
|
else
|
|
|
|
return log_maxsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_max_log_size(gint value)
|
|
|
|
{
|
|
|
|
log_maxsize = value;
|
2013-02-02 21:35:04 -05:00
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_LOGGING, "maxsize", value);
|
2012-11-11 16:44:55 -05:00
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
gint
|
|
|
|
prefs_get_inpblock(void)
|
2014-12-21 13:15:29 -05:00
|
|
|
{
|
|
|
|
int val = g_key_file_get_integer(prefs, PREF_GROUP_UI, "inpblock", NULL);
|
|
|
|
if (val == 0) {
|
|
|
|
return INPBLOCK_DEFAULT;
|
|
|
|
} else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
void
|
|
|
|
prefs_set_inpblock(gint value)
|
2014-12-21 13:15:29 -05:00
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "inpblock", value);
|
|
|
|
}
|
|
|
|
|
2012-11-24 21:14:38 -05:00
|
|
|
gint
|
|
|
|
prefs_get_reconnect(void)
|
|
|
|
{
|
2014-07-29 10:40:51 -04:00
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_CONNECTION, "reconnect", NULL)) {
|
|
|
|
return 30;
|
|
|
|
} else {
|
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "reconnect", NULL);
|
|
|
|
}
|
2012-11-24 21:14:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_reconnect(gint value)
|
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_CONNECTION, "reconnect", value);
|
2012-11-24 21:14:38 -05:00
|
|
|
}
|
|
|
|
|
2012-11-26 18:58:24 -05:00
|
|
|
gint
|
|
|
|
prefs_get_autoping(void)
|
|
|
|
{
|
2015-07-01 19:10:31 -04:00
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_CONNECTION, "autoping", NULL)) {
|
|
|
|
return 60;
|
|
|
|
} else {
|
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "autoping", NULL);
|
|
|
|
}
|
2012-11-26 18:58:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_autoping(gint value)
|
|
|
|
{
|
2013-02-02 21:35:04 -05:00
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_CONNECTION, "autoping", value);
|
2012-11-26 18:58:24 -05:00
|
|
|
}
|
|
|
|
|
2016-01-01 14:50:13 -05:00
|
|
|
gint
|
|
|
|
prefs_get_autoping_timeout(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", NULL)) {
|
2016-08-22 17:22:43 -04:00
|
|
|
return 20;
|
2016-01-01 14:50:13 -05:00
|
|
|
} else {
|
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_autoping_timeout(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_CONNECTION, "autoping.timeout", value);
|
|
|
|
}
|
|
|
|
|
2012-11-30 18:34:14 -05:00
|
|
|
gint
|
|
|
|
prefs_get_autoaway_time(void)
|
|
|
|
{
|
2015-09-27 18:08:30 -04:00
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.awaytime", NULL);
|
2012-11-30 18:34:14 -05:00
|
|
|
|
|
|
|
if (result == 0) {
|
|
|
|
return 15;
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-27 18:08:30 -04:00
|
|
|
gint
|
|
|
|
prefs_get_autoxa_time(void)
|
|
|
|
{
|
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.xatime", NULL);
|
|
|
|
}
|
|
|
|
|
2012-11-30 18:34:14 -05:00
|
|
|
void
|
|
|
|
prefs_set_autoaway_time(gint value)
|
|
|
|
{
|
2015-09-27 18:08:30 -04:00
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.awaytime", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_autoxa_time(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.xatime", value);
|
2012-11-30 18:34:14 -05:00
|
|
|
}
|
|
|
|
|
2016-05-14 20:41:34 -04:00
|
|
|
void
|
|
|
|
prefs_set_tray_timer(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_NOTIFICATIONS, "tray.timer", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
prefs_get_tray_timer(void)
|
|
|
|
{
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_NOTIFICATIONS, "tray.timer", NULL);
|
|
|
|
|
|
|
|
if (result == 0) {
|
|
|
|
return 5;
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-08 18:11:49 -05:00
|
|
|
gint
|
|
|
|
prefs_get_statusbartabs(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "statusbar.tabs", NULL)) {
|
|
|
|
return 10;
|
|
|
|
} else {
|
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_UI, "statusbar.tabs", NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_statusbartabs(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "statusbar.tabs", value);
|
|
|
|
}
|
|
|
|
|
2018-03-10 20:18:46 -05:00
|
|
|
gint
|
|
|
|
prefs_get_statusbartablen(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "statusbar.tablen", NULL)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return g_key_file_get_integer(prefs, PREF_GROUP_UI, "statusbar.tablen", NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_statusbartablen(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "statusbar.tablen", value);
|
|
|
|
}
|
|
|
|
|
2016-02-14 19:09:51 -05:00
|
|
|
gchar**
|
2016-02-14 17:28:55 -05:00
|
|
|
prefs_get_plugins(void)
|
|
|
|
{
|
2017-02-05 17:37:48 -05:00
|
|
|
if (!g_key_file_has_group(prefs, PREF_GROUP_PLUGINS)) {
|
2016-02-14 17:28:55 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-02-05 17:37:48 -05:00
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_PLUGINS, "load", NULL)) {
|
2016-02-14 17:28:55 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-02-05 17:37:48 -05:00
|
|
|
return g_key_file_get_string_list(prefs, PREF_GROUP_PLUGINS, "load", NULL, NULL);
|
2016-02-14 17:28:55 -05:00
|
|
|
}
|
|
|
|
|
2016-04-09 20:15:11 -04:00
|
|
|
void
|
|
|
|
prefs_add_plugin(const char *const name)
|
|
|
|
{
|
2017-02-05 17:37:48 -05:00
|
|
|
conf_string_list_add(prefs, PREF_GROUP_PLUGINS, "load", name);
|
2016-04-09 20:15:11 -04:00
|
|
|
_save_prefs();
|
|
|
|
}
|
|
|
|
|
2016-06-30 18:14:05 -04:00
|
|
|
void
|
|
|
|
prefs_remove_plugin(const char *const name)
|
|
|
|
{
|
2017-02-05 17:37:48 -05:00
|
|
|
conf_string_list_remove(prefs, PREF_GROUP_PLUGINS, "load", name);
|
2016-06-30 18:14:05 -04:00
|
|
|
_save_prefs();
|
|
|
|
}
|
|
|
|
|
2016-02-14 19:09:51 -05:00
|
|
|
void
|
|
|
|
prefs_free_plugins(gchar **plugins)
|
|
|
|
{
|
|
|
|
g_strfreev(plugins);
|
|
|
|
}
|
|
|
|
|
2014-11-15 18:47:27 -05:00
|
|
|
void
|
|
|
|
prefs_set_occupants_size(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "occupants.size", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
prefs_get_occupants_size(void)
|
|
|
|
{
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "occupants.size", NULL);
|
|
|
|
|
|
|
|
if (result > 99 || result < 1) {
|
2015-02-24 17:53:57 -05:00
|
|
|
return 15;
|
2014-11-15 18:47:27 -05:00
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 11:01:55 -04:00
|
|
|
char
|
|
|
|
prefs_get_occupants_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_occupants_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_occupants_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "occupants.char", NULL);
|
|
|
|
}
|
|
|
|
|
2019-04-18 14:53:02 -04:00
|
|
|
gint
|
|
|
|
prefs_get_occupants_indent(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "occupants.indent", NULL)) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "occupants.indent", NULL);
|
|
|
|
if (result < 0) {
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_occupants_indent(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "occupants.indent", value);
|
|
|
|
}
|
|
|
|
|
2019-04-23 07:50:58 -04:00
|
|
|
char
|
|
|
|
prefs_get_occupants_header_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "occupants.header.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_occupants_header_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "occupants.header.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_occupants_header_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "occupants.header.char", NULL);
|
|
|
|
}
|
|
|
|
|
2014-11-15 18:47:27 -05:00
|
|
|
void
|
|
|
|
prefs_set_roster_size(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.size", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
prefs_get_roster_size(void)
|
|
|
|
{
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "roster.size", NULL);
|
|
|
|
|
|
|
|
if (result > 99 || result < 1) {
|
2015-02-24 17:53:57 -05:00
|
|
|
return 25;
|
2014-11-15 18:47:27 -05:00
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:06:10 -04:00
|
|
|
char
|
|
|
|
prefs_get_otr_char(void)
|
|
|
|
{
|
|
|
|
char result = '~';
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_OTR, "otr.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = '~';
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_otr_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_OTR, "otr.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
char
|
|
|
|
prefs_get_pgp_char(void)
|
|
|
|
{
|
|
|
|
char result = '~';
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_PGP, "pgp.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = '~';
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_pgp_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_PGP, "pgp.char", str);
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:53:06 -05:00
|
|
|
char
|
|
|
|
prefs_get_omemo_char(void)
|
|
|
|
{
|
|
|
|
char result = '~';
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_OMEMO, "omemo.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = '~';
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_omemo_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_OMEMO, "omemo.char", str);
|
|
|
|
}
|
|
|
|
|
2015-11-19 18:21:51 -05:00
|
|
|
char
|
|
|
|
prefs_get_roster_header_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.header.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_header_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.header.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_roster_header_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.header.char", NULL);
|
|
|
|
}
|
|
|
|
|
2015-11-19 19:06:46 -05:00
|
|
|
char
|
|
|
|
prefs_get_roster_contact_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_contact_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.contact.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_roster_contact_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
|
|
|
|
}
|
|
|
|
|
2015-11-21 21:04:59 -05:00
|
|
|
char
|
|
|
|
prefs_get_roster_resource_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_resource_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.resource.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_roster_resource_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
|
|
|
|
}
|
|
|
|
|
2016-01-23 21:28:22 -05:00
|
|
|
char
|
|
|
|
prefs_get_roster_private_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_private_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.private.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_roster_private_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.private.char", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
char
|
|
|
|
prefs_get_roster_room_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_room_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.char", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_clear_roster_room_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL);
|
|
|
|
}
|
|
|
|
|
2016-01-31 15:17:20 -05:00
|
|
|
char
|
|
|
|
prefs_get_roster_room_private_char(void)
|
|
|
|
{
|
|
|
|
char result = 0;
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2016-01-23 21:28:22 -05:00
|
|
|
|
2016-01-31 15:17:20 -05:00
|
|
|
void
|
|
|
|
prefs_set_roster_room_private_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
2016-01-23 21:28:22 -05:00
|
|
|
|
2016-01-31 15:17:20 -05:00
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.private.char", str);
|
|
|
|
}
|
2016-01-23 21:28:22 -05:00
|
|
|
|
2016-01-31 15:17:20 -05:00
|
|
|
void
|
|
|
|
prefs_clear_roster_room_private_char(void)
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.rooms.pruvate.char", NULL);
|
|
|
|
}
|
2016-01-23 21:28:22 -05:00
|
|
|
|
2015-11-21 16:03:53 -05:00
|
|
|
gint
|
|
|
|
prefs_get_roster_contact_indent(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "roster.contact.indent", NULL)) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "roster.contact.indent", NULL);
|
|
|
|
if (result < 0) {
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_contact_indent(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.contact.indent", value);
|
|
|
|
}
|
|
|
|
|
2015-11-21 16:49:12 -05:00
|
|
|
gint
|
|
|
|
prefs_get_roster_resource_indent(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "roster.resource.indent", NULL)) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "roster.resource.indent", NULL);
|
|
|
|
if (result < 0) {
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_resource_indent(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.resource.indent", value);
|
|
|
|
}
|
|
|
|
|
2015-11-21 17:03:43 -05:00
|
|
|
gint
|
|
|
|
prefs_get_roster_presence_indent(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "roster.presence.indent", NULL)) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", NULL);
|
2015-11-21 19:30:42 -05:00
|
|
|
if (result < -1) {
|
2015-11-21 17:03:43 -05:00
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_roster_presence_indent(gint value)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", value);
|
|
|
|
}
|
|
|
|
|
2020-02-10 07:48:31 -05:00
|
|
|
char
|
|
|
|
prefs_get_correction_char(void)
|
|
|
|
{
|
|
|
|
char result = '+';
|
|
|
|
|
|
|
|
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "correction.char", NULL);
|
|
|
|
if (!resultstr) {
|
|
|
|
result = '+';
|
|
|
|
} else {
|
|
|
|
result = resultstr[0];
|
|
|
|
}
|
|
|
|
free(resultstr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_set_correction_char(char ch)
|
|
|
|
{
|
|
|
|
char str[2];
|
|
|
|
str[0] = ch;
|
|
|
|
str[1] = '\0';
|
|
|
|
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_UI, "correction.char", str);
|
|
|
|
}
|
|
|
|
|
2015-11-23 19:38:33 -05:00
|
|
|
gboolean
|
|
|
|
prefs_add_room_notify_trigger(const char * const text)
|
|
|
|
{
|
|
|
|
gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
|
|
|
|
|
2015-11-23 20:34:06 -05:00
|
|
|
if (res) {
|
|
|
|
autocomplete_add(room_trigger_ac, text);
|
|
|
|
}
|
|
|
|
|
2015-11-23 19:38:33 -05:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_remove_room_notify_trigger(const char * const text)
|
|
|
|
{
|
|
|
|
gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
|
|
|
|
_save_prefs();
|
|
|
|
|
2015-11-23 20:34:06 -05:00
|
|
|
if (res) {
|
|
|
|
autocomplete_remove(room_trigger_ac, text);
|
|
|
|
}
|
|
|
|
|
2015-11-23 19:38:33 -05:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
GList*
|
|
|
|
prefs_get_room_notify_triggers(void)
|
|
|
|
{
|
|
|
|
GList *result = NULL;
|
|
|
|
gsize len = 0;
|
|
|
|
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
result = g_list_append(result, strdup(triggers[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev(triggers);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-09-22 19:56:53 -04:00
|
|
|
ProfWinPlacement*
|
|
|
|
prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = malloc(sizeof(ProfWinPlacement));
|
|
|
|
placement->titlebar_pos = titlebar;
|
|
|
|
placement->mainwin_pos = mainwin;
|
|
|
|
placement->statusbar_pos = statusbar;
|
|
|
|
placement->inputwin_pos = inputwin;
|
|
|
|
|
|
|
|
return placement;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_free_win_placement(ProfWinPlacement *placement)
|
|
|
|
{
|
|
|
|
free(placement);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfWinPlacement*
|
|
|
|
prefs_get_win_placement(void)
|
|
|
|
{
|
|
|
|
// read from settings file
|
|
|
|
int titlebar_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "titlebar.position", NULL);
|
|
|
|
int mainwin_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "mainwin.position", NULL);
|
|
|
|
int statusbar_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "statusbar.position", NULL);
|
|
|
|
int inputwin_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "inputwin.position", NULL);
|
|
|
|
|
|
|
|
// default if setting invalid, or not present
|
|
|
|
if (titlebar_pos < 1 || titlebar_pos > 4) {
|
|
|
|
titlebar_pos = 1;
|
|
|
|
}
|
|
|
|
if (mainwin_pos < 1 || mainwin_pos > 4) {
|
|
|
|
mainwin_pos = 2;
|
|
|
|
}
|
|
|
|
if (statusbar_pos < 1 || statusbar_pos > 4) {
|
|
|
|
statusbar_pos = 3;
|
|
|
|
}
|
|
|
|
if (inputwin_pos < 1 || inputwin_pos > 4) {
|
|
|
|
inputwin_pos = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return default if duplicates found
|
|
|
|
if (titlebar_pos == mainwin_pos) {
|
2016-09-25 15:49:54 -04:00
|
|
|
return prefs_create_profwin_placement(1, 2, 3, 4);
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
if (titlebar_pos == statusbar_pos) {
|
2016-09-25 15:49:54 -04:00
|
|
|
return prefs_create_profwin_placement(1, 2, 3, 4);
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
if (titlebar_pos == inputwin_pos) {
|
2016-09-25 15:49:54 -04:00
|
|
|
return prefs_create_profwin_placement(1, 2, 3, 4);
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mainwin_pos == statusbar_pos) {
|
2016-09-25 15:49:54 -04:00
|
|
|
return prefs_create_profwin_placement(1, 2, 3, 4);
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
if (mainwin_pos == inputwin_pos) {
|
2016-09-25 15:49:54 -04:00
|
|
|
return prefs_create_profwin_placement(1, 2, 3, 4);
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (statusbar_pos == inputwin_pos) {
|
2016-09-25 15:49:54 -04:00
|
|
|
return prefs_create_profwin_placement(1, 2, 3, 4);
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// return settings
|
|
|
|
return prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_save_win_placement(ProfWinPlacement *placement)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "titlebar.position", placement->titlebar_pos);
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "mainwin.position", placement->mainwin_pos);
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "statusbar.position", placement->statusbar_pos);
|
|
|
|
g_key_file_set_integer(prefs, PREF_GROUP_UI, "inputwin.position", placement->inputwin_pos);
|
|
|
|
_save_prefs();
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_titlebar_pos_up(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 2;
|
|
|
|
for (pos = 2; pos<5; pos++) {
|
|
|
|
if (placement->titlebar_pos == pos) {
|
|
|
|
placement->titlebar_pos = pos-1;
|
|
|
|
|
|
|
|
if (placement->mainwin_pos == pos-1) {
|
|
|
|
placement->mainwin_pos = pos;
|
|
|
|
} else if (placement->statusbar_pos == pos-1) {
|
|
|
|
placement->statusbar_pos = pos;
|
|
|
|
} else if (placement->inputwin_pos == pos-1) {
|
|
|
|
placement->inputwin_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_mainwin_pos_up(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 2;
|
|
|
|
for (pos = 2; pos<5; pos++) {
|
|
|
|
if (placement->mainwin_pos == pos) {
|
|
|
|
placement->mainwin_pos = pos-1;
|
|
|
|
|
|
|
|
if (placement->titlebar_pos == pos-1) {
|
|
|
|
placement->titlebar_pos = pos;
|
|
|
|
} else if (placement->statusbar_pos == pos-1) {
|
|
|
|
placement->statusbar_pos = pos;
|
|
|
|
} else if (placement->inputwin_pos == pos-1) {
|
|
|
|
placement->inputwin_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_statusbar_pos_up(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 2;
|
|
|
|
for (pos = 2; pos<5; pos++) {
|
|
|
|
if (placement->statusbar_pos == pos) {
|
|
|
|
placement->statusbar_pos = pos-1;
|
|
|
|
|
|
|
|
if (placement->titlebar_pos == pos-1) {
|
|
|
|
placement->titlebar_pos = pos;
|
|
|
|
} else if (placement->mainwin_pos == pos-1) {
|
|
|
|
placement->mainwin_pos = pos;
|
|
|
|
} else if (placement->inputwin_pos == pos-1) {
|
|
|
|
placement->inputwin_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_inputwin_pos_up(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 2;
|
|
|
|
for (pos = 2; pos<5; pos++) {
|
|
|
|
if (placement->inputwin_pos == pos) {
|
|
|
|
placement->inputwin_pos = pos-1;
|
|
|
|
|
|
|
|
if (placement->titlebar_pos == pos-1) {
|
|
|
|
placement->titlebar_pos = pos;
|
|
|
|
} else if (placement->mainwin_pos == pos-1) {
|
|
|
|
placement->mainwin_pos = pos;
|
|
|
|
} else if (placement->statusbar_pos == pos-1) {
|
|
|
|
placement->statusbar_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_titlebar_pos_down(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 1;
|
|
|
|
for (pos = 1; pos<4; pos++) {
|
|
|
|
if (placement->titlebar_pos == pos) {
|
|
|
|
placement->titlebar_pos = pos+1;
|
|
|
|
|
|
|
|
if (placement->mainwin_pos == pos+1) {
|
|
|
|
placement->mainwin_pos = pos;
|
|
|
|
} else if (placement->statusbar_pos == pos+1) {
|
|
|
|
placement->statusbar_pos = pos;
|
|
|
|
} else if (placement->inputwin_pos == pos+1) {
|
|
|
|
placement->inputwin_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_mainwin_pos_down(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 1;
|
|
|
|
for (pos = 1; pos<4; pos++) {
|
|
|
|
if (placement->mainwin_pos == pos) {
|
|
|
|
placement->mainwin_pos = pos+1;
|
|
|
|
|
|
|
|
if (placement->titlebar_pos == pos+1) {
|
|
|
|
placement->titlebar_pos = pos;
|
|
|
|
} else if (placement->statusbar_pos == pos+1) {
|
|
|
|
placement->statusbar_pos = pos;
|
|
|
|
} else if (placement->inputwin_pos == pos+1) {
|
|
|
|
placement->inputwin_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_statusbar_pos_down(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 1;
|
|
|
|
for (pos = 1; pos<4; pos++) {
|
|
|
|
if (placement->statusbar_pos == pos) {
|
|
|
|
placement->statusbar_pos = pos+1;
|
|
|
|
|
|
|
|
if (placement->titlebar_pos == pos+1) {
|
|
|
|
placement->titlebar_pos = pos;
|
|
|
|
} else if (placement->mainwin_pos == pos+1) {
|
|
|
|
placement->mainwin_pos = pos;
|
|
|
|
} else if (placement->inputwin_pos == pos+1) {
|
|
|
|
placement->inputwin_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
prefs_inputwin_pos_down(void)
|
|
|
|
{
|
|
|
|
ProfWinPlacement *placement = prefs_get_win_placement();
|
2016-09-22 20:04:41 -04:00
|
|
|
|
2016-09-25 16:24:29 -04:00
|
|
|
int pos = 1;
|
|
|
|
for (pos = 1; pos<4; pos++) {
|
|
|
|
if (placement->inputwin_pos == pos) {
|
|
|
|
placement->inputwin_pos = pos+1;
|
|
|
|
|
|
|
|
if (placement->titlebar_pos == pos+1) {
|
|
|
|
placement->titlebar_pos = pos;
|
|
|
|
} else if (placement->mainwin_pos == pos+1) {
|
|
|
|
placement->mainwin_pos = pos;
|
|
|
|
} else if (placement->statusbar_pos == pos+1) {
|
|
|
|
placement->statusbar_pos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_save_win_placement(placement);
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return TRUE;
|
2016-09-22 19:56:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_free_win_placement(placement);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-01-23 17:38:12 -05:00
|
|
|
gboolean
|
2015-10-25 18:23:38 -04:00
|
|
|
prefs_add_alias(const char *const name, const char *const value)
|
2014-01-23 17:29:53 -05:00
|
|
|
{
|
2014-01-23 17:38:12 -05:00
|
|
|
if (g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
g_key_file_set_string(prefs, PREF_GROUP_ALIAS, name, value);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-01-23 17:29:53 -05:00
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
char*
|
|
|
|
prefs_get_alias(const char *const name)
|
2014-01-23 17:29:53 -05:00
|
|
|
{
|
|
|
|
return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2015-10-25 18:23:38 -04:00
|
|
|
prefs_remove_alias(const char *const name)
|
2014-01-23 17:29:53 -05:00
|
|
|
{
|
|
|
|
if (!g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
g_key_file_remove_key(prefs, PREF_GROUP_ALIAS, name, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
_alias_cmp(gconstpointer *p1, gconstpointer *p2)
|
|
|
|
{
|
|
|
|
ProfAlias *alias1 = (ProfAlias*)p1;
|
|
|
|
ProfAlias *alias2 = (ProfAlias*)p2;
|
|
|
|
|
|
|
|
return strcmp(alias1->name, alias2->name);
|
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
GList*
|
2014-01-23 17:29:53 -05:00
|
|
|
prefs_get_aliases(void)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_group(prefs, PREF_GROUP_ALIAS)) {
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
GList *result = NULL;
|
|
|
|
gsize len;
|
|
|
|
gchar **keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL);
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
char *name = keys[i];
|
|
|
|
char *value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
|
|
|
|
2015-05-04 17:33:19 -04:00
|
|
|
if (value) {
|
2014-06-18 16:36:09 -04:00
|
|
|
ProfAlias *alias = malloc(sizeof(struct prof_alias_t));
|
|
|
|
alias->name = strdup(name);
|
|
|
|
alias->value = strdup(value);
|
2014-01-23 17:29:53 -05:00
|
|
|
|
2014-06-18 16:36:09 -04:00
|
|
|
free(value);
|
|
|
|
|
|
|
|
result = g_list_insert_sorted(result, alias, (GCompareFunc)_alias_cmp);
|
|
|
|
}
|
2014-01-23 17:29:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev(keys);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_free_alias(ProfAlias *alias)
|
|
|
|
{
|
|
|
|
FREE_SET_NULL(alias->name);
|
|
|
|
FREE_SET_NULL(alias->value);
|
|
|
|
FREE_SET_NULL(alias);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
prefs_free_aliases(GList *aliases)
|
|
|
|
{
|
|
|
|
g_list_free_full(aliases, (GDestroyNotify)_free_alias);
|
|
|
|
}
|
|
|
|
|
2012-07-24 18:19:48 -04:00
|
|
|
static void
|
|
|
|
_save_prefs(void)
|
2012-05-10 05:02:03 -04:00
|
|
|
{
|
|
|
|
gsize g_data_size;
|
2014-06-15 12:19:56 -04:00
|
|
|
gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
|
2016-07-24 16:35:12 -04:00
|
|
|
gchar *base = g_path_get_basename(prefs_loc);
|
|
|
|
gchar *true_loc = get_file_or_linked(prefs_loc, base);
|
|
|
|
|
2014-10-26 16:43:05 -04:00
|
|
|
g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL);
|
2014-10-18 16:26:38 -04:00
|
|
|
g_chmod(prefs_loc, S_IRUSR | S_IWUSR);
|
2016-07-24 16:35:12 -04:00
|
|
|
|
|
|
|
g_free(base);
|
2014-10-26 16:43:05 -04:00
|
|
|
free(true_loc);
|
2014-06-15 12:19:56 -04:00
|
|
|
g_free(g_prefs_data);
|
2013-02-02 17:18:08 -05:00
|
|
|
}
|
2013-02-02 21:51:15 -05:00
|
|
|
|
2015-01-10 14:22:38 -05:00
|
|
|
// 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.
|
2015-10-25 18:23:38 -04:00
|
|
|
static const char*
|
2013-02-02 21:51:15 -05:00
|
|
|
_get_group(preference_t pref)
|
|
|
|
{
|
|
|
|
switch (pref)
|
|
|
|
{
|
2016-11-06 19:26:15 -05:00
|
|
|
case PREF_CLEAR_PERSIST_HISTORY:
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_SPLASH:
|
|
|
|
case PREF_BEEP:
|
|
|
|
case PREF_THEME:
|
|
|
|
case PREF_VERCHECK:
|
2016-09-22 16:42:00 -04:00
|
|
|
case PREF_WINTITLE_SHOW:
|
|
|
|
case PREF_WINTITLE_GOODBYE:
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_FLASH:
|
|
|
|
case PREF_INTYPE:
|
|
|
|
case PREF_HISTORY:
|
2014-10-09 17:02:39 -04:00
|
|
|
case PREF_OCCUPANTS:
|
2015-04-11 21:14:37 -04:00
|
|
|
case PREF_OCCUPANTS_JID:
|
2019-04-23 10:54:40 -04:00
|
|
|
case PREF_OCCUPANTS_WRAP:
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_STATUSES:
|
2014-01-19 11:17:34 -05:00
|
|
|
case PREF_STATUSES_CONSOLE:
|
|
|
|
case PREF_STATUSES_CHAT:
|
|
|
|
case PREF_STATUSES_MUC:
|
2014-10-18 15:22:34 -04:00
|
|
|
case PREF_MUC_PRIVILEGES:
|
2014-11-07 17:38:34 -05:00
|
|
|
case PREF_PRESENCE:
|
2014-11-09 18:29:25 -05:00
|
|
|
case PREF_WRAP:
|
2015-09-30 17:34:27 -04:00
|
|
|
case PREF_TIME_CONSOLE:
|
|
|
|
case PREF_TIME_CHAT:
|
|
|
|
case PREF_TIME_MUC:
|
2018-04-11 12:57:50 -04:00
|
|
|
case PREF_TIME_CONFIG:
|
2015-09-30 17:34:27 -04:00
|
|
|
case PREF_TIME_PRIVATE:
|
|
|
|
case PREF_TIME_XMLCONSOLE:
|
2015-03-10 19:35:08 -04:00
|
|
|
case PREF_TIME_STATUSBAR:
|
2015-09-29 18:30:23 -04:00
|
|
|
case PREF_TIME_LASTACTIVITY:
|
2014-11-10 18:23:02 -05:00
|
|
|
case PREF_ROSTER:
|
|
|
|
case PREF_ROSTER_OFFLINE:
|
|
|
|
case PREF_ROSTER_RESOURCE:
|
2015-11-15 16:33:48 -05:00
|
|
|
case PREF_ROSTER_PRESENCE:
|
|
|
|
case PREF_ROSTER_STATUS:
|
2015-07-08 07:11:56 -04:00
|
|
|
case PREF_ROSTER_EMPTY:
|
2014-11-10 18:23:02 -05:00
|
|
|
case PREF_ROSTER_BY:
|
2015-11-17 18:37:33 -05:00
|
|
|
case PREF_ROSTER_ORDER:
|
2016-01-16 21:17:12 -05:00
|
|
|
case PREF_ROSTER_UNREAD:
|
2015-11-17 21:02:49 -05:00
|
|
|
case PREF_ROSTER_COUNT:
|
2016-01-27 18:02:28 -05:00
|
|
|
case PREF_ROSTER_COUNT_ZERO:
|
2015-11-17 21:14:11 -05:00
|
|
|
case PREF_ROSTER_PRIORITY:
|
2015-11-21 20:39:20 -05:00
|
|
|
case PREF_ROSTER_WRAP:
|
2015-11-22 11:37:05 -05:00
|
|
|
case PREF_ROSTER_RESOURCE_JOIN:
|
2016-01-19 20:48:41 -05:00
|
|
|
case PREF_ROSTER_CONTACTS:
|
2016-02-06 19:49:48 -05:00
|
|
|
case PREF_ROSTER_UNSUBSCRIBED:
|
2016-01-01 20:29:12 -05:00
|
|
|
case PREF_ROSTER_ROOMS:
|
2016-01-19 17:38:00 -05:00
|
|
|
case PREF_ROSTER_ROOMS_POS:
|
2016-01-31 20:11:01 -05:00
|
|
|
case PREF_ROSTER_ROOMS_BY:
|
2016-01-09 17:21:09 -05:00
|
|
|
case PREF_ROSTER_ROOMS_ORDER:
|
2016-01-16 20:49:16 -05:00
|
|
|
case PREF_ROSTER_ROOMS_UNREAD:
|
2018-01-21 13:49:07 -05:00
|
|
|
case PREF_ROSTER_ROOMS_SERVER:
|
2020-01-23 10:50:43 -05:00
|
|
|
case PREF_ROSTER_ROOMS_USE_AS_NAME:
|
2016-01-23 20:04:21 -05:00
|
|
|
case PREF_ROSTER_PRIVATE:
|
2015-01-10 14:10:10 -05:00
|
|
|
case PREF_RESOURCE_TITLE:
|
|
|
|
case PREF_RESOURCE_MESSAGE:
|
2015-06-21 16:07:57 -04:00
|
|
|
case PREF_ENC_WARN:
|
2015-01-12 05:32:32 -05:00
|
|
|
case PREF_INPBLOCK_DYNAMIC:
|
2015-10-13 19:46:16 -04:00
|
|
|
case PREF_TLS_SHOW:
|
2015-12-29 18:00:49 -05:00
|
|
|
case PREF_CONSOLE_MUC:
|
2016-02-03 18:39:20 -05:00
|
|
|
case PREF_CONSOLE_PRIVATE:
|
2016-02-03 18:02:52 -05:00
|
|
|
case PREF_CONSOLE_CHAT:
|
2019-12-03 14:49:22 -05:00
|
|
|
case PREF_COLOR_NICK:
|
2019-12-19 12:53:22 -05:00
|
|
|
case PREF_ROSTER_COLOR_NICK:
|
2019-12-19 13:14:59 -05:00
|
|
|
case PREF_OCCUPANTS_COLOR_NICK:
|
2018-03-08 17:27:49 -05:00
|
|
|
case PREF_STATUSBAR_SHOW_NAME:
|
2018-03-09 18:44:28 -05:00
|
|
|
case PREF_STATUSBAR_SHOW_NUMBER:
|
2018-03-10 17:16:52 -05:00
|
|
|
case PREF_STATUSBAR_SELF:
|
2018-03-09 16:11:59 -05:00
|
|
|
case PREF_STATUSBAR_CHAT:
|
|
|
|
case PREF_STATUSBAR_ROOM:
|
2020-01-23 13:42:22 -05:00
|
|
|
case PREF_TITLEBAR_MUC_TITLE:
|
2014-01-23 17:29:53 -05:00
|
|
|
return PREF_GROUP_UI;
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_STATES:
|
|
|
|
case PREF_OUTTYPE:
|
2014-01-23 17:29:53 -05:00
|
|
|
return PREF_GROUP_CHATSTATES;
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_NOTIFY_TYPING:
|
2014-05-24 16:13:33 -04:00
|
|
|
case PREF_NOTIFY_TYPING_CURRENT:
|
2015-11-28 19:08:49 -05:00
|
|
|
case PREF_NOTIFY_CHAT:
|
|
|
|
case PREF_NOTIFY_CHAT_CURRENT:
|
|
|
|
case PREF_NOTIFY_CHAT_TEXT:
|
2014-05-24 10:54:10 -04:00
|
|
|
case PREF_NOTIFY_ROOM:
|
2015-11-25 16:24:21 -05:00
|
|
|
case PREF_NOTIFY_ROOM_MENTION:
|
|
|
|
case PREF_NOTIFY_ROOM_TRIGGER:
|
2014-05-24 15:46:03 -04:00
|
|
|
case PREF_NOTIFY_ROOM_CURRENT:
|
2014-05-24 17:14:26 -04:00
|
|
|
case PREF_NOTIFY_ROOM_TEXT:
|
2013-04-22 18:48:23 -04:00
|
|
|
case PREF_NOTIFY_INVITE:
|
2013-04-27 18:46:49 -04:00
|
|
|
case PREF_NOTIFY_SUB:
|
2016-04-06 20:01:27 -04:00
|
|
|
case PREF_NOTIFY_MENTION_CASE_SENSITIVE:
|
|
|
|
case PREF_NOTIFY_MENTION_WHOLE_WORD:
|
2016-04-17 18:17:43 -04:00
|
|
|
case PREF_TRAY:
|
2016-05-14 19:55:19 -04:00
|
|
|
case PREF_TRAY_READ:
|
2020-01-23 16:54:47 -05:00
|
|
|
case PREF_ADV_NOTIFY_DISCO_OR_VERSION:
|
2014-01-23 17:29:53 -05:00
|
|
|
return PREF_GROUP_NOTIFICATIONS;
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_CHLOG:
|
2013-05-04 19:16:10 -04:00
|
|
|
case PREF_GRLOG:
|
2014-04-13 15:41:11 -04:00
|
|
|
case PREF_LOG_ROTATE:
|
2014-04-13 16:56:35 -04:00
|
|
|
case PREF_LOG_SHARED:
|
2014-01-23 17:29:53 -05:00
|
|
|
return PREF_GROUP_LOGGING;
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_AUTOAWAY_CHECK:
|
2013-02-02 22:24:13 -05:00
|
|
|
case PREF_AUTOAWAY_MODE:
|
|
|
|
case PREF_AUTOAWAY_MESSAGE:
|
2015-09-27 18:08:30 -04:00
|
|
|
case PREF_AUTOXA_MESSAGE:
|
2015-10-14 16:17:46 -04:00
|
|
|
case PREF_LASTACTIVITY:
|
2014-01-23 17:29:53 -05:00
|
|
|
return PREF_GROUP_PRESENCE;
|
2013-11-07 18:04:12 -05:00
|
|
|
case PREF_CONNECT_ACCOUNT:
|
2014-11-27 12:42:23 -05:00
|
|
|
case PREF_DEFAULT_ACCOUNT:
|
2015-02-02 05:10:05 -05:00
|
|
|
case PREF_CARBONS:
|
2015-03-19 18:57:51 -04:00
|
|
|
case PREF_RECEIPTS_SEND:
|
|
|
|
case PREF_RECEIPTS_REQUEST:
|
2020-01-23 17:35:46 -05:00
|
|
|
case PREF_REVEAL_OS:
|
2015-10-17 19:03:15 -04:00
|
|
|
case PREF_TLS_CERTPATH:
|
2020-02-10 08:52:42 -05:00
|
|
|
case PREF_CORRECTION_ALLOW:
|
2014-01-23 17:29:53 -05:00
|
|
|
return PREF_GROUP_CONNECTION;
|
2014-05-11 08:13:25 -04:00
|
|
|
case PREF_OTR_LOG:
|
|
|
|
case PREF_OTR_POLICY:
|
2020-02-17 02:44:26 -05:00
|
|
|
case PREF_OTR_SENDFILE:
|
2014-05-11 08:13:25 -04:00
|
|
|
return PREF_GROUP_OTR;
|
2015-06-21 16:42:58 -04:00
|
|
|
case PREF_PGP_LOG:
|
2020-02-17 02:57:35 -05:00
|
|
|
case PREF_PGP_SENDFILE:
|
2015-06-21 16:42:58 -04:00
|
|
|
return PREF_GROUP_PGP;
|
2016-05-23 18:53:44 -04:00
|
|
|
case PREF_BOOKMARK_INVITE:
|
2018-02-05 15:01:54 -05:00
|
|
|
case PREF_ROOM_LIST_CACHE:
|
2016-05-23 18:53:44 -04:00
|
|
|
return PREF_GROUP_MUC;
|
2017-02-05 17:37:48 -05:00
|
|
|
case PREF_PLUGINS_SOURCEPATH:
|
|
|
|
return PREF_GROUP_PLUGINS;
|
2019-03-22 13:32:15 -04:00
|
|
|
case PREF_OMEMO_LOG:
|
2019-04-15 16:09:47 -04:00
|
|
|
case PREF_OMEMO_POLICY:
|
2020-02-17 02:31:46 -05:00
|
|
|
case PREF_OMEMO_SENDFILE:
|
2019-03-22 13:32:15 -04:00
|
|
|
return PREF_GROUP_OMEMO;
|
2013-02-02 21:51:15 -05:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 14:22:38 -05:00
|
|
|
// get the key used in .profrc for the preference
|
|
|
|
// for example the PREF_AUTOAWAY_MODE maps to "autoaway.mode" in .profrc
|
2015-10-25 18:23:38 -04:00
|
|
|
static const char*
|
2013-02-02 21:51:15 -05:00
|
|
|
_get_key(preference_t pref)
|
|
|
|
{
|
|
|
|
switch (pref)
|
|
|
|
{
|
2016-11-06 19:26:15 -05:00
|
|
|
case PREF_CLEAR_PERSIST_HISTORY:
|
|
|
|
return "clear.persist_history";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_SPLASH:
|
|
|
|
return "splash";
|
|
|
|
case PREF_BEEP:
|
|
|
|
return "beep";
|
|
|
|
case PREF_THEME:
|
|
|
|
return "theme";
|
|
|
|
case PREF_VERCHECK:
|
|
|
|
return "vercheck";
|
2016-09-22 16:42:00 -04:00
|
|
|
case PREF_WINTITLE_SHOW:
|
|
|
|
return "wintitle.show";
|
|
|
|
case PREF_WINTITLE_GOODBYE:
|
|
|
|
return "wintitle.goodbye";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_FLASH:
|
|
|
|
return "flash";
|
2016-04-16 10:29:32 -04:00
|
|
|
case PREF_TRAY:
|
|
|
|
return "tray";
|
2016-05-14 19:55:19 -04:00
|
|
|
case PREF_TRAY_READ:
|
|
|
|
return "tray.read";
|
2020-01-23 16:54:47 -05:00
|
|
|
case PREF_ADV_NOTIFY_DISCO_OR_VERSION:
|
|
|
|
return "adv.notify.discoversion";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_INTYPE:
|
|
|
|
return "intype";
|
|
|
|
case PREF_HISTORY:
|
|
|
|
return "history";
|
2015-02-02 05:10:05 -05:00
|
|
|
case PREF_CARBONS:
|
|
|
|
return "carbons";
|
2015-03-19 18:57:51 -04:00
|
|
|
case PREF_RECEIPTS_SEND:
|
|
|
|
return "receipts.send";
|
|
|
|
case PREF_RECEIPTS_REQUEST:
|
|
|
|
return "receipts.request";
|
2020-01-23 17:35:46 -05:00
|
|
|
case PREF_REVEAL_OS:
|
|
|
|
return "reveal.os";
|
2014-10-09 17:02:39 -04:00
|
|
|
case PREF_OCCUPANTS:
|
|
|
|
return "occupants";
|
2015-04-11 21:14:37 -04:00
|
|
|
case PREF_OCCUPANTS_JID:
|
|
|
|
return "occupants.jid";
|
2019-04-23 10:54:40 -04:00
|
|
|
case PREF_OCCUPANTS_WRAP:
|
|
|
|
return "occupants.wrap";
|
2014-10-18 15:22:34 -04:00
|
|
|
case PREF_MUC_PRIVILEGES:
|
|
|
|
return "privileges";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_STATUSES:
|
|
|
|
return "statuses";
|
2014-01-19 11:17:34 -05:00
|
|
|
case PREF_STATUSES_CONSOLE:
|
|
|
|
return "statuses.console";
|
|
|
|
case PREF_STATUSES_CHAT:
|
|
|
|
return "statuses.chat";
|
|
|
|
case PREF_STATUSES_MUC:
|
|
|
|
return "statuses.muc";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_STATES:
|
|
|
|
return "enabled";
|
|
|
|
case PREF_OUTTYPE:
|
|
|
|
return "outtype";
|
|
|
|
case PREF_NOTIFY_TYPING:
|
|
|
|
return "typing";
|
2014-05-24 16:13:33 -04:00
|
|
|
case PREF_NOTIFY_TYPING_CURRENT:
|
|
|
|
return "typing.current";
|
2015-11-28 19:08:49 -05:00
|
|
|
case PREF_NOTIFY_CHAT:
|
2013-02-02 21:51:15 -05:00
|
|
|
return "message";
|
2015-11-28 19:08:49 -05:00
|
|
|
case PREF_NOTIFY_CHAT_CURRENT:
|
2014-05-24 15:46:03 -04:00
|
|
|
return "message.current";
|
2015-11-28 19:08:49 -05:00
|
|
|
case PREF_NOTIFY_CHAT_TEXT:
|
2014-05-24 17:14:26 -04:00
|
|
|
return "message.text";
|
2014-05-24 10:54:10 -04:00
|
|
|
case PREF_NOTIFY_ROOM:
|
|
|
|
return "room";
|
2015-11-25 16:24:21 -05:00
|
|
|
case PREF_NOTIFY_ROOM_TRIGGER:
|
|
|
|
return "room.trigger";
|
|
|
|
case PREF_NOTIFY_ROOM_MENTION:
|
|
|
|
return "room.mention";
|
2014-05-24 15:46:03 -04:00
|
|
|
case PREF_NOTIFY_ROOM_CURRENT:
|
|
|
|
return "room.current";
|
2014-05-24 17:14:26 -04:00
|
|
|
case PREF_NOTIFY_ROOM_TEXT:
|
|
|
|
return "room.text";
|
2013-04-22 18:48:23 -04:00
|
|
|
case PREF_NOTIFY_INVITE:
|
|
|
|
return "invite";
|
2013-04-27 18:46:49 -04:00
|
|
|
case PREF_NOTIFY_SUB:
|
|
|
|
return "sub";
|
2016-04-06 20:01:27 -04:00
|
|
|
case PREF_NOTIFY_MENTION_CASE_SENSITIVE:
|
2016-04-03 18:33:21 -04:00
|
|
|
return "room.mention.casesensitive";
|
2016-04-06 20:01:27 -04:00
|
|
|
case PREF_NOTIFY_MENTION_WHOLE_WORD:
|
2016-04-03 18:33:21 -04:00
|
|
|
return "room.mention.wholeword";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_CHLOG:
|
|
|
|
return "chlog";
|
2013-05-04 19:16:10 -04:00
|
|
|
case PREF_GRLOG:
|
|
|
|
return "grlog";
|
2013-02-02 21:51:15 -05:00
|
|
|
case PREF_AUTOAWAY_CHECK:
|
|
|
|
return "autoaway.check";
|
2013-02-02 22:24:13 -05:00
|
|
|
case PREF_AUTOAWAY_MODE:
|
|
|
|
return "autoaway.mode";
|
|
|
|
case PREF_AUTOAWAY_MESSAGE:
|
2015-09-27 18:08:30 -04:00
|
|
|
return "autoaway.awaymessage";
|
|
|
|
case PREF_AUTOXA_MESSAGE:
|
|
|
|
return "autoaway.xamessage";
|
2013-11-07 18:04:12 -05:00
|
|
|
case PREF_CONNECT_ACCOUNT:
|
|
|
|
return "account";
|
2014-11-27 12:42:23 -05:00
|
|
|
case PREF_DEFAULT_ACCOUNT:
|
|
|
|
return "defaccount";
|
2014-01-13 15:17:45 -05:00
|
|
|
case PREF_OTR_LOG:
|
2014-05-11 08:13:25 -04:00
|
|
|
return "log";
|
2014-04-22 18:53:15 -04:00
|
|
|
case PREF_OTR_POLICY:
|
2014-05-11 08:13:25 -04:00
|
|
|
return "policy";
|
2020-02-17 02:44:26 -05:00
|
|
|
case PREF_OTR_SENDFILE:
|
|
|
|
return "sendfile";
|
2014-04-13 15:41:11 -04:00
|
|
|
case PREF_LOG_ROTATE:
|
|
|
|
return "rotate";
|
2014-04-13 16:56:35 -04:00
|
|
|
case PREF_LOG_SHARED:
|
|
|
|
return "shared";
|
2014-11-07 17:38:34 -05:00
|
|
|
case PREF_PRESENCE:
|
|
|
|
return "presence";
|
2014-11-09 18:29:25 -05:00
|
|
|
case PREF_WRAP:
|
|
|
|
return "wrap";
|
2015-09-30 17:34:27 -04:00
|
|
|
case PREF_TIME_CONSOLE:
|
|
|
|
return "time.console";
|
|
|
|
case PREF_TIME_CHAT:
|
|
|
|
return "time.chat";
|
|
|
|
case PREF_TIME_MUC:
|
|
|
|
return "time.muc";
|
2018-04-11 12:57:50 -04:00
|
|
|
case PREF_TIME_CONFIG:
|
|
|
|
return "time.config";
|
2015-09-30 17:34:27 -04:00
|
|
|
case PREF_TIME_PRIVATE:
|
|
|
|
return "time.private";
|
|
|
|
case PREF_TIME_XMLCONSOLE:
|
|
|
|
return "time.xmlconsole";
|
2015-03-10 19:35:08 -04:00
|
|
|
case PREF_TIME_STATUSBAR:
|
|
|
|
return "time.statusbar";
|
2015-09-29 18:30:23 -04:00
|
|
|
case PREF_TIME_LASTACTIVITY:
|
|
|
|
return "time.lastactivity";
|
2014-11-10 18:23:02 -05:00
|
|
|
case PREF_ROSTER:
|
|
|
|
return "roster";
|
|
|
|
case PREF_ROSTER_OFFLINE:
|
|
|
|
return "roster.offline";
|
|
|
|
case PREF_ROSTER_RESOURCE:
|
|
|
|
return "roster.resource";
|
2015-11-15 16:33:48 -05:00
|
|
|
case PREF_ROSTER_PRESENCE:
|
|
|
|
return "roster.presence";
|
|
|
|
case PREF_ROSTER_STATUS:
|
|
|
|
return "roster.status";
|
2015-07-08 07:11:56 -04:00
|
|
|
case PREF_ROSTER_EMPTY:
|
|
|
|
return "roster.empty";
|
2014-11-10 18:23:02 -05:00
|
|
|
case PREF_ROSTER_BY:
|
|
|
|
return "roster.by";
|
2015-11-17 18:37:33 -05:00
|
|
|
case PREF_ROSTER_ORDER:
|
|
|
|
return "roster.order";
|
2016-01-16 21:17:12 -05:00
|
|
|
case PREF_ROSTER_UNREAD:
|
|
|
|
return "roster.unread";
|
2015-11-17 21:02:49 -05:00
|
|
|
case PREF_ROSTER_COUNT:
|
|
|
|
return "roster.count";
|
2016-01-27 18:02:28 -05:00
|
|
|
case PREF_ROSTER_COUNT_ZERO:
|
|
|
|
return "roster.count.zero";
|
2015-11-17 21:14:11 -05:00
|
|
|
case PREF_ROSTER_PRIORITY:
|
|
|
|
return "roster.priority";
|
2015-11-21 20:39:20 -05:00
|
|
|
case PREF_ROSTER_WRAP:
|
|
|
|
return "roster.wrap";
|
2015-11-22 11:37:05 -05:00
|
|
|
case PREF_ROSTER_RESOURCE_JOIN:
|
|
|
|
return "roster.resource.join";
|
2016-01-19 20:48:41 -05:00
|
|
|
case PREF_ROSTER_CONTACTS:
|
|
|
|
return "roster.contacts";
|
2016-02-06 19:49:48 -05:00
|
|
|
case PREF_ROSTER_UNSUBSCRIBED:
|
|
|
|
return "roster.unsubscribed";
|
2016-01-01 20:29:12 -05:00
|
|
|
case PREF_ROSTER_ROOMS:
|
|
|
|
return "roster.rooms";
|
2016-01-19 17:38:00 -05:00
|
|
|
case PREF_ROSTER_ROOMS_POS:
|
|
|
|
return "roster.rooms.pos";
|
2016-01-31 20:11:01 -05:00
|
|
|
case PREF_ROSTER_ROOMS_BY:
|
|
|
|
return "roster.rooms.by";
|
2016-01-09 17:21:09 -05:00
|
|
|
case PREF_ROSTER_ROOMS_ORDER:
|
|
|
|
return "roster.rooms.order";
|
2016-01-16 20:49:16 -05:00
|
|
|
case PREF_ROSTER_ROOMS_UNREAD:
|
|
|
|
return "roster.rooms.unread";
|
2018-01-21 13:49:07 -05:00
|
|
|
case PREF_ROSTER_ROOMS_SERVER:
|
|
|
|
return "roster.rooms.server";
|
2020-01-23 10:50:43 -05:00
|
|
|
case PREF_ROSTER_ROOMS_USE_AS_NAME:
|
|
|
|
return "roster.rooms.use.name";
|
2016-01-23 20:04:21 -05:00
|
|
|
case PREF_ROSTER_PRIVATE:
|
|
|
|
return "roster.private";
|
2015-01-10 14:10:10 -05:00
|
|
|
case PREF_RESOURCE_TITLE:
|
|
|
|
return "resource.title";
|
|
|
|
case PREF_RESOURCE_MESSAGE:
|
|
|
|
return "resource.message";
|
2015-01-12 05:32:32 -05:00
|
|
|
case PREF_INPBLOCK_DYNAMIC:
|
|
|
|
return "inpblock.dynamic";
|
2015-06-21 16:07:57 -04:00
|
|
|
case PREF_ENC_WARN:
|
|
|
|
return "enc.warn";
|
2020-01-23 13:42:22 -05:00
|
|
|
case PREF_TITLEBAR_MUC_TITLE:
|
|
|
|
return "titlebar.muc.title";
|
2015-06-21 16:42:58 -04:00
|
|
|
case PREF_PGP_LOG:
|
|
|
|
return "log";
|
2020-02-17 02:57:35 -05:00
|
|
|
case PREF_PGP_SENDFILE:
|
|
|
|
return "sendfile";
|
2015-10-17 19:03:15 -04:00
|
|
|
case PREF_TLS_CERTPATH:
|
|
|
|
return "tls.certpath";
|
2015-10-13 19:46:16 -04:00
|
|
|
case PREF_TLS_SHOW:
|
|
|
|
return "tls.show";
|
2015-10-14 16:17:46 -04:00
|
|
|
case PREF_LASTACTIVITY:
|
|
|
|
return "lastactivity";
|
2015-12-29 18:00:49 -05:00
|
|
|
case PREF_CONSOLE_MUC:
|
|
|
|
return "console.muc";
|
2016-02-03 18:39:20 -05:00
|
|
|
case PREF_CONSOLE_PRIVATE:
|
|
|
|
return "console.private";
|
2016-02-03 18:02:52 -05:00
|
|
|
case PREF_CONSOLE_CHAT:
|
|
|
|
return "console.chat";
|
2019-12-03 14:49:22 -05:00
|
|
|
case PREF_COLOR_NICK:
|
|
|
|
return "color.nick";
|
2019-12-19 12:53:22 -05:00
|
|
|
case PREF_ROSTER_COLOR_NICK:
|
|
|
|
return "color.roster.nick";
|
2019-12-19 13:14:59 -05:00
|
|
|
case PREF_OCCUPANTS_COLOR_NICK:
|
|
|
|
return "color.occupants.nick";
|
2016-05-23 18:53:44 -04:00
|
|
|
case PREF_BOOKMARK_INVITE:
|
|
|
|
return "bookmark.invite";
|
2017-02-05 17:37:48 -05:00
|
|
|
case PREF_PLUGINS_SOURCEPATH:
|
|
|
|
return "sourcepath";
|
2018-02-05 15:01:54 -05:00
|
|
|
case PREF_ROOM_LIST_CACHE:
|
|
|
|
return "rooms.cache";
|
2018-03-08 17:27:49 -05:00
|
|
|
case PREF_STATUSBAR_SHOW_NAME:
|
|
|
|
return "statusbar.show.name";
|
2018-03-09 18:44:28 -05:00
|
|
|
case PREF_STATUSBAR_SHOW_NUMBER:
|
|
|
|
return "statusbar.show.number";
|
2018-03-10 17:16:52 -05:00
|
|
|
case PREF_STATUSBAR_SELF:
|
|
|
|
return "statusbar.self";
|
2018-03-09 16:11:59 -05:00
|
|
|
case PREF_STATUSBAR_CHAT:
|
|
|
|
return "statusbar.chat";
|
|
|
|
case PREF_STATUSBAR_ROOM:
|
|
|
|
return "statusbar.room";
|
2019-03-22 13:32:15 -04:00
|
|
|
case PREF_OMEMO_LOG:
|
|
|
|
return "log";
|
2019-04-15 16:09:47 -04:00
|
|
|
case PREF_OMEMO_POLICY:
|
|
|
|
return "policy";
|
2020-02-17 02:31:46 -05:00
|
|
|
case PREF_OMEMO_SENDFILE:
|
|
|
|
return "sendfile";
|
2020-02-10 08:52:42 -05:00
|
|
|
case PREF_CORRECTION_ALLOW:
|
|
|
|
return "correction.allow";
|
2013-02-02 21:51:15 -05:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 14:22:38 -05:00
|
|
|
// the default setting for a boolean type preference
|
|
|
|
// if it is not specified in .profrc
|
2013-02-02 21:51:15 -05:00
|
|
|
static gboolean
|
|
|
|
_get_default_boolean(preference_t pref)
|
|
|
|
{
|
|
|
|
switch (pref)
|
|
|
|
{
|
2015-06-21 16:07:57 -04:00
|
|
|
case PREF_ENC_WARN:
|
2014-04-03 16:46:43 -04:00
|
|
|
case PREF_AUTOAWAY_CHECK:
|
2014-04-13 15:41:11 -04:00
|
|
|
case PREF_LOG_ROTATE:
|
2014-04-13 16:56:35 -04:00
|
|
|
case PREF_LOG_SHARED:
|
2015-11-28 19:08:49 -05:00
|
|
|
case PREF_NOTIFY_CHAT:
|
|
|
|
case PREF_NOTIFY_CHAT_CURRENT:
|
2015-11-25 16:24:21 -05:00
|
|
|
case PREF_NOTIFY_ROOM:
|
2014-05-24 15:46:03 -04:00
|
|
|
case PREF_NOTIFY_ROOM_CURRENT:
|
2015-02-24 17:53:57 -05:00
|
|
|
case PREF_NOTIFY_TYPING:
|
2014-05-24 16:13:33 -04:00
|
|
|
case PREF_NOTIFY_TYPING_CURRENT:
|
2015-02-24 17:53:57 -05:00
|
|
|
case PREF_NOTIFY_SUB:
|
|
|
|
case PREF_NOTIFY_INVITE:
|
2014-08-09 14:00:59 -04:00
|
|
|
case PREF_SPLASH:
|
2014-10-09 17:02:39 -04:00
|
|
|
case PREF_OCCUPANTS:
|
2014-10-18 15:22:34 -04:00
|
|
|
case PREF_MUC_PRIVILEGES:
|
2014-11-07 17:38:34 -05:00
|
|
|
case PREF_PRESENCE:
|
2014-11-09 18:29:25 -05:00
|
|
|
case PREF_WRAP:
|
2015-01-12 05:32:32 -05:00
|
|
|
case PREF_INPBLOCK_DYNAMIC:
|
2015-02-24 17:53:57 -05:00
|
|
|
case PREF_RESOURCE_TITLE:
|
|
|
|
case PREF_RESOURCE_MESSAGE:
|
|
|
|
case PREF_ROSTER:
|
|
|
|
case PREF_ROSTER_OFFLINE:
|
2015-07-08 07:11:56 -04:00
|
|
|
case PREF_ROSTER_EMPTY:
|
2016-01-27 18:02:28 -05:00
|
|
|
case PREF_ROSTER_COUNT_ZERO:
|
2015-11-17 21:14:11 -05:00
|
|
|
case PREF_ROSTER_PRIORITY:
|
2015-11-22 11:37:05 -05:00
|
|
|
case PREF_ROSTER_RESOURCE_JOIN:
|
2016-01-19 20:48:41 -05:00
|
|
|
case PREF_ROSTER_CONTACTS:
|
2016-02-06 19:49:48 -05:00
|
|
|
case PREF_ROSTER_UNSUBSCRIBED:
|
2016-01-01 20:29:12 -05:00
|
|
|
case PREF_ROSTER_ROOMS:
|
2018-01-27 14:39:33 -05:00
|
|
|
case PREF_ROSTER_ROOMS_SERVER:
|
2015-10-13 19:46:16 -04:00
|
|
|
case PREF_TLS_SHOW:
|
2015-10-14 16:17:46 -04:00
|
|
|
case PREF_LASTACTIVITY:
|
2016-04-06 20:01:27 -04:00
|
|
|
case PREF_NOTIFY_MENTION_WHOLE_WORD:
|
2016-05-14 19:55:19 -04:00
|
|
|
case PREF_TRAY_READ:
|
2016-05-23 18:53:44 -04:00
|
|
|
case PREF_BOOKMARK_INVITE:
|
2018-02-05 15:01:54 -05:00
|
|
|
case PREF_ROOM_LIST_CACHE:
|
2018-03-09 18:44:28 -05:00
|
|
|
case PREF_STATUSBAR_SHOW_NUMBER:
|
2020-01-23 17:35:46 -05:00
|
|
|
case PREF_REVEAL_OS:
|
2014-04-03 16:46:43 -04:00
|
|
|
return TRUE;
|
2013-02-02 21:51:15 -05:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 14:22:38 -05:00
|
|
|
// the default setting for a string type preference
|
|
|
|
// if it is not specified in .profrc
|
2015-10-25 18:23:38 -04:00
|
|
|
static char*
|
2013-02-02 22:24:13 -05:00
|
|
|
_get_default_string(preference_t pref)
|
|
|
|
{
|
|
|
|
switch (pref)
|
|
|
|
{
|
|
|
|
case PREF_AUTOAWAY_MODE:
|
2015-06-08 15:26:23 -04:00
|
|
|
return "off";
|
2014-01-13 15:17:45 -05:00
|
|
|
case PREF_OTR_LOG:
|
|
|
|
return "redact";
|
2014-04-22 18:53:15 -04:00
|
|
|
case PREF_OTR_POLICY:
|
|
|
|
return "manual";
|
2014-01-19 12:20:31 -05:00
|
|
|
case PREF_STATUSES_CONSOLE:
|
|
|
|
case PREF_STATUSES_CHAT:
|
2014-03-15 18:25:15 -04:00
|
|
|
case PREF_STATUSES_MUC:
|
2014-01-19 12:20:31 -05:00
|
|
|
return "all";
|
2014-11-10 18:23:02 -05:00
|
|
|
case PREF_ROSTER_BY:
|
2015-02-24 17:53:57 -05:00
|
|
|
return "presence";
|
2016-01-27 18:02:28 -05:00
|
|
|
case PREF_ROSTER_COUNT:
|
|
|
|
return "unread";
|
2015-11-17 18:37:33 -05:00
|
|
|
case PREF_ROSTER_ORDER:
|
2015-11-17 20:03:35 -05:00
|
|
|
return "presence";
|
2016-01-16 21:17:12 -05:00
|
|
|
case PREF_ROSTER_UNREAD:
|
|
|
|
return "after";
|
2016-01-19 17:38:00 -05:00
|
|
|
case PREF_ROSTER_ROOMS_POS:
|
|
|
|
return "last";
|
2016-01-31 20:11:01 -05:00
|
|
|
case PREF_ROSTER_ROOMS_BY:
|
|
|
|
return "none";
|
2020-01-23 10:50:43 -05:00
|
|
|
case PREF_ROSTER_ROOMS_USE_AS_NAME:
|
|
|
|
return "name";
|
2020-01-23 13:42:22 -05:00
|
|
|
case PREF_TITLEBAR_MUC_TITLE:
|
|
|
|
return "name";
|
2016-01-09 17:21:09 -05:00
|
|
|
case PREF_ROSTER_ROOMS_ORDER:
|
|
|
|
return "name";
|
2016-01-16 20:49:16 -05:00
|
|
|
case PREF_ROSTER_ROOMS_UNREAD:
|
|
|
|
return "after";
|
2016-01-23 20:04:21 -05:00
|
|
|
case PREF_ROSTER_PRIVATE:
|
|
|
|
return "room";
|
2015-09-30 17:34:27 -04:00
|
|
|
case PREF_TIME_CONSOLE:
|
|
|
|
return "%H:%M:%S";
|
|
|
|
case PREF_TIME_CHAT:
|
|
|
|
return "%H:%M:%S";
|
|
|
|
case PREF_TIME_MUC:
|
|
|
|
return "%H:%M:%S";
|
2018-04-11 12:57:50 -04:00
|
|
|
case PREF_TIME_CONFIG:
|
2015-11-14 17:42:17 -05:00
|
|
|
return "%H:%M:%S";
|
|
|
|
case PREF_TIME_PRIVATE:
|
|
|
|
return "%H:%M:%S";
|
2015-09-30 17:34:27 -04:00
|
|
|
case PREF_TIME_XMLCONSOLE:
|
2015-01-27 20:55:16 -05:00
|
|
|
return "%H:%M:%S";
|
2015-03-10 19:35:08 -04:00
|
|
|
case PREF_TIME_STATUSBAR:
|
2015-05-29 20:53:37 -04:00
|
|
|
return "%H:%M";
|
2015-09-29 18:30:23 -04:00
|
|
|
case PREF_TIME_LASTACTIVITY:
|
2015-09-30 18:22:39 -04:00
|
|
|
return "%d/%m/%y %H:%M:%S";
|
2015-06-21 16:42:58 -04:00
|
|
|
case PREF_PGP_LOG:
|
|
|
|
return "redact";
|
2015-12-29 18:00:49 -05:00
|
|
|
case PREF_CONSOLE_MUC:
|
2016-02-03 18:39:20 -05:00
|
|
|
case PREF_CONSOLE_PRIVATE:
|
2016-02-03 18:02:52 -05:00
|
|
|
case PREF_CONSOLE_CHAT:
|
|
|
|
return "all";
|
2018-03-10 17:16:52 -05:00
|
|
|
case PREF_STATUSBAR_SELF:
|
|
|
|
return "fulljid";
|
2018-03-09 16:11:59 -05:00
|
|
|
case PREF_STATUSBAR_CHAT:
|
|
|
|
return "user";
|
|
|
|
case PREF_STATUSBAR_ROOM:
|
|
|
|
return "room";
|
2019-03-22 13:32:15 -04:00
|
|
|
case PREF_OMEMO_LOG:
|
|
|
|
return "redact";
|
2019-04-15 16:09:47 -04:00
|
|
|
case PREF_OMEMO_POLICY:
|
|
|
|
return "automatic";
|
2020-02-05 09:29:17 -05:00
|
|
|
case PREF_COLOR_NICK:
|
2020-02-06 04:54:03 -05:00
|
|
|
return "false";
|
2013-02-02 22:24:13 -05:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-05-17 17:05:43 -04:00
|
|
|
}
|