From 02b77cfa4e9b600c03c2fa79ab0e3fa55c33961f Mon Sep 17 00:00:00 2001 From: lightb Date: Sat, 19 Apr 2014 04:00:41 -0400 Subject: [PATCH] Added PREF_OTR_POLICY to preferences.c -> key -> otr.policy Added default value "manual" to PREF_OTR_POLICy -> preferences.c Modified help string to reflect otr_policy, started checks on cmd_otr --- src/command/command.c | 5 +++-- src/command/commands.c | 7 +++++++ src/config/preferences.c | 4 ++++ src/otr/otr.c | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 23d5bae4..31a481b7 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -594,8 +594,8 @@ static struct cmd_t command_defs[] = { "/otr", cmd_otr, parse_args, 1, 2, NULL, - { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver", "Off The Record encryption commands.", - { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver", + { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver|policy", "Off The Record encryption commands.", + { "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn|libver|policy", "-------------------------------------------------------------", "gen - Generate your private key.", "myfp - Show your fingerprint.", @@ -607,6 +607,7 @@ static struct cmd_t command_defs[] = "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.", "libver - Show which version of the libotr library is being used.", + "policy - manual, opportunistic or always.", NULL } } }, { "/outtype", diff --git a/src/command/commands.c b/src/command/commands.c index 8e026b50..ad94211c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2609,6 +2609,13 @@ cmd_otr(gchar **args, struct cmd_help_t help) char *version = otr_libotr_version(); cons_show("Using libotr version %s", version); return TRUE; + } else if (strcmp(args[0], "policy") == 0) { + char *choice = args[1]; + if (g_strcmp0(choice, "manual") == 0) { + prefs_set_string(PREF_OTR_POLICY, "manual"); + cons_show("OTR policy is now set to: manual"); + } + return TRUE; } if (jabber_get_connection_status() != JABBER_CONNECTED) { diff --git a/src/config/preferences.c b/src/config/preferences.c index 9cc91cb6..4c00597e 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -466,6 +466,8 @@ _get_key(preference_t pref) return "otr"; case PREF_OTR_WARN: return "otr.warn"; + case PREF_OTR_POLICY: + return "otr.policy"; case PREF_LOG_ROTATE: return "rotate"; case PREF_LOG_SHARED: @@ -500,6 +502,8 @@ _get_default_string(preference_t pref) return "off"; case PREF_OTR_LOG: return "redact"; + case PREF_OTR_POLICY: + return "manual"; case PREF_STATUSES_CONSOLE: case PREF_STATUSES_CHAT: case PREF_STATUSES_MUC: diff --git a/src/otr/otr.c b/src/otr/otr.c index 5424b09a..8ff64640 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -421,6 +421,7 @@ _otr_get_their_fingerprint(const char * const recipient) static char * _otr_encrypt_message(const char * const to, const char * const message) { + return NULL; char *newmessage = NULL; gcry_error_t err = otrlib_encrypt_message(user_state, &ops, jid, to, message, &newmessage);