forked from blue/squawk
feat(OMEMO): DeviceKeyStorage, DeviceService, UserDeviceList stubs
This commit is contained in:
parent
6721b62629
commit
b1a8f162ce
@ -1,8 +1,14 @@
|
||||
target_sources(squawk PRIVATE
|
||||
device_key_storage.cpp
|
||||
device_key_storage.h
|
||||
device_service.cpp
|
||||
device_service.h
|
||||
signal.h
|
||||
signal.cpp
|
||||
qomemo.cpp
|
||||
qomemo.h
|
||||
sce.cpp
|
||||
sce.h
|
||||
user_device_list.cpp
|
||||
user_device_list.h
|
||||
)
|
15
qomemo/device_key_storage.cpp
Normal file
15
qomemo/device_key_storage.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Created by victoria on 2021-05-12.
|
||||
*/
|
||||
|
||||
#include "device_key_storage.h"
|
||||
#include <QRandomGenerator>
|
||||
|
||||
int QXmpp::Omemo::DeviceKeyStorage::generateDeviceId() {
|
||||
QRandomGenerator random{};
|
||||
|
||||
return 1 + random.bounded(INT32_MAX - 1);
|
||||
}
|
||||
|
||||
QXmpp::Omemo::DeviceKeyStorage::DeviceKeyStorage(int deviceId)
|
||||
: deviceId(deviceId) {}
|
18
qomemo/device_key_storage.h
Normal file
18
qomemo/device_key_storage.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Created by victoria on 2021-05-12.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace QXmpp::Omemo {
|
||||
|
||||
class DeviceKeyStorage {
|
||||
public:
|
||||
static int generateDeviceId();
|
||||
|
||||
explicit DeviceKeyStorage(int deviceId);
|
||||
|
||||
const int deviceId;
|
||||
};
|
||||
|
||||
} // namespace QXmpp::Omemo
|
30
qomemo/device_service.cpp
Normal file
30
qomemo/device_service.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Created by victoria on 2021-05-12.
|
||||
*/
|
||||
|
||||
#include "device_service.h"
|
||||
|
||||
#include <QXmppClient.h>
|
||||
#include <QXmppPubSubIq.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
QXmpp::Omemo::DeviceService::DeviceService(QXmppClient &client, QObject *parent)
|
||||
: QObject(parent), client(client) {
|
||||
connect(&client, &QXmppClient::iqReceived, this,
|
||||
&DeviceService::onIqReceived);
|
||||
}
|
||||
|
||||
void QXmpp::Omemo::DeviceService::onIqReceived(const QXmppIq &iq) {
|
||||
// Update OMEMO device list
|
||||
}
|
||||
|
||||
void QXmpp::Omemo::DeviceService::fetch() {
|
||||
QXmppPubSubIq fetchOwnDevices{};
|
||||
fetchOwnDevices.setFrom(client.configuration().jid());
|
||||
fetchOwnDevices.setTo(client.configuration().jidBare());
|
||||
fetchOwnDevices.setType(QXmppIq::Get);
|
||||
fetchOwnDevices.setQueryNode("urn:xmpp:omemo:1:devices");
|
||||
|
||||
client.sendPacket(fetchOwnDevices);
|
||||
}
|
31
qomemo/device_service.h
Normal file
31
qomemo/device_service.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Created by victoria on 2021-05-12.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "user_device_list.h"
|
||||
|
||||
#include <QXmppClient.h>
|
||||
|
||||
namespace QXmpp::Omemo {
|
||||
|
||||
class DeviceService : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeviceService(QXmppClient& client, QObject *parent);
|
||||
|
||||
void fetch();
|
||||
|
||||
public slots:
|
||||
void onIqReceived(const QXmppIq& iq);
|
||||
|
||||
private:
|
||||
void announce();
|
||||
|
||||
QXmppClient& client;
|
||||
QMap<QString, UserDeviceList> device_lists{};
|
||||
};
|
||||
|
||||
} // namespace QXmpp::Omemo
|
@ -91,4 +91,4 @@ public:
|
||||
QXmppMessage message{};
|
||||
};
|
||||
|
||||
} // namespace QOmemo
|
||||
} // namespace QXmpp::Omemo
|
||||
|
10
qomemo/user_device_list.cpp
Normal file
10
qomemo/user_device_list.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Created by victoria on 2021-05-12.
|
||||
*/
|
||||
|
||||
#include "user_device_list.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
QXmpp::Omemo::UserDeviceList::UserDeviceList(QString jid)
|
||||
: jid(std::move(jid)) {}
|
17
qomemo/user_device_list.h
Normal file
17
qomemo/user_device_list.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Created by victoria on 2021-05-12.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
namespace QXmpp::Omemo {
|
||||
|
||||
class UserDeviceList {
|
||||
public:
|
||||
explicit UserDeviceList(QString jid);
|
||||
|
||||
const QString jid;
|
||||
};
|
||||
|
||||
} // namespace QXmpp::Omemo
|
Loading…
Reference in New Issue
Block a user