[Tkabber-dev] r1038 - in trunk/tkabber: . examples/tools jabberlib-tclxml plugins/general plugins/roster plugins/si

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Mar 10 17:09:41 MSK 2007


Author: sergei
Date: 2007-03-10 17:09:40 +0300 (Sat, 10 Mar 2007)
New Revision: 1038

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/disco.tcl
   trunk/tkabber/examples/tools/rssbot.tcl
   trunk/tkabber/filters.tcl
   trunk/tkabber/jabberlib-tclxml/jabberlib.tcl
   trunk/tkabber/login.tcl
   trunk/tkabber/plugins/general/stats.tcl
   trunk/tkabber/plugins/roster/rosterx.tcl
   trunk/tkabber/plugins/si/ibb.tcl
   trunk/tkabber/plugins/si/iqibb.tcl
   trunk/tkabber/privacy.tcl
   trunk/tkabber/pubsub.tcl
   trunk/tkabber/userinfo.tcl
Log:
	* jabberlib-tclxml/jabberlib.tcl: Made -connection argument mandatory
	  for send_iq. Call user callback even in case of disconnect.

	* disco.tcl, examples/tools/rssbot.tcl, filters.tcl, login.tcl,
	  plugins/general/stats.tcl, plugins/roster/rosterx.tcl,
	  plugins/si/ibb.tcl, plugins/si/iqibb.tcl, pubsub.tcl, userinfo.tcl:
	  Added -connection argument to all jlib::send_iq calls, where it was
	  missing. Fixed several bugs with backslash at the end of line.

	* privacy.tcl: Made error messageboxes appear only in case of errors
	  (ignore disconnects).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/ChangeLog	2007-03-10 14:09:40 UTC (rev 1038)
@@ -1,3 +1,17 @@
+2007-03-10  Sergei Golovan  <sgolovan at nes.ru>
+
+	* jabberlib-tclxml/jabberlib.tcl: Made -connection argument mandatory
+	  for send_iq. Call user callback even in case of disconnect.
+
+	* disco.tcl, examples/tools/rssbot.tcl, filters.tcl, login.tcl,
+	  plugins/general/stats.tcl, plugins/roster/rosterx.tcl,
+	  plugins/si/ibb.tcl, plugins/si/iqibb.tcl, pubsub.tcl, userinfo.tcl:
+	  Added -connection argument to all jlib::send_iq calls, where it was
+	  missing. Fixed several bugs with backslash at the end of line.
+
+	* privacy.tcl: Made error messageboxes appear only in case of errors
+	  (ignore disconnects).
+
 2007-03-09  Sergei Golovan  <sgolovan at nes.ru>
 
 	* ifacetk/iface.tcl, splash.tcl, tkabber.tcl: Withdraw main window at

Modified: trunk/tkabber/disco.tcl
===================================================================
--- trunk/tkabber/disco.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/disco.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -419,7 +419,7 @@
 
     jlib::send_iq set \
 	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(disco#publish) node $node]
+	     -vars [list xmlns $::NS(disco#publish) node $node] \
 	     -subtags $items] \
 	-to $jid \
 	-connection $connid \

Modified: trunk/tkabber/examples/tools/rssbot.tcl
===================================================================
--- trunk/tkabber/examples/tools/rssbot.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/examples/tools/rssbot.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -296,7 +296,7 @@
         }
     }
 
-    jlib::send_iq $result $xmldata -to $from -id $id
+    jlib::send_iq $result $xmldata -to $from -id $id -connection [jlib::route ""]
 }
 
 proc client:roster_push {args} {}
@@ -362,6 +362,7 @@
                      -vars [list xmlns jabber:iq:private] \
                      -subtags [list [jlib::wrapper:createtag $array \
                                          -vars [list xmlns rssbot.$array]]]] \
