QXmpp  Version:0.8.0
 All Classes Functions Variables Enumerations Enumerator Properties Groups
QXmppVCardIq.h
1 /*
2  * Copyright (C) 2008-2014 The QXmpp developers
3  *
4  * Author:
5  * Manjeet Dahiya
6  *
7  * Source:
8  * http://code.google.com/p/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 
88 
89 class QXMPP_EXPORT QXmppVCardEmail
90 {
91 public:
93  enum TypeFlag {
94  None = 0x0,
95  Home = 0x1,
96  Work = 0x2,
97  Internet = 0x4,
98  Preferred = 0x8,
99  X400 = 0x10
100  };
101  Q_DECLARE_FLAGS(Type, TypeFlag)
102 
103  QXmppVCardEmail();
104  QXmppVCardEmail(const QXmppVCardEmail &other);
105  ~QXmppVCardEmail();
106 
107  QXmppVCardEmail& operator=(const QXmppVCardEmail &other);
108 
109  QString address() const;
110  void setAddress(const QString &address);
111 
112  Type type() const;
113  void setType(Type type);
114 
116  void parse(const QDomElement &element);
117  void toXml(QXmlStreamWriter *stream) const;
119 
120 private:
121  QSharedDataPointer<QXmppVCardEmailPrivate> d;
122 };
123 
125 
126 class QXMPP_EXPORT QXmppVCardPhone
127 {
128 public:
130  enum TypeFlag {
131  None = 0x0,
132  Home = 0x1,
133  Work = 0x2,
134  Voice = 0x4,
135  Fax = 0x8,
136  Pager = 0x10,
137  Messaging = 0x20,
138  Cell = 0x40,
139  Video = 0x80,
140  BBS = 0x100,
141  Modem = 0x200,
142  ISDN = 0x400,
143  PCS = 0x800,
144  Preferred = 0x1000
145  };
146  Q_DECLARE_FLAGS(Type, TypeFlag)
147 
148  QXmppVCardPhone();
149  QXmppVCardPhone(const QXmppVCardPhone &other);
150  ~QXmppVCardPhone();
151 
152  QXmppVCardPhone& operator=(const QXmppVCardPhone &other);
153 
154  QString number() const;
155  void setNumber(const QString &number);
156 
157  Type type() const;
158  void setType(Type type);
159 
161  void parse(const QDomElement &element);
162  void toXml(QXmlStreamWriter *stream) const;
164 
165 private:
166  QSharedDataPointer<QXmppVCardPhonePrivate> d;
167 };
168 
173 
174 class QXMPP_EXPORT QXmppVCardOrganization
175 {
176 public:
177  QXmppVCardOrganization();
178  QXmppVCardOrganization(const QXmppVCardOrganization &other);
179  ~QXmppVCardOrganization();
180 
181  QXmppVCardOrganization& operator=(const QXmppVCardOrganization &other);
182 
183  QString organization() const;
184  void setOrganization(const QString&);
185 
186  QString unit() const;
187  void setUnit(const QString&);
188 
189  QString title() const;
190  void setTitle(const QString&);
191 
192  QString role() const;
193  void setRole(const QString&);
194 
196  void parse(const QDomElement &element);
197  void toXml(QXmlStreamWriter *stream) const;
199 
200 private:
201  QSharedDataPointer<QXmppVCardOrganizationPrivate> d;
202 };
203 
213 
214 class QXMPP_EXPORT QXmppVCardIq : public QXmppIq
215 {
216 public:
217  QXmppVCardIq(const QString& bareJid = "");
218  QXmppVCardIq(const QXmppVCardIq &other);
219  ~QXmppVCardIq();
220 
221  QXmppVCardIq& operator=(const QXmppVCardIq &other);
222 
223  QDate birthday() const;
224  void setBirthday(const QDate &birthday);
225 
226  QString description() const;
227  void setDescription(const QString &description);
228 
229  QString email() const;
230  void setEmail(const QString&);
231 
232  QString firstName() const;
233  void setFirstName(const QString&);
234 
235  QString fullName() const;
236  void setFullName(const QString&);
237 
238  QString lastName() const;
239  void setLastName(const QString&);
240 
241  QString middleName() const;
242  void setMiddleName(const QString&);
243 
244  QString nickName() const;
245  void setNickName(const QString&);
246 
247  QByteArray photo() const;
248  void setPhoto(const QByteArray&);
249 
250  QString photoType() const;
251  void setPhotoType(const QString &type);
252 
253  QString url() const;
254  void setUrl(const QString&);
255 
256  QList<QXmppVCardAddress> addresses() const;
257  void setAddresses(const QList<QXmppVCardAddress> &addresses);
258 
259  QList<QXmppVCardEmail> emails() const;
260  void setEmails(const QList<QXmppVCardEmail> &emails);
261 
262  QList<QXmppVCardPhone> phones() const;
263  void setPhones(const QList<QXmppVCardPhone> &phones);
264 
265  QXmppVCardOrganization organization() const;
266  void setOrganization(const QXmppVCardOrganization&);
267 
269  static bool isVCard(const QDomElement &element);
271 
272 protected:
274  void parseElementFromChild(const QDomElement&);
275  void toXmlElementFromChild(QXmlStreamWriter *writer) const;
277 
278 private:
279  QSharedDataPointer<QXmppVCardIqPrivate> d;
280 };
281 
282 #endif // QXMPPVCARDIQ_H