about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-04-23 00:20:34 +0100
committerJames Booth <boothj5@gmail.com>2014-04-23 00:20:34 +0100
commit1706980fd798a3ef800adad5b59611019b69cbab (patch)
tree9f46eae8c41a51db0ce010b35281787c1ba2d099
parent4d8caee483f265c47c2441d6ad0fec94be88876b (diff)
parente08ee67f5f5e1edbd533b61c6460bda6f40ec8dd (diff)
downloadprofani-tty-1706980fd798a3ef800adad5b59611019b69cbab.tar.gz
Merge remote-tracking branch 'lucian/master'
Conflicts:
	src/server_events.c
-rw-r--r--src/server_events.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/server_events.c b/src/server_events.c
index bd63de82..faedac83 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -208,21 +208,21 @@ handle_incoming_message(char *from, char *message, gboolean priv)
     gboolean was_decrypted = FALSE;
     char *newmessage;
 
-   if (!priv) {
+    char *policy = prefs_get_string(PREF_OTR_POLICY);
+    char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE);
+
+    if (!priv) {
         //check for OTR whitespace (opportunistic or always)
-        char *policy = prefs_get_string(PREF_OTR_POLICY);
         if (strcmp(policy, "opportunistic") == 0 || strcmp(policy, "always") == 0) {
-            char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE);
             if (whitespace_base) {
                 if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) {
                     // Remove whitespace pattern for proper display in UI
                     // Handle both BASE+TAGV1/2(16+8) and BASE+TAGV1+TAGV2(16+8+8)
-                    int tag_length = 24;
+                    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);
@@ -238,6 +238,11 @@ handle_incoming_message(char *from, char *message, gboolean priv)
     } else {
         newmessage = message;
     }
+    if (strcmp(policy, "always") == 0 && !was_decrypted && !whitespace_base) {
+        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);