[Tkabber-dev] r1713 - in trunk/tkabber-plugins: . whiteboard

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Mar 12 20:08:06 MSK 2009


Author: sergei
Date: 2009-03-12 20:08:06 +0300 (Thu, 12 Mar 2009)
New Revision: 1713

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/whiteboard/svgrender.tcl
   trunk/tkabber-plugins/whiteboard/whiteboard.tcl
Log:
	* whiteboard/svgrender.tcl, whiteboard/whiteboard.tcl: Switched to
	  Bits of Binary (Xep-0231) interface when sending bitmaps.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2009-03-12 17:06:25 UTC (rev 1712)
+++ trunk/tkabber-plugins/ChangeLog	2009-03-12 17:08:06 UTC (rev 1713)
@@ -1,3 +1,8 @@
+2009-03-12  Sergei Golovan <sgolovan at nes.ru>
+
+	* whiteboard/svgrender.tcl, whiteboard/whiteboard.tcl: Switched to
+	  Bits of Binary (Xep-0231) interface when sending bitmaps.
+
 2009-03-10  Sergei Golovan <sgolovan at nes.ru>
 
 	* poker/poker.tcl: Fixed bug with pot splitting.

Modified: trunk/tkabber-plugins/whiteboard/svgrender.tcl
===================================================================
--- trunk/tkabber-plugins/whiteboard/svgrender.tcl	2009-03-12 17:06:25 UTC (rev 1712)
+++ trunk/tkabber-plugins/whiteboard/svgrender.tcl	2009-03-12 17:08:06 UTC (rev 1713)
@@ -407,10 +407,18 @@
     array set Attrs $curAttrs
     array set Attrs $attrs
 
-    if {[catch {image create photo -data $cdata} image]} {
+    # Works only with BOB data included in the same XMPP stanza
+    set cid [::xmpp::xml::getAttr $attrs http://www.w3.org/1999/xlink:href]
+    lassign [::xmpp::bob::get $cid] type data
+
+    if {$data == ""} {
 	return ""
     }
 
+    if {[catch {image create photo -data $data} image]} {
+	return ""
+    }
+
     bind $c <Destroy> +[list image delete $image]
 
     set opts [ImageOpts]

Modified: trunk/tkabber-plugins/whiteboard/whiteboard.tcl
===================================================================
--- trunk/tkabber-plugins/whiteboard/whiteboard.tcl	2009-03-12 17:06:25 UTC (rev 1712)
+++ trunk/tkabber-plugins/whiteboard/whiteboard.tcl	2009-03-12 17:08:06 UTC (rev 1713)
@@ -309,7 +309,7 @@
     return [rand 10000][clock seconds][set [namespace current]::id_base]
 }
 
-proc wb::send_svg {chatid tag} {
+proc wb::send_svg {chatid tag {tag2 ""}} {
     if {[chat::is_groupchat $chatid]} {
 	set type groupchat
     } else {
@@ -317,12 +317,18 @@
     }
     set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
-    ::xmpp::sendMessage $xlib $jid \
-	-type $type \
-	-xlist [list [::xmpp::xml::create x \
+
+    set xlist [list [::xmpp::xml::create x \
 			  -xmlns tkabber:whiteboard \
 			  -subelement [::xmpp::xml::create svg \
+					      -xmlns http://www.w3.org/2000/svg \
+					      -attrs {xmlns:xlink http://www.w3.org/1999/xlink} \
 					      -subelement $tag]]]
+    if {$tag2 != ""} {
+	lappend xlist $tag2
+    }
+
+    ::xmpp::sendMessage $xlib $jid -type $type -xlist $xlist
 }
 
 proc wb::send_clear {chatid} {
@@ -1240,13 +1246,14 @@
 	default { set type "image" }
     }
 
-    set base64val [base64::encode $binval]
+    set cid [::xmpp::bob::cid $binval]
+    set data [::xmpp::bob::data $type $binval -maxage 0]
     
     set id [create_id]
     set attrs [list id $id x $image_info(x) y $image_info(y) \
-		    type $type]
+		    type $type xlink:href $cid]
 
-    set tag [::xmpp::xml::create image -attrs $attrs -cdata $base64val]
+    set tag [::xmpp::xml::create image -attrs $attrs]
 
     if {![chat::is_groupchat $chatid]} {
 	set imageid [svg::parseSVGItem $c {} {} $tag]
@@ -1255,7 +1262,7 @@
 	$c addtag [time_tag created $jid] withtag $imageid
     }
 
-    send_svg $chatid $tag
+    send_svg $chatid $tag $data
 }
 
 ###############################################################################



More information about the Tkabber-dev mailing list