diff options
-rw-r--r-- | src/command/cmd_defs.c | 13 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 9 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 1 | ||||
-rw-r--r-- | src/config/preferences.c | 52 | ||||
-rw-r--r-- | src/config/preferences.h | 1 |
5 files changed, 58 insertions, 18 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 2c227153..e7ece238 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2408,6 +2408,19 @@ static struct cmd_t command_defs[] = CMD_NOARGS CMD_NOEXAMPLES }, + + { "/reload", + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_reload) + CMD_NOTAGS + CMD_SYN( + "/reload") + CMD_DESC( + "Reload preferences from configuration file.") + CMD_NOARGS + CMD_NOEXAMPLES + }, }; static GHashTable *search_index; diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 9f73cb07..30e7720f 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -8551,3 +8551,12 @@ cmd_save(ProfWin *window, const char *const command, gchar **args) prefs_save(); return TRUE; } + +gboolean +cmd_reload(ProfWin *window, const char *const command, gchar **args) +{ + log_info("Reloading preferences"); + cons_show("Reloading preferences."); + prefs_reload(); + return TRUE; +} diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index c623ca83..9102e1e1 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -227,4 +227,5 @@ gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **ar gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args); gboolean cmd_save(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args); #endif diff --git a/src/config/preferences.c b/src/config/preferences.c index e8f19996..fc755bff 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -78,25 +78,9 @@ static const char* _get_key(preference_t pref); static gboolean _get_default_boolean(preference_t pref); static char* _get_default_string(preference_t pref); -void -prefs_load(char *config_file) +void _prefs_load(void) { - GError *err; - - 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); - - err = NULL; + GError *err = NULL; log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err); if (err) { log_maxsize = 0; @@ -181,6 +165,38 @@ prefs_load(char *config_file) } 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(); +} + +void prefs_save(void) { _save_prefs(); diff --git a/src/config/preferences.h b/src/config/preferences.h index 08f13cb0..1a6250a4 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -169,6 +169,7 @@ typedef struct prof_winplacement_t { void prefs_load(char *config_file); void prefs_save(void); void prefs_close(void); +void prefs_reload(void); char* prefs_find_login(char *prefix); void prefs_reset_login_search(void); |