Moved OTR policy check to otr module
This commit is contained in:
@@ -1363,7 +1363,7 @@ cmd_execute_default(const char * const inp)
|
|||||||
ui_current_print_line("You are not currently connected.");
|
ui_current_print_line("You are not currently connected.");
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
if ((strcmp(prefs_get_string(PREF_OTR_POLICY), "always") == 0) && !otr_is_secure(recipient)) {
|
if ((strcmp(otr_get_policy(recipient), "always") == 0) && !otr_is_secure(recipient)) {
|
||||||
cons_show_error("Failed to send message. Please check OTR policy");
|
cons_show_error("Failed to send message. Please check OTR policy");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1004,7 +1004,7 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
cons_show_error("Failed to encrypt and send message,");
|
cons_show_error("Failed to encrypt and send message,");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char *policy = prefs_get_string(PREF_OTR_POLICY);
|
char *policy = otr_get_policy(usr_jid);
|
||||||
|
|
||||||
if (strcmp(policy, "always") == 0) {
|
if (strcmp(policy, "always") == 0) {
|
||||||
cons_show_error("Failed to send message. Please check OTR policy");
|
cons_show_error("Failed to send message. Please check OTR policy");
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "roster_list.h"
|
#include "roster_list.h"
|
||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
#include "config/preferences.h"
|
||||||
|
|
||||||
#define PRESENCE_ONLINE 1
|
#define PRESENCE_ONLINE 1
|
||||||
#define PRESENCE_OFFLINE 0
|
#define PRESENCE_OFFLINE 0
|
||||||
@@ -515,6 +516,13 @@ _otr_get_their_fingerprint(const char * const recipient)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_otr_get_policy(const char * const recipient)
|
||||||
|
{
|
||||||
|
// check global setting
|
||||||
|
return prefs_get_string(PREF_OTR_POLICY);
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_otr_encrypt_message(const char * const to, const char * const message)
|
_otr_encrypt_message(const char * const to, const char * const message)
|
||||||
{
|
{
|
||||||
@@ -596,4 +604,5 @@ otr_init_module(void)
|
|||||||
otr_smp_secret = _otr_smp_secret;
|
otr_smp_secret = _otr_smp_secret;
|
||||||
otr_smp_question = _otr_smp_question;
|
otr_smp_question = _otr_smp_question;
|
||||||
otr_smp_answer = _otr_smp_answer;
|
otr_smp_answer = _otr_smp_answer;
|
||||||
|
otr_get_policy = _otr_get_policy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,6 @@ char * (*otr_decrypt_message)(const char * const from, const char * const messag
|
|||||||
|
|
||||||
void (*otr_free_message)(char *message);
|
void (*otr_free_message)(char *message);
|
||||||
|
|
||||||
|
char * (*otr_get_policy)(const char * const recipient);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
|||||||
gboolean was_decrypted = FALSE;
|
gboolean was_decrypted = FALSE;
|
||||||
char *newmessage;
|
char *newmessage;
|
||||||
|
|
||||||
char *policy = prefs_get_string(PREF_OTR_POLICY);
|
char *policy = otr_get_policy(from);
|
||||||
char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE);
|
char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE);
|
||||||
|
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
|
|||||||
Reference in New Issue
Block a user