[Tkabber-dev] [tclxmpp commit] r90 - * xmpp/data.tcl: Parse data forms media items.

codesite-noreply at google.com codesite-noreply at google.com
Sun Mar 15 10:14:13 MSK 2009


Author: sgolovan
Date: Sun Mar 15 00:12:58 2009
New Revision: 90

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

Log:
	* xmpp/data.tcl: Parse data forms media items.


Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Sun Mar 15 00:12:58 2009
@@ -1,3 +1,7 @@
+2009-03-15  Sergei Golovan  <sgolovan at nes.ru>
+
+	* xmpp/data.tcl: Parse data forms media items.
+
  2009-03-14  Sergei Golovan  <sgolovan at nes.ru>

  	* xmpp/disco.tcl: Fixed searching cached info and items.

Modified: trunk/xmpp/data.tcl
==============================================================================
--- trunk/xmpp/data.tcl	(original)
+++ trunk/xmpp/data.tcl	Sun Mar 15 00:12:58 2009
@@ -1,7 +1,7 @@
  # data.tcl --
  #
  #       This file is a part of the XMPP library. It implements support for
-#       data forms (XEP-0004).
+#       data forms (XEP-0004) and data forms media items (XEP-0221).
  #
  # Copyright (c) 2008-2009 Sergei Golovan <sgolovan at nes.ru>
  #
@@ -338,7 +338,7 @@

                      foreach value $sssubels {
                          ::xmpp::xml::split $value s3tag s3xmlns s3attrs  
s3cdata s3subels
-
+
                          if {[string equal $s3tag value]} {
                              lappend values $s3cdata
                          }
@@ -385,6 +385,7 @@

      foreach item $subels {
          ::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+
          switch -- $stag {
              required {
                  set required true
@@ -410,8 +411,26 @@
              }
              media {
                  if {[string equal $sxmlns urn:xmpp:media-element]} {
-                    # TODO: Parse media item
-                    lappend media $item
+                    set mitem {}
+
+                    foreach sitem $ssubels {
+                        ::xmpp::xml::split $sitem \
+                                           sstag ssxmlns ssattrs \
+                                           sscdata sssubels
+                        switch -- $sstag {
+                            uri {
+                                if {![::xmpp::xml::isAttr $ssattrs type]} {
+                                    continue
+                                }
+                                set mtype [::xmpp::xml::getAttr $ssattrs  
type]
+                                set uri $sscdata
+
+                                lappend mitem $mtype $uri
+                            }
+                        }
+                    }
+
+                    lappend media $mitem
                  }
              }
          }


More information about the Tkabber-dev mailing list