aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppRegisterIq.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2020-02-01 16:50:34 +0100
committerLNJ <lnj@kaidan.im>2020-02-03 00:11:35 +0100
commit2dd54da9620028e1c051c3d4a9a6121ccab3f866 (patch)
treeed68af9a65531f2a4ae46313cf8cd3beb0ad1cbb /src/base/QXmppRegisterIq.cpp
parentb9c58b05300a292437c9554181970c7e1933b19e (diff)
downloadqxmpp-2dd54da9620028e1c051c3d4a9a6121ccab3f866.tar.gz
QXmppRegisterIq: Add utility methods to create common requests
This adds utility methods to create an unregistration or a change password request in one line.
Diffstat (limited to 'src/base/QXmppRegisterIq.cpp')
-rw-r--r--src/base/QXmppRegisterIq.cpp36
1 files changed, 36 insertions, 0 deletions
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