Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Side by Side Diff: webrtc/libjingle/xmpp/jingleinfotask.cc

Issue 2011503002: Remove unused libjingle_xmpphelp target. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Also remove autoportallocator.h, which seems to be orphaned, yet references the task type Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/libjingle/xmpp/jingleinfotask.h ('k') | webrtc/p2p/client/autoportallocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2010 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 #include "webrtc/libjingle/xmpp/jingleinfotask.h"
12
13 #include <memory>
14
15 #include "webrtc/libjingle/xmpp/constants.h"
16 #include "webrtc/libjingle/xmpp/xmppclient.h"
17 #include "webrtc/libjingle/xmpp/xmpptask.h"
18 #include "webrtc/base/socketaddress.h"
19
20 namespace buzz {
21
22 class JingleInfoTask::JingleInfoGetTask : public XmppTask {
23 public:
24 explicit JingleInfoGetTask(XmppTaskParentInterface* parent)
25 : XmppTask(parent, XmppEngine::HL_SINGLE),
26 done_(false) {}
27
28 virtual int ProcessStart() {
29 std::unique_ptr<XmlElement> get(
30 MakeIq(STR_GET, Jid(), task_id()));
31 get->AddElement(new XmlElement(QN_JINGLE_INFO_QUERY, true));
32 if (SendStanza(get.get()) != XMPP_RETURN_OK) {
33 return STATE_ERROR;
34 }
35 return STATE_RESPONSE;
36 }
37 virtual int ProcessResponse() {
38 if (done_)
39 return STATE_DONE;
40 return STATE_BLOCKED;
41 }
42
43 protected:
44 virtual bool HandleStanza(const XmlElement * stanza) {
45 if (!MatchResponseIq(stanza, Jid(), task_id()))
46 return false;
47
48 if (stanza->Attr(QN_TYPE) != STR_RESULT)
49 return false;
50
51 // Queue the stanza with the parent so these don't get handled out of order
52 JingleInfoTask* parent = static_cast<JingleInfoTask*>(GetParent());
53 parent->QueueStanza(stanza);
54
55 // Wake ourselves so we can go into the done state
56 done_ = true;
57 Wake();
58 return true;
59 }
60
61 bool done_;
62 };
63
64
65 void JingleInfoTask::RefreshJingleInfoNow() {
66 JingleInfoGetTask* get_task = new JingleInfoGetTask(this);
67 get_task->Start();
68 }
69
70 bool
71 JingleInfoTask::HandleStanza(const XmlElement * stanza) {
72 if (!MatchRequestIq(stanza, "set", QN_JINGLE_INFO_QUERY))
73 return false;
74
75 // only respect relay push from the server
76 Jid from(stanza->Attr(QN_FROM));
77 if (!from.IsEmpty() &&
78 !from.BareEquals(GetClient()->jid()) &&
79 from != Jid(GetClient()->jid().domain()))
80 return false;
81
82 QueueStanza(stanza);
83 return true;
84 }
85
86 int
87 JingleInfoTask::ProcessStart() {
88 std::vector<std::string> relay_hosts;
89 std::vector<rtc::SocketAddress> stun_hosts;
90 std::string relay_token;
91 const XmlElement * stanza = NextStanza();
92 if (stanza == NULL)
93 return STATE_BLOCKED;
94 const XmlElement * query = stanza->FirstNamed(QN_JINGLE_INFO_QUERY);
95 if (query == NULL)
96 return STATE_START;
97 const XmlElement *stun = query->FirstNamed(QN_JINGLE_INFO_STUN);
98 if (stun) {
99 for (const XmlElement *server = stun->FirstNamed(QN_JINGLE_INFO_SERVER);
100 server != NULL; server = server->NextNamed(QN_JINGLE_INFO_SERVER)) {
101 std::string host = server->Attr(QN_JINGLE_INFO_HOST);
102 std::string port = server->Attr(QN_JINGLE_INFO_UDP);
103 if (host != STR_EMPTY && host != STR_EMPTY) {
104 stun_hosts.push_back(rtc::SocketAddress(host, atoi(port.c_str())));
105 }
106 }
107 }
108
109 const XmlElement *relay = query->FirstNamed(QN_JINGLE_INFO_RELAY);
110 if (relay) {
111 relay_token = relay->TextNamed(QN_JINGLE_INFO_TOKEN);
112 for (const XmlElement *server = relay->FirstNamed(QN_JINGLE_INFO_SERVER);
113 server != NULL; server = server->NextNamed(QN_JINGLE_INFO_SERVER)) {
114 std::string host = server->Attr(QN_JINGLE_INFO_HOST);
115 if (host != STR_EMPTY) {
116 relay_hosts.push_back(host);
117 }
118 }
119 }
120 SignalJingleInfo(relay_token, relay_hosts, stun_hosts);
121 return STATE_START;
122 }
123 }
OLDNEW
« no previous file with comments | « webrtc/libjingle/xmpp/jingleinfotask.h ('k') | webrtc/p2p/client/autoportallocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698