QXmppPresence.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 QXMPPPRESENCE_H
  24. #define QXMPPPRESENCE_H
  25. #include "QXmppStanza.h"
  26. #include "QXmppMucIq.h"
  27. class QXmppPresencePrivate;
  28. /// \brief The QXmppPresence class represents an XMPP presence stanza.
  29. ///
  30. /// \ingroup Stanzas
  31. class QXMPP_EXPORT QXmppPresence : public QXmppStanza
  32. {
  33. public:
  34. /// This enum is used to describe a presence type.
  35. enum Type
  36. {
  37. Error = 0, ///< An error has occurred regarding processing or delivery of a previously-sent presence stanza.
  38. Available, ///< Signals that the sender is online and available for communication.
  39. Unavailable, ///< Signals that the sender is no longer available for communication.
  40. Subscribe, ///< The sender wishes to subscribe to the recipient's presence.
  41. Subscribed, ///< The sender has allowed the recipient to receive their presence.
  42. Unsubscribe, ///< The sender is unsubscribing from another entity's presence.
  43. Unsubscribed, ///< The subscription request has been denied or a previously-granted subscription has been cancelled.
  44. Probe ///< A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user.
  45. };
  46. /// This enum is used to describe an availability status.
  47. enum AvailableStatusType
  48. {
  49. Online = 0, ///< The entity or resource is online.
  50. Away, ///< The entity or resource is temporarily away.
  51. XA, ///< The entity or resource is away for an extended period.
  52. DND, ///< The entity or resource is busy ("Do Not Disturb").
  53. Chat, ///< The entity or resource is actively interested in chatting.
  54. Invisible ///< obsolete XEP-0018: Invisible Presence
  55. };
  56. /// This enum is used to describe vCard updates as defined by
  57. /// XEP-0153: vCard-Based Avatars
  58. enum VCardUpdateType
  59. {
  60. VCardUpdateNone = 0, ///< Protocol is not supported
  61. VCardUpdateNoPhoto, ///< User is not using any image
  62. VCardUpdateValidPhoto, ///< User is advertising an image
  63. VCardUpdateNotReady ///< User is not ready to advertise an image
  64. /// \note This enables recipients to distinguish between the absence of an image
  65. /// (empty photo element) and mere support for the protocol (empty update child).
  66. };
  67. /// \cond
  68. // deprecated since 0.6.2
  69. class QXMPP_EXPORT Status
  70. {
  71. public:
  72. /// This enum is used to describe an availability status.
  73. enum Type
  74. {
  75. Online = 0, ///< The entity or resource is online.
  76. Away, ///< The entity or resource is temporarily away.
  77. XA, ///< The entity or resource is away for an extended period.
  78. DND, ///< The entity or resource is busy ("Do Not Disturb").
  79. Chat, ///< The entity or resource is actively interested in chatting.
  80. Invisible ///< obsolete XEP-0018: Invisible Presence
  81. };
  82. Status(QXmppPresence::Status::Type type = QXmppPresence::Status::Online,
  83. const QString statusText = "", int priority = 0);
  84. QXmppPresence::Status::Type type() const;
  85. void setType(QXmppPresence::Status::Type);
  86. QString statusText() const;
  87. void setStatusText(const QString&);
  88. int priority() const;
  89. void setPriority(int);
  90. void parse(const QDomElement &element);
  91. void toXml(QXmlStreamWriter *writer) const;
  92. private:
  93. QXmppPresence::Status::Type m_type;
  94. QString m_statusText;
  95. int m_priority;
  96. };
  97. QXmppPresence::Status Q_DECL_DEPRECATED &status();
  98. const QXmppPresence::Status Q_DECL_DEPRECATED &status() const;
  99. void Q_DECL_DEPRECATED setStatus(const QXmppPresence::Status&);
  100. /// \endcond
  101. QXmppPresence(QXmppPresence::Type type = QXmppPresence::Available);
  102. QXmppPresence(const QXmppPresence &other);
  103. ~QXmppPresence();
  104. QXmppPresence& operator=(const QXmppPresence &other);
  105. AvailableStatusType availableStatusType() const;
  106. void setAvailableStatusType(AvailableStatusType type);
  107. int priority() const;
  108. void setPriority(int priority);
  109. QXmppPresence::Type type() const;
  110. void setType(QXmppPresence::Type);
  111. QString statusText() const;
  112. void setStatusText(const QString& statusText);
  113. /// \cond
  114. void parse(const QDomElement &element);
  115. void toXml(QXmlStreamWriter *writer) const;
  116. /// \endcond
  117. // XEP-0045: Multi-User Chat
  118. QXmppMucItem mucItem() const;
  119. void setMucItem(const QXmppMucItem &item);
  120. QString mucPassword() const;
  121. void setMucPassword(const QString &password);
  122. QList<int> mucStatusCodes() const;
  123. void setMucStatusCodes(const QList<int> &codes);
  124. bool isMucSupported() const;
  125. void setMucSupported(bool supported);
  126. /// XEP-0153: vCard-Based Avatars
  127. QByteArray photoHash() const;
  128. void setPhotoHash(const QByteArray&);
  129. VCardUpdateType vCardUpdateType() const;
  130. void setVCardUpdateType(VCardUpdateType type);
  131. // XEP-0115: Entity Capabilities
  132. QString capabilityHash() const;
  133. void setCapabilityHash(const QString&);
  134. QString capabilityNode() const;
  135. void setCapabilityNode(const QString&);
  136. QByteArray capabilityVer() const;
  137. void setCapabilityVer(const QByteArray&);
  138. QStringList capabilityExt() const;
  139. private:
  140. QSharedDataPointer<QXmppPresencePrivate> d;
  141. };
  142. #endif // QXMPPPRESENCE_H