Browse Source

derive Show for IMPresence

master
Philipp Balzarek 13 years ago
parent
commit
96b6e5b6e9
  1. 2
      source/Network/Xmpp/IM/Presence.hs
  2. 13
      tests/Tests.hs

2
source/Network/Xmpp/IM/Presence.hs

@ -30,7 +30,7 @@ instance Read ShowStatus where @@ -30,7 +30,7 @@ instance Read ShowStatus where
data IMPresence = IMP { showStatus :: Maybe ShowStatus
, status :: Maybe Text
, priority :: Maybe Int
}
} deriving Show
imPresence :: IMPresence
imPresence = IMP { showStatus = Nothing

13
tests/Tests.hs

@ -80,8 +80,13 @@ iqResponder context = do @@ -80,8 +80,13 @@ iqResponder context = do
autoAccept :: Xmpp ()
autoAccept context = forever $ do
st <- waitForPresence (\p -> presenceType p == Just Subscribe) context
sendPresence (presenceSubscribed (fromJust $ presenceFrom st)) context
st <- waitForPresence (\p -> presenceType p == Subscribe) context
sendPresence (presenceSubscribed (fromJust $ presenceFrom st)) context
showPresence context = forever $ do
pr <- waitForPresence (const True) context
print $ getIMPresence pr
simpleMessage :: Jid -> Text -> Message
simpleMessage to txt = message
@ -169,12 +174,12 @@ runMain debug number multi = do @@ -169,12 +174,12 @@ runMain debug number multi = do
config
sendPresence presenceOnline context
thread1 <- forkIO $ autoAccept =<< dupSession context
sendPresence (presenceSubscribe them) context
thread2 <- forkIO $ iqResponder =<< dupSession context
thread2 <- forkIO $ showPresence =<< dupSession context
when active $ do
liftIO $ threadDelay 1000000 -- Wait for the other thread to go online
-- discoTest debug'
when multi $ iqTest debug' we them context
-- when multi $ iqTest debug' we them context
killThread thread1
killThread thread2
return ()

Loading…
Cancel
Save