summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-11-26 15:14:05 -0500
committerjoe <joe@jerkface.net>2017-11-26 15:14:05 -0500
commit63954e507c79fa989095348f000e2267fb93cd37 (patch)
treeca0d03f2a1a332b1f4b59d92a1c44c9ed1a16c99 /src
parente71e49c604277c66dfe448e2cfc13dbbcac8f6dd (diff)
Use Data.Set to track which accounts activate for XMPP clients.
Diffstat (limited to 'src')
-rw-r--r--src/Network/Tox/ContactInfo.hs10
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 #-}
2module Network.Tox.ContactInfo where 2module Network.Tox.ContactInfo where
3 3
4import ConnectionKey
5
4import Control.Concurrent.STM 6import Control.Concurrent.STM
5import Control.Monad 7import Control.Monad
6import Crypto.PubKey.Curve25519 8import Crypto.PubKey.Curve25519
7import qualified Data.HashMap.Strict as HashMap 9import qualified Data.HashMap.Strict as HashMap
8 ;import Data.HashMap.Strict (HashMap) 10 ;import Data.HashMap.Strict (HashMap)
9import Data.Maybe 11import Data.Maybe
12import qualified Data.Set as Set
13 ;import Data.Set (Set)
10import Network.Tox.DHT.Transport as DHT 14import Network.Tox.DHT.Transport as DHT
11import Network.Tox.NodeId 15import Network.Tox.NodeId
12import Network.Tox.Onion.Transport as Onion 16import Network.Tox.Onion.Transport as Onion
@@ -15,8 +19,9 @@ import System.IO
15newtype ContactInfo = ContactInfo { accounts :: TVar (HashMap NodeId Account) } 19newtype ContactInfo = ContactInfo { accounts :: TVar (HashMap NodeId Account) }
16 20
17data Account = Account 21data 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
22data Contact = Contact 27data Contact = Contact
@@ -41,6 +46,7 @@ newContactInfo = atomically $ ContactInfo <$> newTVar HashMap.empty
41 46
42newAccount :: SecretKey -> STM Account 47newAccount :: SecretKey -> STM Account
43newAccount sk = Account sk <$> newTVar HashMap.empty 48newAccount sk = Account sk <$> newTVar HashMap.empty
49 <*> newTVar Set.empty
44 50
45addContactInfo :: ContactInfo -> SecretKey -> STM () 51addContactInfo :: ContactInfo -> SecretKey -> STM ()
46addContactInfo (ContactInfo as) sk = do 52addContactInfo (ContactInfo as) sk = do