From 28aad17d6d928ee0a983d7032ae0f11fbc71bb06 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Mon, 5 Jul 2021 15:17:12 +0200 Subject: Add QXmppClient::sendGenericIq() just returning Success/StanzaError --- src/client/QXmppClient.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/client/QXmppClient.cpp') diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp index 4f8bfc26..74875275 100644 --- a/src/client/QXmppClient.cpp +++ b/src/client/QXmppClient.cpp @@ -29,6 +29,7 @@ #include "QXmppDiscoveryIq.h" #include "QXmppDiscoveryManager.h" #include "QXmppEntityTimeManager.h" +#include "QXmppFutureUtils_p.h" #include "QXmppLogger.h" #include "QXmppMessage.h" #include "QXmppOutgoingClient.h" @@ -117,6 +118,18 @@ QStringList QXmppClientPrivate::discoveryFeatures() /// (with type 'error' or 'result') or it contains the packet error, if the /// request couldn't be sent. /// +/// \since QXmpp 1.5 +/// + +/// +/// \typedef QXmppClient::EmptyResult +/// +/// Result of a generic request without a return value. Contains Success in case +/// everything went well. If the returned IQ contained an error a +/// QXmppStanza::Error is reported. +/// +/// \since QXmpp 1.5 +/// /// Creates a QXmppClient object. /// \param parent is passed to the QObject's constructor. @@ -345,6 +358,10 @@ QFuture QXmppClient::send(const QXmppStanza &stanza) /// /// Sends an IQ packet and returns the response asynchronously. /// +/// This is useful for further processing and parsing of the returned +/// QDomElement. If you don't expect a special response, you may want use +/// sendGenericIq(). +/// /// \warning THIS API IS NOT FINALIZED YET! /// /// \since QXmpp 1.5 @@ -354,6 +371,27 @@ QFuture QXmppClient::sendIq(const QXmppIq &iq) return d->stream->sendIq(iq); } +/// +/// Sends an IQ and returns possible stanza errors. +/// +/// If you want to parse a special IQ response in the result case, you can use +/// sendIq() and parse the returned QDomElement. +/// +/// \returns Returns QXmpp::Success (on response type 'result') or the contained +/// QXmppStanza::Error (on response type 'error') +/// +/// \warning THIS API IS NOT FINALIZED YET! +/// +/// \since QXmpp 1.5 +/// +QFuture QXmppClient::sendGenericIq(const QXmppIq &iq) +{ + using namespace QXmpp::Private; + return chainIq(sendIq(iq), this, [](const QXmppIq &) { + return QXmpp::Success(); + }); +} + /// Disconnects the client and the current presence of client changes to /// QXmppPresence::Unavailable and status text changes to "Logged out". /// -- cgit v1.2.3