OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2012 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/mucroomuniquehangoutidtask.h" | |
12 | |
13 #include "webrtc/libjingle/xmpp/constants.h" | |
14 | |
15 namespace buzz { | |
16 | |
17 MucRoomUniqueHangoutIdTask::MucRoomUniqueHangoutIdTask(XmppTaskParentInterface*
parent, | |
18 const Jid& lookup_server_jid) | |
19 : IqTask(parent, STR_GET, lookup_server_jid, MakeUniqueRequestXml()) { | |
20 } | |
21 | |
22 // Construct a stanza to request a unique room id. eg: | |
23 // | |
24 // <unique hangout-id="true" xmlns="http://jabber.org/protocol/muc#unique"/> | |
25 XmlElement* MucRoomUniqueHangoutIdTask::MakeUniqueRequestXml() { | |
26 XmlElement* xml = new XmlElement(QN_MUC_UNIQUE_QUERY, false); | |
27 xml->SetAttr(QN_HANGOUT_ID, STR_TRUE); | |
28 return xml; | |
29 } | |
30 | |
31 // Handle a response like the following: | |
32 // | |
33 // <unique hangout-id="hangout_id" | |
34 // xmlns="http://jabber.org/protocol/muc#unique"/> | |
35 // muvc-private-chat-guid@groupchat.google.com | |
36 // </unique> | |
37 void MucRoomUniqueHangoutIdTask::HandleResult(const XmlElement* stanza) { | |
38 | |
39 const XmlElement* unique_elem = stanza->FirstNamed(QN_MUC_UNIQUE_QUERY); | |
40 if (unique_elem == NULL || | |
41 !unique_elem->HasAttr(QN_HANGOUT_ID)) { | |
42 SignalError(this, stanza); | |
43 return; | |
44 } | |
45 | |
46 std::string hangout_id = unique_elem->Attr(QN_HANGOUT_ID); | |
47 | |
48 SignalResult(this, hangout_id); | |
49 } | |
50 | |
51 } // namespace buzz | |
OLD | NEW |