QXmpp  Version:1.1.0
QXmppRosterIq.h
1 /*
2  * Copyright (C) 2008-2019 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 
26 #ifndef QXMPPROSTERIQ_H
27 #define QXMPPROSTERIQ_H
28 
29 #include "QXmppIq.h"
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  {
52  None = 0,
53  From = 1,
56  To = 2,
58  Both = 3,
60  Remove = 4,
62  NotSet = 8
63  };
64 
65  Item();
66  Item(const Item &other);
67  ~Item();
68 
69  Item &operator=(const Item &other);
70 
71  QString bareJid() const;
72  QSet<QString> groups() const;
73  QString name() const;
74  QString subscriptionStatus() const;
75  SubscriptionType subscriptionType() const;
76 
77  void setBareJid(const QString&);
78  void setGroups(const QSet<QString>&);
79  void setName(const QString&);
80  void setSubscriptionStatus(const QString&);
81  void setSubscriptionType(SubscriptionType);
82 
84  void parse(const QDomElement &element);
85  void toXml(QXmlStreamWriter *writer) const;
87 
88  private:
89  QString getSubscriptionTypeStr() const;
90  void setSubscriptionTypeFromStr(const QString&);
91 
92  QSharedDataPointer<ItemPrivate> d;
93  };
94 
95  QXmppRosterIq();
97  ~QXmppRosterIq() override;
98 
99  QXmppRosterIq &operator=(const QXmppRosterIq &);
100 
101  QString version() const;
102  void setVersion(const QString&);
103 
104  void addItem(const Item&);
105  QList<Item> items() const;
106 
108  static bool isRosterIq(const QDomElement &element);
110 
111 protected:
113  void parseElementFromChild(const QDomElement &element) override;
114  void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
116 
117 private:
118  QSharedDataPointer<QXmppRosterIqPrivate> d;
119 };
120 
121 #endif // QXMPPROSTERIQ_H
The QXmppRosterIq class represents a roster IQ.
Definition: QXmppRosterIq.h:40
SubscriptionType
An enumeration for type of subscription with the bareJid in the roster.
Definition: QXmppRosterIq.h:50
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:42
The QXmppRosterIq::Item class represents a roster entry.
Definition: QXmppRosterIq.h:46