QXmpp  Version:0.9.1
QXmppVCardIq.h
1 /*
2  * Copyright (C) 2008-2014 The QXmpp developers
3  *
4  * Author:
5  * Manjeet Dahiya
6  *
7  * Source:
8  * https://github.com/qxmpp-project/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 
25 #ifndef QXMPPVCARDIQ_H
26 #define QXMPPVCARDIQ_H
27 
28 #include "QXmppIq.h"
29 #include <QDate>
30 #include <QMap>
31 #include <QDomElement>
32 
33 class QXmppVCardAddressPrivate;
34 class QXmppVCardEmailPrivate;
35 class QXmppVCardPhonePrivate;
36 class QXmppVCardOrganizationPrivate;
37 class QXmppVCardIqPrivate;
38 
40 
41 class QXMPP_EXPORT QXmppVCardAddress
42 {
43 public:
45  enum TypeFlag {
46  None = 0x0,
47  Home = 0x1,
48  Work = 0x2,
49  Postal = 0x4,
50  Preferred = 0x8
51  };
52  Q_DECLARE_FLAGS(Type, TypeFlag)
53 
55  QXmppVCardAddress(const QXmppVCardAddress &other);
56  ~QXmppVCardAddress();
57 
58  QXmppVCardAddress& operator=(const QXmppVCardAddress &other);
59 
60  QString country() const;
61  void setCountry(const QString &country);
62 
63  QString locality() const;
64  void setLocality(const QString &locality);
65 
66  QString postcode() const;
67  void setPostcode(const QString &postcode);
68 
69  QString region() const;
70  void setRegion(const QString &region);
71 
72  QString street() const;
73  void setStreet(const QString &street);
74 
75  Type type() const;
76  void setType(Type type);
77 
79  void parse(const QDomElement &element);
80  void toXml(QXmlStreamWriter *stream) const;
82 
83 private:
84  QSharedDataPointer<QXmppVCardAddressPrivate> d;
85 };
86 
87 QXMPP_EXPORT bool operator==(const QXmppVCardAddress&, const QXmppVCardAddress&);
88 QXMPP_EXPORT bool operator!=(const QXmppVCardAddress&, const QXmppVCardAddress&);
89 
91 
92 class QXMPP_EXPORT QXmppVCardEmail
93 {
94 public:
96  enum TypeFlag {
97  None = 0x0,
98  Home = 0x1,
99  Work = 0x2,
100  Internet = 0x4,
101  Preferred = 0x8,
102  X400 = 0x10
103  };
104  Q_DECLARE_FLAGS(Type, TypeFlag)
105 
106  QXmppVCardEmail();
107  QXmppVCardEmail(const QXmppVCardEmail &other);
108  ~QXmppVCardEmail();
109 
110  QXmppVCardEmail& operator=(const QXmppVCardEmail &other);
111 
112  QString address() const;
113  void setAddress(const QString &address);
114 
115  Type type() const;
116  void setType(Type type);
117 
119  void parse(const QDomElement &element);
120  void toXml(QXmlStreamWriter *stream) const;
122 
123 private:
124  QSharedDataPointer<QXmppVCardEmailPrivate> d;
125 };
126 
127 QXMPP_EXPORT bool operator==(const QXmppVCardEmail&, const QXmppVCardEmail&);
128 QXMPP_EXPORT bool operator!=(const QXmppVCardEmail&, const QXmppVCardEmail&);
129 
131 
132 class QXMPP_EXPORT QXmppVCardPhone
133 {
134 public:
136  enum TypeFlag {
137  None = 0x0,
138  Home = 0x1,
139  Work = 0x2,
140  Voice = 0x4,
141  Fax = 0x8,
142  Pager = 0x10,
143  Messaging = 0x20,
144  Cell = 0x40,
145  Video = 0x80,
146  BBS = 0x100,
147  Modem = 0x200,
148  ISDN = 0x400,
149  PCS = 0x800,
150  Preferred = 0x1000
151  };
152  Q_DECLARE_FLAGS(Type, TypeFlag)
153 
154  QXmppVCardPhone();
155  QXmppVCardPhone(const QXmppVCardPhone &other);
156  ~QXmppVCardPhone();
157 
158  QXmppVCardPhone& operator=(const QXmppVCardPhone &other);
159 
160  QString number() const;
161  void setNumber(const QString &number);
162 
163  Type type() const;
164  void setType(Type type);
165 
167  void parse(const QDomElement &element);
168  void toXml(QXmlStreamWriter *stream) const;
170 
171 private:
172  QSharedDataPointer<QXmppVCardPhonePrivate> d;
173 };
174 
175 QXMPP_EXPORT bool operator==(const QXmppVCardPhone&, const QXmppVCardPhone&);
176 QXMPP_EXPORT bool operator!=(const QXmppVCardPhone&, const QXmppVCardPhone&);
177 
182 
183 class QXMPP_EXPORT QXmppVCardOrganization
184 {
185 public:
186  QXmppVCardOrganization();
187  QXmppVCardOrganization(const QXmppVCardOrganization &other);
188  ~QXmppVCardOrganization();
189 
190  QXmppVCardOrganization& operator=(const QXmppVCardOrganization &other);
191 
192  QString organization() const;
193  void setOrganization(const QString&);
194 
195  QString unit() const;
196  void setUnit(const QString&);
197 
198  QString title() const;
199  void setTitle(const QString&);
200 
201  QString role() const;
202  void setRole(const QString&);
203 
205  void parse(const QDomElement &element);
206  void toXml(QXmlStreamWriter *stream) const;
208 
209 private:
210  QSharedDataPointer<QXmppVCardOrganizationPrivate> d;
211 };
212 
213 QXMPP_EXPORT bool operator==(const QXmppVCardOrganization&, const QXmppVCardOrganization&);
214 QXMPP_EXPORT bool operator!=(const QXmppVCardOrganization&, const QXmppVCardOrganization&);
215 
225 
226 class QXMPP_EXPORT QXmppVCardIq : public QXmppIq
227 {
228 public:
229  QXmppVCardIq(const QString& bareJid = QString());
230  QXmppVCardIq(const QXmppVCardIq &other);
231  ~QXmppVCardIq();
232 
233  QXmppVCardIq& operator=(const QXmppVCardIq &other);
234 
235  QDate birthday() const;
236  void setBirthday(const QDate &birthday);
237 
238  QString description() const;
239  void setDescription(const QString &description);
240 
241  QString email() const;
242  void setEmail(const QString&);
243 
244  QString firstName() const;
245  void setFirstName(const QString&);
246 
247  QString fullName() const;
248  void setFullName(const QString&);
249 
250  QString lastName() const;
251  void setLastName(const QString&);
252 
253  QString middleName() const;
254  void setMiddleName(const QString&);
255 
256  QString nickName() const;
257  void setNickName(const QString&);
258 
259  QByteArray photo() const;
260  void setPhoto(const QByteArray&);
261 
262  QString photoType() const;
263  void setPhotoType(const QString &type);
264 
265  QString url() const;
266  void setUrl(const QString&);
267 
268  QList<QXmppVCardAddress> addresses() const;
269  void setAddresses(const QList<QXmppVCardAddress> &addresses);
270 
271  QList<QXmppVCardEmail> emails() const;
272  void setEmails(const QList<QXmppVCardEmail> &emails);
273 
274  QList<QXmppVCardPhone> phones() const;
275  void setPhones(const QList<QXmppVCardPhone> &phones);
276 
277  QXmppVCardOrganization organization() const;
278  void setOrganization(const QXmppVCardOrganization&);
279 
281  static bool isVCard(const QDomElement &element);
283 
284 protected:
286  void parseElementFromChild(const QDomElement&);
287  void toXmlElementFromChild(QXmlStreamWriter *writer) const;
289 
290 private:
291  QSharedDataPointer<QXmppVCardIqPrivate> d;
292 };
293 
294 QXMPP_EXPORT bool operator==(const QXmppVCardIq&, const QXmppVCardIq&);
295 QXMPP_EXPORT bool operator!=(const QXmppVCardIq&, const QXmppVCardIq&);
296 
297 #endif // QXMPPVCARDIQ_H
Represents a vCard phone number.
Definition: QXmppVCardIq.h:132
TypeFlag
Describes e-mail address types.
Definition: QXmppVCardIq.h:45
TypeFlag
Describes phone number types.
Definition: QXmppVCardIq.h:136
TypeFlag
Describes e-mail address types.
Definition: QXmppVCardIq.h:96
Represents the XMPP vCard.
Definition: QXmppVCardIq.h:226
Represents a vCard e-mail address.
Definition: QXmppVCardIq.h:92
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:42
Represent a vCard address.
Definition: QXmppVCardIq.h:41
Represents organization information in XMPP vCards.
Definition: QXmppVCardIq.h:183
QXmppIq & operator=(const QXmppIq &other)
Assigns other to this IQ.
Definition: QXmppIq.cpp:70