[Tkabber-dev] r1734 - in trunk/tkabber: . plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Mar 15 10:14:28 MSK 2009


Author: sergei
Date: 2009-03-15 10:14:28 +0300 (Sun, 15 Mar 2009)
New Revision: 1734

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/datagathering.tcl
   trunk/tkabber/plugins/general/captcha.tcl
Log:
	* msgs/de.msg: Updated German translation (thanks to Roger Sondermann).

	* datagathering.tcl, plugins/general/captcha.tcl: Removed support for
	  old robot challenge support and moved media element parsing to
	  TclXMPP.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-03-15 06:19:19 UTC (rev 1733)
+++ trunk/tkabber/ChangeLog	2009-03-15 07:14:28 UTC (rev 1734)
@@ -2,6 +2,10 @@
 
 	* msgs/de.msg: Updated German translation (thanks to Roger Sondermann).
 
+	* datagathering.tcl, plugins/general/captcha.tcl: Removed support for
+	  old robot challenge support and moved media element parsing to
+	  TclXMPP.
+
 2009-03-14  Sergei Golovan  <sgolovan at nes.ru>
 
 	* chats.tcl, muc.tcl: Converted chat and conference menus into dynamic

Modified: trunk/tkabber/datagathering.tcl
===================================================================
--- trunk/tkabber/datagathering.tcl	2009-03-15 06:19:19 UTC (rev 1733)
+++ trunk/tkabber/datagathering.tcl	2009-03-15 07:14:28 UTC (rev 1734)
@@ -116,60 +116,35 @@
 
 proc data::render_media {g row media_list} {
     foreach item $media_list {
-	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	set unsupported 1
-	foreach subel $subels {
-	    ::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
-	    switch -- $stag {
-		uri {
-		    if {[string first cid: $scdata] == 0} {
-			set cid [string range $scdata 4 end]
-			set type [::xmpp::xml::getAttr $sattrs type]
-			switch -glob -- $type {
-			    image/* {
-				# TODO: Request BOB data if it isn't present
-				set tdata [::xmpp::bob::get $cid]
-				if {[llength $tdata] < 2} {
-				    continue
-				}
-				lassign $tdata type data
-				if {![catch {image create photo -data $data} img]} {
-				    label $g.mediaimg$row -image $img
-				    bind $g.mediaimg$row <Destroy> [list image delete $img]
-				    grid $g.mediaimg$row -row $row -column 1 -sticky ew
-				    set unsupported 0
-				    incr row
-				}
-			    }
-			    default {
-				# TODO
-			    }
+	foreach {type uri} $item {
+	    if {[string first cid: $uri] == 0} {
+		set cid [string range $uri 4 end]
+		switch -glob -- $type {
+		    image/* {
+			# TODO: Request BOB data if it isn't present
+			set tdata [::xmpp::bob::get $cid]
+			if {[llength $tdata] < 2} {
+			    continue
 			}
-		    } else {
-			render_url $g.mediauri$row $scdata $scdata -bg [get_conf $g -bg]
-			grid $g.mediauri$row -row $row -column 1 -sticky ew
-			set unsupported 0
-			incr row
-		    }
-		}
-		data {
-		    # Old-style data element
-		    set type [::xmpp::xml::getAttr $sattrs type]
-		    switch -glob -- $type {
-			image/* {
-			    if {![catch {image create photo -data [base64::decode $scdata]} img]} {
-				label $g.mediaimg$row -image $img
-				bind $g.mediaimg$row <Destroy> [list image delete $img]
-				grid $g.mediaimg$row -row $row -column 1 -sticky ew
-				set unsupported 0
-				incr row
-			    }
+			lassign $tdata type data
+			if {![catch {image create photo -data $data} img]} {
+			    label $g.mediaimg$row -image $img
+			    bind $g.mediaimg$row <Destroy> [list image delete $img]
+			    grid $g.mediaimg$row -row $row -column 1 -sticky ew
+			    set unsupported 0
+			    incr row
 			}
-			default {
-			    # TODO: implement other types
-			}
 		    }
+		    default {
+			# TODO
+		    }
 		}
+	    } else {
+		render_url $g.mediauri$row $uri $uri -bg [get_conf $g -bg]
+		grid $g.mediauri$row -row $row -column 1 -sticky ew
+		set unsupported 0
+		incr row
 	    }
 	}
 	if {$unsupported} {

Modified: trunk/tkabber/plugins/general/captcha.tcl
===================================================================
--- trunk/tkabber/plugins/general/captcha.tcl	2009-03-15 06:19:19 UTC (rev 1733)
+++ trunk/tkabber/plugins/general/captcha.tcl	2009-03-15 07:14:28 UTC (rev 1734)
@@ -4,9 +4,6 @@
 #
 
 namespace eval captcha {
-    set ::NS(challenge) "urn:xmpp:tmp:challenge"
-    set ::NS(captcha) "urn:xmpp:captcha"
-
     hook::add message_process_x_hook [namespace current]::process_x 10
 }
 
@@ -20,8 +17,7 @@
     foreach xa $x {
 	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
-	if {![string equal $xmlns $::NS(challenge)] && \
-			    ![string equal $xmlns $::NS(captcha)]} {
+	if {![string equal $xmlns urn:xmpp:captcha]} {
 	    continue
 	}
 
@@ -29,7 +25,7 @@
 
 	lassign [::xmpp::data::findForm $subels] type form
 	if {[string equal $type form]} {
-	    if {[catch {process_x_data $f $xlib $from $xmlns $form}]} {
+	    if {[catch {process_x_data $f $xlib $from $form}]} {
 		# Cannot process CAPTCHA form, so falling back to a
 		# legacy CAPTCHA method if any.
 		# TODO: Show error message to user.
@@ -46,20 +42,15 @@
     }
 }
 
-proc captcha::process_x_data {f xlib from xmlns x} {
+proc captcha::process_x_data {f xlib from x} {
     data::draw_window [list $x] \
-		      [namespace code [list send_x_data $xlib $from $xmlns]]
+		      [namespace code [list send_x_data $xlib $from]]
 }
 
-proc captcha::send_x_data {xlib to xmlns w restags} {
-    if {[string equal $xmlns $::NS(captcha)]} {
-	set tag captcha
-    } elseif {[string equal $xmlns $::NS(challenge)]} {
-	set tag challenge
-    }
+proc captcha::send_x_data {xlib to w restags} {
     ::xmpp::sendIQ $xlib set \
-		   -query [::xmpp::xml::create $tag \
-					-xmlns $xmlns \
+		   -query [::xmpp::xml::create captcha \
+					-xmlns urn:xmpp:captcha \
 					-subelements $restags] \
 		   -to $to \
 		   -command [list [namespace current]::result $xlib $to]



More information about the Tkabber-dev mailing list