diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/Presence.hs | 19 |
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 | ||
41 | import ControlMaybe | 41 | import ControlMaybe |
42 | import LockedChan (LockedChan) | 42 | import LockedChan (LockedChan) |
43 | import Text.Read (readMaybe) | ||
43 | import TraversableT | 44 | import TraversableT |
44 | import UTmp (ProcessID,users) | 45 | import UTmp (ProcessID,users) |
45 | import LocalPeerCred | 46 | import LocalPeerCred |
@@ -49,7 +50,7 @@ import ConsoleWriter | |||
49 | import ClientState | 50 | import ClientState |
50 | import Util | 51 | import Util |
51 | import qualified Connection | 52 | import qualified Connection |
52 | import Network.Tox.NodeId (key2id,parseNoSpamId,nospam64,NoSpamId(..)) | 53 | import Network.Tox.NodeId (key2id,parseNoSpamId,nospam64,NoSpamId(..),ToxProgress,ToxContact(..)) |
53 | import Crypto.Tox (decodeSecret) | 54 | import Crypto.Tox (decodeSecret) |
54 | import DPut | 55 | import 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) |