From 4f98bc8c25075891a1fd5a954ae83e961405a664 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 16 Jan 2014 22:44:23 +0000 Subject: Show OTR coloured status Customisable within theme files e.g.: titlebar.unencrypted=red titlebar.encrypted=green titlebar.trusted=red titlebar.untrusted=green Shows [unencrypted] for all non-OTR chat Disable with '/otr warn off' --- src/command/command.c | 14 +++++++++++--- src/command/commands.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index d0d32fe7..e1833ede 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -571,9 +571,9 @@ static struct cmd_t command_defs[] = { "/otr", cmd_otr, parse_args, 1, 2, NULL, - { "/otr gen|myfp|theirfp|start|end|trust|untrust|log", "Off The Record encryption commands.", - { "/otr gen|myfp|theirfp|start|end|trust|untrust|log", - "-------------------------------------------------", + { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn", "Off The Record encryption commands.", + { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn", + "------------------------------------------------------", "gen - Generate your private key.", "myfp - Show your fingerprint.", "theirfp - Show contacts fingerprint.", @@ -582,6 +582,7 @@ static struct cmd_t command_defs[] = "trust - Indicate that you have verified the contact's fingerprint.", "untrust - Indicate the the contact's fingerprint is not verified,", "log - How to log OTR messages, options are 'on', 'off' and 'redact', with redaction being the default.", + "warn - Show when unencrypted messaging is being used in the title bar, options are 'on' and 'off' with 'on' being the default.", NULL } } }, { "/outtype", @@ -997,6 +998,7 @@ cmd_init(void) autocomplete_add(otr_ac, "trust"); autocomplete_add(otr_ac, "untrust"); autocomplete_add(otr_ac, "log"); + autocomplete_add(otr_ac, "warn"); otr_log_ac = autocomplete_new(); autocomplete_add(otr_log_ac, "on"); @@ -1588,6 +1590,12 @@ _otr_autocomplete(char *input, int *size) return result; } + result = autocomplete_param_with_func(input, size, "/otr warn", + prefs_autocomplete_boolean_choice); + if (result != NULL) { + return result; + } + result = autocomplete_param_with_ac(input, size, "/otr", otr_ac); if (result != NULL) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index 6adec3c5..a8d47eed 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2327,6 +2327,12 @@ cmd_otr(gchar **args, struct cmd_help_t help) cons_show("Usage: %s", help.usage); } return TRUE; + } else if (strcmp(args[0], "warn") == 0) { + gboolean result = _cmd_set_boolean_preference(args[1], help, + "OTR warning message", PREF_OTR_WARN); + // update the current window + ui_switch_win(wins_get_current_num()); + return result; } if (jabber_get_connection_status() != JABBER_CONNECTED) { @@ -2493,7 +2499,11 @@ _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help, GString *disabled = g_string_new(display); g_string_append(disabled, " disabled."); - if (strcmp(arg, "on") == 0) { + if (arg == NULL) { + char usage[strlen(help.usage) + 8]; + sprintf(usage, "Usage: %s", help.usage); + cons_show(usage); + } else if (strcmp(arg, "on") == 0) { cons_show(enabled->str); prefs_set_boolean(pref, TRUE); } else if (strcmp(arg, "off") == 0) { -- cgit 1.4.1-2-gfad0