diff options
-rw-r--r-- | src/command/command.c | 17 | ||||
-rw-r--r-- | src/command/commands.c | 11 | ||||
-rw-r--r-- | src/command/commands.h | 1 | ||||
-rw-r--r-- | src/config/preferences.c | 26 | ||||
-rw-r--r-- | src/config/preferences.h | 4 | ||||
-rw-r--r-- | src/config/theme.c | 2 | ||||
-rw-r--r-- | src/event/server_events.c | 2 | ||||
-rw-r--r-- | src/ui/console.c | 17 | ||||
-rw-r--r-- | src/ui/titlebar.c | 3 | ||||
-rw-r--r-- | src/ui/ui.h | 1 | ||||
-rw-r--r-- | tests/unittests/test_cmd_otr.c | 62 | ||||
-rw-r--r-- | tests/unittests/test_cmd_otr.h | 4 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 1 | ||||
-rw-r--r-- | tests/unittests/unittests.c | 8 | ||||
-rw-r--r-- | theme_template | 2 | ||||
-rw-r--r-- | themes/boothj5 | 2 | ||||
-rw-r--r-- | themes/complex | 2 | ||||
-rw-r--r-- | themes/simple | 2 |
18 files changed, 46 insertions, 121 deletions
diff --git a/src/command/command.c b/src/command/command.c index af91bf16..05ca9737 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -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; diff --git a/src/command/commands.c b/src/command/commands.c index 2fe4c2f6..03a3f9f6 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -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, diff --git a/src/command/commands.h b/src/command/commands.h index d7044ea1..6f2bada2 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -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); diff --git a/src/config/preferences.c b/src/config/preferences.c index 62e2522b..64fb13bd 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -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: diff --git a/src/config/preferences.h b/src/config/preferences.h index 273ce6bb..16a4d4e0 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -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 { diff --git a/src/config/theme.c b/src/config/theme.c index 640b7298..d870b371 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -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 * diff --git a/src/event/server_events.c b/src/event/server_events.c index 8d830d5e..824a12cb 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -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) { diff --git a/src/ui/console.c b/src/ui/console.c index 1e20c964..ac18c7da 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -885,6 +885,16 @@ cons_winstidy_setting(void) } 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) { if (prefs_get_boolean(PREF_PRESENCE)) @@ -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"); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 3642417a..16a9eaff 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -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, "["); diff --git a/src/ui/ui.h b/src/ui/ui.h index 7cfad86c..b5bfb482 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -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); diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index dd1898a9..7d4a3291 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -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)); diff --git a/tests/unittests/test_cmd_otr.h b/tests/unittests/test_cmd_otr.h index 8ef182e9..469d7c54 100644 --- a/tests/unittests/test_cmd_otr.h +++ b/tests/unittests/test_cmd_otr.h @@ -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); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 085ff03b..6d008414 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -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) {} diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index a0fb8886..d20cf0b2 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -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), diff --git a/theme_template b/theme_template index 4020c000..e2380b44 100644 --- a/theme_template +++ b/theme_template @@ -58,7 +58,7 @@ time= privileges= presence= intype= -otr.warn= +enc.warn= resource.title= resource.message= statuses.console= diff --git a/themes/boothj5 b/themes/boothj5 index 3f591fc1..090f7bc3 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -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 diff --git a/themes/complex b/themes/complex index a5510baa..46e926c2 100644 --- a/themes/complex +++ b/themes/complex @@ -21,4 +21,4 @@ roster.size=25 privileges=true presence=true intype=true -otr.warn=true +enc.warn=true diff --git a/themes/simple b/themes/simple index 3ddd2893..e873723b 100644 --- a/themes/simple +++ b/themes/simple @@ -20,5 +20,5 @@ roster.size=25 privileges=false presence=false intype=false -otr.warn=false +enc.warn=false wins.autotidy=false |