ref(omemo): reformat qomemo/

This commit is contained in:
vae 2021-05-13 17:54:37 +03:00
parent 574210f5d9
commit bbeeee4c8a
Signed by: vae
GPG Key ID: A9A33351400E00E5
23 changed files with 447 additions and 455 deletions

View File

@ -1,12 +0,0 @@
* Generate device w/ keys
* PubSub set urn:xmpp:omemo:1:devices to announce new device
* PubSub set urn:xmpp:omemo:1:bundles to announce new key bundles
* PubSub get urn:xmpp:omemo:1:bundles to get user bundles
Sending a message:
* Create urn:xmpp:sce:0 with padding and content
* Add <encrypted xmlns='urn:xmpp:omemo:1'> with header (key list) and payload (b64)
Receiving a message:
* Check <keys> => <key>
* Decrypt (TODO)

View File

@ -8,7 +8,9 @@
#include <QString>
class QXmppPubSubIq;
class QXmppElement;
class QXmppIq;
namespace QXmpp::Omemo {

View File

@ -7,6 +7,7 @@
#include <QList>
class QXmppElement;
class QXmppIq;
namespace QXmpp::Omemo {

View File

@ -11,5 +11,4 @@ int QXmpp::Omemo::DeviceKeyStorage::generateDeviceId() {
return 1 + random.bounded(INT32_MAX - 1);
}
QXmpp::Omemo::DeviceKeyStorage::DeviceKeyStorage(int deviceId)
: deviceId(deviceId) {}
QXmpp::Omemo::DeviceKeyStorage::DeviceKeyStorage(int deviceId) : deviceId(deviceId) {}

View File

@ -7,8 +7,7 @@
QXmpp::Omemo::DeviceService::DeviceService(QObject *parent) : QObject(parent) {}
void QXmpp::Omemo::DeviceService::onDeviceListReceived(
const QString &jid, const QXmpp::Omemo::DeviceList &list) {
void QXmpp::Omemo::DeviceService::onDeviceListReceived(const QString &jid, const QXmpp::Omemo::DeviceList &list) {
for (const auto &device : list.devices) {
qInfo() << "Got device for" << jid << ":" << device.id;

View File

@ -20,7 +20,7 @@ public:
explicit DeviceService(QObject *parent);
public slots:
void onDeviceListReceived(const QString &jid, const DeviceList &list);
void onDeviceListReceived(const QString &jid, const QXmpp::Omemo::DeviceList &list);
private:
QMap<QString, UserDeviceList> device_lists{};

View File

@ -18,8 +18,7 @@ using namespace QXmpp::Omemo;
Manager::Manager()
: deviceService(new DeviceService(this)),
omemoVariant(new Variant::Conversations) {
connect(this, &Manager::deviceListReceived, deviceService.get(),
&DeviceService::onDeviceListReceived);
connect(this, &Manager::deviceListReceived, deviceService.get(), &DeviceService::onDeviceListReceived);
}
bool QXmpp::Omemo::Manager::handleStanza(const QDomElement &stanza) {

View File

@ -25,7 +25,7 @@ public slots:
void fetchOwnDevices();
signals:
void deviceListReceived(const QString &jid, const DeviceList &list);
void deviceListReceived(const QString &jid, const QXmpp::Omemo::DeviceList &list);
protected:
void setClient(QXmppClient *client) override;

View File

@ -6,12 +6,14 @@
#include <QRandomGenerator>
#define RPAD_ALPHABET "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
constexpr int RPAD_MAX_LENGTH = 200;
QString QXmpp::Sce::generatePadding() {
QRandomGenerator random{};
QString result{};
QString alphabet{ QStringLiteral("!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~") };
QString alphabet{QStringLiteral(RPAD_ALPHABET)};
auto length = random.bounded(RPAD_MAX_LENGTH);
result.resize(length);

View File

@ -35,7 +35,8 @@ int Signal::Store::SignedPreKeyStore::loadSignedPreKey(signal_buffer **record, u
return 0;
}
int Signal::Store::SignedPreKeyStore::storeSignedPreKey(uint32_t signed_pre_key_id, uint8_t *record, size_t record_len) {
int
Signal::Store::SignedPreKeyStore::storeSignedPreKey(uint32_t signed_pre_key_id, uint8_t *record, size_t record_len) {
return 0;
}

View File

@ -6,5 +6,4 @@
#include <utility>
QXmpp::Omemo::UserDeviceList::UserDeviceList(QString jid)
: jid(std::move(jid)) {}
QXmpp::Omemo::UserDeviceList::UserDeviceList(QString jid) : jid(std::move(jid)) {}

View File

@ -5,11 +5,13 @@
#pragma once
class QXmppElement;
class QXmppIq;
namespace QXmpp::Omemo {
class Device;
class DeviceList;
namespace Variant {