forked from blue/squawk
keeping up with qxmpp
This commit is contained in:
parent
73d83f55af
commit
3c6b611a41
@ -130,6 +130,7 @@ if (NOT SYSTEM_QXMPP)
|
||||
|
||||
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/base)
|
||||
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/client)
|
||||
target_include_directories(squawk PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/qxmpp/src)
|
||||
|
||||
if (WITH_OMEMO)
|
||||
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/omemo)
|
||||
|
@ -108,23 +108,19 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
||||
client.addExtension(om);
|
||||
|
||||
if (oh->hasOwnDevice()) {
|
||||
QFuture<bool> future = om->load();
|
||||
QXmppTask<bool> future = om->load();
|
||||
loadingOmemo = true;
|
||||
|
||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(this);
|
||||
QObject::connect(watcher, &QFutureWatcherBase::finished, [watcher, this] () {
|
||||
future.then(this, [this] (bool result) {
|
||||
loadingOmemo = false;
|
||||
if (state == Shared::ConnectionState::scheduled) {
|
||||
client.connectToServer(config, presence);
|
||||
}
|
||||
if (watcher->result()) {
|
||||
if (result) {
|
||||
qDebug() << "successfully loaded OMEMO data for account" << getName();
|
||||
} else {
|
||||
qDebug() << "couldn't load OMEMO data for account" << getName();
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -235,20 +231,17 @@ void Core::Account::onClientStateChange(QXmppClient::State st)
|
||||
#ifdef WITH_OMEMO
|
||||
if (!oh->hasOwnDevice()) {
|
||||
qDebug() << "setting up OMEMO data for account" << getName();
|
||||
QFuture<bool> future = om->setUp();
|
||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(this);
|
||||
QObject::connect(watcher, &QFutureWatcherBase::finished, [watcher, this] () {
|
||||
if (watcher->result()) {
|
||||
QXmppTask<bool> future = om->setUp();
|
||||
future.then(this, [this] (bool result) {
|
||||
if (result)
|
||||
qDebug() << "successfully set up OMEMO data for account" << getName();
|
||||
} else {
|
||||
else
|
||||
qDebug() << "couldn't set up OMEMO data for account" << getName();
|
||||
}
|
||||
watcher->deleteLater();
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
|
||||
if (state == Shared::ConnectionState::connected)
|
||||
runDiscoveryService();
|
||||
}
|
||||
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
} else {
|
||||
runDiscoveryService();
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
#define CORE_ADAPTER_FUNCTIONS_H
|
||||
|
||||
#include <QXmppVCardIq.h>
|
||||
#include <QXmppTask.h>
|
||||
#include <QXmppPromise.h>
|
||||
#include <shared/vcard.h>
|
||||
|
||||
namespace Core {
|
||||
@ -26,6 +28,19 @@ namespace Core {
|
||||
void initializeVCard(Shared::VCard& vCard, const QXmppVCardIq& card);
|
||||
void initializeQXmppVCard(QXmppVCardIq& card, const Shared::VCard& vCard);
|
||||
|
||||
template<typename T>
|
||||
QXmppTask<T> makeReadyTask(T &&value) {
|
||||
QXmppPromise<T> promise;
|
||||
promise.finish(std::move(value));
|
||||
return promise.task();
|
||||
}
|
||||
|
||||
inline QXmppTask<void> makeReadyTask() {
|
||||
QXmppPromise<void> promise;
|
||||
promise.finish();
|
||||
return promise.task();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +29,35 @@ Core::MessageHandler::MessageHandler(Core::Account* account):
|
||||
|
||||
void Core::MessageHandler::onMessageReceived(const QXmppMessage& msg)
|
||||
{
|
||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
|
||||
#ifdef WITH_OMEMO
|
||||
switch (msg.encryptionMethod()) {
|
||||
case QXmpp::NoEncryption:
|
||||
break; //just do nothing
|
||||
case QXmpp::UnknownEncryption:
|
||||
qDebug() << "Account" << acc->getName() << "received a message with unknown encryption type";
|
||||
break; //let it go the way it is, there is nothing I can do here
|
||||
case QXmpp::Otr:
|
||||
qDebug() << "Account" << acc->getName() << "received an OTR encrypted message, not supported yet";
|
||||
break; //let it go the way it is, there is nothing I can do yet
|
||||
case QXmpp::LegacyOpenPgp:
|
||||
qDebug() << "Account" << acc->getName() << "received an LegacyOpenPgp encrypted message, not supported yet";
|
||||
break; //let it go the way it is, there is nothing I can do yet
|
||||
case QXmpp::Ox:
|
||||
qDebug() << "Account" << acc->getName() << "received an Ox encrypted message, not supported yet";
|
||||
break; //let it go the way it is, there is nothing I can do yet
|
||||
case QXmpp::Omemo0:
|
||||
qDebug() << "Account" << acc->getName() << "received an Omemo0 encrypted message, not supported yet";
|
||||
break; //let it go the way it is, there is nothing I can do yet
|
||||
case QXmpp::Omemo1:
|
||||
qDebug() << "Account" << acc->getName() << "received an Omemo1 encrypted message, not supported yet";
|
||||
break; //let it go the way it is, there is nothing I can do yet
|
||||
case QXmpp::Omemo2:
|
||||
qDebug() << "Account" << acc->getName() << "received an Omemo2 encrypted message, not supported yet";
|
||||
break; //let it go the way it is, there is nothing I can do yet
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
bool handled = false;
|
||||
switch (msg.type()) {
|
||||
case QXmppMessage::Normal:
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <QDebug>
|
||||
#include "omemohandler.h"
|
||||
#include "core/account.h"
|
||||
#include "core/adapterfunctions.h"
|
||||
|
||||
Core::OmemoHandler::OmemoHandler(Account* account) :
|
||||
QXmppOmemoStorage(),
|
||||
@ -46,13 +47,7 @@ bool Core::OmemoHandler::hasOwnDevice() {
|
||||
return ownDevice.has_value();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::emptyVoidFuture() {
|
||||
QFutureInterface<QXmppOmemoStorage::OmemoData> result(QFutureInterfaceBase::Started);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
}
|
||||
|
||||
QFuture<QXmppOmemoStorage::OmemoData> Core::OmemoHandler::allData() {
|
||||
QXmppTask<QXmppOmemoStorage::OmemoData> Core::OmemoHandler::allData() {
|
||||
OmemoData data;
|
||||
data.ownDevice = ownDevice;
|
||||
|
||||
@ -72,13 +67,10 @@ QFuture<QXmppOmemoStorage::OmemoData> Core::OmemoHandler::allData() {
|
||||
data.devices.insert(pair.first, pair.second);
|
||||
}
|
||||
|
||||
QFutureInterface<QXmppOmemoStorage::OmemoData> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(std::move(data));
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(data));
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::addDevice(const QString& jid, uint32_t deviceId, const QXmppOmemoStorage::Device& device) {
|
||||
QXmppTask<void> Core::OmemoHandler::addDevice(const QString& jid, uint32_t deviceId, const QXmppOmemoStorage::Device& device) {
|
||||
QHash<uint32_t, Device> devs;
|
||||
bool had = true;
|
||||
try {
|
||||
@ -94,23 +86,23 @@ QFuture<void> Core::OmemoHandler::addDevice(const QString& jid, uint32_t deviceI
|
||||
devices->addRecord(jid, devs);
|
||||
}
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::addPreKeyPairs(const QHash<uint32_t, QByteArray>& keyPairs) {
|
||||
QXmppTask<void> Core::OmemoHandler::addPreKeyPairs(const QHash<uint32_t, QByteArray>& keyPairs) {
|
||||
for (QHash<uint32_t, QByteArray>::const_iterator itr = keyPairs.begin(), end = keyPairs.end(); itr != end; ++itr) {
|
||||
preKeyPairs->forceRecord(itr.key(), itr.value());
|
||||
}
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::addSignedPreKeyPair(uint32_t keyId, const QXmppOmemoStorage::SignedPreKeyPair& keyPair) {
|
||||
QXmppTask<void> Core::OmemoHandler::addSignedPreKeyPair(uint32_t keyId, const QXmppOmemoStorage::SignedPreKeyPair& keyPair) {
|
||||
signedPreKeyPairs->forceRecord(keyId, std::make_pair(keyPair.creationDate, keyPair.data));
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::removeDevice(const QString& jid, uint32_t deviceId) {
|
||||
QXmppTask<void> Core::OmemoHandler::removeDevice(const QString& jid, uint32_t deviceId) {
|
||||
QHash<uint32_t, Device> devs = devices->getRecord(jid);
|
||||
devs.remove(deviceId);
|
||||
if (devs.isEmpty()) {
|
||||
@ -118,25 +110,27 @@ QFuture<void> Core::OmemoHandler::removeDevice(const QString& jid, uint32_t devi
|
||||
} else {
|
||||
devices->changeRecord(jid, devs);
|
||||
}
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::removeDevices(const QString& jid) {
|
||||
QXmppTask<void> Core::OmemoHandler::removeDevices(const QString& jid) {
|
||||
devices->removeRecord(jid);
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::removePreKeyPair(uint32_t keyId) {
|
||||
QXmppTask<void> Core::OmemoHandler::removePreKeyPair(uint32_t keyId) {
|
||||
preKeyPairs->removeRecord(keyId);
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::removeSignedPreKeyPair(uint32_t keyId) {
|
||||
signedPreKeyPairs->removeRecord(keyId);
|
||||
return emptyVoidFuture();
|
||||
QXmppTask<void> Core::OmemoHandler::removeSignedPreKeyPair(uint32_t keyId) {
|
||||
try {
|
||||
signedPreKeyPairs->removeRecord(keyId);
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::setOwnDevice(const std::optional<OwnDevice>& device) {
|
||||
QXmppTask<void> Core::OmemoHandler::setOwnDevice(const std::optional<OwnDevice>& device) {
|
||||
bool had = ownDevice.has_value();
|
||||
ownDevice = device;
|
||||
if (ownDevice.has_value()) {
|
||||
@ -150,14 +144,14 @@ QFuture<void> Core::OmemoHandler::setOwnDevice(const std::optional<OwnDevice>& d
|
||||
meta->removeRecord("ownDevice");
|
||||
}
|
||||
}
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> Core::OmemoHandler::resetAll() {
|
||||
QXmppTask<void> Core::OmemoHandler::resetAll() {
|
||||
ownDevice = std::nullopt;
|
||||
db.drop();
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QDataStream & operator >> (QDataStream& in, QXmppOmemoStorage::Device& device) {
|
||||
|
@ -34,27 +34,24 @@ public:
|
||||
OmemoHandler(Account* account);
|
||||
~OmemoHandler() override;
|
||||
|
||||
QFuture<OmemoData> allData() override;
|
||||
QXmppTask<OmemoData> allData() override;
|
||||
|
||||
QFuture<void> setOwnDevice(const std::optional<OwnDevice> &device) override;
|
||||
QXmppTask<void> setOwnDevice(const std::optional<OwnDevice> &device) override;
|
||||
|
||||
QFuture<void> addSignedPreKeyPair(uint32_t keyId, const QXmppOmemoStorage::SignedPreKeyPair &keyPair) override;
|
||||
QFuture<void> removeSignedPreKeyPair(uint32_t keyId) override;
|
||||
QXmppTask<void> addSignedPreKeyPair(uint32_t keyId, const QXmppOmemoStorage::SignedPreKeyPair &keyPair) override;
|
||||
QXmppTask<void> removeSignedPreKeyPair(uint32_t keyId) override;
|
||||
|
||||
QFuture<void> addPreKeyPairs(const QHash<uint32_t, QByteArray> &keyPairs) override;
|
||||
QFuture<void> removePreKeyPair(uint32_t keyId) override;
|
||||
QXmppTask<void> addPreKeyPairs(const QHash<uint32_t, QByteArray> &keyPairs) override;
|
||||
QXmppTask<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;
|
||||
QXmppTask<void> addDevice(const QString &jid, uint32_t deviceId, const Device &device) override;
|
||||
QXmppTask<void> removeDevice(const QString &jid, uint32_t deviceId) override;
|
||||
QXmppTask<void> removeDevices(const QString &jid) override;
|
||||
|
||||
QFuture<void> resetAll() override;
|
||||
QXmppTask<void> resetAll() override;
|
||||
|
||||
bool hasOwnDevice();
|
||||
|
||||
private:
|
||||
static QFuture<void> emptyVoidFuture();
|
||||
|
||||
private:
|
||||
Account* acc;
|
||||
std::optional<OwnDevice> ownDevice;
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "trusthandler.h"
|
||||
#include "core/account.h"
|
||||
#include "core/adapterfunctions.h"
|
||||
|
||||
using namespace Core;
|
||||
|
||||
@ -75,37 +76,25 @@ Core::TrustHandler::KeyCache * Core::TrustHandler::createNewCache(const QString&
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
||||
QFuture<void> Core::TrustHandler::emptyVoidFuture() {
|
||||
QFutureInterface<QXmppOmemoStorage::OmemoData> result(QFutureInterfaceBase::Started);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
}
|
||||
|
||||
|
||||
QFuture<void> Core::TrustHandler::resetAll(const QString& encryption) {
|
||||
QXmppTask<void> Core::TrustHandler::resetAll(const QString& encryption) {
|
||||
securityPolicies->removeRecord(encryption);
|
||||
ownKeys->removeRecord(encryption);
|
||||
getCache(encryption)->drop();
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<QXmpp::TrustLevel> Core::TrustHandler::trustLevel(
|
||||
QXmppTask<QXmpp::TrustLevel> Core::TrustHandler::trustLevel(
|
||||
const QString& encryption,
|
||||
const QString& keyOwnerJid,
|
||||
const QByteArray& keyId)
|
||||
{
|
||||
Keys map = getCache(encryption)->getRecord(keyOwnerJid);
|
||||
Shared::TrustLevel level = map.at(keyId);
|
||||
|
||||
QFutureInterface<QXmpp::TrustLevel> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(convert(level));
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(convert(level)));
|
||||
}
|
||||
|
||||
QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> Core::TrustHandler::setTrustLevel(
|
||||
QXmppTask<QHash<QString, QMultiHash<QString, QByteArray>>> Core::TrustHandler::setTrustLevel(
|
||||
const QString& encryption,
|
||||
const QList<QString>& keyOwnerJids,
|
||||
QXmpp::TrustLevel oldTrustLevel,
|
||||
@ -130,14 +119,10 @@ QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> Core::TrustHandler::set
|
||||
cache->changeRecord(keyOwnerJid, map);
|
||||
}
|
||||
}
|
||||
|
||||
QFutureInterface<QHash<QString, QMultiHash<QString, QByteArray>>> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(modifiedKeys);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(modifiedKeys));
|
||||
}
|
||||
|
||||
QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> Core::TrustHandler::setTrustLevel(
|
||||
QXmppTask<QHash<QString, QMultiHash<QString, QByteArray>>> Core::TrustHandler::setTrustLevel(
|
||||
const QString& encryption,
|
||||
const QMultiHash<QString, QByteArray>& keyIds,
|
||||
QXmpp::TrustLevel trustLevel)
|
||||
@ -160,14 +145,10 @@ QFuture<QHash<QString, QMultiHash<QString, QByteArray>>> Core::TrustHandler::set
|
||||
cache->changeRecord(keyOwnerJid, map);
|
||||
}
|
||||
}
|
||||
|
||||
QFutureInterface<QHash<QString, QMultiHash<QString, QByteArray>>> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(modifiedKeys);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(modifiedKeys));
|
||||
}
|
||||
|
||||
QFuture<bool> TrustHandler::hasKey(const QString& encryption,
|
||||
QXmppTask<bool> TrustHandler::hasKey(const QString& encryption,
|
||||
const QString& keyOwnerJid,
|
||||
QXmpp::TrustLevels trustLevels)
|
||||
{
|
||||
@ -182,14 +163,10 @@ QFuture<bool> TrustHandler::hasKey(const QString& encryption,
|
||||
}
|
||||
}
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
|
||||
QFutureInterface<bool> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(found);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(found));
|
||||
}
|
||||
|
||||
QFuture<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> TrustHandler::keys(
|
||||
QXmppTask<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> TrustHandler::keys(
|
||||
const QString& encryption,
|
||||
const QList<QString>& keyOwnerJids,
|
||||
QXmpp::TrustLevels trustLevels)
|
||||
@ -209,14 +186,10 @@ QFuture<QHash<QString, QHash<QByteArray, QXmpp::TrustLevel>>> TrustHandler::keys
|
||||
}
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
}
|
||||
|
||||
QFutureInterface<HSHBTL> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(res);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(res));
|
||||
}
|
||||
|
||||
QFuture<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> TrustHandler::keys(
|
||||
QXmppTask<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> TrustHandler::keys(
|
||||
const QString& encryption,
|
||||
QXmpp::TrustLevels trustLevels)
|
||||
{
|
||||
@ -231,24 +204,20 @@ QFuture<QHash<QXmpp::TrustLevel, QMultiHash<QString, QByteArray>>> TrustHandler:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QFutureInterface<QHash<TL, MultySB>> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(res);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(res));
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::removeKeys(const QString& encryption) {
|
||||
QXmppTask<void> TrustHandler::removeKeys(const QString& encryption) {
|
||||
getCache(encryption)->drop();
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::removeKeys(const QString& encryption, const QString& keyOwnerJid) {
|
||||
QXmppTask<void> TrustHandler::removeKeys(const QString& encryption, const QString& keyOwnerJid) {
|
||||
getCache(encryption)->removeRecord(keyOwnerJid);
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::removeKeys(const QString& encryption, const QList<QByteArray>& keyIds) {
|
||||
QXmppTask<void> TrustHandler::removeKeys(const QString& encryption, const QList<QByteArray>& keyIds) {
|
||||
std::set<QByteArray> set;
|
||||
for (const QByteArray& keyId : keyIds) {
|
||||
set.insert(keyId);
|
||||
@ -278,10 +247,10 @@ QFuture<void> TrustHandler::removeKeys(const QString& encryption, const QList<QB
|
||||
cache->replaceAll(data);
|
||||
}
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::addKeys(
|
||||
QXmppTask<void> TrustHandler::addKeys(
|
||||
const QString& encryption,
|
||||
const QString& keyOwnerJid,
|
||||
const QList<QByteArray>& keyIds,
|
||||
@ -308,61 +277,53 @@ QFuture<void> TrustHandler::addKeys(
|
||||
cache->addRecord(keyOwnerJid, data);
|
||||
}
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<QByteArray> TrustHandler::ownKey(const QString& encryption) {
|
||||
QXmppTask<QByteArray> TrustHandler::ownKey(const QString& encryption) {
|
||||
QByteArray res;
|
||||
try {
|
||||
res = ownKeys->getRecord(encryption);
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
|
||||
QFutureInterface<QByteArray> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(res);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(res));
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::resetOwnKey(const QString& encryption) {
|
||||
QXmppTask<void> TrustHandler::resetOwnKey(const QString& encryption) {
|
||||
try {
|
||||
ownKeys->removeRecord(encryption);
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::setOwnKey(const QString& encryption, const QByteArray& keyId) {
|
||||
QXmppTask<void> TrustHandler::setOwnKey(const QString& encryption, const QByteArray& keyId) {
|
||||
ownKeys->forceRecord(encryption, keyId);
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<QXmpp::TrustSecurityPolicy> TrustHandler::securityPolicy(const QString& encryption) {
|
||||
QXmppTask<QXmpp::TrustSecurityPolicy> TrustHandler::securityPolicy(const QString& encryption) {
|
||||
QXmpp::TrustSecurityPolicy res;
|
||||
try {
|
||||
res = static_cast<QXmpp::TrustSecurityPolicy>(securityPolicies->getRecord(encryption));
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
|
||||
QFutureInterface<QXmpp::TrustSecurityPolicy> result(QFutureInterfaceBase::Started);
|
||||
result.reportResult(res);
|
||||
result.reportFinished();
|
||||
return result.future();
|
||||
return Core::makeReadyTask(std::move(res));
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::resetSecurityPolicy(const QString& encryption) {
|
||||
QXmppTask<void> TrustHandler::resetSecurityPolicy(const QString& encryption) {
|
||||
try {
|
||||
securityPolicies->removeRecord(encryption);
|
||||
} catch (const DataBase::NotFound& e) {}
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
QFuture<void> TrustHandler::setSecurityPolicy(
|
||||
QXmppTask<void> TrustHandler::setSecurityPolicy(
|
||||
const QString& encryption,
|
||||
QXmpp::TrustSecurityPolicy securityPolicy)
|
||||
{
|
||||
uint8_t pol = securityPolicy;
|
||||
securityPolicies->forceRecord(encryption, pol);
|
||||
|
||||
return emptyVoidFuture();
|
||||
return Core::makeReadyTask();
|
||||
}
|
||||
|
||||
Shared::TrustLevel Core::TrustHandler::convert(Core::TrustHandler::TL level)
|
||||
|
@ -41,29 +41,28 @@ public:
|
||||
typedef std::map<QByteArray, Shared::TrustLevel> Keys;
|
||||
typedef DataBase::Cache<QString, Keys> KeyCache;
|
||||
|
||||
virtual QFuture<void> resetAll(CSR encryption);
|
||||
virtual QFuture<TL> trustLevel(CSR encryption, CSR keyOwnerJid, const QByteArray& keyId);
|
||||
virtual QFuture<HashSM> setTrustLevel(CSR encryption, CLSR keyOwnerJids, TL oldTrustLevel, TL newTrustLevel);
|
||||
virtual QFuture<HashSM> setTrustLevel(CSR encryption, const MultySB& keyIds, TL trustLevel);
|
||||
virtual QFuture<bool> hasKey(CSR encryption, CSR keyOwnerJid, QXmpp::TrustLevels trustLevels);
|
||||
virtual QFuture<HSHBTL> keys(CSR encryption, CLSR keyOwnerJids, QXmpp::TrustLevels trustLevels);
|
||||
virtual QFuture<QHash<TL, MultySB>> keys(CSR encryption, QXmpp::TrustLevels trustLevels);
|
||||
virtual QFuture<void> removeKeys(CSR encryption);
|
||||
virtual QFuture<void> removeKeys(CSR encryption, CSR keyOwnerJid);
|
||||
virtual QFuture<void> removeKeys(CSR encryption, CLBAR keyIds);
|
||||
virtual QFuture<void> addKeys(CSR encryption, CSR keyOwnerJid, CLBAR keyIds, TL trustLevel);
|
||||
virtual QFuture<QByteArray> ownKey(CSR encryption);
|
||||
virtual QFuture<void> resetOwnKey(CSR encryption);
|
||||
virtual QFuture<void> setOwnKey(CSR encryption, const QByteArray& keyId);
|
||||
virtual QFuture<QXmpp::TrustSecurityPolicy> securityPolicy(CSR encryption);
|
||||
virtual QFuture<void> resetSecurityPolicy(CSR encryption);
|
||||
virtual QFuture<void> setSecurityPolicy(CSR encryption, QXmpp::TrustSecurityPolicy securityPolicy);
|
||||
virtual QXmppTask<void> resetAll(CSR encryption);
|
||||
virtual QXmppTask<TL> trustLevel(CSR encryption, CSR keyOwnerJid, const QByteArray& keyId);
|
||||
virtual QXmppTask<HashSM> setTrustLevel(CSR encryption, CLSR keyOwnerJids, TL oldTrustLevel, TL newTrustLevel);
|
||||
virtual QXmppTask<HashSM> setTrustLevel(CSR encryption, const MultySB& keyIds, TL trustLevel);
|
||||
virtual QXmppTask<bool> hasKey(CSR encryption, CSR keyOwnerJid, QXmpp::TrustLevels trustLevels);
|
||||
virtual QXmppTask<HSHBTL> keys(CSR encryption, CLSR keyOwnerJids, QXmpp::TrustLevels trustLevels);
|
||||
virtual QXmppTask<QHash<TL, MultySB>> keys(CSR encryption, QXmpp::TrustLevels trustLevels);
|
||||
virtual QXmppTask<void> removeKeys(CSR encryption);
|
||||
virtual QXmppTask<void> removeKeys(CSR encryption, CSR keyOwnerJid);
|
||||
virtual QXmppTask<void> removeKeys(CSR encryption, CLBAR keyIds);
|
||||
virtual QXmppTask<void> addKeys(CSR encryption, CSR keyOwnerJid, CLBAR keyIds, TL trustLevel);
|
||||
virtual QXmppTask<QByteArray> ownKey(CSR encryption);
|
||||
virtual QXmppTask<void> resetOwnKey(CSR encryption);
|
||||
virtual QXmppTask<void> setOwnKey(CSR encryption, const QByteArray& keyId);
|
||||
virtual QXmppTask<QXmpp::TrustSecurityPolicy> securityPolicy(CSR encryption);
|
||||
virtual QXmppTask<void> resetSecurityPolicy(CSR encryption);
|
||||
virtual QXmppTask<void> setSecurityPolicy(CSR encryption, QXmpp::TrustSecurityPolicy securityPolicy);
|
||||
|
||||
static TL convert(Shared::TrustLevel level);
|
||||
static Shared::TrustLevel convert(TL level);
|
||||
|
||||
private:
|
||||
static QFuture<void> emptyVoidFuture();
|
||||
KeyCache* createNewCache(const QString& encryption);
|
||||
KeyCache* getCache(const QString& encryption);
|
||||
|
||||
|
2
external/qxmpp
vendored
2
external/qxmpp
vendored
@ -1 +1 @@
|
||||
Subproject commit befab2fe2e71330170bba48f173258be724c65b9
|
||||
Subproject commit d2c2acd4848f815d0dc3d108f8bc306f9015fc89
|
@ -19,10 +19,14 @@
|
||||
#include <QXmppGlobal.h>
|
||||
#include <QDebug>
|
||||
|
||||
#if (QXMPP_VERSION) < QT_VERSION_CHECK(1, 3, 0)
|
||||
static const std::string QXMPP_VERSION_PATCH(std::to_string(QXMPP_VERSION & 0xff));
|
||||
static const std::string QXMPP_VERSION_MINOR(std::to_string((QXMPP_VERSION & 0xff00) >> 8));
|
||||
static const std::string QXMPP_VERSION_MAJOR(std::to_string(QXMPP_VERSION >> 16));
|
||||
static const QString QXMPP_VERSION_STRING = QString::fromStdString(QXMPP_VERSION_MAJOR + "." + QXMPP_VERSION_MINOR + "." + QXMPP_VERSION_PATCH);
|
||||
#else
|
||||
static const QString QXMPP_VERSION_STRING = QXmppVersion();
|
||||
#endif
|
||||
|
||||
About::About(QWidget* parent):
|
||||
QWidget(parent),
|
||||
|
Loading…
Reference in New Issue
Block a user