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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Nov 9 22:05:26 MSK 2008


Author: sergei
Date: 2008-11-09 22:05:26 +0300 (Sun, 09 Nov 2008)
New Revision: 1609

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/login.tcl
   trunk/tkabber/plugins/general/rawxml.tcl
   trunk/tkabber/tkabber.tcl
Log:
	* tkabber.tcl, login.tcl, plugins/general/rawxml.tcl: Adapted XML
	  console to a new log callback in XMPP library.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-11-06 17:11:29 UTC (rev 1608)
+++ trunk/tkabber/ChangeLog	2008-11-09 19:05:26 UTC (rev 1609)
@@ -1,3 +1,8 @@
+2008-11-09  Sergei Golovan  <sgolovan at nes.ru>
+
+	* tkabber.tcl, login.tcl, plugins/general/rawxml.tcl: Adapted XML
+	  console to a new log callback in XMPP library.
+
 2008-11-06  Sergei Golovan  <sgolovan at nes.ru>
 
 	* ifacetk/ilogin.tcl: Call logout even if there is no connections to

Modified: trunk/tkabber/login.tcl
===================================================================
--- trunk/tkabber/login.tcl	2008-11-06 17:11:29 UTC (rev 1608)
+++ trunk/tkabber/login.tcl	2008-11-09 19:05:26 UTC (rev 1609)
@@ -466,7 +466,8 @@
 				  -iqcommand         client:iq         \
 				  -disconnectcommand client:disconnect \
 				  -statuscommand     client:status     \
-				  -errorcommand      client:error]
+				  -errorcommand      client:error      \
+				  -logcommand        client:log]
 	}
     } else {
 	set xlib [::xmpp::new -messagecommand    client:message    \
@@ -474,7 +475,8 @@
 			      -iqcommand         client:iq         \
 			      -disconnectcommand client:disconnect \
 			      -statuscommand     client:status     \
-			      -errorcommand      client:error]
+			      -errorcommand      client:error      \
+			      -logcommand        client:log]
 	set connhist($njid) $xlib
     }
 
@@ -756,6 +758,10 @@
 
 hook::add disconnected_hook ::xmpp::disconnect 10
 
+proc client:log {xlib dir type msg} {
+    hook::run log_hook $xlib $dir $type $msg
+}
+
 proc recv_auth_result {xlib logindata res xml} {
     global connjid
 

Modified: trunk/tkabber/plugins/general/rawxml.tcl
===================================================================
--- trunk/tkabber/plugins/general/rawxml.tcl	2008-11-06 17:11:29 UTC (rev 1608)
+++ trunk/tkabber/plugins/general/rawxml.tcl	2008-11-09 19:05:26 UTC (rev 1609)
@@ -30,22 +30,34 @@
 	[::msgcat::mc "Indentation for pretty-printed XML subtags."] \
 	-group RawXML -type integer
 
-    set pass 0
     variable tabs
 }
 
 
-proc rawxml::handle_inout {xlib text prefix tag} {
+proc rawxml::handle_inout {xlib dir type msg} {
     variable options
-    variable pass
 
     set w .rawxml
     if {![winfo exists $w]} return
-    if {$options(pretty_print) && ($tag != "out" || $pass)} {
-	set pass 0
+
+    if {$options(pretty_print) && $type == "xml"} {
+	handle_inout_x $xlib $dir $msg
 	return
+    } elseif {$type == "xml"} {
+	set msg [::xmpp::xml::toText $msg]
     }
 
+    switch -- $dir {
+	output {
+	    set prefix OUT
+	    set tag out
+	}
+	default {
+	    set prefix IN
+	    set tag in
+	}
+    }
+
     set dump $w.dump
     $dump configure -state normal
 
@@ -56,7 +68,7 @@
 
     $dump insert end \
 	"$prefix$id:\n" {} \
-	"$text" $tag
+	"$msg" $tag
 
     if {![$dump compare "end -1 chars linestart" == "end -1 chars"]} {
 	$dump insert end "\n"
@@ -69,15 +81,24 @@
     $dump configure -state disabled
 }
 
-proc rawxml::handle_inout_x {xlib xml prefix tag} {
+proc rawxml::handle_inout_x {xlib dir xml} {
     variable options
-    variable pass
 
     set w .rawxml
     if {![winfo exists $w]} return
     if {!$options(pretty_print)} return
-    if {$tag == "out"} {set pass 1}
 
+    switch -- $dir {
+	output {
+	    set prefix OUT
+	    set tag out
+	}
+	default {
+	    set prefix IN
+	    set tag in
+	}
+    }
+
     set dump $w.dump
     $dump configure -state normal
 
@@ -153,14 +174,7 @@
     }
 }
 
-proc ::LOG_INPUT {xlib t} \
-    "[namespace current]::rawxml::handle_inout \$xlib \$t IN in"
-proc ::LOG_OUTPUT {xlib t} \
-    "[namespace current]::rawxml::handle_inout \$xlib \$t OUT out"
-proc ::LOG_INPUT_XML {xlib x} \
-    "[namespace current]::rawxml::handle_inout_x \$xlib \$x IN in"
-proc ::LOG_OUTPUT_XML {xlib x} \
-    "[namespace current]::rawxml::handle_inout_x \$xlib \$x OUT out"
+hook::add log_hook [namespace current]::rawxml::handle_inout
 
 proc rawxml::open_window {} {
     set w .rawxml

Modified: trunk/tkabber/tkabber.tcl
===================================================================
--- trunk/tkabber/tkabber.tcl	2008-11-06 17:11:29 UTC (rev 1608)
+++ trunk/tkabber/tkabber.tcl	2008-11-09 19:05:26 UTC (rev 1609)
@@ -208,14 +208,6 @@
 
 load_source splash.tcl
 
-proc ::LOG {text} {
-    debugmsg jlib $text
-}
-
-proc ::HTTP_LOG {text} {
-    debugmsg http $text
-}
-
 if {[catch { package require Img }]} {
     debugmsg tkabber \
 	"unable to load the Img package, so no PNG/JPEG image support!



More information about the Tkabber-dev mailing list