QXmpp  Version: 1.4.0
QXmppRosterManager.h
1 /*
2  * Copyright (C) 2008-2021 The QXmpp developers
3  *
4  * Authors:
5  * Manjeet Dahiya
6  * Jeremy LainĂ©
7  *
8  * Source:
9  * https://github.com/qxmpp-project/qxmpp
10  *
11  * This file is a part of QXmpp library.
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  */
24 
25 #ifndef QXMPPROSTERMANAGER_H
26 #define QXMPPROSTERMANAGER_H
27 
28 #include "QXmppClientExtension.h"
29 #include "QXmppPresence.h"
30 #include "QXmppRosterIq.h"
31 
32 #include <QMap>
33 #include <QObject>
34 #include <QStringList>
35 
36 class QXmppRosterManagerPrivate;
37 
68 class QXMPP_EXPORT QXmppRosterManager : public QXmppClientExtension
69 {
70  Q_OBJECT
71 
72 public:
74  ~QXmppRosterManager() override;
75 
76  bool isRosterReceived() const;
77  QStringList getRosterBareJids() const;
78  QXmppRosterIq::Item getRosterEntry(const QString &bareJid) const;
79 
80  QStringList getResources(const QString &bareJid) const;
81  QMap<QString, QXmppPresence> getAllPresencesForBareJid(
82  const QString &bareJid) const;
83  QXmppPresence getPresence(const QString &bareJid,
84  const QString &resource) const;
85 
87  bool handleStanza(const QDomElement &element) override;
89 
90 public Q_SLOTS:
91  bool acceptSubscription(const QString &bareJid, const QString &reason = {});
92  bool refuseSubscription(const QString &bareJid, const QString &reason = {});
93  bool addItem(const QString &bareJid, const QString &name = {}, const QSet<QString> &groups = {});
94  bool removeItem(const QString &bareJid);
95  bool renameItem(const QString &bareJid, const QString &name);
96  bool subscribe(const QString &bareJid, const QString &reason = {});
97  bool unsubscribe(const QString &bareJid, const QString &reason = {});
98 
99 Q_SIGNALS:
109 
111  void presenceChanged(const QString &bareJid, const QString &resource);
112 
120  void subscriptionReceived(const QString &bareJid);
121 
124  void itemAdded(const QString &bareJid);
125 
128  void itemChanged(const QString &bareJid);
129 
132  void itemRemoved(const QString &bareJid);
133 
134 private Q_SLOTS:
135  void _q_connected();
136  void _q_disconnected();
137  void _q_presenceReceived(const QXmppPresence &);
138 
139 private:
140  QXmppRosterManagerPrivate *d;
141 };
142 
143 #endif // QXMPPROSTER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:94
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:36
The QXmppRosterIq::Item class represents a roster entry.
Definition: QXmppRosterIq.h:47
The QXmppRosterManager class provides access to a connected client's roster.
Definition: QXmppRosterManager.h:69
void subscriptionReceived(const QString &bareJid)
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.