OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/libjingle/xmpp/pubsub_task.h" | 11 #include "webrtc/libjingle/xmpp/pubsub_task.h" |
12 | 12 |
13 #include <map> | 13 #include <map> |
| 14 #include <memory> |
14 #include <string> | 15 #include <string> |
15 | 16 |
16 #include "webrtc/libjingle/xmpp/constants.h" | 17 #include "webrtc/libjingle/xmpp/constants.h" |
17 #include "webrtc/libjingle/xmpp/xmppengine.h" | 18 #include "webrtc/libjingle/xmpp/xmppengine.h" |
18 #include "webrtc/base/common.h" | 19 #include "webrtc/base/common.h" |
19 | 20 |
20 namespace buzz { | 21 namespace buzz { |
21 | 22 |
22 PubsubTask::PubsubTask(XmppTaskParentInterface* parent, | 23 PubsubTask::PubsubTask(XmppTaskParentInterface* parent, |
23 const buzz::Jid& pubsub_node_jid) | 24 const buzz::Jid& pubsub_node_jid) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 76 |
76 // Registers a function pointer to be called when the value of the pubsub | 77 // Registers a function pointer to be called when the value of the pubsub |
77 // node changes. | 78 // node changes. |
78 // Note that this does not actually change the XMPP pubsub | 79 // Note that this does not actually change the XMPP pubsub |
79 // subscription. All publish events are always received by everyone in the | 80 // subscription. All publish events are always received by everyone in the |
80 // MUC. This function just controls whether the handle function will get | 81 // MUC. This function just controls whether the handle function will get |
81 // called when the event is received. | 82 // called when the event is received. |
82 bool PubsubTask::SubscribeToNode(const std::string& pubsub_node, | 83 bool PubsubTask::SubscribeToNode(const std::string& pubsub_node, |
83 NodeHandler handler) { | 84 NodeHandler handler) { |
84 subscribed_nodes_[pubsub_node] = handler; | 85 subscribed_nodes_[pubsub_node] = handler; |
85 rtc::scoped_ptr<buzz::XmlElement> get_iq_request( | 86 std::unique_ptr<buzz::XmlElement> get_iq_request( |
86 MakeIq(buzz::STR_GET, pubsub_node_jid_, task_id())); | 87 MakeIq(buzz::STR_GET, pubsub_node_jid_, task_id())); |
87 if (!get_iq_request) { | 88 if (!get_iq_request) { |
88 return false; | 89 return false; |
89 } | 90 } |
90 buzz::XmlElement* pubsub_element = new buzz::XmlElement(QN_PUBSUB, true); | 91 buzz::XmlElement* pubsub_element = new buzz::XmlElement(QN_PUBSUB, true); |
91 buzz::XmlElement* items_element = new buzz::XmlElement(QN_PUBSUB_ITEMS, true); | 92 buzz::XmlElement* items_element = new buzz::XmlElement(QN_PUBSUB_ITEMS, true); |
92 | 93 |
93 items_element->AddAttr(buzz::QN_NODE, pubsub_node); | 94 items_element->AddAttr(buzz::QN_NODE, pubsub_node); |
94 pubsub_element->AddElement(items_element); | 95 pubsub_element->AddElement(items_element); |
95 get_iq_request->AddElement(pubsub_element); | 96 get_iq_request->AddElement(pubsub_element); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 192 } |
192 | 193 |
193 (this->*handler)(item); | 194 (this->*handler)(item); |
194 item = item->NextElement(); | 195 item = item->NextElement(); |
195 } | 196 } |
196 return; | 197 return; |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 } | 201 } |
OLD | NEW |