aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/keyverificationsession.cpp15
-rw-r--r--lib/keyverificationsession.h7
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/keyverificationsession.cpp b/lib/keyverificationsession.cpp
index 44a085fe..24fc08e1 100644
--- a/lib/keyverificationsession.cpp
+++ b/lib/keyverificationsession.cpp
@@ -154,7 +154,7 @@ EmojiEntry emojiForCode(int code, const QString& language)
void KeyVerificationSession::handleKey(const KeyVerificationKeyEvent& event)
{
- if (state() != WAITINGFORKEY && state() != WAITINGFORVERIFICATION) {
+ if (state() != WAITINGFORKEY && state() != ACCEPTED) {
cancelVerification(UNEXPECTED_MESSAGE);
return;
}
@@ -176,7 +176,6 @@ void KeyVerificationSession::handleKey(const KeyVerificationKeyEvent& event)
} else {
sendKey();
}
- setState(WAITINGFORVERIFICATION);
std::string key(olm_sas_pubkey_length(m_sas), '\0');
olm_sas_get_pubkey(m_sas, key.data(), key.size());
@@ -214,6 +213,7 @@ void KeyVerificationSession::handleKey(const KeyVerificationKeyEvent& event)
emit sasEmojisChanged();
emit keyReceived();
+ setState(WAITINGFORVERIFICATION);
}
QString KeyVerificationSession::calculateMac(const QString& input,
@@ -314,6 +314,10 @@ void KeyVerificationSession::sendStartSas()
void KeyVerificationSession::handleReady(const KeyVerificationReadyEvent& event)
{
+ if (state() == ACCEPTED) {
+ // It's possible to receive ready and start in the same sync, in which case start might be handled before ready.
+ return;
+ }
if (state() != WAITINGFORREADY) {
cancelVerification(UNEXPECTED_MESSAGE);
return;
@@ -334,7 +338,7 @@ void KeyVerificationSession::handleReady(const KeyVerificationReadyEvent& event)
void KeyVerificationSession::handleStart(const KeyVerificationStartEvent& event)
{
- if (state() != READY) {
+ if (state() != READY && state() != WAITINGFORREADY) {
cancelVerification(UNEXPECTED_MESSAGE);
return;
}
@@ -510,3 +514,8 @@ KeyVerificationSession::Error KeyVerificationSession::stringToError(const QStrin
}
return NONE;
}
+
+QString KeyVerificationSession::remoteDeviceId() const
+{
+ return m_remoteDeviceId;
+}
diff --git a/lib/keyverificationsession.h b/lib/keyverificationsession.h
index aa0295cb..31f63453 100644
--- a/lib/keyverificationsession.h
+++ b/lib/keyverificationsession.h
@@ -19,6 +19,11 @@ struct QUOTIENT_API EmojiEntry {
Q_GADGET
Q_PROPERTY(QString emoji MEMBER emoji CONSTANT)
Q_PROPERTY(QString description MEMBER description CONSTANT)
+
+public:
+ bool operator==(const EmojiEntry& rhs) const {
+ return emoji == rhs.emoji && description == rhs.description;
+ }
};
/** A key verification session. Listen for incoming sessions by connecting to Connection::newKeyVerificationSession.
@@ -93,6 +98,8 @@ public:
Error error() const;
+ QString remoteDeviceId() const;
+
public Q_SLOTS:
void sendRequest();
void sendReady();