From 6450e2a704c6ed13ec8e5d26d7e5cf933ad00c61 Mon Sep 17 00:00:00 2001 From: lightb Date: Tue, 22 Apr 2014 16:01:57 -0400 Subject: [PATCH] Added OTR opportunistic pattern intercept. When a message is received, OTRL_MESSAGE_TAG_BASE + OTRL_MESSAGE_TAG_V1 or OTRL_MESSAGE_TAG_V2 is searched for, if it is, the client attempts to start an OTR session. Tested between profanity clients: WORKED Tested between profanity and pidgin: NOT WORKING (not sure if pidgin checks for the whitespace) --- src/server_events.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/server_events.c b/src/server_events.c index afb29bcd..0d0ba9c6 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -32,6 +32,7 @@ #ifdef HAVE_LIBOTR #include "otr/otr.h" +#include #endif #include "ui/ui.h" @@ -205,6 +206,17 @@ void handle_incoming_message(char *from, char *message, gboolean priv) { #ifdef HAVE_LIBOTR +//check for OTR whitespace (opportunistic) + char *policy = prefs_get_string(PREF_OTR_POLICY); + if (strcmp(policy, "opportunistic") == 0) { + if (strstr(message,OTRL_MESSAGE_TAG_BASE)) { + if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) { + char *otr_query_message = otr_start_query(); + cons_show("OTR Whitespace pattern detected. Attempting to start OTR session...", message); + message_send(otr_query_message, from); + } + } + } gboolean was_decrypted = FALSE; char *newmessage; if (!priv) {