+		-connection [jlib::route ""] \
                 -command [list [namespace current]::iq_private 0]
         }
         while {$iqP > 0} {
@@ -519,6 +520,7 @@
                      -subtags [list [jlib::wrapper:createtag $array \
                                          -vars [list xmlns rssbot.$array] \
                                          -chdata [array get $array]]]] \
+		-connection [jlib::route ""] \
                 -command [list [namespace current]::iq_private 1]
         }
     }
@@ -904,6 +906,7 @@
                      -subtags [list [jlib::wrapper:createtag $array \
                                          -vars [list xmlns rssbot.$array] \
                                          -chdata [array get $array]]]] \
+		-connection [jlib::route ""] \
                 -command [list [namespace current]::iq_private 1]
         }
 
@@ -943,6 +946,7 @@
                  -subtags [list [jlib::wrapper:createtag subscribers \
                                      -vars [list xmlns rssbot.subscribers] \
                                      -chdata [array get subscribers]]]] \
+	    -connection [jlib::route ""] \
             -command [list [namespace current]::iq_private 1]
 
         if {(![string compare $status available]) \

Modified: trunk/tkabber/filters.tcl
===================================================================
--- trunk/tkabber/filters.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/filters.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -99,6 +99,7 @@
     jlib::send_iq get \
 	[jlib::wrapper:createtag item \
 	     -vars {xmlns jabber:iq:filter}] \
+	-connection [jlib::route ""] \
 	-command [list filters::recv]
 }
 
@@ -427,7 +428,8 @@
     jlib::send_iq set \
 	[jlib::wrapper:createtag item \
 	     -vars {xmlns jabber:iq:filter} \
-	     -subtags $result]
+	     -subtags $result] \
+	-connection [jlib::route ""] \
 
     destroy .filters
 }

Modified: trunk/tkabber/jabberlib-tclxml/jabberlib.tcl
===================================================================
--- trunk/tkabber/jabberlib-tclxml/jabberlib.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/jabberlib-tclxml/jabberlib.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -1369,10 +1369,6 @@
     variable iq
 
     ::LOG "(jlib::send_iq) type:'$type'"
-    if {$lib(connections) == {}} {
-          ::LOG "error (jlib::send_iq) No connection"
-          return -1
-    }
 
     set useto  0
     set useid  0
@@ -1397,9 +1393,17 @@
 	}
     }
     if {![info exists connid]} {
-	set connid [route $to]
+	return -code error "jlib::send_iq: -connection is mandatory"
     }
 
+    if {[lsearch [connections] $connid] < 0} {
+        ::LOG "error (jlib::send_iq) Connection $connid doesn't exist"
+	if {$cmd != ""} {
+	    uplevel #0 $cmd [list DISCONNECT [::msgcat::mc "Disconnected"]]
+	}
+	return -1
+    }
+
     if {$type != "set" && $type != "result" && $type != "error"} {
 	set type "get"
     }
@@ -1495,7 +1499,7 @@
 
 ######################################################################
 # TODO
-proc jlib::send_create {user pass name email cmd} {
+proc jlib::send_create {connid user pass name email cmd} {
     variable lib
 
     ::LOG "(jlib::send_create) username:'$user' password:'$pass' name:'$name' email:'$email'"
@@ -1513,6 +1517,7 @@
 				[wrapper:createtag password -chdata $pass]]]
 
     send_iq set $data \
+	-connection $connid \
 	-command [list [namespace current]::parse_send_create $cmd]
 }
 
@@ -1685,7 +1690,7 @@
 }
 
 ######################################################################
-proc jlib::roster_set {item args} {
+proc jlib::roster_set {connid item args} {
     variable lib
     variable roster
 
@@ -1733,11 +1738,12 @@
 					  -subtags $subdata]]]
 
     send_iq set $xmldata \
+	-connection $connid \
 	-command [list [namespace current]::parse_roster_set $item $cmd $groups $name]
 }
 
 ######################################################################
