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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Jan 26 11:28:30 MSK 2014


Author: sergei
Date: 2014-01-26 11:28:30 +0400 (Sun, 26 Jan 2014)
New Revision: 2095

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/otr/auth.tcl
   trunk/tkabber-plugins/otr/otr.tcl
   trunk/tkabber-plugins/otr/tclotr/auth.tcl
   trunk/tkabber-plugins/otr/tclotr/otr.tcl
Log:
	* otr/tclotr/otr.tcl: Fixed refreshing private connection if the
	  peer has changed his instance tag. Clear messages subject to resend
	  when the message state switches from encrypted.

	* otr/tclotr/auth.tcl: Fixed recreating D-H commit message.

	* otr/otr.tcl: Implemented disabling logs for encrypted OTR messages.

	* otr/auth.tcl: Replaced combobox by option menu to match edit keys
	  dialog.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2014-01-26 07:25:23 UTC (rev 2094)
+++ trunk/tkabber-plugins/ChangeLog	2014-01-26 07:28:30 UTC (rev 2095)
@@ -1,3 +1,16 @@
+2014-01-26  Sergei Golovan <sgolovan at nes.ru>
+
+	* otr/tclotr/otr.tcl: Fixed refreshing private connection if the
+	  peer has changed his instance tag. Clear messages subject to resend
+	  when the message state switches from encrypted.
+
+	* otr/tclotr/auth.tcl: Fixed recreating D-H commit message.
+
+	* otr/otr.tcl: Implemented disabling logs for encrypted OTR messages.
+
+	* otr/auth.tcl: Replaced combobox by option menu to match edit keys
+	  dialog.
+
 2014-01-25  Sergei Golovan <sgolovan at nes.ru>
 
 	* otr/key.tcl, otr/tclotr/crypto.tcl: Code cleanup, made DSA key

Modified: trunk/tkabber-plugins/otr/auth.tcl
===================================================================
--- trunk/tkabber-plugins/otr/auth.tcl	2014-01-26 07:25:23 UTC (rev 2094)
+++ trunk/tkabber-plugins/otr/auth.tcl	2014-01-26 07:28:30 UTC (rev 2095)
@@ -185,17 +185,12 @@
 
     bind $w <Destroy> [list unset -nocomplain [namespace current]::authjid]
 
-    if {[llength $myjids] > 1} {
-	set state normal
-    } else {
-	set state disabled
+    if {[llength $myjids] == 0} {
+	set myjids {""}
     }
 
     label $f.lmyjid -text [::msgcat::mc "Your JID: "]
-    ComboBox $f.myjid \
-	     -textvariable [namespace current]::authjid \
-	     -values $myjids \
-	     -state $state
+    tk_optionMenu $f.myjid [namespace current]::authjid {*}$myjids
 
     grid $f.lmyjid -row 0 -column 0 -sticky e
     grid $f.myjid  -row 0 -column 1 -sticky ew

Modified: trunk/tkabber-plugins/otr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/otr.tcl	2014-01-26 07:25:23 UTC (rev 2094)
+++ trunk/tkabber-plugins/otr/otr.tcl	2014-01-26 07:28:30 UTC (rev 2095)
@@ -921,6 +921,7 @@
 	    return -code break
 	}
     }
+    return
 }
 
 hook::add process_message_hook [namespace current]::otr::discard_message 0.1
@@ -955,17 +956,72 @@
     if {[info exists res(message)]} {
 	set body $res(message)
     } else {
-	# Rewrite 'to' JID to disable sending
-	set to ""
+	# Disable sending
+	hook::unset_flag rewrite_outgoing_message_hook send
 
 	# Don't show this message in the chat log window
 	hook::unset_flag chat_send_message_hook draw
     }
+    return
 }
 
 hook::add rewrite_outgoing_message_hook \
 	  [namespace current]::otr::rewrite_outgoing_message_body 10
 
