From 7ccaa169bc2309df7df2db118dd646177867f2b0 Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 12 Feb 2014 20:35:52 -0500 Subject: Reply to pings with pongs. --- Presence/EventUtil.hs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Presence/EventUtil.hs') 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 import Control.Monad import Data.XML.Types as XML +import qualified Data.List as List getStreamName (EventBeginElement name _) = name @@ -21,3 +22,36 @@ elementAttrs _ _ = mzero streamP name = Name name (Just "http://etherx.jabber.org/streams") (Just "stream") attr name value = (name,[ContentText value]) + +isServerIQOf (EventBeginElement name attrs) testType + | name=="{jabber:server}iq" + && matchAttrib "type" testType attrs + = True +isServerIQOf _ _ = False + +matchAttrib name value attrs = + case List.find ( (==name) . fst) attrs of + Just (_,[ContentText x]) | x==value -> True + Just (_,[ContentEntity x]) | x==value -> True + _ -> False + +lookupAttrib name attrs = + case List.find ( (==name) . fst) attrs of + Just (_,[ContentText x]) -> Just x + Just (_,[ContentEntity x]) -> Just x + _ -> Nothing + +tagAttrs (EventBeginElement _ xs) = xs +tagAttrs _ = [] + + +{- +iqTypeSet = "set" +iqTypeGet = "get" +iqTypeResult = "result" +iqTypeError = "error" +-} + + +tagName (EventBeginElement n _) = n +tagName _ = "" -- cgit v1.2.3