diff options
Diffstat (limited to 'src/Network/Tox/AggregateSession.hs')
-rw-r--r-- | src/Network/Tox/AggregateSession.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Network/Tox/AggregateSession.hs b/src/Network/Tox/AggregateSession.hs index d4497c48..26e7153a 100644 --- a/src/Network/Tox/AggregateSession.hs +++ b/src/Network/Tox/AggregateSession.hs | |||
@@ -9,6 +9,7 @@ module Network.Tox.AggregateSession | |||
9 | , newAggregateSession | 9 | , newAggregateSession |
10 | , aggregateStatus | 10 | , aggregateStatus |
11 | , checkCompatible | 11 | , checkCompatible |
12 | , compatibleKeys | ||
12 | , AddResult(..) | 13 | , AddResult(..) |
13 | , addSession | 14 | , addSession |
14 | , DelResult(..) | 15 | , DelResult(..) |
@@ -321,3 +322,16 @@ checkCompatible me them c = do | |||
321 | con:_ -> Just $ ncTheirPublicKey (singleSession con) == them | 322 | con:_ -> Just $ ncTheirPublicKey (singleSession con) == them |
322 | && (ncMyPublicKey $ singleSession con) == me | 323 | && (ncMyPublicKey $ singleSession con) == me |
323 | [] -> Nothing | 324 | [] -> Nothing |
325 | |||
326 | -- | Returns the local and remote keys that are compatible with this aggregate. | ||
327 | -- If 'Nothing' Is returned, then either no key is compatible ('closeAll' was | ||
328 | -- called) or all keys are compatible because no sessions have been associated. | ||
329 | compatibleKeys :: AggregateSession -> STM (Maybe (PublicKey,PublicKey)) | ||
330 | compatibleKeys c = do | ||
331 | isclosed <- isClosedTMChan (contactChannel c) | ||
332 | imap <- readTVar (contactSession c) | ||
333 | return $ case IntMap.elems imap of | ||
334 | _ | isclosed -> Nothing -- none. | ||
335 | con:_ -> Just ( ncMyPublicKey $ singleSession con | ||
336 | , ncTheirPublicKey (singleSession con)) | ||
337 | [] -> Nothing -- any. | ||