QXmppVCardIq.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright (C) 2008-2012 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. #ifndef QXMPPVCARDIQ_H
  24. #define QXMPPVCARDIQ_H
  25. #include "QXmppIq.h"
  26. #include <QDate>
  27. #include <QMap>
  28. #include <QDomElement>
  29. class QXmppVCardAddressPrivate;
  30. class QXmppVCardEmailPrivate;
  31. class QXmppVCardPhonePrivate;
  32. class QXmppVCardIqPrivate;
  33. /// \brief Represent a vCard address.
  34. class QXMPP_EXPORT QXmppVCardAddress
  35. {
  36. public:
  37. /// \brief Describes e-mail address types.
  38. enum TypeFlag {
  39. None = 0x0,
  40. Home = 0x1,
  41. Work = 0x2,
  42. Postal = 0x4,
  43. Preferred = 0x8
  44. };
  45. Q_DECLARE_FLAGS(Type, TypeFlag);
  46. QXmppVCardAddress();
  47. QXmppVCardAddress(const QXmppVCardAddress &other);
  48. ~QXmppVCardAddress();
  49. QXmppVCardAddress& operator=(const QXmppVCardAddress &other);
  50. QString country() const;
  51. void setCountry(const QString &country);
  52. QString locality() const;
  53. void setLocality(const QString &locality);
  54. QString postcode() const;
  55. void setPostcode(const QString &postcode);
  56. QString region() const;
  57. void setRegion(const QString &region);
  58. QString street() const;
  59. void setStreet(const QString &street);
  60. Type type() const;
  61. void setType(Type type);
  62. /// \cond
  63. void parse(const QDomElement &element);
  64. void toXml(QXmlStreamWriter *stream) const;
  65. /// \endcond
  66. private:
  67. QSharedDataPointer<QXmppVCardAddressPrivate> d;
  68. };
  69. /// \brief Represents a vCard e-mail address.
  70. class QXMPP_EXPORT QXmppVCardEmail
  71. {
  72. public:
  73. /// \brief Describes e-mail address types.
  74. enum TypeFlag {
  75. None = 0x0,
  76. Home = 0x1,
  77. Work = 0x2,
  78. Internet = 0x4,
  79. Preferred = 0x8,
  80. X400 = 0x10
  81. };
  82. Q_DECLARE_FLAGS(Type, TypeFlag);
  83. QXmppVCardEmail();
  84. QXmppVCardEmail(const QXmppVCardEmail &other);
  85. ~QXmppVCardEmail();
  86. QXmppVCardEmail& operator=(const QXmppVCardEmail &other);
  87. QString address() const;
  88. void setAddress(const QString &address);
  89. Type type() const;
  90. void setType(Type type);
  91. /// \cond
  92. void parse(const QDomElement &element);
  93. void toXml(QXmlStreamWriter *stream) const;
  94. /// \endcond
  95. private:
  96. QSharedDataPointer<QXmppVCardEmailPrivate> d;
  97. };
  98. /// \brief Represents a vCard phone number.
  99. class QXMPP_EXPORT QXmppVCardPhone
  100. {
  101. public:
  102. /// \brief Describes phone number types.
  103. enum TypeFlag {
  104. None = 0x0,
  105. Home = 0x1,
  106. Work = 0x2,
  107. Voice = 0x4,
  108. Fax = 0x8,
  109. Pager = 0x10,
  110. Messaging = 0x20,
  111. Cell = 0x40,
  112. Video = 0x80,
  113. BBS = 0x100,
  114. Modem = 0x200,
  115. ISDN = 0x400,
  116. PCS = 0x800,
  117. Preferred = 0x1000
  118. };
  119. Q_DECLARE_FLAGS(Type, TypeFlag);
  120. QXmppVCardPhone();
  121. QXmppVCardPhone(const QXmppVCardPhone &other);
  122. ~QXmppVCardPhone();
  123. QXmppVCardPhone& operator=(const QXmppVCardPhone &other);
  124. QString number() const;
  125. void setNumber(const QString &number);
  126. Type type() const;
  127. void setType(Type type);
  128. /// \cond
  129. void parse(const QDomElement &element);
  130. void toXml(QXmlStreamWriter *stream) const;
  131. /// \endcond
  132. private:
  133. QSharedDataPointer<QXmppVCardPhonePrivate> d;
  134. };
  135. /// \brief Represents the XMPP vCard.
  136. ///
  137. /// The functions names are self explanatory.
  138. /// Look at QXmppVCardManager and XEP-0054: vcard-temp for more details.
  139. ///
  140. /// There are many field of XMPP vCard which are not present in
  141. /// this class. File a issue for the same. We will add the requested
  142. /// field to this class.
  143. ///
  144. class QXMPP_EXPORT QXmppVCardIq : public QXmppIq
  145. {
  146. public:
  147. QXmppVCardIq(const QString& bareJid = "");
  148. QXmppVCardIq(const QXmppVCardIq &other);
  149. ~QXmppVCardIq();
  150. QXmppVCardIq& operator=(const QXmppVCardIq &other);
  151. QDate birthday() const;
  152. void setBirthday(const QDate &birthday);
  153. QString description() const;
  154. void setDescription(const QString &description);
  155. QString email() const;
  156. void setEmail(const QString&);
  157. QString firstName() const;
  158. void setFirstName(const QString&);
  159. QString fullName() const;
  160. void setFullName(const QString&);
  161. QString lastName() const;
  162. void setLastName(const QString&);
  163. QString middleName() const;
  164. void setMiddleName(const QString&);
  165. QString nickName() const;
  166. void setNickName(const QString&);
  167. QByteArray photo() const;
  168. void setPhoto(const QByteArray&);
  169. QString photoType() const;
  170. void setPhotoType(const QString &type);
  171. QString url() const;
  172. void setUrl(const QString&);
  173. QList<QXmppVCardAddress> addresses() const;
  174. void setAddresses(const QList<QXmppVCardAddress> &addresses);
  175. QList<QXmppVCardEmail> emails() const;
  176. void setEmails(const QList<QXmppVCardEmail> &emails);
  177. QList<QXmppVCardPhone> phones() const;
  178. void setPhones(const QList<QXmppVCardPhone> &phones);
  179. /// \cond
  180. static bool isVCard(const QDomElement &element);
  181. /// \endcond
  182. protected:
  183. /// \cond
  184. void parseElementFromChild(const QDomElement&);
  185. void toXmlElementFromChild(QXmlStreamWriter *writer) const;
  186. /// \endcond
  187. private:
  188. QSharedDataPointer<QXmppVCardIqPrivate> d;
  189. };
  190. #endif // QXMPPVCARDIQ_H