summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-03-07 22:54:03 -0500
committerjoe <joe@jerkface.net>2014-03-07 22:54:03 -0500
commitb867a70b2321065d3d98cb55df96a3083e217018 (patch)
tree260460086c3724a806c772f1505050af119639c5
parentcdd35ce0c21f4d90fc7b0470d8b9c9d22d6c05d4 (diff)
peerSubscriptionRequest todo stub
-rw-r--r--Presence/XMPPServer.hs8
-rw-r--r--xmppServer.hs27
2 files changed, 29 insertions, 6 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index a118ce88..4eb89f7f 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -190,7 +190,8 @@ data XMPPServerParameters =
190 , xmppInformClientPresence :: ConnectionKey -> Stanza -> IO () 190 , xmppInformClientPresence :: ConnectionKey -> Stanza -> IO ()
191 , xmppInformPeerPresence :: ConnectionKey -> Stanza -> IO () 191 , xmppInformPeerPresence :: ConnectionKey -> Stanza -> IO ()
192 , xmppAnswerProbe :: ConnectionKey -> Stanza -> TChan Stanza -> IO () 192 , xmppAnswerProbe :: ConnectionKey -> Stanza -> TChan Stanza -> IO ()
193 , xmppClientSubscriptionRequest :: IO () -> ConnectionKey -> Stanza -> IO () 193 , xmppClientSubscriptionRequest :: IO () -> ConnectionKey -> Stanza -> TChan Stanza -> IO ()
194 , xmppPeerSubscriptionRequest :: IO () -> ConnectionKey -> Stanza -> TChan Stanza -> IO ()
194 } 195 }
195 196
196 197
@@ -1610,7 +1611,7 @@ monitor sv params xmpp = do
1610 xmppInformClientPresence xmpp k stanza 1611 xmppInformClientPresence xmpp k stanza
1611 PresenceRequestSubscription {} -> do 1612 PresenceRequestSubscription {} -> do
1612 let fail = return () -- todo 1613 let fail = return () -- todo
1613 xmppClientSubscriptionRequest xmpp fail k stanza 1614 xmppClientSubscriptionRequest xmpp fail k stanza replyto
1614 NotifyClientVersion name version -> do 1615 NotifyClientVersion name version -> do
1615 enableClientHacks name version replyto 1616 enableClientHacks name version replyto
1616 UnrecognizedQuery query -> do 1617 UnrecognizedQuery query -> do
@@ -1629,6 +1630,9 @@ monitor sv params xmpp = do
1629 xmppAnswerProbe xmpp k stanza replyto 1630 xmppAnswerProbe xmpp k stanza replyto
1630 PresenceStatus {} -> do 1631 PresenceStatus {} -> do
1631 xmppInformPeerPresence xmpp k stanza 1632 xmppInformPeerPresence xmpp k stanza
1633 PresenceRequestSubscription {} -> do
1634 let fail = return () -- todo
1635 xmppPeerSubscriptionRequest xmpp fail k stanza replyto
1632 _ -> return () 1636 _ -> return ()
1633 _ -> return () 1637 _ -> return ()
1634 let deliver replyto = do 1638 let deliver replyto = do
diff --git a/xmppServer.hs b/xmppServer.hs
index 41f0012e..7f610587 100644
--- a/xmppServer.hs
+++ b/xmppServer.hs
@@ -613,15 +613,33 @@ sendCachedPresence state k = do
613 -- send local buddies. 613 -- send local buddies.
614 return () 614 return ()
615 615
616clientSubscriptionRequest :: PresenceState -> IO () -> ConnectionKey -> Stanza -> IO () 616clientSubscriptionRequest :: PresenceState -> IO () -> ConnectionKey -> Stanza -> TChan Stanza -> IO ()
617clientSubscriptionRequest state fail k stanza = do 617clientSubscriptionRequest state fail k stanza chan = do
618 flip (maybe fail) (stanzaTo stanza) $ \to -> do 618 flip (maybe fail) (stanzaTo stanza) $ \to -> do
619 -- TODO: resolve hostname 619 -- TODO: resolve hostname
620 -- TODO: add to solicitors 620 -- TODO: add to solicited
621 -- TODO; if already connected, send solicitation 621 -- TODO; if already connected, send solicitation
622 -- TODO: addPeer 622 -- TODO: addPeer
623 return () 623 return ()
624 624
625peerSubscriptionRequest :: PresenceState -> IO () -> ConnectionKey -> Stanza -> TChan Stanza -> IO ()
626peerSubscriptionRequest state fail k stanza chan = do
627 -- TODO: if already subscribed, reply and quit
628
629 -- TODO: add to pending
630
631 -- TODO: send to clients
632 -- "all available resources in accordence with section 8"
633 -- Section 8 says (for presence of type "subscribe", the server MUST
634 -- adhere to the rules defined under Section 3 and summarized under
635 -- Appendix A.
636 -- Appendex A.3.1 says
637 -- contact ∈ subscribers --> SHOULD NOT, already handled
638 -- contact ∉ subscribers & contact ∈ pending --> SHOULD NOT
639 -- contact ∉ subscribers & contact ∉ pending --> MUST
640
641 return ()
642
625main = runResourceT $ do 643main = runResourceT $ do
626 state <- liftIO . atomically $ do 644 state <- liftIO . atomically $ do
627 clients <- newTVar Map.empty 645 clients <- newTVar Map.empty
@@ -658,6 +676,7 @@ main = runResourceT $ do
658 , xmppInformPeerPresence = informPeerPresence state 676 , xmppInformPeerPresence = informPeerPresence state
659 , xmppAnswerProbe = answerProbe state 677 , xmppAnswerProbe = answerProbe state
660 , xmppClientSubscriptionRequest = clientSubscriptionRequest state 678 , xmppClientSubscriptionRequest = clientSubscriptionRequest state
679 , xmppPeerSubscriptionRequest = peerSubscriptionRequest state
661 } 680 }
662 liftIO $ do 681 liftIO $ do
663 atomically $ putTMVar (server state) sv 682 atomically $ putTMVar (server state) sv