From 09571ab88bbf8aa7f29b09036efe2b86688bd7d3 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 3 Sep 2021 18:35:38 +0200 Subject: Adapt IQ parsing to new packet sending Remove now unused QXmpp::PacketState. --- src/base/QXmppStream.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/base/QXmppStream.cpp') diff --git a/src/base/QXmppStream.cpp b/src/base/QXmppStream.cpp index 0ede6b18..3443d6d4 100644 --- a/src/base/QXmppStream.cpp +++ b/src/base/QXmppStream.cpp @@ -212,6 +212,8 @@ QFuture QXmppStream::send(const QXmppNonza &nonza, bool &writ /// QFuture QXmppStream::sendIq(const QXmppIq &iq) { + using namespace QXmpp; + if (iq.id().isEmpty()) { warning(QStringLiteral("QXmppStream::sendIq() error: ID is empty. Using random ID.")); auto newIq = iq; @@ -229,15 +231,15 @@ QFuture QXmppStream::sendIq(const QXmppIq &iq) auto sendFuture = send(iq); if (sendFuture.isFinished()) { - if (std::holds_alternative(sendFuture.result())) { + if (std::holds_alternative(sendFuture.result())) { // early exit (saves QFutureWatcher) - return makeReadyFuture(QXmpp::NotSent); + return makeReadyFuture(std::get(sendFuture.result())); } } else { - awaitLast(sendFuture, this, [this, id = iq.id()](QXmpp::SendResult result) { - if (std::holds_alternative(result)) { + awaitLast(sendFuture, this, [this, id = iq.id()](SendResult result) { + if (std::holds_alternative(result)) { if (auto itr = d->runningIqs.find(id); itr != d->runningIqs.end()) { - itr.value().reportResult(QXmpp::NotSent); + itr.value().reportResult(std::get(result)); itr.value().reportFinished(); d->runningIqs.erase(itr); @@ -252,14 +254,17 @@ QFuture QXmppStream::sendIq(const QXmppIq &iq) } /// -/// Cancels all ongoing IQ requests and reports QXmpp::NotSent. +/// Cancels all ongoing IQ requests and reports QXmpp::SendError::Disconnected. /// /// \since QXmpp 1.5 /// void QXmppStream::cancelOngoingIqs() { for (auto &state : d->runningIqs) { - state.reportResult(QXmpp::NotSent); + state.reportResult(QXmpp::SendError { + QStringLiteral("IQ has been cancelled."), + QXmpp::SendError::Disconnected + }); state.reportFinished(); } d->runningIqs.clear(); -- cgit v1.2.3