QXmpp Version: 1.10.0
QXmppMovedManager.h
1// SPDX-FileCopyrightText: 2024 Filipe Azevedo <pasnox@gmail.com>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPMOVEDMANAGER_H
6#define QXMPPMOVEDMANAGER_H
7
8#include "QXmppClientExtension.h"
9#include "QXmppSendResult.h"
10#include "QXmppTask.h"
11
12class QXmppPresence;
13class QXmppError;
14class QXmppMovedManagerPrivate;
15
16class QXMPP_EXPORT QXmppMovedManager : public QXmppClientExtension
17{
18 Q_OBJECT
19 Q_PROPERTY(bool supportedByServer READ supportedByServer NOTIFY supportedByServerChanged)
20
21public:
22 using Result = std::variant<QXmpp::Success, QXmppError>;
23
24 explicit QXmppMovedManager();
25 ~QXmppMovedManager() override;
26
27 QStringList discoveryFeatures() const override;
28
29 bool supportedByServer() const;
30 Q_SIGNAL void supportedByServerChanged();
31
32 QXmppTask<Result> publishStatement(const QString &newBareJid);
33 QXmppTask<Result> verifyStatement(const QString &oldBareJid, const QString &newBareJid);
34
35 QXmppTask<QXmpp::SendResult> notifyContact(const QString &contactBareJid, const QString &oldBareJid, bool sensitive = true, const QString &reason = {});
36
37protected:
39 void onRegistered(QXmppClient *client) override;
40 void onUnregistered(QXmppClient *client) override;
42
43private:
44 std::optional<QXmppTask<bool>> handleSubscriptionRequest(const QXmppPresence &presence);
45 void handleDiscoInfo(const QXmppDiscoveryIq &iq);
46 Result movedJidsMatch(const QString &newBareJid, const QString &pepBareJid) const;
47
48 void setSupportedByServer(bool supportedByServer);
49 void resetCachedData();
50
51 const std::unique_ptr<QXmppMovedManagerPrivate> d;
52
53 friend class QXmppRosterManager;
54 friend class tst_QXmppMovedManager;
55};
56
57#endif // QXMPPMOVEDMANAGER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:22
virtual void onUnregistered(QXmppClient *client)
Definition: QXmppClientExtension.cpp:95
virtual void onRegistered(QXmppClient *client)
Definition: QXmppClientExtension.cpp:85
Main class for starting and managing connections to XMPP servers.
Definition: QXmppClient.h:62
Definition: QXmppDiscoveryIq.h:18
Definition: QXmppMovedManager.h:17
std::variant< QXmpp::Success, QXmppError > Result
Definition: QXmppMovedManager.h:22
Q_SIGNAL void supportedByServerChanged()
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:22
The QXmppRosterManager class provides access to a connected client's roster.
Definition: QXmppRosterManager.h:57
Definition: QXmppTask.h:62
Definition: QXmppError.h:17