diff options
| author | Linus Jahn <lnj@kaidan.im> | 2021-09-03 18:35:38 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-09-03 20:42:34 +0200 |
| commit | 09571ab88bbf8aa7f29b09036efe2b86688bd7d3 (patch) | |
| tree | 2d3493109f978cb675b690e0171a0c3ec1a00bb5 /src/base/QXmppStream.cpp | |
| parent | 040b7d9a8c7625f93e93690e47dbabb71ff87fd7 (diff) | |
| download | qxmpp-09571ab88bbf8aa7f29b09036efe2b86688bd7d3.tar.gz | |
Adapt IQ parsing to new packet sending
Remove now unused QXmpp::PacketState.
Diffstat (limited to 'src/base/QXmppStream.cpp')
| -rw-r--r-- | src/base/QXmppStream.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
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<QXmpp::SendResult> QXmppStream::send(const QXmppNonza &nonza, bool &writ /// QFuture<QXmppStream::IqResult> 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::IqResult> QXmppStream::sendIq(const QXmppIq &iq) auto sendFuture = send(iq); if (sendFuture.isFinished()) { - if (std::holds_alternative<QXmpp::SendError>(sendFuture.result())) { + if (std::holds_alternative<SendError>(sendFuture.result())) { // early exit (saves QFutureWatcher) - return makeReadyFuture<IqResult>(QXmpp::NotSent); + return makeReadyFuture<IqResult>(std::get<SendError>(sendFuture.result())); } } else { - awaitLast(sendFuture, this, [this, id = iq.id()](QXmpp::SendResult result) { - if (std::holds_alternative<QXmpp::SendError>(result)) { + awaitLast(sendFuture, this, [this, id = iq.id()](SendResult result) { + if (std::holds_alternative<SendError>(result)) { if (auto itr = d->runningIqs.find(id); itr != d->runningIqs.end()) { - itr.value().reportResult(QXmpp::NotSent); + itr.value().reportResult(std::get<SendError>(result)); itr.value().reportFinished(); d->runningIqs.erase(itr); @@ -252,14 +254,17 @@ QFuture<QXmppStream::IqResult> 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(); |
