QXmpp  Version:1.3.0
QXmppRosterManager.h
1 /*
2  * Copyright (C) 2008-2020 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 
66 
67 class QXMPP_EXPORT QXmppRosterManager : public QXmppClientExtension
68 {
69  Q_OBJECT
70 
71 public:
73  ~QXmppRosterManager() override;
74 
75  bool isRosterReceived() const;
76  QStringList getRosterBareJids() const;
77  QXmppRosterIq::Item getRosterEntry(const QString &bareJid) const;
78 
79  QStringList getResources(const QString &bareJid) const;
80  QMap<QString, QXmppPresence> getAllPresencesForBareJid(
81  const QString &bareJid) const;
82  QXmppPresence getPresence(const QString &bareJid,
83  const QString &resource) const;
84 
86  bool handleStanza(const QDomElement &element) override;
88 
89 public Q_SLOTS:
90  bool acceptSubscription(const QString &bareJid, const QString &reason = QString());
91  bool refuseSubscription(const QString &bareJid, const QString &reason = QString());
92  bool addItem(const QString &bareJid, const QString &name = QString(), const QSet<QString> &groups = QSet<QString>());
93  bool removeItem(const QString &bareJid);
94  bool renameItem(const QString &bareJid, const QString &name);
95  bool subscribe(const QString &bareJid, const QString &reason = QString());
96  bool unsubscribe(const QString &bareJid, const QString &reason = QString());
97 
98 Q_SIGNALS:
103  void rosterReceived();
104 
106  void presenceChanged(const QString &bareJid, const QString &resource);
107 
115  void subscriptionReceived(const QString &bareJid);
116 
119  void itemAdded(const QString &bareJid);
120 
123  void itemChanged(const QString &bareJid);
124 
127  void itemRemoved(const QString &bareJid);
128 
129 private Q_SLOTS:
130  void _q_connected();
131  void _q_disconnected();
132  void _q_presenceReceived(const QXmppPresence &);
133 
134 private:
135  QXmppRosterManagerPrivate *d;
136 };
137 
138 #endif // QXMPPROSTER_H
QXmppRosterIq::Item
The QXmppRosterIq::Item class represents a roster entry.
Definition: QXmppRosterIq.h:46
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:35
QXmppRosterManager
The QXmppRosterManager class provides access to a connected client's roster.
Definition: QXmppRosterManager.h:67
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:94
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.