From 2dd54da9620028e1c051c3d4a9a6121ccab3f866 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 1 Feb 2020 16:50:34 +0100 Subject: QXmppRegisterIq: Add utility methods to create common requests This adds utility methods to create an unregistration or a change password request in one line. --- src/base/QXmppRegisterIq.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/base/QXmppRegisterIq.cpp') diff --git a/src/base/QXmppRegisterIq.cpp b/src/base/QXmppRegisterIq.cpp index 79231c9a..de96aee9 100644 --- a/src/base/QXmppRegisterIq.cpp +++ b/src/base/QXmppRegisterIq.cpp @@ -65,6 +65,42 @@ QXmppRegisterIq::~QXmppRegisterIq() = default; QXmppRegisterIq &QXmppRegisterIq::operator=(const QXmppRegisterIq &other) = default; +/// Constructs a regular change password request. +/// +/// \param username The username of the account of which the password should be +/// changed. +/// \param newPassword The new password that should be set. +/// \param to Optional JID of the registration service. If this is omitted, the +/// IQ is automatically addressed to the local server. +/// +/// \since QXmpp 1.2 + +QXmppRegisterIq QXmppRegisterIq::createChangePasswordRequest(const QString &username, const QString &newPassword, const QString &to) +{ + QXmppRegisterIq iq; + iq.setType(QXmppIq::Set); + iq.setTo(to); + iq.setUsername(username); + iq.setPassword(newPassword); + return iq; +} + +/// Constructs a regular unregistration request. +/// +/// \param to Optional JID of the registration service. If this is omitted, the +/// IQ is automatically addressed to the local server. +/// +/// \since QXmpp 1.2 + +QXmppRegisterIq QXmppRegisterIq::createUnregistrationRequest(const QString &to) +{ + QXmppRegisterIq iq; + iq.setType(QXmppIq::Set); + iq.setTo(to); + iq.setRegisterType(QXmppRegisterIq::Remove); + return iq; +} + /// Returns the email for this registration IQ. QString QXmppRegisterIq::email() const -- cgit v1.2.3