QXmpp  Version: 1.10.4
QXmppVCardIq.h
1 // SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com>
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 
5 #ifndef QXMPPVCARDIQ_H
6 #define QXMPPVCARDIQ_H
7 
8 #include "QXmppIq.h"
9 
10 #include <QDate>
11 #include <QDomElement>
12 #include <QMap>
13 
14 namespace QXmpp::Private {
15 struct VCardData;
16 }
17 
18 class QXmppVCardAddressPrivate;
19 class QXmppVCardEmailPrivate;
20 class QXmppVCardPhonePrivate;
21 class QXmppVCardOrganizationPrivate;
22 class QXmppVCardIqPrivate;
23 
25 
26 class QXMPP_EXPORT QXmppVCardAddress
27 {
28 public:
30  enum TypeFlag {
31  None = 0x0,
32  Home = 0x1,
33  Work = 0x2,
34  Postal = 0x4,
35  Preferred = 0x8
36  };
37  Q_DECLARE_FLAGS(Type, TypeFlag)
38 
43 
44  QXmppVCardAddress &operator=(const QXmppVCardAddress &other);
45  QXmppVCardAddress &operator=(QXmppVCardAddress &&);
46 
47  QString country() const;
48  void setCountry(const QString &country);
49 
50  QString locality() const;
51  void setLocality(const QString &locality);
52 
53  QString postcode() const;
54  void setPostcode(const QString &postcode);
55 
56  QString region() const;
57  void setRegion(const QString &region);
58 
59  QString street() const;
60  void setStreet(const QString &street);
61 
62  Type type() const;
63  void setType(Type type);
64 
66  void parse(const QDomElement &element);
67  void toXml(QXmlStreamWriter *stream) const;
69 
70 private:
71  QSharedDataPointer<QXmppVCardAddressPrivate> d;
72 };
73 
74 QXMPP_EXPORT bool operator==(const QXmppVCardAddress &, const QXmppVCardAddress &);
75 QXMPP_EXPORT bool operator!=(const QXmppVCardAddress &, const QXmppVCardAddress &);
76 
78 
79 class QXMPP_EXPORT QXmppVCardEmail
80 {
81 public:
83  enum TypeFlag {
84  None = 0x0,
85  Home = 0x1,
86  Work = 0x2,
87  Internet = 0x4,
88  Preferred = 0x8,
89  X400 = 0x10
90  };
91  Q_DECLARE_FLAGS(Type, TypeFlag)
92 
94  QXmppVCardEmail(const QXmppVCardEmail &other);
95  ~QXmppVCardEmail();
96 
97  QXmppVCardEmail &operator=(const QXmppVCardEmail &other);
98 
99  QString address() const;
100  void setAddress(const QString &address);
101 
102  Type type() const;
103  void setType(Type type);
104 
106  void parse(const QDomElement &element);
107  void toXml(QXmlStreamWriter *stream) const;
109 
110 private:
111  QSharedDataPointer<QXmppVCardEmailPrivate> d;
112 };
113 
114 QXMPP_EXPORT bool operator==(const QXmppVCardEmail &, const QXmppVCardEmail &);
115 QXMPP_EXPORT bool operator!=(const QXmppVCardEmail &, const QXmppVCardEmail &);
116 
118 
119 class QXMPP_EXPORT QXmppVCardPhone
120 {
121 public:
123  enum TypeFlag {
124  None = 0x0,
125  Home = 0x1,
126  Work = 0x2,
127  Voice = 0x4,
128  Fax = 0x8,
129  Pager = 0x10,
130  Messaging = 0x20,
131  Cell = 0x40,
132  Video = 0x80,
133  BBS = 0x100,
134  Modem = 0x200,
135  ISDN = 0x400,
136  PCS = 0x800,
137  Preferred = 0x1000
138  };
139  Q_DECLARE_FLAGS(Type, TypeFlag)
140 
141  QXmppVCardPhone();
142  QXmppVCardPhone(const QXmppVCardPhone &other);
143  ~QXmppVCardPhone();
144 
145  QXmppVCardPhone &operator=(const QXmppVCardPhone &other);
146 
147  QString number() const;
148  void setNumber(const QString &number);
149 
150  Type type() const;
151  void setType(Type type);
152 
154  void parse(const QDomElement &element);
155  void toXml(QXmlStreamWriter *stream) const;
157 
158 private:
159  QSharedDataPointer<QXmppVCardPhonePrivate> d;
160 };
161 
162 QXMPP_EXPORT bool operator==(const QXmppVCardPhone &, const QXmppVCardPhone &);
163 QXMPP_EXPORT bool operator!=(const QXmppVCardPhone &, const QXmppVCardPhone &);
164 
169 
170 class QXMPP_EXPORT QXmppVCardOrganization
171 {
172 public:
176 
177  QXmppVCardOrganization &operator=(const QXmppVCardOrganization &other);
178 
179  QString organization() const;
180  void setOrganization(const QString &);
181 
182  QString unit() const;
183  void setUnit(const QString &);
184 
185  QString title() const;
186  void setTitle(const QString &);
187 
188  QString role() const;
189  void setRole(const QString &);
190 
192  void parse(const QDomElement &element);
193  void toXml(QXmlStreamWriter *stream) const;
195 
196 private:
197  QSharedDataPointer<QXmppVCardOrganizationPrivate> d;
198 };
199 
200 QXMPP_EXPORT bool operator==(const QXmppVCardOrganization &, const QXmppVCardOrganization &);
201 QXMPP_EXPORT bool operator!=(const QXmppVCardOrganization &, const QXmppVCardOrganization &);
202 
212 
213 class QXMPP_EXPORT QXmppVCardIq : public QXmppIq
214 {
215 public:
216  QXmppVCardIq(const QString &bareJid = QString());
217  QXmppVCardIq(const QXmppVCardIq &other);
218  ~QXmppVCardIq() override;
219 
220  QXmppVCardIq &operator=(const QXmppVCardIq &other);
221 
222  QDate birthday() const;
223  void setBirthday(const QDate &birthday);
224 
225  QString description() const;
226  void setDescription(const QString &description);
227 
228  QString email() const;
229  void setEmail(const QString &);
230 
231  QString firstName() const;
232  void setFirstName(const QString &);
233 
234  QString fullName() const;
235  void setFullName(const QString &);
236 
237  QString lastName() const;
238  void setLastName(const QString &);
239 
240  QString middleName() const;
241  void setMiddleName(const QString &);
242 
243  QString nickName() const;
244  void setNickName(const QString &);
245 
246  QByteArray photo() const;
247  void setPhoto(const QByteArray &);
248 
249  QString photoType() const;
250  void setPhotoType(const QString &type);
251 
252  QString url() const;
253  void setUrl(const QString &);
254 
255  QList<QXmppVCardAddress> addresses() const;
256  void setAddresses(const QList<QXmppVCardAddress> &addresses);
257 
258  QList<QXmppVCardEmail> emails() const;
259  void setEmails(const QList<QXmppVCardEmail> &emails);
260 
261  QList<QXmppVCardPhone> phones() const;
262  void setPhones(const QList<QXmppVCardPhone> &phones);
263 
264  QXmppVCardOrganization organization() const;
265  void setOrganization(const QXmppVCardOrganization &);
266 
268  static bool isVCard(const QDomElement &element);
269  static bool checkIqType(const QString &tagName, const QString &xmlNamespace);
271 
272 protected:
273  friend struct QXmpp::Private::VCardData;
274 
276  void parseElementFromChild(const QDomElement &) override;
277  void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
279 
280 private:
281  QSharedDataPointer<QXmppVCardIqPrivate> d;
282 };
283 
284 QXMPP_EXPORT bool operator==(const QXmppVCardIq &, const QXmppVCardIq &);
285 QXMPP_EXPORT bool operator!=(const QXmppVCardIq &, const QXmppVCardIq &);
286 
287 #endif // QXMPPVCARDIQ_H
Represents a vCard phone number.
Definition: QXmppVCardIq.h:119
TypeFlag
Describes e-mail address types.
Definition: QXmppVCardIq.h:30
TypeFlag
Describes phone number types.
Definition: QXmppVCardIq.h:123
TypeFlag
Describes e-mail address types.
Definition: QXmppVCardIq.h:83
Represents the XMPP vCard.
Definition: QXmppVCardIq.h:213
Represents a vCard e-mail address.
Definition: QXmppVCardIq.h:79
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:22
Definition: Algorithms.h:12
Represent a vCard address.
Definition: QXmppVCardIq.h:26
Represents organization information in XMPP vCards.
Definition: QXmppVCardIq.h:170
QXmppIq & operator=(const QXmppIq &other)
Assigns other to this IQ.