15976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org/* 25976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * libjingle 35976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Copyright 2012, Google Inc. 45976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 55976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Redistribution and use in source and binary forms, with or without 65976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * modification, are permitted provided that the following conditions are met: 75976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 85976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 95976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * this list of conditions and the following disclaimer. 105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * this list of conditions and the following disclaimer in the documentation 125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * and/or other materials provided with the distribution. 135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 3. The name of the author may not be used to endorse or promote products 145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * derived from this software without specific prior written permission. 155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * 165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org */ 275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/xmpp/mucroomdiscoverytask.h" 295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 305976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/xmpp/constants.h" 315976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 325976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgnamespace buzz { 335976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 345976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgMucRoomDiscoveryTask::MucRoomDiscoveryTask( 355976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org XmppTaskParentInterface* parent, 365976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const Jid& room_jid) 375976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org : IqTask(parent, STR_GET, room_jid, 385976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org new buzz::XmlElement(buzz::QN_DISCO_INFO_QUERY)) { 395976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org} 405976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 415976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgvoid MucRoomDiscoveryTask::HandleResult(const XmlElement* stanza) { 425976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const XmlElement* query = stanza->FirstNamed(QN_DISCO_INFO_QUERY); 435976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org if (query == NULL) { 445976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org SignalError(this, NULL); 455976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org return; 465976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 475976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 485976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::set<std::string> features; 495976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::map<std::string, std::string> extended_info; 505976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const XmlElement* identity = query->FirstNamed(QN_DISCO_IDENTITY); 515976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org if (identity == NULL || !identity->HasAttr(QN_NAME)) { 52c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org SignalResult(this, false, "", "", features, extended_info); 535976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org return; 545976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 555976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 565976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const std::string name(identity->Attr(QN_NAME)); 575976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 58c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org // Get the conversation id 59e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org const XmlElement* conversation = 60c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org identity->FirstNamed(QN_GOOGLE_MUC_HANGOUT_CONVERSATION_ID); 61c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org std::string conversation_id; 62e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org if (conversation != NULL) { 63e73fa366a56d0c3c46860c534db19fffe110f167mallinath@webrtc.org conversation_id = conversation->BodyText(); 64c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org } 65c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org 665976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org for (const XmlElement* feature = query->FirstNamed(QN_DISCO_FEATURE); 675976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org feature != NULL; feature = feature->NextNamed(QN_DISCO_FEATURE)) { 685976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org features.insert(feature->Attr(QN_VAR)); 695976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 705976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 715976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const XmlElement* data_x = query->FirstNamed(QN_XDATA_X); 725976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org if (data_x != NULL) { 735976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org for (const XmlElement* field = data_x->FirstNamed(QN_XDATA_FIELD); 745976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org field != NULL; field = field->NextNamed(QN_XDATA_FIELD)) { 755976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const std::string key(field->Attr(QN_VAR)); 765976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org extended_info[key] = field->Attr(QN_XDATA_VALUE); 775976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 785976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 795976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 80c237f0ad875cde990bf9d89f41424b18809cc345henrike@webrtc.org SignalResult(this, true, name, conversation_id, features, extended_info); 815976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org} 825976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 835976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org} // namespace buzz 84