aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-10 12:18:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-10 12:18:00 -0400
commit275dbbc0086fd895ae8593f9d37798b57cf51d0f (patch)
tree02721777ae92591531908f54bb0c02e7050b2681 /Assistant/Threads
parentb5b2eb90a83cb2720b21701a523b8a8dcc992215 (diff)
separate data type for push stages
This improves type safety.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/XMPPClient.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs
index 6b6c14ea5..3b2632c76 100644
--- a/Assistant/Threads/XMPPClient.hs
+++ b/Assistant/Threads/XMPPClient.hs
@@ -96,11 +96,11 @@ xmppClient urlrenderer d = do
handle _ (GotNetMessage (NotifyPush us)) = void $ inAssistant $ pull us
handle selfjid (GotNetMessage (PairingNotification stage c u)) =
maybe noop (inAssistant . pairMsgReceived urlrenderer stage u selfjid) (parseJID c)
- handle _ (GotNetMessage pushmsg)
- | isPushInitiationMessage pushmsg = inAssistant $
- unlessM (queueNetPushMessage pushmsg) $
- void $ forkIO <~> handlePushMessage pushmsg
- | otherwise = void $ inAssistant $ queueNetPushMessage pushmsg
+ handle _ (GotNetMessage m@(Pushing _ pushstage))
+ | isPushInitiation pushstage = inAssistant $
+ unlessM (queueNetPushMessage m) $
+ void $ forkIO <~> handlePushMessage m
+ | otherwise = void $ inAssistant $ queueNetPushMessage m
handle _ (Ignorable _) = noop
handle _ (Unknown _) = noop
handle _ (ProtocolError _) = noop
@@ -158,12 +158,12 @@ relayNetMessage selfjid = convert =<< waitNetMessage
convert (PairingNotification stage c u) = withclient c $ \tojid -> do
changeBuddyPairing tojid True
return $ putStanza $ pairingNotification stage u tojid selfjid
- convert (CanPush c) = sendclient c canPush
- convert (PushRequest c) = sendclient c pushRequest
- convert (StartingPush c) = sendclient c startingPush
- convert (ReceivePackOutput c b) = sendclient c $ receivePackOutput b
- convert (SendPackOutput c b) = sendclient c $ sendPackOutput b
- convert (ReceivePackDone c code) = sendclient c $ receivePackDone code
+ convert (Pushing c CanPush) = sendclient c canPush
+ convert (Pushing c PushRequest) = sendclient c pushRequest
+ convert (Pushing c StartingPush) = sendclient c startingPush
+ convert (Pushing c (ReceivePackOutput b)) = sendclient c $ receivePackOutput b
+ convert (Pushing c (SendPackOutput b)) = sendclient c $ sendPackOutput b
+ convert (Pushing c (ReceivePackDone code)) = sendclient c $ receivePackDone code
sendclient c construct = withclient c $ \tojid ->
return $ putStanza $ construct tojid selfjid