[Tkabber-dev] r1600 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Nov 2 20:43:08 MSK 2008


Author: sergei
Date: 2008-11-02 20:43:08 +0300 (Sun, 02 Nov 2008)
New Revision: 1600

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/namespaces.tcl
   trunk/tkabber/pubsub.tcl
Log:
	* namespaces.tcl, pubsub.tcl: Removed creating jabber:x:data forms by
	  hands.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-11-02 17:26:19 UTC (rev 1599)
+++ trunk/tkabber/ChangeLog	2008-11-02 17:43:08 UTC (rev 1600)
@@ -31,6 +31,9 @@
 
 	* messages.tcl: Made use of jabber:x:data explicit.
 
+	* namespaces.tcl, pubsub.tcl: Removed creating jabber:x:data forms by
+	  hands.
+
 2008-11-01  Sergei Golovan  <sgolovan at nes.ru>
 
 	* Makefile: Added rules to make documentation (tkabber.html and

Modified: trunk/tkabber/namespaces.tcl
===================================================================
--- trunk/tkabber/namespaces.tcl	2008-11-02 17:26:19 UTC (rev 1599)
+++ trunk/tkabber/namespaces.tcl	2008-11-02 17:43:08 UTC (rev 1600)
@@ -33,7 +33,6 @@
 	iqavatar    "jabber:iq:avatar" \
 	xavatar     "jabber:x:avatar" \
 	xconference "jabber:x:conference" \
-	data	    "jabber:x:data" \
 	event       "jabber:x:event" \
 	xroster     "jabber:x:roster" \
 	rosterx     "http://jabber.org/protocol/rosterx" \

Modified: trunk/tkabber/pubsub.tcl
===================================================================
--- trunk/tkabber/pubsub.tcl	2008-11-02 17:26:19 UTC (rev 1599)
+++ trunk/tkabber/pubsub.tcl	2008-11-02 17:43:08 UTC (rev 1600)
@@ -253,7 +253,7 @@
     debugmsg pubsub [info level 0]
 
     set command ""
-    set options {}
+    set options [form_type $ns(subscribe_options)]
     foreach {key val} $args {
 	switch -- $key {
 	    -jid { set jid $val }
@@ -266,7 +266,8 @@
 	    -show-values -
 	    -subscription_type -
 	    -subscription_depth {
-		lappend options [field "pubsub#[string range $opt 1 end]" $val]
+		set par [string range $opt 1 end]
+		set options [concat $options [field pubsub#$par $val]]
 	    }
 	}
     }
@@ -284,16 +285,12 @@
 	lappend vars node $node
     }
 
-    if {![lempty $options]} {
+    if {[llength $options] > 2} {
 	set options \
-	    [::xmpp::xml::create options \
-		    -subelement \
-			[::xmpp::xml::create x \
-			    -xmlns $::NS(data) \
-			    -attrs [list type submit] \
-			    -subelements \
-				[linsert $options 0 \
-					 [form_type $ns(subscribe_options)]]]]
+	    [list [::xmpp::xml::create options \
+			    -subelement [::xmpp::data::submitForm $options]]]
+    } else {
+	set options {}
     }
 
     ::xmpp::sendIQ $xlib set \
@@ -301,7 +298,7 @@
 		    -xmlns $::NS(pubsub) \
 		    -subelement [::xmpp::xml::create subscribe \
 					 -attrs $vars] \
-		    -subelement $options] \
+		    -subelements $options] \
 	-to $service \
 	-command [list [namespace current]::subscribe_result $command]
 }
@@ -765,7 +762,7 @@
 
     set command ""
     set options {}
-    set fields {}
+    set fields [form_type $ns(node_config)]
     foreach {key val} $args {
 	switch -- $key {
 	    -command { set command $val }
@@ -796,7 +793,8 @@
 	    -subscribe -
 	    -title -
 	    -type {
-		lappend fields [field "pubsub#[string range $opt 1 end]" $val]
+		set par [string range $opt 1 end]
+		set fields [concat $fields [field pubsub#$par $val]]
 	    }
 	}
     }
@@ -807,14 +805,10 @@
 	set vars [list node $node]
     }
 
-    if {![lempty $fields]} {
-	set fields \
-	    [list [::xmpp::xml::create x \
-		       -xmlns $::NS(data) \
-		       -attrs [list type submit] \
-		       -subelements \
-			   [linsert $fields 0 \
-				    [form_type $ns(node_config)]]]]
+    if {[llength $fields] > 2} {
+	set fields [list [::xmpp::data::submitForm $fields]]
+    } else {
+	set fields {}
     }
 
     ::xmpp::sendIQ $xlib set \
@@ -830,18 +824,11 @@
 }
 
 proc pubsub::form_type {value} {
-    return [::xmpp::xml::create field \
-		-attrs [list var FORM_TYPE \
-			     type hidden]
-		-subelement [::xmpp::xml::create value \
-				    -cdata $value]]
+    return [list FORM_TYPE [list $value]]
 }
 
 proc pubsub::field {var value} {
-    return [::xmpp::xml::create field \
-		-attrs [list var $var] \
-		-subelement [::xmpp::xml::create value \
-				    -cdata $value]]
+    return [list $var [list $value]]
 }
 
 proc pubsub::create_node_result {node command res child} {
@@ -964,11 +951,9 @@
 	    -node_type {
 		set form \
 		    [::xmpp::xml::create default \
-			 -subelement [::xmpp::xml::create x \
-					     -xmlns $::NS(data) \
-					     -attrs [list type submit] \
-					     -subelement [form_type $ns(node_config)] \
-					     -subelement [field pubsub#node_type $val]]]
+			 -subelement [::xmpp::data::submitForm \
+					     [concat [form_type $ns(node_config)] \
+						     [field pubsub#node_type $val]]]]
 	    }
 	}
     }



More information about the Tkabber-dev mailing list