summaryrefslogtreecommitdiff
path: root/Presence/EventUtil.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/EventUtil.hs')
-rw-r--r--Presence/EventUtil.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/Presence/EventUtil.hs b/Presence/EventUtil.hs
index e62f8afc..bdea9fa2 100644
--- a/Presence/EventUtil.hs
+++ b/Presence/EventUtil.hs
@@ -3,6 +3,7 @@ module EventUtil where
3 3
4import Control.Monad 4import Control.Monad
5import Data.XML.Types as XML 5import Data.XML.Types as XML
6import qualified Data.List as List
6 7
7getStreamName (EventBeginElement name _) = name 8getStreamName (EventBeginElement name _) = name
8 9
@@ -21,3 +22,36 @@ elementAttrs _ _ = mzero
21streamP name = Name name (Just "http://etherx.jabber.org/streams") (Just "stream") 22streamP name = Name name (Just "http://etherx.jabber.org/streams") (Just "stream")
22 23
23attr name value = (name,[ContentText value]) 24attr name value = (name,[ContentText value])
25
26isServerIQOf (EventBeginElement name attrs) testType
27 | name=="{jabber:server}iq"
28 && matchAttrib "type" testType attrs
29 = True
30isServerIQOf _ _ = False
31
32matchAttrib name value attrs =
33 case List.find ( (==name) . fst) attrs of
34 Just (_,[ContentText x]) | x==value -> True
35 Just (_,[ContentEntity x]) | x==value -> True
36 _ -> False
37
38lookupAttrib name attrs =
39 case List.find ( (==name) . fst) attrs of
40 Just (_,[ContentText x]) -> Just x
41 Just (_,[ContentEntity x]) -> Just x
42 _ -> Nothing
43
44tagAttrs (EventBeginElement _ xs) = xs
45tagAttrs _ = []
46
47
48{-
49iqTypeSet = "set"
50iqTypeGet = "get"
51iqTypeResult = "result"
52iqTypeError = "error"
53-}
54
55
56tagName (EventBeginElement n _) = n
57tagName _ = ""