diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-02-06 11:49:26 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-02-06 12:17:01 +0100 |
| commit | fd0e02233f925cff699c08b135887a09bdc16e5c (patch) | |
| tree | 5eeb54d9c5824d372980a3f50571fbb00d03610c /src/client/QXmppRegistrationManager.cpp | |
| parent | dee612210008007a9c011b96081605f6e692287d (diff) | |
| download | qxmpp-fd0e02233f925cff699c08b135887a09bdc16e5c.tar.gz | |
QXmppRegistrationManager: Handle result of deleteAccount()
This adds two signals to make the result easily available to the user.
Diffstat (limited to 'src/client/QXmppRegistrationManager.cpp')
| -rw-r--r-- | src/client/QXmppRegistrationManager.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/client/QXmppRegistrationManager.cpp b/src/client/QXmppRegistrationManager.cpp index 48cd3d47..4f8e97a6 100644 --- a/src/client/QXmppRegistrationManager.cpp +++ b/src/client/QXmppRegistrationManager.cpp @@ -47,8 +47,9 @@ public: QString changePasswordIqId; QString newPassword; - QString registrationIqId; + QString deleteAccountIqIq; + QString registrationIqId; QXmppRegisterIq registrationFormToSend; }; @@ -98,16 +99,15 @@ void QXmppRegistrationManager::changePassword(const QString &newPassword) /// /// Cancels an existing registration on the server. /// -/// \returns The ID of the sent IQ, if it was sent successfully. A null string -/// is returned otherwise. +/// \sa accountDeleted() +/// \sa accountDeletionFailed() /// -QString QXmppRegistrationManager::deleteAccount() +void QXmppRegistrationManager::deleteAccount() { auto iq = QXmppRegisterIq::createUnregistrationRequest(); + d->deleteAccountIqIq = iq.id(); - if (client()->sendPacket(iq)) - return iq.id(); - return {}; + client()->sendPacket(iq); } bool QXmppRegistrationManager::supportedByServer() const @@ -258,6 +258,26 @@ bool QXmppRegistrationManager::handleStanza(const QDomElement &stanza) d->changePasswordIqId.clear(); d->newPassword.clear(); return true; + } else if (!id.isEmpty() && id == d->deleteAccountIqIq) { + QXmppIq iq; + iq.parse(stanza); + + switch (iq.type()) { + case QXmppIq::Result: + info(QStringLiteral("Account deleted successfully.")); + emit accountDeleted(); + client()->disconnectFromServer(); + break; + case QXmppIq::Error: + warning(QStringLiteral("Failed to delete account: ").append(iq.error().text())); + emit accountDeletionFailed(iq.error()); + break; + default: + break; // should never occur + } + + d->deleteAccountIqIq.clear(); + return true; } else if (QXmppRegisterIq::isRegisterIq(stanza)) { QXmppRegisterIq iq; iq.parse(stanza); |
