| 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/mucroomdiscoverytask.h" | |
| 12 | |
| 13 #include "webrtc/libjingle/xmpp/constants.h" | |
| 14 | |
| 15 namespace buzz { | |
| 16 | |
| 17 MucRoomDiscoveryTask::MucRoomDiscoveryTask( | |
| 18 XmppTaskParentInterface* parent, | |
| 19 const Jid& room_jid) | |
| 20 : IqTask(parent, STR_GET, room_jid, | |
| 21 new buzz::XmlElement(buzz::QN_DISCO_INFO_QUERY)) { | |
| 22 } | |
| 23 | |
| 24 void MucRoomDiscoveryTask::HandleResult(const XmlElement* stanza) { | |
| 25 const XmlElement* query = stanza->FirstNamed(QN_DISCO_INFO_QUERY); | |
| 26 if (query == NULL) { | |
| 27 SignalError(this, NULL); | |
| 28 return; | |
| 29 } | |
| 30 | |
| 31 std::set<std::string> features; | |
| 32 std::map<std::string, std::string> extended_info; | |
| 33 const XmlElement* identity = query->FirstNamed(QN_DISCO_IDENTITY); | |
| 34 if (identity == NULL || !identity->HasAttr(QN_NAME)) { | |
| 35 SignalResult(this, false, "", "", features, extended_info); | |
| 36 return; | |
| 37 } | |
| 38 | |
| 39 const std::string name(identity->Attr(QN_NAME)); | |
| 40 | |
| 41 // Get the conversation id | |
| 42 const XmlElement* conversation = | |
| 43 identity->FirstNamed(QN_GOOGLE_MUC_HANGOUT_CONVERSATION_ID); | |
| 44 std::string conversation_id; | |
| 45 if (conversation != NULL) { | |
| 46 conversation_id = conversation->BodyText(); | |
| 47 } | |
| 48 | |
| 49 for (const XmlElement* feature = query->FirstNamed(QN_DISCO_FEATURE); | |
| 50 feature != NULL; feature = feature->NextNamed(QN_DISCO_FEATURE)) { | |
| 51 features.insert(feature->Attr(QN_VAR)); | |
| 52 } | |
| 53 | |
| 54 const XmlElement* data_x = query->FirstNamed(QN_XDATA_X); | |
| 55 if (data_x != NULL) { | |
| 56 for (const XmlElement* field = data_x->FirstNamed(QN_XDATA_FIELD); | |
| 57 field != NULL; field = field->NextNamed(QN_XDATA_FIELD)) { | |
| 58 const std::string key(field->Attr(QN_VAR)); | |
| 59 extended_info[key] = field->Attr(QN_XDATA_VALUE); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 SignalResult(this, true, name, conversation_id, features, extended_info); | |
| 64 } | |
| 65 | |
| 66 } // namespace buzz | |
| OLD | NEW |