mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Moved setting otr.warn -> enc.warn
This commit is contained in:
parent
e72ddf5488
commit
446027b950
@ -668,6 +668,14 @@ static struct cmd_t command_defs[] =
|
||||
"If the terminal does not support sounds, it may attempt to flash the screen instead.",
|
||||
NULL } } },
|
||||
|
||||
{ "/encwarn",
|
||||
cmd_encwarn, parse_args, 1, 1, &cons_encwarn_setting,
|
||||
{ "/encwarn on|off", "Titlebar encryption warning.",
|
||||
{ "/encwarn on|off",
|
||||
"---------------",
|
||||
"Enabled or disable the unencrypted warning message in the titlebar.",
|
||||
NULL } } },
|
||||
|
||||
{ "/presence",
|
||||
cmd_presence, parse_args, 1, 1, &cons_presence_setting,
|
||||
{ "/presence on|off", "Show the contacts presence in the titlebar.",
|
||||
@ -1483,7 +1491,6 @@ cmd_init(void)
|
||||
autocomplete_add(otr_ac, "untrust");
|
||||
autocomplete_add(otr_ac, "secret");
|
||||
autocomplete_add(otr_ac, "log");
|
||||
autocomplete_add(otr_ac, "warn");
|
||||
autocomplete_add(otr_ac, "libver");
|
||||
autocomplete_add(otr_ac, "policy");
|
||||
autocomplete_add(otr_ac, "question");
|
||||
@ -1957,7 +1964,7 @@ _cmd_complete_parameters(ProfWin *window, const char * const input)
|
||||
// autocomplete boolean settings
|
||||
gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
|
||||
"/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history",
|
||||
"/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons" };
|
||||
"/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn" };
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice);
|
||||
@ -2460,12 +2467,6 @@ _otr_autocomplete(ProfWin *window, const char * const input)
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_func(input, "/otr warn",
|
||||
prefs_autocomplete_boolean_choice);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/otr", otr_ac, TRUE);
|
||||
if (found) {
|
||||
return found;
|
||||
|
@ -4326,11 +4326,6 @@ cmd_otr(ProfWin *window, gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
} else if (strcmp(args[0], "warn") == 0) {
|
||||
gboolean result = _cmd_set_boolean_preference(args[1], help,
|
||||
"OTR warning message", PREF_OTR_WARN);
|
||||
return result;
|
||||
|
||||
} else if (strcmp(args[0], "libver") == 0) {
|
||||
char *version = otr_libotr_version();
|
||||
cons_show("Using libotr version %s", version);
|
||||
@ -4608,6 +4603,12 @@ cmd_otr(ProfWin *window, gchar **args, struct cmd_help_t help)
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_encwarn(ProfWin *window, gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
return _cmd_set_boolean_preference(args[0], help, "Encryption warning message", PREF_ENC_WARN);
|
||||
}
|
||||
|
||||
// helper function for status change commands
|
||||
static void
|
||||
_update_presence(const resource_presence_t resource_presence,
|
||||
|
@ -146,6 +146,7 @@ gboolean cmd_wrap(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_time(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_resource(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_inpblock(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_encwarn(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||
|
||||
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);
|
||||
|
||||
|
@ -94,22 +94,12 @@ prefs_load(void)
|
||||
g_error_free(err);
|
||||
}
|
||||
|
||||
// move pre 0.4.6 OTR warn preferences to [ui] group
|
||||
// move pre 0.4.7 enc.warn to enc.warn
|
||||
err = NULL;
|
||||
gboolean otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_OTR, "warn", &err);
|
||||
gboolean otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "otr.warn", &err);
|
||||
if (err == NULL) {
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_UI, _get_key(PREF_OTR_WARN), otr_warn);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_OTR, "warn", NULL);
|
||||
} else {
|
||||
g_error_free(err);
|
||||
}
|
||||
|
||||
// move pre 0.4.6 titlebar preference
|
||||
err = NULL;
|
||||
gchar *old_titlebar = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar", &err);
|
||||
if (err == NULL) {
|
||||
g_key_file_set_string(prefs, PREF_GROUP_UI, _get_key(PREF_TITLEBAR_SHOW), old_titlebar);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar", NULL);
|
||||
g_key_file_set_boolean(prefs, PREF_GROUP_UI, _get_key(PREF_ENC_WARN), otr_warn);
|
||||
g_key_file_remove_key(prefs, PREF_GROUP_UI, "otr.warn", NULL);
|
||||
} else {
|
||||
g_error_free(err);
|
||||
}
|
||||
@ -510,7 +500,7 @@ _get_group(preference_t pref)
|
||||
case PREF_ROSTER_BY:
|
||||
case PREF_RESOURCE_TITLE:
|
||||
case PREF_RESOURCE_MESSAGE:
|
||||
case PREF_OTR_WARN:
|
||||
case PREF_ENC_WARN:
|
||||
case PREF_INPBLOCK_DYNAMIC:
|
||||
return PREF_GROUP_UI;
|
||||
case PREF_STATES:
|
||||
@ -637,8 +627,6 @@ _get_key(preference_t pref)
|
||||
return "defaccount";
|
||||
case PREF_OTR_LOG:
|
||||
return "log";
|
||||
case PREF_OTR_WARN:
|
||||
return "otr.warn";
|
||||
case PREF_OTR_POLICY:
|
||||
return "policy";
|
||||
case PREF_LOG_ROTATE:
|
||||
@ -669,6 +657,8 @@ _get_key(preference_t pref)
|
||||
return "resource.message";
|
||||
case PREF_INPBLOCK_DYNAMIC:
|
||||
return "inpblock.dynamic";
|
||||
case PREF_ENC_WARN:
|
||||
return "enc.warn";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -681,7 +671,7 @@ _get_default_boolean(preference_t pref)
|
||||
{
|
||||
switch (pref)
|
||||
{
|
||||
case PREF_OTR_WARN:
|
||||
case PREF_ENC_WARN:
|
||||
case PREF_AUTOAWAY_CHECK:
|
||||
case PREF_LOG_ROTATE:
|
||||
case PREF_LOG_SHARED:
|
||||
|
@ -98,11 +98,11 @@ typedef enum {
|
||||
PREF_LOG_ROTATE,
|
||||
PREF_LOG_SHARED,
|
||||
PREF_OTR_LOG,
|
||||
PREF_OTR_WARN,
|
||||
PREF_OTR_POLICY,
|
||||
PREF_RESOURCE_TITLE,
|
||||
PREF_RESOURCE_MESSAGE,
|
||||
PREF_INPBLOCK_DYNAMIC
|
||||
PREF_INPBLOCK_DYNAMIC,
|
||||
PREF_ENC_WARN,
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t {
|
||||
|
@ -463,7 +463,7 @@ _load_preferences(void)
|
||||
_set_boolean_preference("presence", PREF_PRESENCE);
|
||||
_set_boolean_preference("intype", PREF_INTYPE);
|
||||
|
||||
_set_boolean_preference("otr.warn", PREF_OTR_WARN);
|
||||
_set_boolean_preference("enc.warn", PREF_ENC_WARN);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
@ -201,7 +201,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
|
||||
prof_enc_t enc_mode = chatwin->enc_mode;
|
||||
if (enc_message) {
|
||||
if (enc_mode == PROF_ENC_OTR) {
|
||||
// TODO show error
|
||||
win_println((ProfWin*)chatwin, "PGP encrypted message received whilst in OTR session.");
|
||||
} else { // PROF_ENC_NONE, PROF_ENC_PGP
|
||||
char *decrypted = p_gpg_decrypt(barejid, enc_message);
|
||||
if (decrypted) {
|
||||
|
@ -884,6 +884,16 @@ cons_winstidy_setting(void)
|
||||
cons_show("Window Auto Tidy (/winstidy) : OFF");
|
||||
}
|
||||
|
||||
void
|
||||
cons_encwarn_setting(void)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_ENC_WARN)) {
|
||||
cons_show("Warn unencrypted (/encwarn) : ON");
|
||||
} else {
|
||||
cons_show("Warn unencrypted (/encwarn) : OFF");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cons_presence_setting(void)
|
||||
{
|
||||
@ -1058,6 +1068,7 @@ cons_show_ui_prefs(void)
|
||||
cons_roster_setting();
|
||||
cons_privileges_setting();
|
||||
cons_titlebar_setting();
|
||||
cons_encwarn_setting();
|
||||
cons_presence_setting();
|
||||
cons_inpblock_setting();
|
||||
|
||||
@ -1398,12 +1409,6 @@ cons_show_otr_prefs(void)
|
||||
cons_show("OTR policy (/otr policy) : %s", policy_value);
|
||||
prefs_free_string(policy_value);
|
||||
|
||||
if (prefs_get_boolean(PREF_OTR_WARN)) {
|
||||
cons_show("Warn non-OTR (/otr warn) : ON");
|
||||
} else {
|
||||
cons_show("Warn non-OTR (/otr warn) : OFF");
|
||||
}
|
||||
|
||||
char *log_value = prefs_get_string(PREF_OTR_LOG);
|
||||
if (strcmp(log_value, "on") == 0) {
|
||||
cons_show("OTR logging (/otr log) : ON");
|
||||
|
@ -252,8 +252,7 @@ _show_privacy(ProfChatWin *chatwin)
|
||||
|
||||
switch (chatwin->enc_mode) {
|
||||
case PROF_ENC_NONE:
|
||||
// TODO generalise to PROF_ENC_WARN
|
||||
if (prefs_get_boolean(PREF_OTR_WARN)) {
|
||||
if (prefs_get_boolean(PREF_ENC_WARN)) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
|
@ -288,6 +288,7 @@ void cons_privileges_setting(void);
|
||||
void cons_beep_setting(void);
|
||||
void cons_flash_setting(void);
|
||||
void cons_splash_setting(void);
|
||||
void cons_encwarn_setting(void);
|
||||
void cons_vercheck_setting(void);
|
||||
void cons_occupants_setting(void);
|
||||
void cons_roster_setting(void);
|
||||
|
@ -167,68 +167,6 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_otr_warn_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "Some usage";
|
||||
gchar *args[] = { "warn", NULL };
|
||||
|
||||
expect_cons_show("Usage: Some usage");
|
||||
|
||||
gboolean result = cmd_otr(NULL, args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_otr_warn_shows_usage_when_invalid_arg(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "Some usage";
|
||||
gchar *args[] = { "warn", "badarg", NULL };
|
||||
|
||||
expect_cons_show("Usage: Some usage");
|
||||
|
||||
gboolean result = cmd_otr(NULL, args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_otr_warn_on_enables_unencrypted_warning(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "warn", "on", NULL };
|
||||
prefs_set_boolean(PREF_OTR_WARN, FALSE);
|
||||
|
||||
expect_cons_show("OTR warning message enabled.");
|
||||
|
||||
gboolean result = cmd_otr(NULL, args, *help);
|
||||
gboolean otr_warn_enabled = prefs_get_boolean(PREF_OTR_WARN);
|
||||
|
||||
assert_true(result);
|
||||
assert_true(otr_warn_enabled);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_otr_warn_off_disables_unencrypted_warning(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "warn", "off", NULL };
|
||||
prefs_set_boolean(PREF_OTR_WARN, TRUE);
|
||||
|
||||
expect_cons_show("OTR warning message disabled.");
|
||||
|
||||
gboolean result = cmd_otr(NULL, args, *help);
|
||||
gboolean otr_warn_enabled = prefs_get_boolean(PREF_OTR_WARN);
|
||||
|
||||
assert_true(result);
|
||||
assert_false(otr_warn_enabled);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_otr_libver_shows_libotr_version(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
|
@ -10,10 +10,6 @@ void cmd_otr_log_off_disables_logging(void **state);
|
||||
void cmd_otr_redact_redacts_logging(void **state);
|
||||
void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state);
|
||||
void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state);
|
||||
void cmd_otr_warn_shows_usage_when_no_args(void **state);
|
||||
void cmd_otr_warn_shows_usage_when_invalid_arg(void **state);
|
||||
void cmd_otr_warn_on_enables_unencrypted_warning(void **state);
|
||||
void cmd_otr_warn_off_disables_unencrypted_warning(void **state);
|
||||
void cmd_otr_libver_shows_libotr_version(void **state);
|
||||
void cmd_otr_gen_shows_message_when_not_connected(void **state);
|
||||
void cmd_otr_gen_generates_key_for_connected_account(void **state);
|
||||
|
@ -447,6 +447,7 @@ void cons_roster_setting(void) {}
|
||||
void cons_presence_setting(void) {}
|
||||
void cons_wrap_setting(void) {}
|
||||
void cons_winstidy_setting(void) {}
|
||||
void cons_encwarn_setting(void) {}
|
||||
void cons_time_setting(void) {}
|
||||
void cons_mouse_setting(void) {}
|
||||
void cons_statuses_setting(void) {}
|
||||
|
@ -500,14 +500,6 @@ int main(int argc, char* argv[]) {
|
||||
unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test(cmd_otr_warn_shows_usage_when_no_args),
|
||||
unit_test(cmd_otr_warn_shows_usage_when_invalid_arg),
|
||||
unit_test_setup_teardown(cmd_otr_warn_on_enables_unencrypted_warning,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_otr_warn_off_disables_unencrypted_warning,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test(cmd_otr_libver_shows_libotr_version),
|
||||
unit_test(cmd_otr_gen_shows_message_when_not_connected),
|
||||
unit_test(cmd_otr_gen_generates_key_for_connected_account),
|
||||
|
@ -58,7 +58,7 @@ time=
|
||||
privileges=
|
||||
presence=
|
||||
intype=
|
||||
otr.warn=
|
||||
enc.warn=
|
||||
resource.title=
|
||||
resource.message=
|
||||
statuses.console=
|
||||
|
@ -59,7 +59,7 @@ time.statusbar=seconds
|
||||
privileges=true
|
||||
presence=true
|
||||
intype=true
|
||||
otr.warn=true
|
||||
enc.warn=true
|
||||
resource.title=true
|
||||
resource.message=true
|
||||
statuses.console=all
|
||||
|
@ -21,4 +21,4 @@ roster.size=25
|
||||
privileges=true
|
||||
presence=true
|
||||
intype=true
|
||||
otr.warn=true
|
||||
enc.warn=true
|
||||
|
@ -20,5 +20,5 @@ roster.size=25
|
||||
privileges=false
|
||||
presence=false
|
||||
intype=false
|
||||
otr.warn=false
|
||||
enc.warn=false
|
||||
wins.autotidy=false
|
||||
|
Loading…
Reference in New Issue
Block a user