QXmpp  Version:1.0.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 
36 
37 class QXMPP_EXPORT QXmppRosterIq : public QXmppIq
38 {
39 public:
40 
42  class QXMPP_EXPORT Item
43  {
44  public:
47  {
48  None = 0,
49  From = 1,
52  To = 2,
54  Both = 3,
56  Remove = 4,
58  NotSet = 8
59  };
60 
61  Item();
62  QString bareJid() const;
63  QSet<QString> groups() const;
64  QString name() const;
65  QString subscriptionStatus() const;
66  SubscriptionType subscriptionType() const;
67 
68  void setBareJid(const QString&);
69  void setGroups(const QSet<QString>&);
70  void setName(const QString&);
71  void setSubscriptionStatus(const QString&);
72  void setSubscriptionType(SubscriptionType);
73 
75  void parse(const QDomElement &element);
76  void toXml(QXmlStreamWriter *writer) const;
78 
79  private:
80  QString getSubscriptionTypeStr() const;
81  void setSubscriptionTypeFromStr(const QString&);
82 
83  QString m_bareJid;
84  SubscriptionType m_type;
85  QString m_name;
86  // can be subscribe/unsubscribe (attribute "ask")
87  QString m_subscriptionStatus;
88  QSet<QString> m_groups;
89  };
90 
91  QString version() const;
92  void setVersion(const QString&);
93 
94  void addItem(const Item&);
95  QList<Item> items() const;
96 
98  static bool isRosterIq(const QDomElement &element);
100 
101 protected:
103  void parseElementFromChild(const QDomElement &element);
104  void toXmlElementFromChild(QXmlStreamWriter *writer) const;
106 
107 private:
108  QList<Item> m_items;
109  // XEP-0237 Roster Versioning
110  QString m_version;
111 };
112 
113 #endif // QXMPPROSTERIQ_H
QXmppRosterIq::Item
The QXmppRosterIq::Item class represents a roster entry.
Definition: QXmppRosterIq.h:42
QXmppRosterIq::Item::SubscriptionType
SubscriptionType
An enumeration for type of subscription with the bareJid in the roster.
Definition: QXmppRosterIq.h:46
QXmppRosterIq
The QXmppRosterIq class represents a roster IQ.
Definition: QXmppRosterIq.h:37
QXmppIq
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:42