From a687e3f6b4abe5e5917d25fea9f9d0bfb0c3a98d Mon Sep 17 00:00:00 2001 From: lightb Date: Sat, 19 Apr 2014 04:18:53 -0400 Subject: [PATCH] Added /otr policy to commands (still need to add autocomplete stuff?) --- src/command/commands.c | 19 ++++++++++++++++++- src/config/preferences.c | 3 +++ src/otr/otr.c | 1 - 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/command/commands.c b/src/command/commands.c index ad94211c..e92bbe1d 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2610,11 +2610,28 @@ cmd_otr(gchar **args, struct cmd_help_t help) cons_show("Using libotr version %s", version); return TRUE; } else if (strcmp(args[0], "policy") == 0) { + if (args[1] == NULL) { + char *policy = prefs_get_string(PREF_OTR_POLICY); + cons_show("OTR policy is now set to: %s", policy); + return TRUE; + } + 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"); - } + } else + if (g_strcmp0(choice, "opportunistic") == 0) { + prefs_set_string(PREF_OTR_POLICY, "opportunistic"); + cons_show("OTR policy is now set to: opportunistic"); + } else + if (g_strcmp0(choice, "always") == 0) { + prefs_set_string(PREF_OTR_POLICY, "always"); + cons_show("OTR policy is now set to: always"); + } else + { + cons_show("OTR policy can be set to: manual, opportunistic or always."); + } return TRUE; } diff --git a/src/config/preferences.c b/src/config/preferences.c index 4c00597e..f4133413 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -45,6 +45,7 @@ #define PREF_GROUP_PRESENCE "presence" #define PREF_GROUP_CONNECTION "connection" #define PREF_GROUP_ALIAS "alias" +#define PREF_GROUP_OTR_POLICY "policy" static gchar *prefs_loc; static GKeyFile *prefs; @@ -396,6 +397,8 @@ _get_group(preference_t pref) case PREF_LOG_ROTATE: case PREF_LOG_SHARED: return PREF_GROUP_LOGGING; + case PREF_OTR_POLICY: + return PREF_GROUP_OTR_POLICY; case PREF_AUTOAWAY_CHECK: case PREF_AUTOAWAY_MODE: case PREF_AUTOAWAY_MESSAGE: diff --git a/src/otr/otr.c b/src/otr/otr.c index 8ff64640..5424b09a 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -421,7 +421,6 @@ _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);