forked from blue/squawk
Own omemo key display, a bit of CMake clean up
This commit is contained in:
parent
19835af3cf
commit
00af582287
16 changed files with 443 additions and 360 deletions
|
@ -1,18 +1,20 @@
|
|||
// 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/>.
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include "omemohandler.h"
|
||||
|
@ -196,18 +198,7 @@ void Core::OmemoHandler::requestOwnBundles() {
|
|||
}
|
||||
|
||||
void Core::OmemoHandler::onBundlesReceived(const QString& jid) {
|
||||
std::list<Shared::KeyInfo> keys;
|
||||
acc->oh->getDevices(jid, keys);
|
||||
std::map<QByteArray, Shared::TrustLevel> trustLevels = acc->th->getKeys(Shared::EncryptionProtocol::omemo2, jid);
|
||||
|
||||
qDebug() << "OMEMO info for " << jid << " devices:" << keys.size() << ", trustLevels:" << trustLevels.size();
|
||||
for (Shared::KeyInfo& key : keys) {
|
||||
std::map<QByteArray, Shared::TrustLevel>::const_iterator itr = trustLevels.find(key.fingerPrint);
|
||||
if (itr != trustLevels.end()) {
|
||||
key.trustLevel = itr->second;
|
||||
qDebug() << "Found a trust level for a device!";
|
||||
}
|
||||
}
|
||||
std::list<Shared::KeyInfo> keys = readKeys(jid);
|
||||
|
||||
Contact* cnt = acc->rh->getContact(jid);
|
||||
if (cnt)
|
||||
|
@ -217,23 +208,35 @@ void Core::OmemoHandler::onBundlesReceived(const QString& jid) {
|
|||
}
|
||||
|
||||
void Core::OmemoHandler::onOwnBundlesReceived() {
|
||||
QString jid = acc->getBareJid();
|
||||
std::list<Shared::KeyInfo> keys;
|
||||
acc->oh->getDevices(jid, keys);
|
||||
std::map<QByteArray, Shared::TrustLevel> trustLevels = acc->th->getKeys(Shared::EncryptionProtocol::omemo2, jid);
|
||||
|
||||
qDebug() << "OMEMO info for " << jid << " devices:" << keys.size() << ", trustLevels:" << trustLevels.size();
|
||||
for (Shared::KeyInfo& key : keys) {
|
||||
std::map<QByteArray, Shared::TrustLevel>::const_iterator itr = trustLevels.find(key.fingerPrint);
|
||||
if (itr != trustLevels.end()) {
|
||||
key.trustLevel = itr->second;
|
||||
qDebug() << "Found a trust level for a device!";
|
||||
}
|
||||
}
|
||||
std::list<Shared::KeyInfo> keys = readKeys(acc->getBareJid());
|
||||
if (ownDevice)
|
||||
keys.emplace_front(
|
||||
ownDevice->id,
|
||||
ownDevice->publicIdentityKey,
|
||||
ownDevice->label,
|
||||
QDateTime::currentDateTime(),
|
||||
Shared::TrustLevel::authenticated,
|
||||
Shared::EncryptionProtocol::omemo2,
|
||||
true
|
||||
);
|
||||
|
||||
acc->delay->receivedOwnBundles(keys);
|
||||
}
|
||||
|
||||
std::list<Shared::KeyInfo> Core::OmemoHandler::readKeys(const QString& jid) {
|
||||
std::list<Shared::KeyInfo> keys;
|
||||
getDevices(jid, keys);
|
||||
std::map<QByteArray, Shared::TrustLevel> trustLevels = acc->th->getKeys(Shared::EncryptionProtocol::omemo2, jid);
|
||||
|
||||
for (Shared::KeyInfo& key : keys) {
|
||||
std::map<QByteArray, Shared::TrustLevel>::const_iterator itr = trustLevels.find(key.fingerPrint);
|
||||
if (itr != trustLevels.end())
|
||||
key.trustLevel = itr->second;
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
void Core::OmemoHandler::onOmemoDeviceAdded(const QString& jid, uint32_t id) {
|
||||
SHARED_UNUSED(id);
|
||||
qDebug() << "OMEMO device added for" << jid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue