| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/jingle_messages.h" | 5 #include "remoting/protocol/jingle_messages.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/protocol/content_description.h" | 10 #include "remoting/protocol/content_description.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 jingle_tag->AddAttr(QName(kEmptyNamespace, "sid"), sid); | 299 jingle_tag->AddAttr(QName(kEmptyNamespace, "sid"), sid); |
| 300 | 300 |
| 301 const char* action_attr = ValueToName(kActionTypes, action); | 301 const char* action_attr = ValueToName(kActionTypes, action); |
| 302 if (!action_attr) | 302 if (!action_attr) |
| 303 LOG(FATAL) << "Invalid action value " << action; | 303 LOG(FATAL) << "Invalid action value " << action; |
| 304 jingle_tag->AddAttr(QName(kEmptyNamespace, "action"), action_attr); | 304 jingle_tag->AddAttr(QName(kEmptyNamespace, "action"), action_attr); |
| 305 | 305 |
| 306 if (action == SESSION_INFO) { | 306 if (action == SESSION_INFO) { |
| 307 if (info.get()) | 307 if (info.get()) |
| 308 jingle_tag->AddElement(new XmlElement(*info.get())); | 308 jingle_tag->AddElement(new XmlElement(*info.get())); |
| 309 return root.Pass(); | 309 return root; |
| 310 } | 310 } |
| 311 | 311 |
| 312 if (action == SESSION_INITIATE) | 312 if (action == SESSION_INITIATE) |
| 313 jingle_tag->AddAttr(QName(kEmptyNamespace, "initiator"), initiator); | 313 jingle_tag->AddAttr(QName(kEmptyNamespace, "initiator"), initiator); |
| 314 | 314 |
| 315 if (reason != UNKNOWN_REASON) { | 315 if (reason != UNKNOWN_REASON) { |
| 316 XmlElement* reason_tag = new XmlElement(QName(kJingleNamespace, "reason")); | 316 XmlElement* reason_tag = new XmlElement(QName(kJingleNamespace, "reason")); |
| 317 jingle_tag->AddElement(reason_tag); | 317 jingle_tag->AddElement(reason_tag); |
| 318 const char* reason_string = | 318 const char* reason_string = |
| 319 ValueToName(kReasons, reason); | 319 ValueToName(kReasons, reason); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 332 ContentDescription::kChromotingContentName); | 332 ContentDescription::kChromotingContentName); |
| 333 content_tag->AddAttr(QName(kEmptyNamespace, "creator"), "initiator"); | 333 content_tag->AddAttr(QName(kEmptyNamespace, "creator"), "initiator"); |
| 334 | 334 |
| 335 if (description.get()) | 335 if (description.get()) |
| 336 content_tag->AddElement(description->ToXml()); | 336 content_tag->AddElement(description->ToXml()); |
| 337 | 337 |
| 338 if (transport_info) | 338 if (transport_info) |
| 339 content_tag->AddElement(new XmlElement(*transport_info)); | 339 content_tag->AddElement(new XmlElement(*transport_info)); |
| 340 } | 340 } |
| 341 | 341 |
| 342 return root.Pass(); | 342 return root; |
| 343 } | 343 } |
| 344 | 344 |
| 345 JingleMessageReply::JingleMessageReply() | 345 JingleMessageReply::JingleMessageReply() |
| 346 : type(REPLY_RESULT), | 346 : type(REPLY_RESULT), |
| 347 error_type(NONE) { | 347 error_type(NONE) { |
| 348 } | 348 } |
| 349 | 349 |
| 350 JingleMessageReply::JingleMessageReply(ErrorType error) | 350 JingleMessageReply::JingleMessageReply(ErrorType error) |
| 351 : type(error != NONE ? REPLY_ERROR : REPLY_RESULT), | 351 : type(error != NONE ? REPLY_ERROR : REPLY_RESULT), |
| 352 error_type(error) { | 352 error_type(error) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 365 const buzz::XmlElement* request_stanza) const { | 365 const buzz::XmlElement* request_stanza) const { |
| 366 scoped_ptr<XmlElement> iq( | 366 scoped_ptr<XmlElement> iq( |
| 367 new XmlElement(QName(kJabberNamespace, "iq"), true)); | 367 new XmlElement(QName(kJabberNamespace, "iq"), true)); |
| 368 iq->SetAttr(QName(kEmptyNamespace, "to"), | 368 iq->SetAttr(QName(kEmptyNamespace, "to"), |
| 369 request_stanza->Attr(QName(kEmptyNamespace, "from"))); | 369 request_stanza->Attr(QName(kEmptyNamespace, "from"))); |
| 370 iq->SetAttr(QName(kEmptyNamespace, "id"), | 370 iq->SetAttr(QName(kEmptyNamespace, "id"), |
| 371 request_stanza->Attr(QName(kEmptyNamespace, "id"))); | 371 request_stanza->Attr(QName(kEmptyNamespace, "id"))); |
| 372 | 372 |
| 373 if (type == REPLY_RESULT) { | 373 if (type == REPLY_RESULT) { |
| 374 iq->SetAttr(QName(kEmptyNamespace, "type"), "result"); | 374 iq->SetAttr(QName(kEmptyNamespace, "type"), "result"); |
| 375 return iq.Pass(); | 375 return iq; |
| 376 } | 376 } |
| 377 | 377 |
| 378 DCHECK_EQ(type, REPLY_ERROR); | 378 DCHECK_EQ(type, REPLY_ERROR); |
| 379 | 379 |
| 380 iq->SetAttr(QName(kEmptyNamespace, "type"), "error"); | 380 iq->SetAttr(QName(kEmptyNamespace, "type"), "error"); |
| 381 | 381 |
| 382 for (const buzz::XmlElement* child = request_stanza->FirstElement(); | 382 for (const buzz::XmlElement* child = request_stanza->FirstElement(); |
| 383 child != nullptr; child = child->NextElement()) { | 383 child != nullptr; child = child->NextElement()) { |
| 384 iq->AddElement(new buzz::XmlElement(*child)); | 384 iq->AddElement(new buzz::XmlElement(*child)); |
| 385 } | 385 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (!error_text.empty()) { | 433 if (!error_text.empty()) { |
| 434 // It's okay to always use English here. This text is for | 434 // It's okay to always use English here. This text is for |
| 435 // debugging purposes only. | 435 // debugging purposes only. |
| 436 buzz::XmlElement* text_elem = | 436 buzz::XmlElement* text_elem = |
| 437 new buzz::XmlElement(QName(kJabberNamespace, "text")); | 437 new buzz::XmlElement(QName(kJabberNamespace, "text")); |
| 438 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); | 438 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); |
| 439 text_elem->SetBodyText(error_text); | 439 text_elem->SetBodyText(error_text); |
| 440 error->AddElement(text_elem); | 440 error->AddElement(text_elem); |
| 441 } | 441 } |
| 442 | 442 |
| 443 return iq.Pass(); | 443 return iq; |
| 444 } | 444 } |
| 445 | 445 |
| 446 IceTransportInfo::IceTransportInfo() {} | 446 IceTransportInfo::IceTransportInfo() {} |
| 447 IceTransportInfo::~IceTransportInfo() {} | 447 IceTransportInfo::~IceTransportInfo() {} |
| 448 | 448 |
| 449 bool IceTransportInfo::ParseXml( | 449 bool IceTransportInfo::ParseXml( |
| 450 const buzz::XmlElement* element) { | 450 const buzz::XmlElement* element) { |
| 451 if (element->Name() != QName(kIceTransportNamespace, "transport")) | 451 if (element->Name() != QName(kIceTransportNamespace, "transport")) |
| 452 return false; | 452 return false; |
| 453 | 453 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 478 | 478 |
| 479 scoped_ptr<buzz::XmlElement> IceTransportInfo::ToXml() const { | 479 scoped_ptr<buzz::XmlElement> IceTransportInfo::ToXml() const { |
| 480 scoped_ptr<buzz::XmlElement> result( | 480 scoped_ptr<buzz::XmlElement> result( |
| 481 new XmlElement(QName(kIceTransportNamespace, "transport"), true)); | 481 new XmlElement(QName(kIceTransportNamespace, "transport"), true)); |
| 482 for (const IceCredentials& credentials : ice_credentials) { | 482 for (const IceCredentials& credentials : ice_credentials) { |
| 483 result->AddElement(FormatIceCredentials(credentials)); | 483 result->AddElement(FormatIceCredentials(credentials)); |
| 484 } | 484 } |
| 485 for (const NamedCandidate& candidate : candidates) { | 485 for (const NamedCandidate& candidate : candidates) { |
| 486 result->AddElement(FormatIceCandidate(candidate)); | 486 result->AddElement(FormatIceCandidate(candidate)); |
| 487 } | 487 } |
| 488 return result.Pass(); | 488 return result; |
| 489 } | 489 } |
| 490 | 490 |
| 491 } // namespace protocol | 491 } // namespace protocol |
| 492 } // namespace remoting | 492 } // namespace remoting |
| OLD | NEW |