summaryrefslogtreecommitdiff
path: root/src/Contact.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-12-19 22:59:01 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-12-19 23:18:05 +0100
commit8416b3e959fd0f6ade7c2b61a6caea681ee03e15 (patch)
tree5a32fadd89efa165dd71c0f0f1ee23fdf06bab03 /src/Contact.hs
parent070122683d0c9a11f9221ede93df0590bc28494d (diff)
Pairing: use service attributes for hooks
Diffstat (limited to 'src/Contact.hs')
-rw-r--r--src/Contact.hs34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/Contact.hs b/src/Contact.hs
index 01bd49d..9accc4d 100644
--- a/src/Contact.hs
+++ b/src/Contact.hs
@@ -86,27 +86,29 @@ instance Storable ContactAccepted where
instance PairingResult ContactAccepted where
pairingServiceID _ = mkServiceID "d9c37368-0da1-4280-93e9-d9bd9a198084"
- pairingHookRequest = do
- peer <- asks $ svcPeerIdentity
- svcPrint $ "Contact pairing from " ++ T.unpack (displayIdentity peer) ++ " initiated"
+ defaultPairingAttributes _ = PairingAttributes
+ { pairingHookRequest = do
+ peer <- asks $ svcPeerIdentity
+ svcPrint $ "Contact pairing from " ++ T.unpack (displayIdentity peer) ++ " initiated"
- pairingHookResponse confirm = do
- peer <- asks $ svcPeerIdentity
- svcPrint $ "Confirm contact " ++ T.unpack (displayIdentity $ finalOwner peer) ++ ": " ++ confirm
+ , pairingHookResponse = \confirm -> do
+ peer <- asks $ svcPeerIdentity
+ svcPrint $ "Confirm contact " ++ T.unpack (displayIdentity $ finalOwner peer) ++ ": " ++ confirm
- pairingHookRequestNonce confirm = do
- peer <- asks $ svcPeerIdentity
- svcPrint $ "Contact request from " ++ T.unpack (displayIdentity $ finalOwner peer) ++ ": " ++ confirm
+ , pairingHookRequestNonce = \confirm -> do
+ peer <- asks $ svcPeerIdentity
+ svcPrint $ "Contact request from " ++ T.unpack (displayIdentity $ finalOwner peer) ++ ": " ++ confirm
- pairingHookRequestNonceFailed = do
- peer <- asks $ svcPeerIdentity
- svcPrint $ "Failed contact request from " ++ T.unpack (displayIdentity peer)
+ , pairingHookRequestNonceFailed = do
+ peer <- asks $ svcPeerIdentity
+ svcPrint $ "Failed contact request from " ++ T.unpack (displayIdentity peer)
- pairingHookConfirm ContactAccepted = do
- svcPrint $ "Contact confirmed by peer"
- return $ Just ContactAccepted
+ , pairingHookConfirm = \ContactAccepted -> do
+ svcPrint $ "Contact confirmed by peer"
+ return $ Just ContactAccepted
- pairingHookAccept ContactAccepted = return ()
+ , pairingHookAccept = \ContactAccepted -> return ()
+ }
contactRequest :: (MonadIO m, MonadError String m) => (String -> IO ()) -> Peer -> m ()
contactRequest _ = pairingRequest @ContactAccepted Proxy