diff --git a/src/command/command.c b/src/command/command.c index f1432d90..def2815b 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -191,7 +191,8 @@ static struct cmd_t command_defs[] = { "/tls", cmd_tls, parse_args, 1, 3, NULL, CMD_TAGS( - CMD_TAG_CONNECTION) + CMD_TAG_CONNECTION, + CMD_TAG_UI) CMD_SYN( "/tls allow", "/tls always", @@ -200,7 +201,8 @@ static struct cmd_t command_defs[] = "/tls revoke ", "/tls certpath", "/tls certpath set ", - "/tls certpath clear") + "/tls certpath clear", + "/tls show on|off") CMD_DESC( "Handle TLS certificates. ") CMD_ARGS( @@ -211,7 +213,8 @@ static struct cmd_t command_defs[] = { "revoke ", "Remove a manually trusted certificate." }, { "certpath", "Show the trusted certificate path." }, { "certpath set ", "Specify filesystem path containing trusted certificates." }, - { "certpath clear", "Clear the trusted certificate path." }) + { "certpath clear", "Clear the trusted certificate path." }, + { "show on|off", "Show or hide the TLS indicator in the titlebar." }) CMD_NOEXAMPLES }, @@ -2158,6 +2161,7 @@ cmd_init(void) autocomplete_add(tls_ac, "trusted"); autocomplete_add(tls_ac, "revoke"); autocomplete_add(tls_ac, "certpath"); + autocomplete_add(tls_ac, "show"); tls_certpath_ac = autocomplete_new(); autocomplete_add(tls_certpath_ac, "set"); @@ -3628,6 +3632,11 @@ _tls_autocomplete(ProfWin *window, const char * const input) return result; } + result = autocomplete_param_with_func(input, "/tls show", prefs_autocomplete_boolean_choice); + if (result) { + return result; + } + result = autocomplete_param_with_ac(input, "/tls", tls_ac, TRUE); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index c34c7cc3..94e768db 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -237,6 +237,8 @@ cmd_tls(ProfWin *window, const char * const command, gchar **args) } } return TRUE; + } else if (g_strcmp0(args[0], "show") == 0) { + return _cmd_set_boolean_preference(args[1], command, "TLS titlebar indicator", PREF_TLS_SHOW); } else { cons_bad_cmd_usage(command); return TRUE; diff --git a/src/config/preferences.c b/src/config/preferences.c index 527ed302..9aaa9083 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -602,6 +602,7 @@ _get_group(preference_t pref) case PREF_RESOURCE_MESSAGE: case PREF_ENC_WARN: case PREF_INPBLOCK_DYNAMIC: + case PREF_TLS_SHOW: return PREF_GROUP_UI; case PREF_STATES: case PREF_OUTTYPE: @@ -781,6 +782,8 @@ _get_key(preference_t pref) return "log"; case PREF_CERT_PATH: return "certpath"; + case PREF_TLS_SHOW: + return "tls.show"; default: return NULL; } @@ -817,6 +820,7 @@ _get_default_boolean(preference_t pref) case PREF_ROSTER_OFFLINE: case PREF_ROSTER_RESOURCE: case PREF_ROSTER_EMPTY: + case PREF_TLS_SHOW: return TRUE; default: return FALSE; diff --git a/src/config/preferences.h b/src/config/preferences.h index 770e379e..a0b3c06e 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -112,6 +112,7 @@ typedef enum { PREF_ENC_WARN, PREF_PGP_LOG, PREF_CERT_PATH, + PREF_TLS_SHOW, } preference_t; typedef struct prof_alias_t { diff --git a/src/config/theme.c b/src/config/theme.c index e840fab5..0c9a39b7 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -471,6 +471,7 @@ _load_preferences(void) _set_boolean_preference("intype", PREF_INTYPE); _set_boolean_preference("enc.warn", PREF_ENC_WARN); + _set_boolean_preference("tls.show", PREF_TLS_SHOW); if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) { gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL); diff --git a/src/ui/console.c b/src/ui/console.c index 820684c1..319e451d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -941,6 +941,16 @@ cons_encwarn_setting(void) } } +void +cons_tlsshow_setting(void) +{ + if (prefs_get_boolean(PREF_TLS_SHOW)) { + cons_show("TLS show (/tls) : ON"); + } else { + cons_show("TLS show (/tls) : OFF"); + } +} + void cons_presence_setting(void) { @@ -1147,6 +1157,7 @@ cons_show_ui_prefs(void) cons_encwarn_setting(); cons_presence_setting(); cons_inpblock_setting(); + cons_tlsshow_setting(); cons_alert(); } diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 32ba13b4..41715811 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -282,7 +282,7 @@ _show_self_presence(void) mvwaddch(win, 0, cols - 2, ']'); wattroff(win, bracket_attrs); - if (is_connected) { + if (is_connected && prefs_get_boolean(PREF_TLS_SHOW)) { wattron(win, bracket_attrs); mvwaddch(win, 0, cols - tls_start, '['); wattroff(win, bracket_attrs); diff --git a/src/ui/ui.h b/src/ui/ui.h index 93fde07b..add38fb4 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -304,6 +304,7 @@ void cons_beep_setting(void); void cons_flash_setting(void); void cons_splash_setting(void); void cons_encwarn_setting(void); +void cons_tlsshow_setting(void); void cons_vercheck_setting(void); void cons_occupants_setting(void); void cons_roster_setting(void); diff --git a/themes/boothj5 b/themes/boothj5 index 251f2119..b6dbe5b9 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -83,3 +83,4 @@ occupants.jid=false wins.autotidy=true otr.char=@ pgp.char=% +tls.show=true diff --git a/themes/complex b/themes/complex index 470255da..2f8e2d8f 100644 --- a/themes/complex +++ b/themes/complex @@ -28,3 +28,4 @@ privileges=true presence=true intype=true enc.warn=true +tls.show=true diff --git a/themes/simple b/themes/simple index 03140560..32a4b20f 100644 --- a/themes/simple +++ b/themes/simple @@ -28,3 +28,4 @@ presence=false intype=false enc.warn=false wins.autotidy=false +tls.show=false