QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
QXmppRosterManager.h
1// SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com>
2// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
3// SPDX-FileCopyrightText: 2021 Melvin Keskin <melvo@olomono.de>
4//
5// SPDX-License-Identifier: LGPL-2.1-or-later
6
7#ifndef QXMPPROSTERMANAGER_H
8#define QXMPPROSTERMANAGER_H
9
10#include "QXmppClientExtension.h"
11#include "QXmppPresence.h"
12#include "QXmppRosterIq.h"
13#include "QXmppSendResult.h"
14
15#include <variant>
16
17#include <QMap>
18#include <QObject>
19#include <QStringList>
20
21template<typename T>
22class QXmppTask;
23class QXmppRosterManagerPrivate;
24
55class QXMPP_EXPORT QXmppRosterManager : public QXmppClientExtension
56{
57 Q_OBJECT
58
59public:
61 using Result = std::variant<QXmpp::Success, QXmppError>;
62
64 ~QXmppRosterManager() override;
65
66 bool isRosterReceived() const;
67 QStringList getRosterBareJids() const;
68 QXmppRosterIq::Item getRosterEntry(const QString &bareJid) const;
69
70 QStringList getResources(const QString &bareJid) const;
71 QMap<QString, QXmppPresence> getAllPresencesForBareJid(
72 const QString &bareJid) const;
73 QXmppPresence getPresence(const QString &bareJid,
74 const QString &resource) const;
75
76 QXmppTask<Result> addRosterItem(const QString &bareJid, const QString &name = {}, const QSet<QString> &groups = {});
77 QXmppTask<Result> removeRosterItem(const QString &bareJid);
78 QXmppTask<Result> renameRosterItem(const QString &bareJid, const QString &name);
79 QXmppTask<QXmpp::SendResult> subscribeTo(const QString &bareJid, const QString &reason = {});
80 QXmppTask<QXmpp::SendResult> unsubscribeFrom(const QString &bareJid, const QString &reason = {});
81
83 bool handleStanza(const QDomElement &element) override;
85
86public Q_SLOTS:
87 bool acceptSubscription(const QString &bareJid, const QString &reason = {});
88 bool refuseSubscription(const QString &bareJid, const QString &reason = {});
89 bool addItem(const QString &bareJid, const QString &name = {}, const QSet<QString> &groups = {});
90 bool removeItem(const QString &bareJid);
91 bool renameItem(const QString &bareJid, const QString &name);
92 bool subscribe(const QString &bareJid, const QString &reason = {});
93 bool unsubscribe(const QString &bareJid, const QString &reason = {});
94
95Q_SIGNALS:
105
107 void presenceChanged(const QString &bareJid, const QString &resource);
108
116 void subscriptionReceived(const QString &bareJid);
117
118 void subscriptionRequestReceived(const QString &subscriberBareJid, const QXmppPresence &presence);
119
122 void itemAdded(const QString &bareJid);
123
126 void itemChanged(const QString &bareJid);
127
130 void itemRemoved(const QString &bareJid);
131
132private Q_SLOTS:
133 void _q_connected();
134 void _q_disconnected();
135 void _q_presenceReceived(const QXmppPresence &);
136
137private:
138 const std::unique_ptr<QXmppRosterManagerPrivate> d;
139};
140
141#endif // QXMPPROSTER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:33
virtual bool handleStanza(const QDomElement &stanza)
You need to implement this method to process incoming XMPP stanzas.
Definition QXmppClientExtension.cpp:51
The QXmppClient class is the main class for using QXmpp.
Definition QXmppClient.h:84
The QXmppPresence class represents an XMPP presence stanza.
Definition QXmppPresence.h:21
The QXmppRosterIq::Item class represents a roster entry.
Definition QXmppRosterIq.h:28
The QXmppRosterManager class provides access to a connected client's roster.
Definition QXmppRosterManager.h:56
void subscriptionReceived(const QString &bareJid)
void subscriptionRequestReceived(const QString &subscriberBareJid, const QXmppPresence &presence)
void itemRemoved(const QString &bareJid)
void itemChanged(const QString &bareJid)
void itemAdded(const QString &bareJid)
void presenceChanged(const QString &bareJid, const QString &resource)
This signal is emitted when the presence of a particular bareJid and resource changes.
std::variant< QXmpp::Success, QXmppError > Result
Empty result containing QXmpp::Success or a QXmppError.
Definition QXmppRosterManager.h:61
Definition QXmppTask.h:62