2022-09-03 11:39:42 +00:00
|
|
|
// Squawk messenger.
|
|
|
|
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
//
|
|
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef CORE_OMEMOHANDLER_H
|
|
|
|
#define CORE_OMEMOHANDLER_H
|
|
|
|
|
|
|
|
#include <QXmppOmemoStorage.h>
|
2022-12-14 23:08:08 +00:00
|
|
|
#include <cache.h>
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QXmppOmemoStorage::OwnDevice);
|
2022-09-03 11:39:42 +00:00
|
|
|
|
|
|
|
namespace Core {
|
2022-12-14 23:08:08 +00:00
|
|
|
class Account;
|
2022-09-03 11:39:42 +00:00
|
|
|
|
|
|
|
class OmemoHandler : public QXmppOmemoStorage
|
|
|
|
{
|
|
|
|
public:
|
2022-12-14 23:08:08 +00:00
|
|
|
OmemoHandler(Account* account);
|
2022-09-03 11:39:42 +00:00
|
|
|
~OmemoHandler() override;
|
|
|
|
|
|
|
|
QFuture<OmemoData> allData() override;
|
|
|
|
|
|
|
|
QFuture<void> setOwnDevice(const std::optional<OwnDevice> &device) override;
|
|
|
|
|
|
|
|
QFuture<void> addSignedPreKeyPair(uint32_t keyId, const SignedPreKeyPair &keyPair) override;
|
|
|
|
QFuture<void> removeSignedPreKeyPair(uint32_t keyId) override;
|
|
|
|
|
|
|
|
QFuture<void> addPreKeyPairs(const QHash<uint32_t, QByteArray> &keyPairs) override;
|
|
|
|
QFuture<void> removePreKeyPair(uint32_t keyId) override;
|
|
|
|
|
|
|
|
QFuture<void> addDevice(const QString &jid, uint32_t deviceId, const Device &device) override;
|
|
|
|
QFuture<void> removeDevice(const QString &jid, uint32_t deviceId) override;
|
|
|
|
QFuture<void> removeDevices(const QString &jid) override;
|
|
|
|
|
|
|
|
QFuture<void> resetAll() override;
|
|
|
|
|
|
|
|
private:
|
2022-12-14 23:08:08 +00:00
|
|
|
static QFuture<void> emptyVoidFuture();
|
2022-09-03 11:39:42 +00:00
|
|
|
|
2022-12-14 23:08:08 +00:00
|
|
|
private:
|
|
|
|
Account* acc;
|
|
|
|
std::optional<OwnDevice> ownDevice;
|
|
|
|
DataBase db;
|
|
|
|
DataBase::Cache<QString, QVariant>* meta;
|
|
|
|
DataBase::Cache<QString, QHash<uint32_t, Device>>* devices;
|
|
|
|
DataBase::Cache<uint32_t, QByteArray>* preKeyPairs;
|
|
|
|
DataBase::Cache<uint32_t, QXmppOmemoStorage::SignedPreKeyPair>* signedPreKeyPairs;
|
2022-09-03 11:39:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2022-12-14 23:08:08 +00:00
|
|
|
|
|
|
|
QDataStream& operator << (QDataStream &out, const QXmppOmemoStorage::Device& device);
|
|
|
|
QDataStream& operator >> (QDataStream &out, QXmppOmemoStorage::Device device);
|
|
|
|
|
|
|
|
QDataStream& operator << (QDataStream &out, const QXmppOmemoStorage::SignedPreKeyPair& device);
|
|
|
|
QDataStream& operator >> (QDataStream &out, QXmppOmemoStorage::SignedPreKeyPair device);
|
|
|
|
|
2022-09-03 11:39:42 +00:00
|
|
|
#endif // CORE_OMEMOHANDLER_H
|