diff options
Diffstat (limited to 'xmpp.scm')
-rw-r--r-- | xmpp.scm | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -1,9 +1,10 @@ (define-module (gnubba xmpp) #:use-module (sxml simple) + #:use-module ((sxml xpath) #:select (sxpath)) #:use-module ((srfi srfi-1) #:select (find)) - #:export (iq - presence - message + #:export (iq iq? + presence presence? + message message? stanza-id stanza-to stanza-from @@ -89,14 +90,14 @@ is unregistered." (to "") (type "get") (id (next-stanza-id! 'iq))) - `(iq ,(drop-empty-attr `(@ (from ,from) - (to ,to) - (type ,type) - (id ,id))) - ,body)) + `(*TOP* (iq ,(drop-empty-attr `(@ (from ,from) + (to ,to) + (type ,type) + (id ,id))) + ,body))) (define (message to body) - `(message (@ (to ,to)) (body ,body))) + `(*TOP* (message (@ (to ,to)) (body ,body)))) (define* (presence #:optional body #:key (from "") @@ -108,9 +109,9 @@ is unregistered." (from ,from) (to ,to) (id ,id))))) - (if body - `(presence ,attr ,body) - `(presence ,attr)))) + `(*TOP* ,(if body + `(presence ,attr ,body) + `(presence ,attr))))) (define (stanza-find-property property-name stanza) @@ -148,7 +149,6 @@ is unregistered." ;; (define-attributes (from to type id)) -;; TODO: define some useful predicates -(define (iq? stanza) #f) -(define (message? stanza) #f) -(define (presence? stanza) #f) +(define (iq? stanza) (not (null? ((sxpath '(iq)) stanza)))) +(define (message? stanza) (not (null? ((sxpath '(message)) stanza)))) +(define (presence? stanza) (not (null? ((sxpath '(presence)) stanza)))) |