summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-02-16 23:28:28 -0500
committerjoe <joe@jerkface.net>2014-02-16 23:28:28 -0500
commit8bb04df557c3b78ff47ffca7facb06ac7f076110 (patch)
treeaf277e226682078ac6c04b4b18e738110c271995 /Presence
parentdf83e87aa66748d1e38a471ff6c7ef8ddbe5dc83 (diff)
xmppTellMyName
Diffstat (limited to 'Presence')
-rw-r--r--Presence/XMPPServer.hs23
1 files changed, 15 insertions, 8 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index 222d8ac4..96998198 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -122,6 +122,8 @@ data Stanza = Stanza
122data XMPPServerParameters = 122data XMPPServerParameters =
123 XMPPServerParameters 123 XMPPServerParameters
124 { xmppChooseResourceName :: ConnectionKey -> SockAddr -> Maybe Text -> IO Text 124 { xmppChooseResourceName :: ConnectionKey -> SockAddr -> Maybe Text -> IO Text
125 , xmppTellMyNameToClient :: IO Text
126 , xmppTellMyNameToPeer :: SockAddr -> IO Text
125 , xmppNewConnection :: ConnectionKey -> TChan Stanza -> IO () 127 , xmppNewConnection :: ConnectionKey -> TChan Stanza -> IO ()
126 , xmppEOF :: ConnectionKey -> IO () 128 , xmppEOF :: ConnectionKey -> IO ()
127 , xmppRosterBuddies :: ConnectionKey -> IO [Text] 129 , xmppRosterBuddies :: ConnectionKey -> IO [Text]
@@ -618,22 +620,25 @@ goodbye =
618 ] 620 ]
619 621
620forkConnection :: Server ConnectionKey SockAddr 622forkConnection :: Server ConnectionKey SockAddr
623 -> XMPPServerParameters
621 -> ConnectionKey 624 -> ConnectionKey
625 -> SockAddr
622 -> FlagCommand 626 -> FlagCommand
623 -> Source IO XML.Event 627 -> Source IO XML.Event
624 -> Sink (Flush XML.Event) IO () 628 -> Sink (Flush XML.Event) IO ()
625 -> TChan Stanza 629 -> TChan Stanza
626 -> IO (TChan Stanza) 630 -> IO (TChan Stanza)
627forkConnection sv k pingflag src snk stanzas = do 631forkConnection sv xmpp k laddr pingflag src snk stanzas = do
628 let namespace = case k of 632 let (namespace,tellmyname) = case k of
629 ClientKey {} -> "jabber:client" 633 ClientKey {} -> ("jabber:client", xmppTellMyNameToClient xmpp)
630 PeerKey {} -> "jabber:server" 634 PeerKey {} -> ("jabber:server",xmppTellMyNameToPeer xmpp laddr)
635 me <- tellmyname
631 rdone <- atomically newEmptyTMVar 636 rdone <- atomically newEmptyTMVar
632 slots <- atomically $ Slotted.new isEventBeginElement isEventEndElement 637 slots <- atomically $ Slotted.new isEventBeginElement isEventEndElement
633 needsFlush <- atomically $ newTVar False 638 needsFlush <- atomically $ newTVar False
634 let _ = slots :: Slotted.UpdateStream XMPPState XML.Event 639 let _ = slots :: Slotted.UpdateStream XMPPState XML.Event
635 let greet_src = do 640 let greet_src = do
636 CL.sourceList (greet' namespace "localhost") =$= CL.map Chunk 641 CL.sourceList (greet' namespace me) =$= CL.map Chunk
637 yield Flush 642 yield Flush
638 slot_src = do 643 slot_src = do
639 what <- lift . atomically $ foldr1 orElse 644 what <- lift . atomically $ foldr1 orElse
@@ -823,7 +828,7 @@ monitor sv params xmpp = do
823 Connection pingflag conread conwrite -> do 828 Connection pingflag conread conwrite -> do
824 wlog $ tomsg k "Connection" 829 wlog $ tomsg k "Connection"
825 let (xsrc,xsnk) = xmlStream conread conwrite 830 let (xsrc,xsnk) = xmlStream conread conwrite
826 outs <- forkConnection sv k pingflag xsrc xsnk stanzas 831 outs <- forkConnection sv xmpp k u pingflag xsrc xsnk stanzas
827 xmppNewConnection xmpp k outs 832 xmppNewConnection xmpp k outs
828 return () 833 return ()
829 ConnectFailure addr -> return () -- wlog $ tomsg k "ConnectFailure" 834 ConnectFailure addr -> return () -- wlog $ tomsg k "ConnectFailure"
@@ -846,7 +851,8 @@ monitor sv params xmpp = do
846 let reply = iq_bind_reply (stanzaId stanza) rsc 851 let reply = iq_bind_reply (stanzaId stanza) rsc
847 sendReply quitVar SetResource reply replyto 852 sendReply quitVar SetResource reply replyto
848 SessionRequest -> do 853 SessionRequest -> do
849 let reply = iq_session_reply (stanzaId stanza) "localhost" 854 me <- xmppTellMyNameToClient xmpp
855 let reply = iq_session_reply (stanzaId stanza) me
850 sendReply quitVar Pong reply replyto 856 sendReply quitVar Pong reply replyto
851 RequestRoster -> do 857 RequestRoster -> do
852 sendRoster stanza xmpp replyto 858 sendRoster stanza xmpp replyto
@@ -857,7 +863,8 @@ monitor sv params xmpp = do
857 PresenceStatus {} -> do 863 PresenceStatus {} -> do
858 xmppInformClientPresence xmpp k stanza 864 xmppInformClientPresence xmpp k stanza
859 UnrecognizedQuery query -> do 865 UnrecognizedQuery query -> do
860 let reply = iq_service_unavailable (stanzaId stanza) "localhost" query 866 me <- xmppTellMyNameToClient xmpp
867 let reply = iq_service_unavailable (stanzaId stanza) me query
861 sendReply quitVar Error reply replyto 868 sendReply quitVar Error reply replyto
862 _ -> return () 869 _ -> return ()
863 _ -> return () 870 _ -> return ()