about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorlightb <lightb@bigfoot>2014-04-22 18:07:53 -0400
committerlightb <lightb@bigfoot>2014-04-22 18:07:53 -0400
commit5a5ad31edf137e62ee5678f9845c155811d9e2e1 (patch)
tree357ba36f8964b5bad2df351e7fe998c6b5d987c6
parent1192e67cf76ba953031f420e5ac790989a81530c (diff)
downloadprofani-tty-5a5ad31edf137e62ee5678f9845c155811d9e2e1.tar.gz
Added new functionality to OTR always policy
If policy is set to always, and unencrypted message is received it will try to start an otr session.

Note: Fully tested with pidgin, is now working (opportunistic and always)
-rw-r--r--src/server_events.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/server_events.c b/src/server_events.c
index 3935bfbc..7797b4f4 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -221,7 +221,6 @@ handle_incoming_message(char *from, char *message, gboolean priv)
 			int tag_length	=	24;
 			if (strstr(message, OTRL_MESSAGE_TAG_V2) && strstr(message, OTRL_MESSAGE_TAG_V1)) tag_length = 32;
 			memmove(whitespace_base, whitespace_base+tag_length, tag_length);
-			log_debug("<%s>", message);
         		char *otr_query_message = otr_start_query();
 			cons_show("OTR Whitespace pattern detected. Attempting to start OTR session...");
         		message_send(otr_query_message, from);
@@ -237,6 +236,13 @@ handle_incoming_message(char *from, char *message, gboolean priv)
     } else {
         newmessage = message;
     }
+    char *policy = prefs_get_string(PREF_OTR_POLICY);
+    if (strcmp(policy, "always") == 0 && !was_decrypted)
+                {
+                        char *otr_query_message = otr_start_query();
+                        cons_show("Attempting to start OTR session..");
+                        message_send(otr_query_message, from);
+                }
 
     ui_incoming_msg(from, newmessage, NULL, priv);