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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Jan 20 22:55:55 MSK 2014


Author: sergei
Date: 2014-01-20 22:55:55 +0400 (Mon, 20 Jan 2014)
New Revision: 2071

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/otr/otr.tcl
   trunk/tkabber-plugins/otr/tclotr/otr.tcl
Log:
	* otr/otr.tcl, otr/tclotr/otr.tcl: Warn user if plaintext message
	  is received while encryption is required.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2014-01-20 18:39:39 UTC (rev 2070)
+++ trunk/tkabber-plugins/ChangeLog	2014-01-20 18:55:55 UTC (rev 2071)
@@ -27,6 +27,9 @@
 
 	* otr/tclotr/otr.tcl: Fixed typo in ::otr::configure.
 
+	* otr/otr.tcl, otr/tclotr/otr.tcl: Warn user if plaintext message
+	  is received while encryption is required.
+
 2014-01-19  Sergei Golovan <sgolovan at nes.ru>
 
 	* otr/tclotr/otr.tcl: Fixed checking data message hash for protocol

Modified: trunk/tkabber-plugins/otr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/otr.tcl	2014-01-20 18:39:39 UTC (rev 2070)
+++ trunk/tkabber-plugins/otr/otr.tcl	2014-01-20 18:55:55 UTC (rev 2071)
@@ -121,7 +121,18 @@
     once_only $xlib $from
 
     switch -- $ctx(msgstate,$xlib,$from) {
-	MSGSTATE_PLAIN {}
+	MSGSTATE_PLAIN {
+	    foreach xe $x {
+		::xmpp::xml::split $xe tag xmlns attrs cdata subels
+
+		if {$tag eq "" && $xmlns eq $ns} {
+		    if {[::xmpp::xml::getAttr $attrs warn] == 1} {
+			$chatw image create end -image otr/notprivate
+		    }
+		    break
+		}
+	    }
+	}
 	MSGSTATE_ENCRYPTED -
 	MSGSTATE_FINISHED {
 	    foreach xe $x {
@@ -157,7 +168,23 @@
     once_only $xlib $from
 
     switch -- $ctx(msgstate,$xlib,$from) {
-	MSGSTATE_PLAIN {}
+	MSGSTATE_PLAIN {
+	    foreach xe $x {
+		::xmpp::xml::split $xe tag xmlns attrs cdata subels
+
+		if {$tag eq "" && $xmlns eq $ns} {
+		    set lb [join [lrange [split $f .] 0 end-1] .].title.otrmsgstate
+		    if {[winfo exists $lb]} {
+			destroy $lb
+		    }
+		    if {[::xmpp::xml::getAttr $attrs warn] == 1} {
+			Label $lb -image otr/notprivate
+			grid $lb -row 1 -column 4 -sticky e
+		    }
+		    break
+		}
+	    }
+	}
 	MSGSTATE_ENCRYPTED -
 	MSGSTATE_FINISHED {
 	    foreach xe $x {

Modified: trunk/tkabber-plugins/otr/tclotr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/tclotr/otr.tcl	2014-01-20 18:39:39 UTC (rev 2070)
+++ trunk/tkabber-plugins/otr/tclotr/otr.tcl	2014-01-20 18:55:55 UTC (rev 2071)
@@ -469,10 +469,16 @@
                             state(AuthState) state(MsgState) reply
             switch -- $state(MsgState) {
                 MSGSTATE_PLAINTEXT {
-                    return [list authstate $state(AuthState) \
-                                 msgstate  $state(MsgState) \
-                                 body      $message \
-                                 reply     [list $reply]]
+                    set ret [list authstate $state(AuthState) \
+                                  msgstate  $state(MsgState) \
+                                  body      $message \
+                                  reply     [list $reply]]
+                    if {[QueryPolicy $token REQUIRE_ENCRYPTION]} {
+                        return [linsert $ret 0 warn 1]
+                    } else {
+                        return $ret
+                    }
+
                 }
                 MSGSTATE_ENCRYPTED -
                 MSGSTATE_FINISHED {
@@ -486,7 +492,12 @@
         } else {
             switch -- $state(MsgState) {
                 MSGSTATE_PLAINTEXT {
-                    return [list body $message]
+                    if {[QueryPolicy $token REQUIRE_ENCRYPTION]} {
+                        return [list warn 1 \
+                                     body $message]
+                    } else {
+                        return [list body $message]
+                    }
                 }
                 MSGSTATE_ENCRYPTED -
                 MSGSTATE_FINISHED {



More information about the Tkabber-dev mailing list