-proc jlib::roster_del {item args} {
+proc jlib::roster_del {connid item args} {
     variable lib
     variable roster
 
@@ -1762,6 +1768,7 @@
 						     subscription remove]]]]
 
     send_iq set $xmldata \
+	-connection $connid \
 	-command [list [namespace current]::parse_roster_del $item $cmd]
 }
 

Modified: trunk/tkabber/login.tcl
===================================================================
--- trunk/tkabber/login.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/login.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -491,6 +491,7 @@
 					     -chdata $lc(user)] \
 					[jlib::wrapper:createtag password \
 					     -chdata $lc(password)]]] \
+		    -connection $connid \
 		    -command [list recv_register_result $connid $logindata]
 		return
 	    }
@@ -582,6 +583,8 @@
 	return
     }
 
+    set connid [jlib::route $loginconf(server)]
+
     jlib::send_iq set \
 	    [jlib::wrapper:createtag query \
 		    -vars {xmlns jabber:iq:register} \
@@ -590,6 +593,7 @@
 				   [jlib::wrapper:createtag password \
 					-chdata $password]]] \
 	    -to $loginconf(server) \
+	    -connection $connid \
 	    -command recv_change_password_result
 }
 

Modified: trunk/tkabber/plugins/general/stats.tcl
===================================================================
--- trunk/tkabber/plugins/general/stats.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/plugins/general/stats.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -109,6 +109,7 @@
     jlib::send_iq get [jlib::wrapper:createtag query \
 			   -vars $vars] \
 	-to $jid \
+	-connection [jlib::route $jid] \
 	-command [list [namespace current]::recv_query_list_result $jid $node]
 }
 
@@ -146,6 +147,7 @@
 			   -subtags [list [jlib::wrapper:createtag stat \
 					       -vars [list name $name]]]] \
 	-to $jid \
+	-connection [jlib::route $jid] \
 	-command [list [namespace current]::recv_values_result $jid $node]
 }
 

Modified: trunk/tkabber/plugins/roster/rosterx.tcl
===================================================================
--- trunk/tkabber/plugins/roster/rosterx.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/plugins/roster/rosterx.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -20,17 +20,17 @@
 	    $::NS(rosterx) {
 		set rosterx 1
 		foreach child $children {
-		    process_x_rosterx $f $child $row $from
+		    process_x_rosterx $f $child $row $connid $from
 		    incr row
 		}
 	    } \
 	    $::NS(xroster) {
 		if {$rosterx} break
 		foreach child $children {
-		    process_x_xroster $f $child $row $from
+		    process_x_xroster $f $child $row $connid $from
 		    incr row
 		}
-	    } \
+	    }
 	}
 
     return
@@ -40,7 +40,7 @@
 
 ###############################################################################
 
-proc rosterx::process_x_rosterx {f x row from} {
+proc rosterx::process_x_rosterx {f x row connid from} {
     jlib::wrapper:splitxml $x tag vars isempty chdata children
 
     set jid [jlib::wrapper:getattr $vars jid]
@@ -57,15 +57,15 @@
 
     label $f.luser$row -text [::msgcat::mc "Attached user:"]
     set cb [button $f.user$row -text $desc \
-                -command [list [namespace current]::process_user $jid \
-                              "$from asked me to add you to my roster."]]
+                -command [list [namespace current]::process_user $connid $jid \
+			       $name "$from asked me to add you to my roster."]]
     grid $f.luser$row -row $row -column 0 -sticky e
     grid $f.user$row  -row $row -column 1 -sticky ew
 }
 
 ###############################################################################
 
-proc rosterx::process_x_xroster {f x row from} {
+proc rosterx::process_x_xroster {f x row connid from} {
     jlib::wrapper:splitxml $x tag vars isempty chdata children
 
     set jid [jlib::wrapper:getattr $vars jid]
@@ -81,22 +81,31 @@
 
     label $f.luser$row -text [::msgcat::mc "Attached user:"]
     set cb [button $f.user$row -text $desc \
-                -command [list [namespace current]::process_user $jid \
-                              "$from asked me to add you to my roster."]]
+                -command [list [namespace current]::process_user $connid $jid \
+                               $name "$from asked me to add you to my roster."]]
     grid $f.luser$row -row $row -column 0 -sticky e
     grid $f.user$row  -row $row -column 1 -sticky ew
 }
 
 ###############################################################################
 