+###############################################################################
+
+proc otr::disable_log {chatid from type body x} {
+    set xlib [chat::get_xlib $chatid]
+    set jid [chat::get_jid $chatid]
+
+    if {[log_is_disabled $xlib $jid]} {
+	hook::unset_flag process_message_hook log
+    }
+    return
+}
+
+hook::add draw_message_hook [namespace current]::otr::disable_log 10
+
+proc otr::disable_archive_in {xlib from id type is_subject subject body err thread priority x} {
+    if {[log_is_disabled $xlib $from]} {
+	hook::unset_flag process_message_hook log
+    }
+    return
+}
+
+hook::add process_message_hook [namespace current]::otr::disable_archive_in 10
+
+proc otr::disable_archive_out {xlib to subject body thread} {
+    if {[log_is_disabled $xlib $to]} {
+	hook::unset_flag send_normal_message_hook log
+    }
+    return
+}
+
+hook::add send_normal_message_hook [namespace current]::otr::disable_archive_out 10
+
+proc otr::log_is_disabled {xlib jid} {
+    variable options
+    variable ctx
+
+    if {![info exists ctx($xlib,$jid)]} {
+	return 0
+    }
+
+    set njid [::xmpp::jid::normalize $jid]
+
+    switch -- $ctx(msgstate,$xlib,$jid) {
+	MSGSTATE_ENCRYPTED {
+	    if {[info exists options(dont-log-otr-messages,$xlib,$njid)]} {
+		return $options(dont-log-otr-messages,$xlib,$njid)
+	    } else {
+		return $options(dont-log-otr-messages)
+	    }
+	}
+    }
+    return 0
+}
+
 #############################################################################
 
 proc otr::msgstate:trace {script xlib jid} {

Modified: trunk/tkabber-plugins/otr/tclotr/auth.tcl
===================================================================
--- trunk/tkabber-plugins/otr/tclotr/auth.tcl	2014-01-26 07:25:23 UTC (rev 2094)
+++ trunk/tkabber-plugins/otr/tclotr/auth.tcl	2014-01-26 07:28:30 UTC (rev 2095)
@@ -157,13 +157,12 @@
             
             if {[::otr::data::Bin2Int $myhgxmpi] >
                                         [::otr::data::Bin2Int $hgxmpi]} {
-                return [list $authstate $msgstate [createDHCommitMessage \
-                                                        $version \
-                                                        $authstate \
-                                                        $msgstate \
-                                                        $r \
-                                                        $x \
-                                                        -sinstance $rinstance]]
+                return [createDHCommitMessage $version \
+                                              $authstate \
+                                              $msgstate \
+                                              $r \
+                                              $x \
+                                              -sinstance $rinstance]
             } else {
                 set authstate AUTHSTATE_AWAITING_REVEALSIG
                 return [list $authstate $msgstate [createDHKeyMessage \

Modified: trunk/tkabber-plugins/otr/tclotr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/tclotr/otr.tcl	2014-01-26 07:25:23 UTC (rev 2094)
+++ trunk/tkabber-plugins/otr/tclotr/otr.tcl	2014-01-26 07:28:30 UTC (rev 2095)
@@ -745,6 +745,7 @@
         } elseif {$version == 2 && [QueryPolicy $token ALLOW_V2]} {
             set state(version) 2
         } else {
+            Debug $token 1 "Protocol version $version is disabled"
             return {}
         }
 
@@ -761,6 +762,7 @@
                 return {}
             }
             default {
+                Debug $token 1 "Non-data message and state(version) is not set"
                 return {}
             }
         }
@@ -777,11 +779,15 @@
     if {$version >= 3} {
         if {$sinstance < 0x100 ||
                 ($rinstance > 0 && $rinstance != $state(sinstance))} {
+            Debug $token 1 "sinstance: $sinstance, rinstance: $rinstance,\
+                            state(sinstance): $state(sinstance)"
             return {}
         }
         if {![info exists state(rinstance)]} {
             set state(rinstance) $sinstance
         } elseif {$sinstance != $state(rinstance)} {
+            Debug $token 1 "sinstance: $sinstance,\
+                            state(rinstance): $state(rinstance)"
             return {}
         }
     } else {
@@ -1362,6 +1368,7 @@
     upvar 0 $token state
 
     set state(version) $version
+    unset -nocomplain state(rinstance)
     set state(r) [::otr::crypto::Int2Octets [::otr::crypto::random 128] 128]
     set keyid [expr {$state(keyid)-1}]
     ::otr::auth::createDHCommitMessage $state(version) \
@@ -1562,6 +1569,7 @@
             switch -- $state(msgstate) {
                 MSGSTATE_FINISHED  -
                 MSGSTATE_PLAINTEXT {
+                    Delete $token
                     CallBack $token info "Private conversation is finished"
                 }
             }



More information about the Tkabber-dev mailing list