File indexing completed on 2024-09-08 12:51:42
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "libruqolacore_export.h" 0010 0011 #include <QDebug> 0012 #include <QJsonArray> 0013 0014 struct CryptoSettings { 0015 QString mCrypt; 0016 [[nodiscard]] bool operator==(const CryptoSettings &other) const; 0017 }; 0018 0019 class LIBRUQOLACORE_EXPORT Otr 0020 { 0021 Q_GADGET 0022 public: 0023 Otr(); 0024 ~Otr(); 0025 0026 enum OtrType { 0027 Unknown = 0, 0028 End, 0029 Handshake, 0030 Deny, 0031 AcknowLedge, 0032 }; 0033 Q_ENUM(OtrType) 0034 0035 void parseOtr(const QJsonArray &contents); 0036 0037 [[nodiscard]] OtrType type() const; 0038 0039 [[nodiscard]] QString roomId() const; 0040 0041 [[nodiscard]] QString userId() const; 0042 0043 [[nodiscard]] bool isValid() const; 0044 0045 [[nodiscard]] CryptoSettings crypto() const; 0046 0047 [[nodiscard]] bool operator==(const Otr &other) const; 0048 0049 private: 0050 LIBRUQOLACORE_NO_EXPORT void parseCryptoSettings(const QString &publicKey); 0051 LIBRUQOLACORE_NO_EXPORT void extractRoomUser(const QJsonObject &obj); 0052 // TODO add crypto support 0053 QString mRoomId; 0054 QString mUserId; 0055 OtrType mType = OtrType::Unknown; 0056 CryptoSettings mCrypto; 0057 }; 0058 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0059 Q_DECLARE_METATYPE(Otr) 0060 #endif 0061 Q_DECLARE_TYPEINFO(Otr, Q_MOVABLE_TYPE); 0062 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const Otr &t); 0063 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const CryptoSettings &t);