diff options
-rw-r--r-- | ToxManager.hs | 2 | ||||
-rw-r--r-- | ToxToXMPP.hs | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/ToxManager.hs b/ToxManager.hs index 1e9c618d..460b2fe5 100644 --- a/ToxManager.hs +++ b/ToxManager.hs | |||
@@ -111,8 +111,8 @@ toxman announcer toxbkts tox presence = ToxManager | |||
111 | -- Stop the recurring search for that contact | 111 | -- Stop the recurring search for that contact |
112 | -- | 112 | -- |
113 | -- Stop recurring announce. | 113 | -- Stop recurring announce. |
114 | akey <- packAnnounceKey announcer ("toxid:" ++ show pubid) | ||
114 | fmap Just $ forM toxbkts $ \(nm,bkts) -> do | 115 | fmap Just $ forM toxbkts $ \(nm,bkts) -> do |
115 | akey <- packAnnounceKey announcer (nm ++ "id:" ++ show pubid) | ||
116 | return (akey,bkts) | 116 | return (akey,bkts) |
117 | else return Nothing | 117 | else return Nothing |
118 | forM_ bStopped $ \kbkts -> do | 118 | forM_ bStopped $ \kbkts -> do |
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 () | |||
111 | dispatch tx (SessionEstablished theirKey) = stopConnecting tx theirKey | 111 | dispatch tx (SessionEstablished theirKey) = stopConnecting tx theirKey |
112 | dispatch tx (SessionTerminated theirKey) = startConnecting tx theirKey | 112 | dispatch tx (SessionTerminated theirKey) = startConnecting tx theirKey |
113 | dispatch tx (AddrChange theirkey saddr) = return () -- todo | 113 | dispatch tx (AddrChange theirkey saddr) = return () -- todo |
114 | dispatch tx (PolicyChange theirkey policy ) = return () -- todo | 114 | dispatch tx (PolicyChange theirkey TryingToConnect ) = startConnecting tx theirkey |
115 | dispatch tx (PolicyChange theirkey policy ) = stopConnecting tx theirkey | ||
115 | dispatch tx (OnionRouted theirkey (OnionDHTPublicKey pkey)) = return () -- todo | 116 | dispatch tx (OnionRouted theirkey (OnionDHTPublicKey pkey)) = return () -- todo |
116 | dispatch tx (OnionRouted theirkey (OnionFriendRequest fr) ) = do | 117 | dispatch 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 | ||
199 | stopConnecting :: ToxToXMPP -> PublicKey -> IO () | 200 | stopConnecting :: ToxToXMPP -> PublicKey -> IO () |
200 | stopConnecting ToxToXMPP{txAnnouncer=announcer,txAccount=acnt} them = do | 201 | stopConnecting 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 | |||
207 | forkAccountWatcher acc tox st announcer = forkIO $ do | 209 | forkAccountWatcher 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 | |||
233 | toxQSearch :: Tox.Tox -> Search Tox.NodeId (IP, PortNumber) Nonce32 Tox.NodeInfo Tox.Rendezvous | 240 | toxQSearch :: Tox.Tox -> Search Tox.NodeId (IP, PortNumber) Nonce32 Tox.NodeInfo Tox.Rendezvous |
234 | toxQSearch tox = Tox.toxidSearch (Tox.onionTimeout tox) (Tox.toxCryptoKeys tox) (Tox.toxOnion tox) | 241 | toxQSearch tox = Tox.toxidSearch (Tox.onionTimeout tox) (Tox.toxCryptoKeys tox) (Tox.toxOnion tox) |
235 | 242 | ||