summaryrefslogtreecommitdiff
path: root/src/Network/Tox/ContactInfo.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-18 06:14:11 -0400
committerjoe <joe@jerkface.net>2018-06-18 06:14:11 -0400
commit19364a287f7083fc60beed2d6eae3dd71d27e737 (patch)
treebb784eeb3c8acb25fd8b656142d92aac2dd096ca /src/Network/Tox/ContactInfo.hs
parent2dbb1e710d6d58fc00126d84763ec3597d92437d (diff)
tox: Automatically share dhtkey with roster contacts.
Diffstat (limited to 'src/Network/Tox/ContactInfo.hs')
-rw-r--r--src/Network/Tox/ContactInfo.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Network/Tox/ContactInfo.hs b/src/Network/Tox/ContactInfo.hs
index 47c07237..9f29d587 100644
--- a/src/Network/Tox/ContactInfo.hs
+++ b/src/Network/Tox/ContactInfo.hs
@@ -34,6 +34,8 @@ data Account = Account
34data ContactEvent = OnionRouted { contact :: PublicKey, onionRouted :: OnionData } 34data ContactEvent = OnionRouted { contact :: PublicKey, onionRouted :: OnionData }
35 | PolicyChange { contact :: PublicKey, policyChange :: Policy } 35 | PolicyChange { contact :: PublicKey, policyChange :: Policy }
36 | AddrChange { contact :: PublicKey, addrChange :: SockAddr } 36 | AddrChange { contact :: PublicKey, addrChange :: SockAddr }
37 | SessionEstablished { contact :: PublicKey }
38 | SessionTerminated { contact :: PublicKey }
37 39
38data Contact = Contact 40data Contact = Contact
39 { contactKeyPacket :: TVar (Maybe (POSIXTime,DHT.DHTPublicKey)) 41 { contactKeyPacket :: TVar (Maybe (POSIXTime,DHT.DHTPublicKey))
@@ -105,6 +107,13 @@ setContactAddr now remoteUserKey addr acc = do
105 updateAccount' remoteUserKey acc $ addrUpdate now addr 107 updateAccount' remoteUserKey acc $ addrUpdate now addr
106 writeTChan (eventChan acc) $ AddrChange remoteUserKey addr 108 writeTChan (eventChan acc) $ AddrChange remoteUserKey addr
107 109
110setEstablished :: POSIXTime -> PublicKey -> Account -> STM ()
111setEstablished now remoteUserKey acc =
112 writeTChan (eventChan acc) $ SessionEstablished remoteUserKey
113
114setTerminated :: POSIXTime -> PublicKey -> Account -> STM ()
115setTerminated now remoteUserKey acc =
116 writeTChan (eventChan acc) $ SessionTerminated remoteUserKey
108 117
109 118
110addContactInfo :: ContactInfo -> SecretKey -> STM () 119addContactInfo :: ContactInfo -> SecretKey -> STM ()