QXmppPubSubIq.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2008-2012 The QXmpp developers
  3. *
  4. * Author:
  5. * Jeremy Lainé
  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 QXMPPPUBSUBIQ_H
  24. #define QXMPPPUBSUBIQ_H
  25. #include "QXmppIq.h"
  26. /// \brief The QXmppPubSubItem class represents a publish-subscribe item
  27. /// as defined by XEP-0060: Publish-Subscribe.
  28. ///
  29. class QXMPP_EXPORT QXmppPubSubItem
  30. {
  31. public:
  32. QString id() const;
  33. void setId(const QString &id);
  34. QXmppElement contents() const;
  35. void setContents(const QXmppElement &contents);
  36. /// \cond
  37. void parse(const QDomElement &element);
  38. void toXml(QXmlStreamWriter *writer) const;
  39. /// \endcond
  40. private:
  41. QString m_id;
  42. QXmppElement m_contents;
  43. };
  44. /// \brief The QXmppPubSubIq class represents an IQ used for the
  45. /// publish-subscribe mechanisms defined by XEP-0060: Publish-Subscribe.
  46. ///
  47. /// \ingroup Stanzas
  48. class QXMPP_EXPORT QXmppPubSubIq : public QXmppIq
  49. {
  50. public:
  51. /// This enum is used to describe a publish-subscribe query type.
  52. enum QueryType
  53. {
  54. AffiliationsQuery,
  55. DefaultQuery,
  56. ItemsQuery,
  57. PublishQuery,
  58. RetractQuery,
  59. SubscribeQuery,
  60. SubscriptionQuery,
  61. SubscriptionsQuery,
  62. UnsubscribeQuery,
  63. };
  64. QXmppPubSubIq::QueryType queryType() const;
  65. void setQueryType(QXmppPubSubIq::QueryType queryType);
  66. QString queryJid() const;
  67. void setQueryJid(const QString &jid);
  68. QString queryNode() const;
  69. void setQueryNode(const QString &node);
  70. QList<QXmppPubSubItem> items() const;
  71. void setItems(const QList<QXmppPubSubItem> &items);
  72. QString subscriptionId() const;
  73. void setSubscriptionId(const QString &id);
  74. /// \cond
  75. static bool isPubSubIq(const QDomElement &element);
  76. /// \endcond
  77. protected:
  78. /// \cond
  79. void parseElementFromChild(const QDomElement&);
  80. void toXmlElementFromChild(QXmlStreamWriter *writer) const;
  81. /// \endcond
  82. private:
  83. QXmppPubSubIq::QueryType m_queryType;
  84. QString m_queryJid;
  85. QString m_queryNode;
  86. QList<QXmppPubSubItem> m_items;
  87. QString m_subscriptionId;
  88. QString m_subscriptionType;
  89. };
  90. #endif