aboutsummaryrefslogtreecommitdiff
path: root/lib/keyverificationsession.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-08-25 19:58:48 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-08-25 19:59:29 +0200
commit6404b8cd4d57468b810538da04f8017fb13ccc37 (patch)
treea7ea65d971b24791368d9eae5b1db92551ef0ea8 /lib/keyverificationsession.h
parent376da43a29f3ebad807da2761e7a0c0b105587ec (diff)
downloadlibquotient-6404b8cd4d57468b810538da04f8017fb13ccc37.tar.gz
libquotient-6404b8cd4d57468b810538da04f8017fb13ccc37.zip
Refactor the code handling emoji
- Use a dedicated structure, EmojiEntry, instead of QVariantMap (it's Q_GADGET, should be readable from QML just fine) - While we're at it, QVector is better than QList in Qt 5.15 - Remove language from the session state - it's used in a single method - Modernise handleKey() code
Diffstat (limited to 'lib/keyverificationsession.h')
-rw-r--r--lib/keyverificationsession.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/keyverificationsession.h b/lib/keyverificationsession.h
index 73c9384e..aa0295cb 100644
--- a/lib/keyverificationsession.h
+++ b/lib/keyverificationsession.h
@@ -12,6 +12,15 @@ struct OlmSAS;
namespace Quotient {
class Connection;
+struct QUOTIENT_API EmojiEntry {
+ QString emoji;
+ QString description;
+
+ Q_GADGET
+ Q_PROPERTY(QString emoji MEMBER emoji CONSTANT)
+ Q_PROPERTY(QString description MEMBER description CONSTANT)
+};
+
/** A key verification session. Listen for incoming sessions by connecting to Connection::newKeyVerificationSession.
Start a new session using Connection::startKeyVerificationSession.
The object is delete after finished is emitted.
@@ -67,7 +76,7 @@ public:
Q_ENUM(Error)
Q_PROPERTY(QString remoteDeviceId MEMBER m_remoteDeviceId CONSTANT)
- Q_PROPERTY(QList<QVariantMap> sasEmojis READ sasEmojis NOTIFY sasEmojisChanged)
+ Q_PROPERTY(QVector<EmojiEntry> sasEmojis READ sasEmojis NOTIFY sasEmojisChanged)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(Error error READ error NOTIFY errorChanged)
@@ -79,7 +88,7 @@ public:
~KeyVerificationSession() override;
Q_DISABLE_COPY_MOVE(KeyVerificationSession)
- QList<QVariantMap> sasEmojis() const;
+ QVector<EmojiEntry> sasEmojis() const;
State state() const;
Error error() const;
@@ -107,13 +116,12 @@ private:
const QString m_transactionId;
Connection* m_connection;
OlmSAS* m_sas = nullptr;
- QList<QVariantMap> m_sasEmojis;
+ QVector<EmojiEntry> m_sasEmojis;
bool startSentByUs = false;
State m_state = INCOMING;
Error m_error = NONE;
QString m_startEvent;
QString m_commitment;
- QString m_language;
bool macReceived = false;
bool m_encrypted;
QStringList m_remoteSupportedMethods;
@@ -133,8 +141,7 @@ private:
QByteArray macInfo(bool verifying, const QString& key = "KEY_IDS"_ls);
QString calculateMac(const QString& input, bool verifying, const QString& keyId= "KEY_IDS"_ls);
-
- std::pair<QString, QString> emojiForCode(int code);
};
} // namespace Quotient
+Q_DECLARE_METATYPE(Quotient::EmojiEntry)