[Tkabber-dev] r2075 - in trunk/tkabber-plugins: . otr/tclotr

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Jan 21 20:24:29 MSK 2014


Author: sergei
Date: 2014-01-21 20:24:29 +0400 (Tue, 21 Jan 2014)
New Revision: 2075

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/otr/tclotr/otr.tcl
Log:
	* otr/tclotr/otr.tcl: Attach the OTR whitespace tag only if there
	  weren't received plaintext messages from the peer before.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2014-01-21 15:52:37 UTC (rev 2074)
+++ trunk/tkabber-plugins/ChangeLog	2014-01-21 16:24:29 UTC (rev 2075)
@@ -12,6 +12,9 @@
 	  changes and SMP progress using callbacks and only in case of actual
 	  change.
 
+	* otr/tclotr/otr.tcl: Attach the OTR whitespace tag only if there
+	  weren't received plaintext messages from the peer before.
+
 2014-01-20  Sergei Golovan <sgolovan at nes.ru>
 
 	* otr/tclotr/otr.tcl: Do not send the OTR query message after an OTR

Modified: trunk/tkabber-plugins/otr/tclotr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/tclotr/otr.tcl	2014-01-21 15:52:37 UTC (rev 2074)
+++ trunk/tkabber-plugins/otr/tclotr/otr.tcl	2014-01-21 16:24:29 UTC (rev 2075)
@@ -125,6 +125,7 @@
     set state(HeartBeat) $heartbeat
     set state(LastMessage) [clock seconds]
     set state(MaxSize) $maxsize
+    set state(ReceivedPlaintext) 0
     while {[set state(sinstance) [::otr::crypto::random 32]] < 0x100} {}
 
     # Init vars for fragmented message
@@ -400,7 +401,8 @@
                                    private conversation..."]
             } elseif {[QueryPolicy $token SEND_WHITESPACE_TAG] &&
                       ([QueryPolicy $token ALLOW_V2] ||
-                       [QueryPolicy $token ALLOW_V3])} {
+                       [QueryPolicy $token ALLOW_V3]) &&
+                      !$state(ReceivedPlaintext)} {
                 return [list body "$body[::otr::data::whitespaceTag \
                                                     $state(Policy)]"]
             } else {
@@ -518,6 +520,7 @@
         } else {
             switch -- $state(MsgState) {
                 MSGSTATE_PLAINTEXT {
+                    set state(ReceivedPlaintext) 1
                     if {[QueryPolicy $token REQUIRE_ENCRYPTION]} {
                         return [list warn 1 \
                                      body $message]
@@ -539,7 +542,13 @@
 
         switch -- $state(MsgState) {
             MSGSTATE_PLAINTEXT {
-                return [list body $message]
+                set state(ReceivedPlaintext) 1
+                if {[QueryPolicy $token REQUIRE_ENCRYPTION]} {
+                    return [list warn 1 \
+                                 body $message]
+                } else {
+                    return [list body $message]
+                }
             }
             MSGSTATE_ENCRYPTED -
             MSGSTATE_FINISHED {
@@ -1286,6 +1295,12 @@
 
     set state(StoredMsgState) $state(MsgState)
 
+    switch -- $state(MsgState) {
+        MSGSTATE_PLAINTEXT {
+            set state(ReceivedPlaintext) 0
+        }
+    }
+
     foreach cmd $state(MsgStateCommands) {
         {*}$cmd $state(MsgState)
     }



More information about the Tkabber-dev mailing list