diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Tox.hs | 1 | ||||
-rw-r--r-- | src/Network/Tox/ContactInfo.hs | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 5a4c02ea..52dba0f5 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -351,6 +351,7 @@ netCryptoWithBackoff millisecs tox myseckey theirpubkey = do | |||
351 | hPutStrLn stderr "Unable to establish session..." | 351 | hPutStrLn stderr "Unable to establish session..." |
352 | return [] | 352 | return [] |
353 | 353 | ||
354 | -- | Create a DHTPublicKey packet to send to a remote contact. | ||
354 | getContactInfo :: Tox -> IO DHT.DHTPublicKey | 355 | getContactInfo :: Tox -> IO DHT.DHTPublicKey |
355 | getContactInfo Tox{toxCryptoKeys,toxRouting} = join $ atomically $ do | 356 | getContactInfo Tox{toxCryptoKeys,toxRouting} = join $ atomically $ do |
356 | r4 <- readTVar $ DHT.routing4 toxRouting | 357 | r4 <- readTVar $ DHT.routing4 toxRouting |
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 | |||
34 | data ContactEvent = OnionRouted { contact :: PublicKey, onionRouted :: OnionData } | 34 | data 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 | ||
38 | data Contact = Contact | 40 | data 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 | ||
110 | setEstablished :: POSIXTime -> PublicKey -> Account -> STM () | ||
111 | setEstablished now remoteUserKey acc = | ||
112 | writeTChan (eventChan acc) $ SessionEstablished remoteUserKey | ||
113 | |||
114 | setTerminated :: POSIXTime -> PublicKey -> Account -> STM () | ||
115 | setTerminated now remoteUserKey acc = | ||
116 | writeTChan (eventChan acc) $ SessionTerminated remoteUserKey | ||
108 | 117 | ||
109 | 118 | ||
110 | addContactInfo :: ContactInfo -> SecretKey -> STM () | 119 | addContactInfo :: ContactInfo -> SecretKey -> STM () |