[Tkabber-dev] Issue 2 in tclxmpp: Enhancement suggestion: Add -xmltracecommand

tclxmpp at googlecode.com tclxmpp at googlecode.com
Thu Sep 23 07:44:16 MSD 2010

Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2 by green.kenneth: Enhancement suggestion: Add -xmltracecommand

The existing -logcommand did not give me what I wanted which was a callback  
with the text of each XML stanza either just before being transmitted or  
right when it was received. The -logcommand sometimes gets called with  
fragments of complete stanzas.

So I added a new callback "-xmltracecommand" and invoked it in a couple of  
locations. A complete diff report is attached to this issue.

What version of the product are you using? On what operating system?

$Id: xmpp.tcl 142 2010-01-29 15:14:25Z sgolovan $
package provide xmpp 0.1

Please provide any additional information below.

Added to header comments (last line below):

# ::xmpp::new --
#       Create a new XMPP token and assigns client callbacks for XMPP  
# Arguments:
#       token                   (optional, if missing then token is created
#                               automatically, if present then it must be a
#                               fully namespaced nonexistent variable) XMPP
#                               token to create.
#       -packetcommand     cmd  (optional) Command to call on every incoming
#                               XMPP packet except stream errors.
#       -messagecommand    cmd  (optional) Command to call on every XMPP
#                               message packet (overrides -packetCommand).
#       -presencecommand   cmd  (optional) Command to call on every XMPP
#                               presence packet (overrides -packetCommand).
#       -disconnectcommand cmd  (optional) Command to call on forced  
#                               from XMPP server.
#       -statuscommand     cmd  (optional) Command to call when XMPP  
#                               status is changed (e.g. after successful
#                               authentication).
#       -errorcommand      cmd  (optional) Command to call on XMPP stream  
#                               packet.
#       -xmltracecommand   cmd  (optional) Command to call for each Tx or  
Rx XML stanza

Added to initialisation (last 2 lines below):
     foreach {key val} $args {
         switch -- $key {
             -packetcommand -
             -messagecommand -
             -presencecommand -
             -iqcommand -
             -disconnectcommand -
             -statuscommand -
             -errorcommand -
             -logcommand -
             -xmltracecommand {

Modified xmpp::outXML :

proc ::xmpp::outXML {xlib xmlElement} {
     variable $xlib
     upvar 0 $xlib state

     set xmlString "[xml::toTabbedText $xmlElement]"
     Debug $xlib 2 $xmlString
     CallBack $xlib xmltrace TX $xmlString
     CallBack $xlib log output xml $xmlElement

     transport::use $state(transport) outXML $xmlElement

Modified xmpp::Parse (2nd last line below):

     Debug $xlib 2 "$xmlElement"
     CallBack $xlib xmltrace RX "[xml::toTabbedText $xmlElement]"
     CallBack $xlib log input xml $xmlElement

	xmpp_diff_report.htm  1.3 MB

More information about the Tkabber-dev mailing list