OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_LIBJINGLE_XMPP_PUBSUBTASKS_H_ |
| 12 #define WEBRTC_LIBJINGLE_XMPP_PUBSUBTASKS_H_ |
| 13 |
| 14 #include <vector> |
| 15 |
| 16 #include "webrtc/libjingle/xmpp/iqtask.h" |
| 17 #include "webrtc/libjingle/xmpp/receivetask.h" |
| 18 #include "webrtc/base/sigslot.h" |
| 19 |
| 20 namespace buzz { |
| 21 |
| 22 // A PubSub itemid + payload. Useful for signaling items. |
| 23 struct PubSubItem { |
| 24 std::string itemid; |
| 25 // The entire <item>, owned by the stanza handler. To keep a |
| 26 // reference after handling, make a copy. |
| 27 const XmlElement* elem; |
| 28 }; |
| 29 |
| 30 // An IqTask which gets a <pubsub><items> for a particular jid and |
| 31 // node, parses the items in the response and signals the items. |
| 32 class PubSubRequestTask : public IqTask { |
| 33 public: |
| 34 PubSubRequestTask(XmppTaskParentInterface* parent, |
| 35 const Jid& pubsubjid, |
| 36 const std::string& node); |
| 37 |
| 38 sigslot::signal2<PubSubRequestTask*, |
| 39 const std::vector<PubSubItem>&> SignalResult; |
| 40 // SignalError inherited by IqTask. |
| 41 private: |
| 42 virtual void HandleResult(const XmlElement* stanza); |
| 43 }; |
| 44 |
| 45 // A ReceiveTask which listens for <event><items> of a particular |
| 46 // pubsub JID and node and then signals them items. |
| 47 class PubSubReceiveTask : public ReceiveTask { |
| 48 public: |
| 49 PubSubReceiveTask(XmppTaskParentInterface* parent, |
| 50 const Jid& pubsubjid, |
| 51 const std::string& node) |
| 52 : ReceiveTask(parent), |
| 53 pubsubjid_(pubsubjid), |
| 54 node_(node) { |
| 55 } |
| 56 |
| 57 virtual int ProcessStart(); |
| 58 sigslot::signal2<PubSubReceiveTask*, |
| 59 const std::vector<PubSubItem>&> SignalUpdate; |
| 60 |
| 61 protected: |
| 62 virtual bool WantsStanza(const XmlElement* stanza); |
| 63 virtual void ReceiveStanza(const XmlElement* stanza); |
| 64 |
| 65 private: |
| 66 Jid pubsubjid_; |
| 67 std::string node_; |
| 68 }; |
| 69 |
| 70 // An IqTask which publishes a <pubsub><publish><item> to a particular |
| 71 // pubsub jid and node. |
| 72 class PubSubPublishTask : public IqTask { |
| 73 public: |
| 74 // Takes ownership of children |
| 75 PubSubPublishTask(XmppTaskParentInterface* parent, |
| 76 const Jid& pubsubjid, |
| 77 const std::string& node, |
| 78 const std::string& itemid, |
| 79 const std::vector<XmlElement*>& children); |
| 80 |
| 81 const std::string& itemid() const { return itemid_; } |
| 82 |
| 83 sigslot::signal1<PubSubPublishTask*> SignalResult; |
| 84 |
| 85 private: |
| 86 // SignalError inherited by IqTask. |
| 87 virtual void HandleResult(const XmlElement* stanza); |
| 88 |
| 89 std::string itemid_; |
| 90 }; |
| 91 |
| 92 // An IqTask which publishes a <pubsub><publish><retract> to a particular |
| 93 // pubsub jid and node. |
| 94 class PubSubRetractTask : public IqTask { |
| 95 public: |
| 96 PubSubRetractTask(XmppTaskParentInterface* parent, |
| 97 const Jid& pubsubjid, |
| 98 const std::string& node, |
| 99 const std::string& itemid); |
| 100 |
| 101 const std::string& itemid() const { return itemid_; } |
| 102 |
| 103 sigslot::signal1<PubSubRetractTask*> SignalResult; |
| 104 |
| 105 private: |
| 106 // SignalError inherited by IqTask. |
| 107 virtual void HandleResult(const XmlElement* stanza); |
| 108 |
| 109 std::string itemid_; |
| 110 }; |
| 111 |
| 112 } // namespace buzz |
| 113 |
| 114 #endif // WEBRTC_LIBJINGLE_XMPP_PUBSUBTASKS_H_ |
OLD | NEW |