// Squawk messenger. // Copyright (C) 2019 Yury Gubich // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #ifndef CORE_TRUSTHANDLER_H #define CORE_TRUSTHANDLER_H #include #include #include #include namespace Core { class Account; class TrustHandler : public QObject, public QXmppTrustStorage { Q_OBJECT public: TrustHandler(Account* account); ~TrustHandler(); signals: void trustLevelsChanged(const QString& jid, const Shared::TrustSummary& summary) const; public: typedef QMultiHash MultySB; typedef QHash HashSM; typedef const QList& CLSR; typedef const QList& CLBAR; typedef const QString& CSR; typedef QXmpp::TrustLevel TL; typedef QHash> HSHBTL; typedef std::map Keys; typedef LMDBAL::Cache KeyCache; virtual QXmppTask resetAll(CSR encryption) override; virtual QXmppTask trustLevel(CSR encryption, CSR keyOwnerJid, const QByteArray& keyId) override; virtual QXmppTask setTrustLevel(CSR encryption, CLSR keyOwnerJids, TL oldTrustLevel, TL newTrustLevel) override; virtual QXmppTask setTrustLevel(CSR encryption, const MultySB& keyIds, TL trustLevel) override; virtual QXmppTask hasKey(CSR encryption, CSR keyOwnerJid, QXmpp::TrustLevels trustLevels) override; virtual QXmppTask keys(CSR encryption, CLSR keyOwnerJids, QXmpp::TrustLevels trustLevels) override; virtual QXmppTask> keys(CSR encryption, QXmpp::TrustLevels trustLevels) override; virtual QXmppTask removeKeys(CSR encryption) override; virtual QXmppTask removeKeys(CSR encryption, CSR keyOwnerJid) override; virtual QXmppTask removeKeys(CSR encryption, CLBAR keyIds) override; virtual QXmppTask addKeys(CSR encryption, CSR keyOwnerJid, CLBAR keyIds, TL trustLevel) override; virtual QXmppTask ownKey(CSR encryption) override; virtual QXmppTask resetOwnKey(CSR encryption) override; virtual QXmppTask setOwnKey(CSR encryption, const QByteArray& keyId) override; virtual QXmppTask securityPolicy(CSR encryption) override; virtual QXmppTask resetSecurityPolicy(CSR encryption) override; virtual QXmppTask setSecurityPolicy(const QString& encryption, QXmpp::TrustSecurityPolicy securityPolicy) override; static TL convert(Shared::TrustLevel level); static Shared::TrustLevel convert(TL level); Keys getKeys(Shared::EncryptionProtocol protocol, const QString& jid) const; Shared::TrustSummary getSummary(const QString& jid) const; private: KeyCache* createNewCache(const QString& encryption); KeyCache* getCache(const QString& encryption); private: Account* acc; LMDBAL::Base db; QFile protocols; LMDBAL::Cache* securityPolicies; LMDBAL::Cache* ownKeys; std::map keysByProtocol; }; } #endif // CORE_TRUSTHANDLER_H