diff options
author | joe <joe@jerkface.net> | 2017-11-26 15:14:05 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-11-26 15:14:05 -0500 |
commit | 63954e507c79fa989095348f000e2267fb93cd37 (patch) | |
tree | ca0d03f2a1a332b1f4b59d92a1c44c9ed1a16c99 /src | |
parent | e71e49c604277c66dfe448e2cfc13dbbcac8f6dd (diff) |
Use Data.Set to track which accounts activate for XMPP clients.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Tox/ContactInfo.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Network/Tox/ContactInfo.hs b/src/Network/Tox/ContactInfo.hs index f4c4bf12..0d8a9f8a 100644 --- a/src/Network/Tox/ContactInfo.hs +++ b/src/Network/Tox/ContactInfo.hs | |||
@@ -1,12 +1,16 @@ | |||
1 | {-# LANGUAGE NamedFieldPuns #-} | 1 | {-# LANGUAGE NamedFieldPuns #-} |
2 | module Network.Tox.ContactInfo where | 2 | module Network.Tox.ContactInfo where |
3 | 3 | ||
4 | import ConnectionKey | ||
5 | |||
4 | import Control.Concurrent.STM | 6 | import Control.Concurrent.STM |
5 | import Control.Monad | 7 | import Control.Monad |
6 | import Crypto.PubKey.Curve25519 | 8 | import Crypto.PubKey.Curve25519 |
7 | import qualified Data.HashMap.Strict as HashMap | 9 | import qualified Data.HashMap.Strict as HashMap |
8 | ;import Data.HashMap.Strict (HashMap) | 10 | ;import Data.HashMap.Strict (HashMap) |
9 | import Data.Maybe | 11 | import Data.Maybe |
12 | import qualified Data.Set as Set | ||
13 | ;import Data.Set (Set) | ||
10 | import Network.Tox.DHT.Transport as DHT | 14 | import Network.Tox.DHT.Transport as DHT |
11 | import Network.Tox.NodeId | 15 | import Network.Tox.NodeId |
12 | import Network.Tox.Onion.Transport as Onion | 16 | import Network.Tox.Onion.Transport as Onion |
@@ -15,8 +19,9 @@ import System.IO | |||
15 | newtype ContactInfo = ContactInfo { accounts :: TVar (HashMap NodeId Account) } | 19 | newtype ContactInfo = ContactInfo { accounts :: TVar (HashMap NodeId Account) } |
16 | 20 | ||
17 | data Account = Account | 21 | data Account = Account |
18 | { userSecret :: SecretKey -- local secret key | 22 | { userSecret :: SecretKey -- local secret key |
19 | , contacts :: TVar (HashMap NodeId Contact) -- received contact info | 23 | , contacts :: TVar (HashMap NodeId Contact) -- received contact info |
24 | , clientRefs :: TVar (Set ConnectionKey) | ||
20 | } | 25 | } |
21 | 26 | ||
22 | data Contact = Contact | 27 | data Contact = Contact |
@@ -41,6 +46,7 @@ newContactInfo = atomically $ ContactInfo <$> newTVar HashMap.empty | |||
41 | 46 | ||
42 | newAccount :: SecretKey -> STM Account | 47 | newAccount :: SecretKey -> STM Account |
43 | newAccount sk = Account sk <$> newTVar HashMap.empty | 48 | newAccount sk = Account sk <$> newTVar HashMap.empty |
49 | <*> newTVar Set.empty | ||
44 | 50 | ||
45 | addContactInfo :: ContactInfo -> SecretKey -> STM () | 51 | addContactInfo :: ContactInfo -> SecretKey -> STM () |
46 | addContactInfo (ContactInfo as) sk = do | 52 | addContactInfo (ContactInfo as) sk = do |