// 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 namespace Core { class Account; class TrustHandler : public QXmppTrustStorage { public: TrustHandler(Account* account); ~TrustHandler(); 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 DataBase::Cache KeyCache; virtual QFuture resetAll(CSR encryption); virtual QFuture trustLevel(CSR encryption, CSR keyOwnerJid, const QByteArray& keyId); virtual QFuture setTrustLevel(CSR encryption, CLSR keyOwnerJids, TL oldTrustLevel, TL newTrustLevel); virtual QFuture setTrustLevel(CSR encryption, const MultySB& keyIds, TL trustLevel); virtual QFuture hasKey(CSR encryption, CSR keyOwnerJid, QXmpp::TrustLevels trustLevels); virtual QFuture keys(CSR encryption, CLSR keyOwnerJids, QXmpp::TrustLevels trustLevels); virtual QFuture> keys(CSR encryption, QXmpp::TrustLevels trustLevels); virtual QFuture removeKeys(CSR encryption); virtual QFuture removeKeys(CSR encryption, CSR keyOwnerJid); virtual QFuture removeKeys(CSR encryption, CLBAR keyIds); virtual QFuture addKeys(CSR encryption, CSR keyOwnerJid, CLBAR keyIds, TL trustLevel); virtual QFuture ownKey(CSR encryption); virtual QFuture resetOwnKey(CSR encryption); virtual QFuture setOwnKey(CSR encryption, const QByteArray& keyId); virtual QFuture securityPolicy(CSR encryption); virtual QFuture resetSecurityPolicy(CSR encryption); virtual QFuture setSecurityPolicy(CSR encryption, QXmpp::TrustSecurityPolicy securityPolicy); static TL convert(Shared::TrustLevel level); static Shared::TrustLevel convert(TL level); private: static QFuture emptyVoidFuture(); KeyCache* createNewCache(const QString& encryption); KeyCache* getCache(const QString& encryption); private: Account* acc; DataBase db; QFile protocols; DataBase::Cache* securityPolicies; DataBase::Cache* ownKeys; std::map keysByProtocol; }; } #endif // CORE_TRUSTHANDLER_H