summaryrefslogtreecommitdiff
path: root/ToxToXMPP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ToxToXMPP.hs')
-rw-r--r--ToxToXMPP.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/ToxToXMPP.hs b/ToxToXMPP.hs
index ace4e041..c61764ef 100644
--- a/ToxToXMPP.hs
+++ b/ToxToXMPP.hs
@@ -111,7 +111,8 @@ dispatch :: ToxToXMPP -> ContactEvent -> IO ()
111dispatch tx (SessionEstablished theirKey) = stopConnecting tx theirKey 111dispatch tx (SessionEstablished theirKey) = stopConnecting tx theirKey
112dispatch tx (SessionTerminated theirKey) = startConnecting tx theirKey 112dispatch tx (SessionTerminated theirKey) = startConnecting tx theirKey
113dispatch tx (AddrChange theirkey saddr) = return () -- todo 113dispatch tx (AddrChange theirkey saddr) = return () -- todo
114dispatch tx (PolicyChange theirkey policy ) = return () -- todo 114dispatch tx (PolicyChange theirkey TryingToConnect ) = startConnecting tx theirkey
115dispatch tx (PolicyChange theirkey policy ) = stopConnecting tx theirkey
115dispatch tx (OnionRouted theirkey (OnionDHTPublicKey pkey)) = return () -- todo 116dispatch tx (OnionRouted theirkey (OnionDHTPublicKey pkey)) = return () -- todo
116dispatch tx (OnionRouted theirkey (OnionFriendRequest fr) ) = do 117dispatch tx (OnionRouted theirkey (OnionFriendRequest fr) ) = do
117 let ToxToXMPP { txAnnouncer = acr 118 let ToxToXMPP { txAnnouncer = acr
@@ -198,6 +199,7 @@ startConnecting tx them = do
198 199
199stopConnecting :: ToxToXMPP -> PublicKey -> IO () 200stopConnecting :: ToxToXMPP -> PublicKey -> IO ()
200stopConnecting ToxToXMPP{txAnnouncer=announcer,txAccount=acnt} them = do 201stopConnecting ToxToXMPP{txAnnouncer=announcer,txAccount=acnt} them = do
202 hPutStrLn stderr $ "STOP CONNECTING " ++ show (key2id them)
201 let pub = toPublic $ userSecret acnt 203 let pub = toPublic $ userSecret acnt
202 me = key2id pub 204 me = key2id pub
203 akey <- akeyDHTKeyShare announcer me them 205 akey <- akeyDHTKeyShare announcer me them
@@ -207,7 +209,7 @@ forkAccountWatcher :: Account -> Tox -> PresenceState -> Announcer -> IO ThreadI
207forkAccountWatcher acc tox st announcer = forkIO $ do 209forkAccountWatcher acc tox st announcer = forkIO $ do
208 myThreadId >>= flip labelThread ("tox-xmpp:" 210 myThreadId >>= flip labelThread ("tox-xmpp:"
209 ++ show (key2id $ toPublic $ userSecret acc)) 211 ++ show (key2id $ toPublic $ userSecret acc))
210 (chan,contacts) <- atomically $ do 212 (chan,cs) <- atomically $ do
211 chan <- dupTChan $ eventChan acc -- duplicate broadcast channel for reading. 213 chan <- dupTChan $ eventChan acc -- duplicate broadcast channel for reading.
212 contacts <- readTVar (contacts acc) 214 contacts <- readTVar (contacts acc)
213 return (chan,contacts) 215 return (chan,contacts)
@@ -216,7 +218,7 @@ forkAccountWatcher acc tox st announcer = forkIO $ do
216 , txPresence = st 218 , txPresence = st
217 , txTox = tox 219 , txTox = tox
218 } 220 }
219 forM_ (HashMap.toList contacts) $ \(them,c) -> do 221 forM_ (HashMap.toList cs) $ \(them,c) -> do
220 startConnecting0 tx (id2key them) c 222 startConnecting0 tx (id2key them) c
221 223
222 -- Loop endlessly until clientRefs is null. 224 -- Loop endlessly until clientRefs is null.
@@ -230,6 +232,11 @@ forkAccountWatcher acc tox st announcer = forkIO $ do
230 232
231 forM_ mev $ \ev -> dispatch tx ev >> loop 233 forM_ mev $ \ev -> dispatch tx ev >> loop
232 234
235 cs <- atomically $ readTVar (contacts acc)
236 forM_ (HashMap.toList cs) $ \(them,c) -> do
237 stopConnecting tx (id2key them)
238
239
233toxQSearch :: Tox.Tox -> Search Tox.NodeId (IP, PortNumber) Nonce32 Tox.NodeInfo Tox.Rendezvous 240toxQSearch :: Tox.Tox -> Search Tox.NodeId (IP, PortNumber) Nonce32 Tox.NodeInfo Tox.Rendezvous
234toxQSearch tox = Tox.toxidSearch (Tox.onionTimeout tox) (Tox.toxCryptoKeys tox) (Tox.toxOnion tox) 241toxQSearch tox = Tox.toxidSearch (Tox.onionTimeout tox) (Tox.toxCryptoKeys tox) (Tox.toxOnion tox)
235 242