about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorlightb <lightb@bigfoot>2014-04-22 16:01:57 -0400
committerlightb <lightb@bigfoot>2014-04-22 16:01:57 -0400
commit6450e2a704c6ed13ec8e5d26d7e5cf933ad00c61 (patch)
tree827075ed39cc5531e82129749124a5e22cabe3f9 /src
parentf95ae8b0dd98a1ccfffb4fe7866eb3007e28f8f8 (diff)
downloadprofani-tty-6450e2a704c6ed13ec8e5d26d7e5cf933ad00c61.tar.gz
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)
Diffstat (limited to 'src')
-rw-r--r--src/server_events.c12
1 files changed, 12 insertions, 0 deletions
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 <libotr/proto.h>
 #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) {