[Tkabber-dev] [tclxmpp commit] r58 - in trunk: . xmpp

codesite-noreply at google.com codesite-noreply at google.com
Sun Nov 2 18:54:39 MSK 2008


Author: sgolovan
Date: Sun Nov  2 07:53:55 2008
New Revision: 58

Modified:
    trunk/ChangeLog
    trunk/xmpp/data.tcl

Log:
	* xmpp/data.tcl: Added support for creating data forms.


Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Sun Nov  2 07:53:55 2008
@@ -22,6 +22,8 @@
  	* xmpp/register.tcl: Added support for data forms in error service
  	  responses and added support for changing password.

+	* xmpp/data.tcl: Added support for creating data forms.
+
  2008-11-01  Sergei Golovan  <sgolovan at nes.ru>

  	* xmpp/data.tcl, xmpp/pkgIndex.tcl: Added a new package for working

Modified: trunk/xmpp/data.tcl
==============================================================================
--- trunk/xmpp/data.tcl	(original)
+++ trunk/xmpp/data.tcl	Sun Nov  2 07:53:55 2008
@@ -16,6 +16,62 @@

  namespace eval ::xmpp::data {}

+# ::xmpp::data::form --
+
+proc ::xmpp::data::form {fields} {
+    set subels {}
+    foreach {tag field} $fields {
+        switch -- $tag {
+            title {
+                lappend subels [::xmpp::xml::create title -cdata $field]
+            }
+            instructions {
+                lappend subels [::xmpp::xml::create instructions -cdata  
$field]
+            }
+            field {
+                foreach {var type label options values} $field break
+
+                set attrs [list var $var type $type]
+                if {![string equal $label ""]} {
+                    lappend attrs label $label
+                }
+
+                set fsubels {}
+                foreach value $values {
+                    lappend fsubels [::xmpp::xml::create value -cdata  
$value]
+                }
+                foreach {olabel ovalue} $options {
+                    if {[string equal $olabel ""]} {
+                        set oattrs {}
+                    } else {
+                        set oattrs [list label $olabel]
+                    }
+                    lappend fsubels [::xmpp::xml::create option \
+                                            -attrs $oattrs \
+                                            -subelement  
[::xmpp::xml::create value \
+                                                                -cdata  
$ovalue]]
+                }
+                lappend subels [::xmpp::xml::create field \
+                                        -attrs $attrs \
+                                        -subelements $fsubels]
+            }
+        }
+    }
+
+    return [::xmpp::xml::create x \
+                    -xmlns jabber:x:data \
+                    -attrs [list type form] \
+                    -subelements $subels]
+}
+
+# ::xmpp::data::cancelForm --
+
+proc ::xmpp::data::cancelForm {} {
+    return [::xmpp::xml::create x \
+                    -xmlns jabber:x:data \
+                    -attrs [list type cancel]]
+}
+
  # ::xmpp::data::submitForm --

  proc ::xmpp::data::submitForm {fields} {


More information about the Tkabber-dev mailing list