From 6efebe555d30170c2ecfc2372113f342c513b0c2 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 30 Dec 2022 23:35:47 +0100 Subject: Replace QXmpp::SendError with QXmppError everywhere Part of #501. --- src/omemo/QXmppOmemoManager.cpp | 20 ++++++++++---------- src/omemo/QXmppOmemoManager_p.cpp | 19 +++++++++++++------ 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'src/omemo') diff --git a/src/omemo/QXmppOmemoManager.cpp b/src/omemo/QXmppOmemoManager.cpp index 856e00a5..11a7ec36 100644 --- a/src/omemo/QXmppOmemoManager.cpp +++ b/src/omemo/QXmppOmemoManager.cpp @@ -1030,10 +1030,10 @@ QFuture Manager::encryptIq(QXmppIq &&iq, co QFutureInterface interface(QFutureInterfaceBase::Started); if (!d->isStarted) { - QXmpp::SendError error; - error.text = QStringLiteral("OMEMO manager must be started before encrypting"); - error.type = QXmpp::SendError::EncryptionError; - reportFinishedResult(interface, { error }); + interface.reportResult(QXmppError { + QStringLiteral("OMEMO manager must be started before encrypting"), + SendError::EncryptionError }); + interface.reportFinished(); } else { std::optional acceptedTrustLevels; @@ -1048,10 +1048,10 @@ QFuture Manager::encryptIq(QXmppIq &&iq, co auto future = d->encryptStanza(iq, { QXmppUtils::jidToBareJid(iq.to()) }, *acceptedTrustLevels); await(future, this, [=, iq = std::move(iq)](std::optional omemoElement) mutable { if (!omemoElement) { - QXmpp::SendError error; - error.text = QStringLiteral("OMEMO element could not be created"); - error.type = QXmpp::SendError::EncryptionError; - reportFinishedResult(interface, { error }); + interface.reportResult(QXmppError { + QStringLiteral("OMEMO element could not be created"), + SendError::EncryptionError }); + interface.reportFinished(); } else { QXmppOmemoIq omemoIq; omemoIq.setId(iq.id()); @@ -1077,7 +1077,7 @@ QFuture Manager::decryptIq(const QDomElemen { if (!d->isStarted) { // TODO: Add decryption queue to avoid this error - return makeReadyFuture(SendError { + return makeReadyFuture(QXmppError { QStringLiteral("OMEMO manager must be started before decrypting"), SendError::EncryptionError }); } @@ -1088,7 +1088,7 @@ QFuture Manager::decryptIq(const QDomElemen if (result) { return result->iq; } - return SendError { + return QXmppError { QStringLiteral("OMEMO message could not be decrypted"), SendError::EncryptionError }; diff --git a/src/omemo/QXmppOmemoManager_p.cpp b/src/omemo/QXmppOmemoManager_p.cpp index 805f0b56..01981fad 100644 --- a/src/omemo/QXmppOmemoManager_p.cpp +++ b/src/omemo/QXmppOmemoManager_p.cpp @@ -1031,7 +1031,10 @@ QFuture ManagerPrivate::encryptMessage QFutureInterface interface(QFutureInterfaceBase::Started); if (!isStarted) { - QXmpp::SendError error = { QStringLiteral("OMEMO manager must be started before encrypting"), QXmpp::SendError::EncryptionError }; + QXmppError error { + QStringLiteral("OMEMO manager must be started before encrypting"), + SendError::EncryptionError + }; reportFinishedResult(interface, { error }); } else { recipientJids.append(ownBareJid()); @@ -1039,9 +1042,10 @@ QFuture ManagerPrivate::encryptMessage auto future = encryptStanza(message, recipientJids, acceptedTrustLevels); await(future, q, [=, message = std::move(message)](std::optional omemoElement) mutable { if (!omemoElement) { - QXmpp::SendError error; - error.text = QStringLiteral("OMEMO element could not be created"); - error.type = QXmpp::SendError::EncryptionError; + QXmppError error { + QStringLiteral("OMEMO element could not be created"), + QXmpp::SendError::EncryptionError, + }; reportFinishedResult(interface, { error }); } else { const auto areDeliveryReceiptsUsed = message.isReceiptRequested() || !message.receiptId().isEmpty(); @@ -3336,7 +3340,7 @@ QFuture ManagerPrivate::buildSessionWithDeviceBundle(const QString &jid, u } else { auto future = sendEmptyMessage(jid, deviceId, true); await(future, q, [=](QXmpp::SendResult result) mutable { - if (std::holds_alternative(result)) { + if (std::holds_alternative(result)) { warning("Session could be created but empty message could not be sent to JID '" % jid % "' and device ID '" % QString::number(deviceId) % "'"); reportFinishedResult(interface, false); @@ -3580,7 +3584,10 @@ QFuture ManagerPrivate::sendEmptyMessage(const QString &recip warning("OMEMO envelope for recipient JID '" % recipientJid % "' and device ID '" % QString::number(recipientDeviceId) % "' could not be created because its data could not be encrypted"); - SendError error = { QStringLiteral("OMEMO envelope could not be created"), SendError::EncryptionError }; + QXmppError error { + QStringLiteral("OMEMO envelope could not be created"), + SendError::EncryptionError + }; reportFinishedResult(interface, { error }); } else { QXmppOmemoEnvelope omemoEnvelope; -- cgit v1.2.3