QXmpp  Version: 1.15.1
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  static constexpr std::tuple XmlTag = { u"ADR", QXmpp::Private::ns_vcard };
67  void parse(const QDomElement &element);
68  void toXml(QXmlStreamWriter *stream) const;
70 
71 private:
72  QSharedDataPointer<QXmppVCardAddressPrivate> d;
73 };
74 
75 QXMPP_EXPORT bool operator==(const QXmppVCardAddress &, const QXmppVCardAddress &);
76 QXMPP_EXPORT bool operator!=(const QXmppVCardAddress &, const QXmppVCardAddress &);
77 
79 
80 class QXMPP_EXPORT QXmppVCardEmail
81 {
82 public:
84  enum TypeFlag {
85  None = 0x0,
86  Home = 0x1,
87  Work = 0x2,
88  Internet = 0x4,
89  Preferred = 0x8,
90  X400 = 0x10
91  };
92  Q_DECLARE_FLAGS(Type, TypeFlag)
93 
95  QXmppVCardEmail(const QXmppVCardEmail &other);
96  ~QXmppVCardEmail();
97 
98  QXmppVCardEmail &operator=(const QXmppVCardEmail &other);
99 
100  QString address() const;
101  void setAddress(const QString &address);
102 
103  Type type() const;
104  void setType(Type type);
105 
107  static constexpr std::tuple XmlTag = { u"EMAIL", QXmpp::Private::ns_vcard };
108  void parse(const QDomElement &element);
109  void toXml(QXmlStreamWriter *stream) const;
111 
112 private:
113  QSharedDataPointer<QXmppVCardEmailPrivate> d;
114 };
115 
116 QXMPP_EXPORT bool operator==(const QXmppVCardEmail &, const QXmppVCardEmail &);
117 QXMPP_EXPORT bool operator!=(const QXmppVCardEmail &, const QXmppVCardEmail &);
118 
120 
121 class QXMPP_EXPORT QXmppVCardPhone
122 {
123 public:
125  enum TypeFlag {
126  None = 0x0,
127  Home = 0x1,
128  Work = 0x2,
129  Voice = 0x4,
130  Fax = 0x8,
131  Pager = 0x10,
132  Messaging = 0x20,
133  Cell = 0x40,
134  Video = 0x80,
135  BBS = 0x100,
136  Modem = 0x200,
137  ISDN = 0x400,
138  PCS = 0x800,
139  Preferred = 0x1000
140  };
141  Q_DECLARE_FLAGS(Type, TypeFlag)
142 
143  QXmppVCardPhone();
144  QXmppVCardPhone(const QXmppVCardPhone &other);
145  ~QXmppVCardPhone();
146 
147  QXmppVCardPhone &operator=(const QXmppVCardPhone &other);
148 
149  QString number() const;
150  void setNumber(const QString &number);
151 
152  Type type() const;
153  void setType(Type type);
154 
156  static constexpr std::tuple XmlTag = { u"TEL", QXmpp::Private::ns_vcard };
157  void parse(const QDomElement &element);
158  void toXml(QXmlStreamWriter *stream) const;
160 
161 private:
162  QSharedDataPointer<QXmppVCardPhonePrivate> d;
163 };
164 
165 QXMPP_EXPORT bool operator==(const QXmppVCardPhone &, const QXmppVCardPhone &);
166 QXMPP_EXPORT bool operator!=(const QXmppVCardPhone &, const QXmppVCardPhone &);
167 
172 
173 class QXMPP_EXPORT QXmppVCardOrganization
174 {
175 public:
179 
180  QXmppVCardOrganization &operator=(const QXmppVCardOrganization &other);
181 
182  QString organization() const;
183  void setOrganization(const QString &);
184 
185  QString unit() const;
186  void setUnit(const QString &);
187 
188  QString title() const;
189  void setTitle(const QString &);
190 
191  QString role() const;
192  void setRole(const QString &);
193 
195  void parse(const QDomElement &element);
196  void toXml(QXmlStreamWriter *stream) const;
198 
199 private:
200  QSharedDataPointer<QXmppVCardOrganizationPrivate> d;
201 };
202 
203 QXMPP_EXPORT bool operator==(const QXmppVCardOrganization &, const QXmppVCardOrganization &);
204 QXMPP_EXPORT bool operator!=(const QXmppVCardOrganization &, const QXmppVCardOrganization &);
205 
215 
216 class QXMPP_EXPORT QXmppVCardIq : public QXmppIq
217 {
218 public:
219  QXmppVCardIq(const QString &bareJid = QString());
220  QXmppVCardIq(const QXmppVCardIq &other);
221  ~QXmppVCardIq() override;
222 
223  QXmppVCardIq &operator=(const QXmppVCardIq &other);
224 
225  QDate birthday() const;
226  void setBirthday(const QDate &birthday);
227 
228  QString description() const;
229  void setDescription(const QString &description);
230 
231  QString email() const;
232  void setEmail(const QString &);
233 
234  QString firstName() const;
235  void setFirstName(const QString &);
236 
237  QString fullName() const;
238  void setFullName(const QString &);
239 
240  QString lastName() const;
241  void setLastName(const QString &);
242 
243  QString middleName() const;
244  void setMiddleName(const QString &);
245 
246  QString nickName() const;
247  void setNickName(const QString &);
248 
249  QByteArray photo() const;
250  void setPhoto(const QByteArray &);
251 
252  QString photoType() const;
253  void setPhotoType(const QString &type);
254 
255  QString url() const;
256  void setUrl(const QString &);
257 
258  QList<QXmppVCardAddress> addresses() const;
259  void setAddresses(const QList<QXmppVCardAddress> &addresses);
260 
261  QList<QXmppVCardEmail> emails() const;
262  void setEmails(const QList<QXmppVCardEmail> &emails);
263 
264  QList<QXmppVCardPhone> phones() const;
265  void setPhones(const QList<QXmppVCardPhone> &phones);
266 
267  QXmppVCardOrganization organization() const;
268  void setOrganization(const QXmppVCardOrganization &);
269 
271  static constexpr std::tuple PayloadXmlTag = { u"vCard", QXmpp::Private::ns_vcard };
272  [[deprecated("Use QXmpp::isIqElement()")]]
273  static bool isVCard(const QDomElement &element);
274  [[deprecated]]
275  static bool checkIqType(const QString &tagName, const QString &xmlNamespace);
277 
278 protected:
279  friend struct QXmpp::Private::VCardData;
280 
282  void parseElementFromChild(const QDomElement &) override;
283  void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
285 
286 private:
287  QSharedDataPointer<QXmppVCardIqPrivate> d;
288 };
289 
290 QXMPP_EXPORT bool operator==(const QXmppVCardIq &, const QXmppVCardIq &);
291 QXMPP_EXPORT bool operator!=(const QXmppVCardIq &, const QXmppVCardIq &);
292 
293 #endif // QXMPPVCARDIQ_H
Represents a vCard phone number.
Definition: QXmppVCardIq.h:121
TypeFlag
Describes e-mail address types.
Definition: QXmppVCardIq.h:30
TypeFlag
Describes phone number types.
Definition: QXmppVCardIq.h:125
TypeFlag
Describes e-mail address types.
Definition: QXmppVCardIq.h:84
Represents the XMPP vCard.
Definition: QXmppVCardIq.h:216
Represents a vCard e-mail address.
Definition: QXmppVCardIq.h:80
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:22
Definition: Algorithms.h:14
Represent a vCard address.
Definition: QXmppVCardIq.h:26
Represents organization information in XMPP vCards.
Definition: QXmppVCardIq.h:173
QXmppIq & operator=(const QXmppIq &other)
Assigns other to this IQ.