summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
Diffstat (limited to 'Presence')
-rw-r--r--Presence/Presence.hs19
1 files changed, 10 insertions, 9 deletions
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)
40 40
41import ControlMaybe 41import ControlMaybe
42import LockedChan (LockedChan) 42import LockedChan (LockedChan)
43import Text.Read (readMaybe)
43import TraversableT 44import TraversableT
44import UTmp (ProcessID,users) 45import UTmp (ProcessID,users)
45import LocalPeerCred 46import LocalPeerCred
@@ -49,7 +50,7 @@ import ConsoleWriter
49import ClientState 50import ClientState
50import Util 51import Util
51import qualified Connection 52import qualified Connection
52import Network.Tox.NodeId (key2id,parseNoSpamId,nospam64,NoSpamId(..)) 53import Network.Tox.NodeId (key2id,parseNoSpamId,nospam64,NoSpamId(..),ToxProgress,ToxContact(..))
53import Crypto.Tox (decodeSecret) 54import Crypto.Tox (decodeSecret)
54import DPut 55import DPut
55 56
@@ -79,12 +80,7 @@ data ToxManager k = ToxManager
79 { activateAccount :: k -> Text -> SecretKey -> IO () 80 { activateAccount :: k -> Text -> SecretKey -> IO ()
80 -- | Take the given ToxID offline (assuming no other /k/ has a claim). 81 -- | Take the given ToxID offline (assuming no other /k/ has a claim).
81 , deactivateAccount :: k -> Text -> IO () 82 , deactivateAccount :: k -> Text -> IO ()
82 -- | Try to connect to the remote peer (or not). 83 , toxConnections :: Connection.Manager ToxProgress ToxContact
83 --
84 -- The arguments are our public key (in hostname format) followed by
85 -- their public key (in hostname format) and the Policy to set for this
86 -- link.
87 , setToxConnectionPolicy :: Text -> Text -> Connection.Policy -> IO ()
88 -- | Given a remote Tox key, return the address of a connected peer. 84 -- | Given a remote Tox key, return the address of a connected peer.
89 -- 85 --
90 -- The arguments are our public key (in base64 format) followed by 86 -- The arguments are our public key (in base64 format) followed by
@@ -354,7 +350,10 @@ rosterGetStuff what state k = forClient state k (return [])
354 isTox 350 isTox
355 toxman <- toxManager state 351 toxman <- toxManager state
356 (them, ".tox") <- Just $ Text.splitAt 43 host 352 (them, ".tox") <- Just $ Text.splitAt 43 host
357 Just $ setToxConnectionPolicy toxman (clientProfile client) host 353 meid <- readMaybe $ Text.unpack $ Text.take 43 (clientProfile client)
354 themid <- readMaybe $ Text.unpack them
355 return $ Connection.setPolicy (toxConnections toxman)
356 (ToxContact meid themid)
358 policySetter Connection.TryingToConnect 357 policySetter Connection.TryingToConnect
359 atomically $ putTMVar svVar (sv,conns) 358 atomically $ putTMVar svVar (sv,conns)
360 return $ fromMaybe jids0 $ do isTox 359 return $ fromMaybe jids0 $ do isTox
@@ -1104,7 +1103,9 @@ clientSubscriptionRequest state fail k stanza chan = do
1104 (connChan con) 1103 (connChan con)
1105 let policySetter = fromMaybe (Connection.setPolicy conns h) $ do 1104 let policySetter = fromMaybe (Connection.setPolicy conns h) $ do
1106 (toxman,_,_) <- weAreTox state client h 1105 (toxman,_,_) <- weAreTox state client h
1107 Just $ setToxConnectionPolicy toxman (clientProfile client) h 1106 meid <- readMaybe $ Text.unpack $ Text.take 43 (clientProfile client)
1107 themid <- readMaybe $ Text.unpack h
1108 Just $ Connection.setPolicy (toxConnections toxman) (ToxContact meid themid)
1108 -- Add peer if we are not already associated ... 1109 -- Add peer if we are not already associated ...
1109 policySetter Connection.TryingToConnect 1110 policySetter Connection.TryingToConnect
1110 atomically $ putTMVar svVar (sv,conns) 1111 atomically $ putTMVar svVar (sv,conns)