/* * 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 . */ #pragma once #include #include #include #include #include #include #include Q_DECLARE_METATYPE(QXmppOmemoStorage::OwnDevice); Q_DECLARE_METATYPE(QXmppOmemoStorage::Device); namespace Core { class Account; class OmemoHandler : public QObject, public QXmppOmemoStorage { Q_OBJECT public: typedef std::pair SignedPreKeyPair; OmemoHandler(Account* account); ~OmemoHandler() override; virtual QXmppTask allData() override; virtual QXmppTask setOwnDevice(const std::optional &device) override; virtual QXmppTask addSignedPreKeyPair(uint32_t keyId, const QXmppOmemoStorage::SignedPreKeyPair &keyPair) override; virtual QXmppTask removeSignedPreKeyPair(uint32_t keyId) override; virtual QXmppTask addPreKeyPairs(const QHash &keyPairs) override; virtual QXmppTask removePreKeyPair(uint32_t keyId) override; virtual QXmppTask addDevice(const QString &jid, uint32_t deviceId, const Device &device) override; virtual QXmppTask removeDevice(const QString &jid, uint32_t deviceId) override; virtual QXmppTask removeDevices(const QString &jid) override; virtual QXmppTask resetAll() override; bool hasOwnDevice(); void requestBundles(const QString& jid); void requestOwnBundles(); void getDevices(const QString& jid, std::list& out) const; public slots: void onOmemoDeviceAdded(const QString& jid, uint32_t id); private slots: void onBundlesReceived(const QString& jid); void onOwnBundlesReceived(); std::list readKeys(const QString& jid); private: Account* acc; std::optional ownDevice; LMDBAL::Base db; LMDBAL::Cache* meta; LMDBAL::Cache>* devices; LMDBAL::Cache* preKeyPairs; LMDBAL::Cache* signedPreKeyPairs; }; } QDataStream& operator << (QDataStream &out, const QXmppOmemoStorage::Device& device); QDataStream& operator >> (QDataStream &in, QXmppOmemoStorage::Device& device); QDataStream& operator << (QDataStream &out, const QXmppOmemoStorage::OwnDevice& device); QDataStream& operator >> (QDataStream &in, QXmppOmemoStorage::OwnDevice& device);