summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2014-12-01 21:33:21 +0100
committerrekado <rekado@elephly.net>2014-12-01 21:33:21 +0100
commita7d638168947b36cec0c17cc89bad20f113d23ae (patch)
treea6faf0d66c0c2bbac11da533a9a4adce66c418d6
parentcdaa43d9fe9041006dcbdfcd816e40e8401e3aff (diff)
implement predicates for iq/message/presence
-rw-r--r--xmpp.scm32
1 files changed, 16 insertions, 16 deletions
diff --git a/xmpp.scm b/xmpp.scm
index 274524b..91d8662 100644
--- a/xmpp.scm
+++ b/xmpp.scm
@@ -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))))