-proc rosterx::process_user {jid body} {
-    jlib::send_presence -to $jid -type subscribe -stat $body
+proc rosterx::process_user {connid jid name body} {
+    jlib::send_presence -to $jid \
+			-type subscribe \
+			-stat $body \
+			-connection $connid
 
+    set vars [list jid $jid]
+    if {$name != ""} {
+	lappend vars name $name
+    }
+
     jlib::send_iq set \
         [jlib::wrapper:createtag query \
              -vars [list xmlns $::NS(roster)] \
              -subtags [list [jlib::wrapper:createtag item \
-                                     -vars [list jid $jid]]]]
+                                     -vars $vars]]] \
+	-connection $connid
 }
 
 ###############################################################################

Modified: trunk/tkabber/plugins/si/ibb.tcl
===================================================================
--- trunk/tkabber/plugins/si/ibb.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/plugins/si/ibb.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -22,6 +22,7 @@
 			 sid $state(id) \
 			 block-size $chunk_size]] \
 	-to $state(jid) \
+	-connection $state(connid) \
 	-command [list [namespace current]::recv_connect_response \
 		       $stream $command]
 }

Modified: trunk/tkabber/plugins/si/iqibb.tcl
===================================================================
--- trunk/tkabber/plugins/si/iqibb.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/plugins/si/iqibb.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -22,6 +22,7 @@
 			 sid $state(id) \
 			 block-size $chunk_size]] \
 	-to $state(jid) \
+	-connection $state(connid) \
 	-command [list [namespace current]::recv_connect_response \
 		      $stream $command]
 }

