2021-05-12 12:50:52 +00:00
|
|
|
/*
|
|
|
|
* Created by victoria on 2021-05-12.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "device_service.h"
|
2021-05-12 21:32:13 +00:00
|
|
|
#include "device.h"
|
2021-05-12 12:50:52 +00:00
|
|
|
|
2021-07-22 17:45:39 +00:00
|
|
|
using namespace QXmpp::Omemo;
|
2021-05-12 12:50:52 +00:00
|
|
|
|
2021-07-22 17:45:39 +00:00
|
|
|
DeviceService::DeviceService(QObject *parent) : QObject(parent) {}
|
|
|
|
|
|
|
|
void DeviceService::onDeviceListReceived(const QString &jid, const QXmpp::Omemo::DeviceList &list) {
|
2021-05-12 12:50:52 +00:00
|
|
|
|
2021-05-13 14:54:37 +00:00
|
|
|
for (const auto &device : list.devices) {
|
|
|
|
qInfo() << "Got device for" << jid << ":" << device.id;
|
|
|
|
}
|
2021-05-12 12:50:52 +00:00
|
|
|
}
|
2021-07-22 17:45:39 +00:00
|
|
|
|
|
|
|
QSharedPointer<Database> DeviceService::getDatabase(const QString &jid) {
|
|
|
|
if (!databases.contains(jid)) {
|
|
|
|
databases.insert(jid, QSharedPointer<Database>::create(jid));
|
|
|
|
}
|
|
|
|
|
|
|
|
return databases[jid];
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceService::addIdentity(const QString &jid, int deviceId, const QByteArray& publicKey) {
|
|
|
|
auto db = getDatabase(jid);
|
|
|
|
|
|
|
|
db->saveIdentityKey(deviceId, publicKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceService::onDeviceListNotFound(const QString &jid) {
|
|
|
|
qInfo() << "Device list not found:" << jid;
|
|
|
|
}
|