diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2022-07-26 22:07:20 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2022-07-27 21:59:09 +0200 |
commit | 384961428e3b47f8af803e2c7520d5ca69cc4926 (patch) | |
tree | e312935080a586bd9f37a630a5a569b669783f5b /src/main.cpp | |
parent | 92bc3e9a534f2960d584b5e6698c7122a9ee2f87 (diff) |
Pairing failure reason
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 84dfe2a..cb9002e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,18 +128,28 @@ void createIdentity(const vector<string> & args) } } -void printAttachResult(string prefix, Peer peer, future<bool> && success) +void printPairingResult(string prefix, Peer peer, future<PairingServiceBase::Outcome> && future) { + auto outcome = future.get(); ostringstream ss; ss << prefix << - (success.get() ? "-done " : "-failed ") << + (outcome == PairingServiceBase::Outcome::Success ? "-done " : "-failed ") << getPeer(peer).id; + switch (outcome) + { + case PairingServiceBase::Outcome::Success: break; + case PairingServiceBase::Outcome::PeerRejected: ss << " rejected"; break; + case PairingServiceBase::Outcome::UserRejected: ss << " user"; break; + case PairingServiceBase::Outcome::UnexpectedMessage: ss << " unexpected"; break; + case PairingServiceBase::Outcome::NonceMismatch: ss << " nonce"; break; + case PairingServiceBase::Outcome::Stale: ss << " stale"; break; + } printLine(ss.str()); } -future<bool> confirmPairing(string prefix, const Peer & peer, string confirm, future<bool> && success) +future<bool> confirmPairing(string prefix, const Peer & peer, string confirm, future<PairingServiceBase::Outcome> && outcome) { - thread(printAttachResult, prefix, peer, move(success)).detach(); + thread(printPairingResult, prefix, peer, move(outcome)).detach(); promise<bool> promise; auto input = promise.get_future(); |