From fb3d30fd7fb1e68623b3bffc9f42ecb2adabce66 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Wed, 22 Aug 2018 20:50:23 -0400 Subject: Removed obsolete Connection.Tox. --- Presence/Presence.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'Presence') diff --git a/Presence/Presence.hs b/Presence/Presence.hs index 3dab724a..4f0deb32 100644 --- a/Presence/Presence.hs +++ b/Presence/Presence.hs @@ -40,6 +40,7 @@ import Crypto.PubKey.Curve25519 (SecretKey,toPublic) import ControlMaybe import LockedChan (LockedChan) +import Text.Read (readMaybe) import TraversableT import UTmp (ProcessID,users) import LocalPeerCred @@ -49,7 +50,7 @@ import ConsoleWriter import ClientState import Util import qualified Connection -import Network.Tox.NodeId (key2id,parseNoSpamId,nospam64,NoSpamId(..)) +import Network.Tox.NodeId (key2id,parseNoSpamId,nospam64,NoSpamId(..),ToxProgress,ToxContact(..)) import Crypto.Tox (decodeSecret) import DPut @@ -79,12 +80,7 @@ data ToxManager k = ToxManager { activateAccount :: k -> Text -> SecretKey -> IO () -- | Take the given ToxID offline (assuming no other /k/ has a claim). , deactivateAccount :: k -> Text -> IO () - -- | Try to connect to the remote peer (or not). - -- - -- The arguments are our public key (in hostname format) followed by - -- their public key (in hostname format) and the Policy to set for this - -- link. - , setToxConnectionPolicy :: Text -> Text -> Connection.Policy -> IO () + , toxConnections :: Connection.Manager ToxProgress ToxContact -- | Given a remote Tox key, return the address of a connected peer. -- -- The arguments are our public key (in base64 format) followed by @@ -354,7 +350,10 @@ rosterGetStuff what state k = forClient state k (return []) isTox toxman <- toxManager state (them, ".tox") <- Just $ Text.splitAt 43 host - Just $ setToxConnectionPolicy toxman (clientProfile client) host + meid <- readMaybe $ Text.unpack $ Text.take 43 (clientProfile client) + themid <- readMaybe $ Text.unpack them + return $ Connection.setPolicy (toxConnections toxman) + (ToxContact meid themid) policySetter Connection.TryingToConnect atomically $ putTMVar svVar (sv,conns) return $ fromMaybe jids0 $ do isTox @@ -1104,7 +1103,9 @@ clientSubscriptionRequest state fail k stanza chan = do (connChan con) let policySetter = fromMaybe (Connection.setPolicy conns h) $ do (toxman,_,_) <- weAreTox state client h - Just $ setToxConnectionPolicy toxman (clientProfile client) h + meid <- readMaybe $ Text.unpack $ Text.take 43 (clientProfile client) + themid <- readMaybe $ Text.unpack h + Just $ Connection.setPolicy (toxConnections toxman) (ToxContact meid themid) -- Add peer if we are not already associated ... policySetter Connection.TryingToConnect atomically $ putTMVar svVar (sv,conns) -- cgit v1.2.3