Modified: trunk/tkabber/privacy.tcl
===================================================================
--- trunk/tkabber/privacy.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/privacy.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -74,7 +74,7 @@
 }
 
 proc privacy::open_dialog {connid res child} {
-    if {![cequal $res OK]} {
+    if {[cequal $res ERR]} {
 	MessageDlg .privacy_err -aspect 50000 -icon error \
 	    -message [::msgcat::mc "Requesting privacy rules: %s" \
 			  [error_to_string $child]] \
@@ -272,7 +272,7 @@
 
 
 proc privacy::edit_list_dialog {connid ln name res child} {
-    if {![cequal $res OK]} {
+    if {[cequal $res ERR]} {
 	MessageDlg .privacy_list_err -aspect 50000 -icon error \
 	    -message [::msgcat::mc "Requesting privacy list: %s" \
 			  [error_to_string $child]] \
@@ -754,7 +754,7 @@
     variable req_messages
     variable edit_messages
 
-    if {![cequal $res OK]} {
+    if {[cequal $res ERR]} {
 	if {[error_type_condition $child] != {cancel item-not-found}} {
 	    MessageDlg .privacy_list_err -aspect 50000 -icon error \
 		-message [format $req_messages($name) [error_to_string $child]] \
@@ -953,6 +953,8 @@
     variable special_list
     variable cboxes
 
+    if {$res == "DISCONNECT"} return
+
     switch -- $name {
 	subscription {
 	    # Subscription list doesn't contain JIDs
@@ -969,7 +971,7 @@
 	}
     }
 
-    if {$res != "OK"} {
+    if {$res == "ERR"} {
 	MessageDlg .privacy_list_err -aspect 50000 -icon error \
 	    -message [format $send_messages($name) [error_to_string $child]] \
 	    -type user -buttons ok -default 0 -cancel 0

Modified: trunk/tkabber/pubsub.tcl
===================================================================
--- trunk/tkabber/pubsub.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/pubsub.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -691,7 +691,7 @@
 	     -vars [list xmlns $::NS(pubsub)] \
 	     -subtags [list [jlib::wrapper:createtag publish \
 				 -vars [list node $node] \
-				 -subtags $item]]]
+				 -subtags $item]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::publish_item_result $command]
@@ -1129,7 +1129,7 @@
 	[jlib::wrapper:createtag pubsub \
 	     -vars [list xmlns $::NS(pubsub#owner)] \
 	     -subtags [list [jlib::wrapper:createtag delete \
-				 -vars [list node $node]]]
+				 -vars [list node $node]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::delete_node_result $command]
@@ -1174,7 +1174,7 @@
 	[jlib::wrapper:createtag pubsub \
 	     -vars [list xmlns $::NS(pubsub#owner)] \
 	     -subtags [list [jlib::wrapper:createtag purge \
-				 -vars [list node $node]]]
+				 -vars [list node $node]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::purge_items_result $command]
@@ -1253,7 +1253,7 @@
 	[jlib::wrapper:createtag pubsub \
 	     -vars [list xmlns $::NS(pubsub#owner)] \
 	     -subtags [list [jlib::wrapper:createtag subscriptions \
-				 -vars [list node $node]]]]
+				 -vars [list node $node]]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::subscriptions_result $command]
@@ -1328,7 +1328,7 @@
 	     -vars [list xmlns $::NS(pubsub#owner)] \
 	     -subtags [list [jlib::wrapper:createtag subscriptions \
 				 -vars [list node $node] \
-				 -subtags $subscriptions]]]
+				 -subtags $subscriptions]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::modify_subscriptions_result $command]
@@ -1373,7 +1373,7 @@
     jlib::send_iq set \
 	[jlib::wrapper:createtag pubsub \
 	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag affiliations]]]
+	     -subtags [list [jlib::wrapper:createtag affiliations]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::affiliations_result $command]
@@ -1448,7 +1448,7 @@
 	     -vars [list xmlns $::NS(pubsub#owner)] \
 	     -subtags [list [jlib::wrapper:createtag affiliations \
 				 -vars [list node $node] \
-				 -subtags $affiliations]]]
+				 -subtags $affiliations]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::modify_affiliations_result $command]
@@ -1495,7 +1495,7 @@
 	     -vars [list xmlns $::NS(pubsub)] \
 	     -subtags \
 		 [list [jlib::wrapper:createtag entities \
-			    -vars [list node $node]]]
+			    -vars [list node $node]]] \
 	-to $service \
 	-connection $connid \
 	-command [list [namespace current]::receive_entities \

Modified: trunk/tkabber/userinfo.tcl
===================================================================
--- trunk/tkabber/userinfo.tcl	2007-03-09 19:07:21 UTC (rev 1037)
+++ trunk/tkabber/userinfo.tcl	2007-03-10 14:09:40 UTC (rev 1038)
@@ -205,7 +205,7 @@
     if {$editable} {
 	set bbox [ButtonBox $w.bbox -spacing 10 -padx 10 -default 0]
 	$bbox add -text [::msgcat::mc "OK"] -command "
-		userinfo::send_vcard [list $jid]
+		userinfo::send_vcard [list $connid] [list $jid]
 		destroy [list $w]
 	"
 	bind $w <Return>  "ButtonBox::invoke $bbox default"
@@ -915,7 +915,7 @@
     }
 }
 
-proc userinfo::send_vcard {jid} {
+proc userinfo::send_vcard {connid jid} {
     variable userinfo
 
     set w [w_from_jid $jid]
@@ -951,8 +951,8 @@
     jlib::send_iq set \
 	[jlib::wrapper:createtag vCard \
 	     -vars [list xmlns vcard-temp] \
-	     -subtags $tags]
-
+	     -subtags $tags] \
+	-connection $connid
 }
 
 proc userinfo::make_n_item {jid} {



More information about the Tkabber-dev mailing list