OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2011 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 <string> |
| 12 #include <vector> |
| 13 |
| 14 #include "webrtc/libjingle/xmpp/mucroomconfigtask.h" |
| 15 |
| 16 #include "webrtc/libjingle/xmpp/constants.h" |
| 17 |
| 18 namespace buzz { |
| 19 |
| 20 MucRoomConfigTask::MucRoomConfigTask( |
| 21 XmppTaskParentInterface* parent, |
| 22 const Jid& room_jid, |
| 23 const std::string& room_name, |
| 24 const std::vector<std::string>& room_features) |
| 25 : IqTask(parent, STR_SET, room_jid, |
| 26 MakeRequest(room_name, room_features)), |
| 27 room_jid_(room_jid) { |
| 28 } |
| 29 |
| 30 XmlElement* MucRoomConfigTask::MakeRequest( |
| 31 const std::string& room_name, |
| 32 const std::vector<std::string>& room_features) { |
| 33 buzz::XmlElement* owner_query = new |
| 34 buzz::XmlElement(buzz::QN_MUC_OWNER_QUERY, true); |
| 35 |
| 36 buzz::XmlElement* x_form = new buzz::XmlElement(buzz::QN_XDATA_X, true); |
| 37 x_form->SetAttr(buzz::QN_TYPE, buzz::STR_FORM); |
| 38 |
| 39 buzz::XmlElement* roomname_field = |
| 40 new buzz::XmlElement(buzz::QN_XDATA_FIELD, false); |
| 41 roomname_field->SetAttr(buzz::QN_VAR, buzz::STR_MUC_ROOMCONFIG_ROOMNAME); |
| 42 roomname_field->SetAttr(buzz::QN_TYPE, buzz::STR_TEXT_SINGLE); |
| 43 |
| 44 buzz::XmlElement* roomname_value = |
| 45 new buzz::XmlElement(buzz::QN_XDATA_VALUE, false); |
| 46 roomname_value->SetBodyText(room_name); |
| 47 |
| 48 roomname_field->AddElement(roomname_value); |
| 49 x_form->AddElement(roomname_field); |
| 50 |
| 51 buzz::XmlElement* features_field = |
| 52 new buzz::XmlElement(buzz::QN_XDATA_FIELD, false); |
| 53 features_field->SetAttr(buzz::QN_VAR, buzz::STR_MUC_ROOMCONFIG_FEATURES); |
| 54 features_field->SetAttr(buzz::QN_TYPE, buzz::STR_LIST_MULTI); |
| 55 |
| 56 for (std::vector<std::string>::const_iterator feature = room_features.begin(); |
| 57 feature != room_features.end(); ++feature) { |
| 58 buzz::XmlElement* features_value = |
| 59 new buzz::XmlElement(buzz::QN_XDATA_VALUE, false); |
| 60 features_value->SetBodyText(*feature); |
| 61 features_field->AddElement(features_value); |
| 62 } |
| 63 |
| 64 x_form->AddElement(features_field); |
| 65 owner_query->AddElement(x_form); |
| 66 return owner_query; |
| 67 } |
| 68 |
| 69 void MucRoomConfigTask::HandleResult(const XmlElement* element) { |
| 70 SignalResult(this); |
| 71 } |
| 72 |
| 73 } // namespace buzz |
OLD | NEW |