some debug, fix a crash removing a currently selected contact

This commit is contained in:
Blue 2023-11-12 19:55:32 -03:00
parent e31ef78e71
commit 19835af3cf
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
9 changed files with 40 additions and 14 deletions

View File

@ -136,11 +136,16 @@ if (NOT SYSTEM_QXMPP)
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/omemo)
target_include_directories(squawk PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/qxmpp/src/omemo)
set(BUILD_OMEMO ON)
set(BUILD_TESTS OFF)
else ()
set(BUILD_OMEMO OFF)
endif ()
add_subdirectory(external/qxmpp)
if (WITH_OMEMO)
target_include_directories(QXmppOmemoQt${QT_VERSION_MAJOR} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/qxmpp/src)
endif()
target_link_libraries(squawk PRIVATE QXmppQt${QT_VERSION_MAJOR})
if (WITH_OMEMO)
target_link_libraries(squawk PRIVATE QXmppOmemoQt${QT_VERSION_MAJOR})

View File

@ -61,7 +61,7 @@
#include "handlers/discoveryhandler.h"
#ifdef WITH_OMEMO
#include <Omemo/QXmppOmemoManager.h>
#include <QXmppOmemoManager.h>
#include <QXmppTrustManager.h>
#include "handlers/trusthandler.h"
#include "handlers/omemohandler.h"

View File

@ -368,9 +368,9 @@ void Core::DelayManager::Manager::receivedBundles(const QString& jid, const std:
Job::Id jobId = itr->second;
requestedBundles.erase(itr);
std::map<Job::Id, Job*>::const_iterator jitr = runningJobs.find(jobId);
if (jitr == runningJobs.end()) {
if (jitr == runningJobs.end())
throw JobNotFound(jobId, "receivedBundles");
}
Job* jb = jitr->second;
InfoForUser* job = dynamic_cast<InfoForUser*>(jb);

View File

@ -357,28 +357,36 @@ std::pair<Shared::Message::State, QString> Core::MessageHandler::scheduleSending
if (task.isFinished()) {
const QXmppE2eeExtension::MessageEncryptResult& res = task.result();
if (std::holds_alternative<std::unique_ptr<QXmppMessage>>(res)) {
qDebug() << "Successfully encrypted a message";
const std::unique_ptr<QXmppMessage>& encrypted = std::get<std::unique_ptr<QXmppMessage>>(res);
encrypted->setBody(QString());
encrypted->setOutOfBandUrl(QString());
bool success = acc->client.sendPacket(*encrypted.get());
if (success)
if (success) {
qDebug() << "Successfully sent an encrypted message";
return {Shared::Message::State::sent, ""};
else
} else {
qDebug() << "Couldn't sent an encrypted message";
return {Shared::Message::State::error, "Error sending successfully encrypted message"};
}
} else if (std::holds_alternative<QXmppError>(res)) {
qDebug() << "Couldn't encrypt a message";
const QXmppError& err = std::get<QXmppError>(res);
return {Shared::Message::State::error, err.description};
} else {
qDebug() << "Couldn't encrypt a message";
return {Shared::Message::State::error, "Unexpected error ecryptng the message"};
}
} else {
task.then(this, [this, id] (QXmppE2eeExtension::MessageEncryptResult&& result) {
if (std::holds_alternative<std::unique_ptr<QXmppMessage>>(result)) {
qDebug() << "Successfully encrypted a message";
const std::unique_ptr<QXmppMessage>& encrypted = std::get<std::unique_ptr<QXmppMessage>>(result);
encrypted->setBody(QString());
encrypted->setOutOfBandUrl(QString());
bool success = acc->client.sendPacket(*encrypted.get());
if (success) {
qDebug() << "Successfully sent an encrypted message";
std::tuple<bool, QString, QString> ids = getOriginalPendingMessageId(id, false);
if (std::get<0>(ids)) {
QString id = std::get<1>(ids);
@ -393,12 +401,15 @@ std::pair<Shared::Message::State, QString> Core::MessageHandler::scheduleSending
qDebug() << "Encrypted message has been successfully sent, but it couldn't be found to update the sate";
}
} else {
qDebug() << "Couldn't sent an encrypted message";
handlePendingMessageError(id, "Error sending successfully encrypted message");
}
} else if (std::holds_alternative<QXmppError>(result)) {
qDebug() << "Couldn't encrypt a message";
const QXmppError& err = std::get<QXmppError>(result);
handlePendingMessageError(id, err.description);
} else {
qDebug() << "Couldn't encrypt a message";
handlePendingMessageError(id, "Unexpected error ecryptng the message");
}
});

View File

@ -169,7 +169,15 @@ void Core::OmemoHandler::getDevices(const QString& jid, std::list<Shared::KeyInf
for (QHash<uint32_t, Device>::const_iterator itr = devs.begin(), end = devs.end(); itr != end; ++itr) {
const Device& dev = itr.value();
out.emplace_back(itr.key(), dev.keyId, dev.label, QDateTime(), Shared::TrustLevel::undecided, Shared::EncryptionProtocol::omemo2, false);
out.emplace_back(
itr.key(),
dev.keyId,
dev.label,
dev.removalFromDeviceListDate,
Shared::TrustLevel::undecided,
Shared::EncryptionProtocol::omemo2,
false
);
}
}

View File

@ -21,7 +21,7 @@
#include <list>
#include <functional>
#include <Omemo/QXmppOmemoStorage.h>
#include <QXmppOmemoStorage.h>
#include <cache.h>
#include <shared/keyinfo.h>

View File

@ -24,7 +24,7 @@
#include <QObject>
#ifdef WITH_OMEMO
#include <Omemo/QXmppOmemoStorage.h>
#include <QXmppOmemoStorage.h>
#endif
int main(int argc, char *argv[]) {

View File

@ -1,6 +1,6 @@
# Maintainer: Yury Gubich <blue@macaw.me>
pkgname=squawk
pkgver=0.2.2
pkgver=0.2.3
pkgrel=1
pkgdesc="An XMPP desktop messenger, written on pure c++ (qt)"
arch=('i686' 'x86_64')

View File

@ -133,10 +133,13 @@ void FeedView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottom
void FeedView::updateGeometries() {
//qDebug() << "updateGeometries";
QScrollBar* bar = verticalScrollBar();
const QStyle* st = style();
const QAbstractItemModel* m = model();
if (m == nullptr)
return QAbstractItemView::updateGeometries();
QScrollBar* bar = verticalScrollBar();
const QStyle* st = style();
QSize layoutBounds = maximumViewportSize();
QStyleOptionViewItem option = viewOptions();
option.rect.setHeight(maxMessageHeight);
@ -210,9 +213,8 @@ void FeedView::updateGeometries() {
positionProgress();
if (specialDelegate) {
if (specialDelegate)
clearWidgetsMode = true;
}
QAbstractItemView::updateGeometries();
}