OLD | NEW |
(Empty) | |
| 1 // Copyright 2004 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBRTC_LIBJINGLE_XMPP_PUBSUB_TASK_H_ |
| 6 #define WEBRTC_LIBJINGLE_XMPP_PUBSUB_TASK_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" |
| 11 #include "third_party/libjingle_xmpp/xmpp/jid.h" |
| 12 #include "third_party/libjingle_xmpp/xmpp/xmpptask.h" |
| 13 |
| 14 namespace buzz { |
| 15 |
| 16 // Base class to help write pubsub tasks. |
| 17 // In ProcessStart call SubscribeNode with namespaces of interest along with |
| 18 // NodeHandlers. |
| 19 // When pubsub notifications arrive and matches the namespace, the NodeHandlers |
| 20 // will be called back. |
| 21 class PubsubTask : public buzz::XmppTask { |
| 22 public: |
| 23 virtual ~PubsubTask(); |
| 24 |
| 25 protected: |
| 26 typedef void (PubsubTask::*NodeHandler)(const buzz::XmlElement* node); |
| 27 |
| 28 PubsubTask(XmppTaskParentInterface* parent, const buzz::Jid& pubsub_node_jid); |
| 29 |
| 30 virtual bool HandleStanza(const buzz::XmlElement* stanza); |
| 31 virtual int ProcessResponse(); |
| 32 |
| 33 bool SubscribeToNode(const std::string& pubsub_node, NodeHandler handler); |
| 34 void UnsubscribeFromNode(const std::string& pubsub_node); |
| 35 |
| 36 // Called when there is an error. Derived class can do what it needs to. |
| 37 virtual void OnPubsubError(const buzz::XmlElement* error_stanza); |
| 38 |
| 39 private: |
| 40 typedef std::map<std::string, NodeHandler> NodeSubscriptions; |
| 41 |
| 42 void HandlePubsubIqGetResponse(const buzz::XmlElement* pubsub_iq_response); |
| 43 void HandlePubsubEventMessage(const buzz::XmlElement* pubsub_event_message); |
| 44 void HandlePubsubItems(const buzz::XmlElement* items); |
| 45 |
| 46 buzz::Jid pubsub_node_jid_; |
| 47 NodeSubscriptions subscribed_nodes_; |
| 48 }; |
| 49 |
| 50 } // namespace buzz |
| 51 |
| 52 #endif // WEBRTC_LIBJINGLE_XMPP_PUBSUB_TASK_H_ |
OLD | NEW |