diff options
Diffstat (limited to 'Presence/EventUtil.hs')
-rw-r--r-- | Presence/EventUtil.hs | 34 |
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 | ||
4 | import Control.Monad | 4 | import Control.Monad |
5 | import Data.XML.Types as XML | 5 | import Data.XML.Types as XML |
6 | import qualified Data.List as List | ||
6 | 7 | ||
7 | getStreamName (EventBeginElement name _) = name | 8 | getStreamName (EventBeginElement name _) = name |
8 | 9 | ||
@@ -21,3 +22,36 @@ elementAttrs _ _ = mzero | |||
21 | streamP name = Name name (Just "http://etherx.jabber.org/streams") (Just "stream") | 22 | streamP name = Name name (Just "http://etherx.jabber.org/streams") (Just "stream") |
22 | 23 | ||
23 | attr name value = (name,[ContentText value]) | 24 | attr name value = (name,[ContentText value]) |
25 | |||
26 | isServerIQOf (EventBeginElement name attrs) testType | ||
27 | | name=="{jabber:server}iq" | ||
28 | && matchAttrib "type" testType attrs | ||
29 | = True | ||
30 | isServerIQOf _ _ = False | ||
31 | |||
32 | matchAttrib 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 | |||
38 | lookupAttrib 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 | |||
44 | tagAttrs (EventBeginElement _ xs) = xs | ||
45 | tagAttrs _ = [] | ||
46 | |||
47 | |||
48 | {- | ||
49 | iqTypeSet = "set" | ||
50 | iqTypeGet = "get" | ||
51 | iqTypeResult = "result" | ||
52 | iqTypeError = "error" | ||
53 | -} | ||
54 | |||
55 | |||
56 | tagName (EventBeginElement n _) = n | ||
57 | tagName _ = "" | ||