[Tkabber-dev] r820 - in trunk/tkabber: . plugins/si

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Dec 5 18:30:28 MSK 2006


Author: sergei
Date: 2006-12-05 18:30:25 +0300 (Tue, 05 Dec 2006)
New Revision: 820

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/gpgme.tcl
   trunk/tkabber/plugins/si/ibb.tcl
Log:
	* gpgme.tcl: Fixed bug with incorrect call of signed:Label.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-12-03 20:01:56 UTC (rev 819)
+++ trunk/tkabber/ChangeLog	2006-12-05 15:30:25 UTC (rev 820)
@@ -1,3 +1,7 @@
+2006-12-05  Sergei Golovan  <sgolovan at nes.ru>
+
+	* gpgme.tcl: Fixed bug with incorrect call of signed:Label.
+
 2006-12-03  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/si/socks5.tcl: Fixed SHA1 hash computing for SOCKS5

Modified: trunk/tkabber/gpgme.tcl
===================================================================
--- trunk/tkabber/gpgme.tcl	2006-12-03 20:01:56 UTC (rev 819)
+++ trunk/tkabber/gpgme.tcl	2006-12-05 15:30:25 UTC (rev 820)
@@ -1348,7 +1348,7 @@
 	    destroy $lb
 	}
 
-	signed:Label $lb $connid $from
+	signed:Label $lb $connid $from \
 		     [signed:input $connid $from $chdata $body \
 				   [::msgcat::mc "Message body"]]
 	grid $lb -row 1 -column 2 -sticky e

Modified: trunk/tkabber/plugins/si/ibb.tcl
===================================================================
--- trunk/tkabber/plugins/si/ibb.tcl	2006-12-03 20:01:56 UTC (rev 819)
+++ trunk/tkabber/plugins/si/ibb.tcl	2006-12-05 15:30:25 UTC (rev 820)
@@ -94,6 +94,37 @@
 	close {
 	    si::closed $stream
 	}
+	data {
+	    set seq [jlib::wrapper:getattr $vars seq]
+	    if {$seq != $state(seq)} {
+		si::closed $stream
+		return [list error modify bad-request \
+			     -text [::trans::trans $lang \
+					"Unexpected packet sequence number"]]
+	    } else {
+		set state(seq) [expr {($state(seq) + 1) % 65536}]
+	    }
+	    set data $chdata
+
+	    if {[catch {set decoded [base64::decode $data]}]} {
+		debugmsg si "IBB: WRONG DATA"
+		si::closed $stream
+		return [list error modify bad-request \
+			     -text [::trans::trans $lang \
+					"Cannot decode recieved data"]]
+	    } else {
+		debugmsg si "IBB: RECV DATA [list $data]"
+		if {![si::recv_data $stream $decoded]} {
+		    si::closed $stream
+		    return [list error cancel not-allowed \
+				 -text [::trans::trans $lang \
+					    "File transfer is aborted"]]
+		}
+	    }
+	}
+	default {
+	    return [list error modify bad-request]
+	}
     }
 
     return [list result ""]
@@ -103,7 +134,19 @@
 
 ###############################################################################
 
-proc ibb::message_handler {connid from id type is_subject subject body \
+proc ibb::return_error {connid jid id error} {
+    if {$id == ""} return
+
+    jlib::send_msg $jid \
+	-type error \
+	-id $id \
+	-xlist [list [eval stanzaerror::error $error]] \
+	-connection $connid \
+}
+
+###############################################################################
+
+proc ibb::message_handler {connid from mid type is_subject subject body \
 				 err thread priority x} {
     foreach item $x {
 	jlib::wrapper:splitxml $item tag vars isempty chdata children
@@ -114,26 +157,45 @@
 	    set id [jlib::wrapper:getattr $vars sid]
 	    if {[catch {si::in $connid $from $id} stream]} {
 		# Unknown Stream ID
+		return_error $connid $from $mid \
+			     [list modify bad-request \
+				   -text [::trans::trans \
+					      "Stream ID has not been negotiated"]]
 		return stop
 	    }
+
 	    upvar #0 $stream state
+	    set seq [jlib::wrapper:getattr $vars seq]
 
-	    set seq [jlib::wrapper:getattr $vars seq]
 	    if {$seq != $state(seq)} {
 		# Incorrect sequence number
 		si::closed $stream
+		return_error $connid $from $mid \
+			     [list modify bad-request \
+				   -text [::trans::trans \
+					      "Unexpected packet sequence number"]]
 		return stop
-	    } else {
-		set state(seq) [expr {($state(seq) + 1) % 65536}]
 	    }
+
+	    set state(seq) [expr {($state(seq) + 1) % 65536}]
 	    set data $chdata
 
 	    if {[catch {set decoded [base64::decode $data]}]} {
 		debugmsg si "IBB: WRONG DATA"
 		si::closed $stream
+		return_error $connid $from $mid \
+			     [list modify bad-request \
+				   -text [::trans::trans \
+					      "Cannot decode recieved data"]]
 	    } else {
 		debugmsg si "IBB: RECV DATA [list $data]"
-		si::recv_data $stream $decoded
+		if {![si::recv_data $stream $decoded]} {
+		    si::closed $stream
+		    return_error $connid $from $mid \
+				 [list cancel not-allowed \
+				       -text [::trans::trans \
+						  "File transfer is aborted"]]
+		}
 	    }
 	    return stop
 	}



More information about the Tkabber-dev mailing list