summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-11-17 16:24:51 -0500
committerjoe <joe@jerkface.net>2013-11-17 16:24:51 -0500
commitbe449c9e0cd90e4b76a7f02628951cd502fb3118 (patch)
tree46972cd0c42ac25073a2510e3c47d771adc89b95
parentf88cf3960d65ae6ec2c613fd04d5e839b75b5ac9 (diff)
Added RestrictedSocket parameter to ActivityBump
-rw-r--r--Presence/SocketLike.hs2
-rw-r--r--Presence/XMPP.hs18
-rw-r--r--Presence/XMPPTypes.hs2
3 files changed, 11 insertions, 11 deletions
diff --git a/Presence/SocketLike.hs b/Presence/SocketLike.hs
index cf52aca8..9cfb85dc 100644
--- a/Presence/SocketLike.hs
+++ b/Presence/SocketLike.hs
@@ -48,7 +48,7 @@ instance SocketLike NS.Socket where
48 sIsReadable = NS.sIsReadable 48 sIsReadable = NS.sIsReadable
49 sIsWritable = NS.sIsWritable 49 sIsWritable = NS.sIsWritable
50 50
51newtype RestrictedSocket = Restricted NS.Socket deriving SocketLike 51newtype RestrictedSocket = Restricted NS.Socket deriving (SocketLike,Show)
52 52
53restrictSocket :: NS.Socket -> RestrictedSocket 53restrictSocket :: NS.Socket -> RestrictedSocket
54restrictSocket socket = Restricted socket 54restrictSocket socket = Restricted socket
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs
index 84035ea2..7a0bb1a2 100644
--- a/Presence/XMPP.hs
+++ b/Presence/XMPP.hs
@@ -636,9 +636,9 @@ listenForRemotePeers addrfamily session_factory port st = do
636 doServer (addrfamily .*. port .*. session_factory .*. st) handlePeer 636 doServer (addrfamily .*. port .*. session_factory .*. st) handlePeer
637 637
638handlePeer 638handlePeer
639 :: (SocketLike sock, HHead l (XMPPPeerClass session), 639 :: (HHead l (XMPPPeerClass session),
640 JabberPeerSession session) => 640 JabberPeerSession session) =>
641 HCons sock (HCons t1 l) -> Source IO ByteString -> t -> IO () 641 HCons RestrictedSocket (HCons t1 l) -> Source IO ByteString -> t -> IO ()
642handlePeer st src snk = do 642handlePeer st src snk = do
643 let HCons sock (HCons _ st') = st 643 let HCons sock (HCons _ st') = st
644 session_factory = hHead st' 644 session_factory = hHead st'
@@ -646,7 +646,7 @@ handlePeer st src snk = do
646 debugL $ "(P) connected " <++> name 646 debugL $ "(P) connected " <++> name
647 session <- newPeerSession session_factory sock 647 session <- newPeerSession session_factory sock
648 648
649 finally ( src $= parseBytes def $$ fromPeer session ) 649 finally ( src $= parseBytes def $$ fromPeer sock session )
650 $ do 650 $ do
651 debugL $ "(P) disconnected " <++> name 651 debugL $ "(P) disconnected " <++> name
652 closePeerSession session 652 closePeerSession session
@@ -912,8 +912,8 @@ handlePeerIQGet session tag = do
912 req -> unhandledGet req 912 req -> unhandledGet req
913 913
914fromPeer :: (MonadThrow m,MonadIO m, JabberPeerSession session) => 914fromPeer :: (MonadThrow m,MonadIO m, JabberPeerSession session) =>
915 session -> Sink XML.Event m () 915 RestrictedSocket -> session -> Sink XML.Event m ()
916fromPeer session = doNestingXML $ do 916fromPeer sock session = doNestingXML $ do
917 let log = liftIO . debugL . ("(P) " <++>) 917 let log = liftIO . debugL . ("(P) " <++>)
918 withXML $ \begindoc -> do 918 withXML $ \begindoc -> do
919 when (begindoc==EventBeginDocument) $ do 919 when (begindoc==EventBeginDocument) $ do
@@ -927,7 +927,7 @@ fromPeer session = doNestingXML $ do
927 whenJust nextElement $ \stanza -> do 927 whenJust nextElement $ \stanza -> do
928 stanza_lvl <- nesting 928 stanza_lvl <- nesting
929 929
930 liftIO $ sendPeerMessage session ActivityBump -- reset ping timer 930 liftIO $ sendPeerMessage session (ActivityBump sock) -- reset ping timer
931 931
932 let unhandledStanza = do 932 let unhandledStanza = do
933 xs <- gatherElement stanza Seq.empty 933 xs <- gatherElement stanza Seq.empty
@@ -987,7 +987,7 @@ instance CommandCache CachedMessages where
987 updateCache (OutBoundMessage msg) cache = cache -- TODO: cache chat? 987 updateCache (OutBoundMessage msg) cache = cache -- TODO: cache chat?
988 updateCache (Pong _ _ _) cache = cache -- pings are not cached 988 updateCache (Pong _ _ _) cache = cache -- pings are not cached
989 updateCache (Unsupported _ _ _ _) cache = cache -- error messages are not cached 989 updateCache (Unsupported _ _ _ _) cache = cache -- error messages are not cached
990 updateCache ActivityBump cache = cache 990 updateCache (ActivityBump sock) cache = cache
991 991
992instance ThreadChannelCommand OutBoundMessage where 992instance ThreadChannelCommand OutBoundMessage where
993 isQuitCommand Disconnect = True 993 isQuitCommand Disconnect = True
@@ -1143,7 +1143,7 @@ toPeer sock cache chan fail = do
1143 pingref <- liftIO $ do 1143 pingref <- liftIO $ do
1144 ping_timer <- liftIO $ newDelay five_sec 1144 ping_timer <- liftIO $ newDelay five_sec
1145 newTVarIO (ping_timer,0::Int) 1145 newTVarIO (ping_timer,0::Int)
1146 let bump = do 1146 let bump fromsock = do
1147 timer <- atomically $ do 1147 timer <- atomically $ do
1148 (timer,v) <- readTVar pingref 1148 (timer,v) <- readTVar pingref
1149 writeTVar pingref (timer,0) 1149 writeTVar pingref (timer,0)
@@ -1206,7 +1206,7 @@ toPeer sock cache chan fail = do
1206 Pong from to mid -> sendPong from to mid 1206 Pong from to mid -> sendPong from to mid
1207 Unsupported from to mid tag -> sendUnsupported from to mid tag 1207 Unsupported from to mid tag -> sendUnsupported from to mid tag
1208 Disconnect -> return () 1208 Disconnect -> return ()
1209 ActivityBump -> liftIO bump 1209 ActivityBump fromsock -> liftIO (bump fromsock)
1210 when (not . isQuitCommand $ event) loop 1210 when (not . isQuitCommand $ event) loop
1211 either chanEvent sendPing event 1211 either chanEvent sendPing event
1212 return () 1212 return ()
diff --git a/Presence/XMPPTypes.hs b/Presence/XMPPTypes.hs
index f1f511e7..f6ffe66e 100644
--- a/Presence/XMPPTypes.hs
+++ b/Presence/XMPPTypes.hs
@@ -284,7 +284,7 @@ data OutBoundMessage = OutBoundPresence Presence
284 | Pong JID JID (Maybe Content) 284 | Pong JID JID (Maybe Content)
285 | Unsupported JID JID (Maybe Content) XML.Name 285 | Unsupported JID JID (Maybe Content) XML.Name
286 | Disconnect 286 | Disconnect
287 | ActivityBump 287 | ActivityBump RestrictedSocket
288 deriving Prelude.Show 288 deriving Prelude.Show
289 289
290getNamesForPeer :: Peer -> IO [S.ByteString] 290getNamesForPeer :: Peer -> IO [S.ByteString]