QXmpp  Version:1.2.0
QXmppRosterIq.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 QXMPPROSTERIQ_H
26 #define QXMPPROSTERIQ_H
27 
28 #include "QXmppIq.h"
29 
30 #include <QList>
31 #include <QSet>
32 #include <QSharedDataPointer>
33 
34 class QXmppRosterIqPrivate;
35 
39 
40 class QXMPP_EXPORT QXmppRosterIq : public QXmppIq
41 {
42 public:
43  class ItemPrivate;
44 
46  class QXMPP_EXPORT Item
47  {
48  public:
51  None = 0,
52  From = 1,
55  To = 2,
57  Both = 3,
59  Remove = 4,
61  NotSet = 8
62  };
63 
64  Item();
65  Item(const Item &other);
66  ~Item();
67 
68  Item &operator=(const Item &other);
69 
70  QString bareJid() const;
71  QSet<QString> groups() const;
72  QString name() const;
73  QString subscriptionStatus() const;
74  SubscriptionType subscriptionType() const;
75 
76  void setBareJid(const QString &);
77  void setGroups(const QSet<QString> &);
78  void setName(const QString &);
79  void setSubscriptionStatus(const QString &);
80  void setSubscriptionType(SubscriptionType);
81 
83  void parse(const QDomElement &element);
84  void toXml(QXmlStreamWriter *writer) const;
86 
87  private:
88  QString getSubscriptionTypeStr() const;
89  void setSubscriptionTypeFromStr(const QString &);
90 
91  QSharedDataPointer<ItemPrivate> d;
92  };
93 
94  QXmppRosterIq();
96  ~QXmppRosterIq() override;
97 
98  QXmppRosterIq &operator=(const QXmppRosterIq &);
99 
100  QString version() const;
101  void setVersion(const QString &);
102 
103  void addItem(const Item &);
104  QList<Item> items() const;
105 
107  static bool isRosterIq(const QDomElement &element);
109 
110 protected:
112  void parseElementFromChild(const QDomElement &element) override;
113  void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
115 
116 private:
117  QSharedDataPointer<QXmppRosterIqPrivate> d;
118 };
119 
120 #endif // QXMPPROSTERIQ_H
QXmppRosterIq::Item
The QXmppRosterIq::Item class represents a roster entry.
Definition: QXmppRosterIq.h:46
QXmppRosterIq::Item::SubscriptionType
SubscriptionType
An enumeration for type of subscription with the bareJid in the roster.
Definition: QXmppRosterIq.h:50
QXmppRosterIq
The QXmppRosterIq class represents a roster IQ.
Definition: QXmppRosterIq.h:40
QXmppIq
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:41