[namespace code [list OnPresenceChange $context]]
# Discovery support
- $xmpp(jlib) disco registeridentity client pc Bullfrog
foreach feature {jabber:client jabber:iq:last jabber:iq:time \
- jabber:iq:version jabber:x:event} {
+ jabber:iq:version jabber:x:event urn:xmpp:receipts} {
jlib::disco::registerfeature $feature
}
+ $xmpp(jlib) disco registeridentity client pc Bullfrog
- #$xmpp(jlib) caps register ? ? ?
set [set xmpp(jlib)]::AppContext $context
Callback $context init
+
+ set e_color \
+ [list [wrapper::createtag "identity" \
+ -attrlist [list category hierarchy type leaf name "color"]]\
+ [wrapper::createtag "feature" \
+ -attrlist [list var "urn:tkchat:color"]]]
+ $xmpp(jlib) caps register color $e_color [list urn:tkchat:color]
+ #$xmpp(jlib) caps register time $e_time [list time urn:tkchat:color]
+ $xmpp(jlib) register_presence_stanza [get_caps $context] -type available
+
set xmpp(jid) [jlib::joinjid $xmpp(-username) $xmpp(-server) $xmpp(-resource)]
$xmpp(jlib) connect init
$xmpp(jlib) connect configure -defaultresource $xmpp(-resource)
if {$thread eq ""} {set thread [uuid::uuid generate] }
}
- if {[catch {dict get $xmll(opts) $channel -chatstate} chatstate]} {
+ if {[catch {dict get $xmpp(opts) $channel -chatstate} chatstate]} {
set chatstate active
}
return $ver
}
+# Generates a jlib xmllist containing the xep-0115 caps data for this
+# version of this application. Should be constant per instance.
proc ::xmppplugin::get_caps {ctx} {
+ upvar #0 $ctx xmpp
foreach {name ver os} [split [Version $ctx] :] break
+ set exts [$xmpp(jlib) caps getexts] ;# registered on startup
set caps [wrapper::createtag c -attrlist \
[list xmlns "http://jabber.org/protocol/caps" \
- node "http://tkchat.tclers.tk/$name/caps" \
- ver $ver ext {color time}]]
+ node "http://tkchat.tcl.tk/$name/caps" \
+ ver $ver ext $exts]]
return $caps
}
ok {
Callback $ctx connect
$jlib send_presence
- $jlib send_presence -priority 2 -extras [list [get_caps $ctx]]
+ $jlib send_presence -priority 2 -show available
$jlib roster send_get -command [list [namespace origin OnRosterGet] $ctx]
if {$xmpp(-autoconnect) && $xmpp(-channel) ne {}} {
Log $ctx "Attempting to join $xmpp(-channel)"
[wrapper::getfirstchildwithtag $xmldata thread]]]
set chatstate [wrapper::gettag \
[wrapper::getfirstchildwithxmlns $xmldata http://jabber.org/protocol/chatstates]]
+ set receipt [wrapper::getchildswithtagandxmlns $xmldata request urn:xmpp:receipts]
foreach x [wrapper::getchildswithtag $xmldata x] {
switch -exact -- [wrapper::getattribute $x xmlns] {
}
}
# if chatstate stuff -- display somehow
+
+ # xep-0183: receipt notification
+ if {[llength $receipt] > 0 && [info exists a(id)]} {
+ $xmpp(jlib) send_message $a(from) -id $a(id) -type $a(type) \
+ -xlist [list [wrapper::createtag received \
+ -attrlist {xmlns urn:xmpp:receipts}]]
+ }
+
if {[llength $body] > 0} {
Callback $ctx chat $a(from) $nick \
[wrapper::getcdata [lindex $body 0]] normal
}
set p [list -date $time -subject $subject]
if {$thread ne {}} {lappend p -thread $thread}
- lappend p -body [wrapper::getcdata [lindex $body 0]]
- eval [linsert $p 0 Callback $ctx message $a(to) $from]
+ lappend p -body [set bodydata [wrapper::getcdata [lindex $body 0]]]
+ if {[string length $body] > 0 || [string length $subject] > 0} {
+ eval [linsert $p 0 Callback $ctx message $a(to) $from]
+ }
}
headline {
Callback $ctx chat $a(to) $a(from) \
}
}
-
proc ::xmppplugin::query_user {Chat user what} {
upvar #0 $Chat ctx
upvar #0 $ctx(xmpp) xmpp
return
}
+proc ::xmppplugin::SendReceipt {Chat} {
+ lappend xlist [wrapper::createtag received \
+ -attrlist {xmlns urn:xmpp:receipts}]
+ set margs [list -type $chat(type) -xlist $xlist]
+ if {![catch {set thread [dict get $xmpp(opts) $chat(channel) -thread]}]} {
+ lappend margs -thread $thread
+ }
+ eval [linsert $margs 0 $xmpp(jlib) send_message $chat(channel)]
+}
+
package provide xmppplugin $::xmppplugin::version
# -------------------------------------------------------------------------