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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 *error = "Unknown action " + action_str; | 335 *error = "Unknown action " + action_str; |
336 return false; | 336 return false; |
337 } | 337 } |
338 | 338 |
339 sid = jingle_tag->Attr(QName(kEmptyNamespace, "sid")); | 339 sid = jingle_tag->Attr(QName(kEmptyNamespace, "sid")); |
340 if (sid.empty()) { | 340 if (sid.empty()) { |
341 *error = "sid attribute is missing"; | 341 *error = "sid attribute is missing"; |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 const XmlElement* attachments_tag = | |
346 jingle_tag->FirstNamed(QName(kChromotingXmlNamespace, "attachments")); | |
347 if (attachments_tag) { | |
348 attachments.reset(new XmlElement(*attachments_tag)); | |
349 } else { | |
350 attachments.reset(); | |
351 } | |
352 | |
345 if (action == SESSION_INFO) { | 353 if (action == SESSION_INFO) { |
346 // session-info messages may contain arbitrary information not | 354 // session-info messages may contain arbitrary information not |
347 // defined by the Jingle protocol. We don't need to parse it. | 355 // defined by the Jingle protocol. We don't need to parse it. |
348 const XmlElement* child = jingle_tag->FirstElement(); | 356 const XmlElement* child = jingle_tag->FirstElement(); |
357 // Plugin messages are action independent, which should not be considered as | |
358 // session-info. | |
359 if (child == attachments_tag) { | |
Sergey Ulanov
2016/12/15 19:18:25
nit: remove {} for consistency with other single-l
Hzj_jie
2016/12/15 22:41:19
Though in coding style, ignoring {} is allowed for
| |
360 child = child->NextElement(); | |
361 } | |
349 if (child) { | 362 if (child) { |
350 // session-info is allowed to be empty. | 363 // session-info is allowed to be empty. |
351 info.reset(new XmlElement(*child)); | 364 info.reset(new XmlElement(*child)); |
352 } else { | 365 } else { |
353 info.reset(nullptr); | 366 info.reset(); |
354 } | 367 } |
355 return true; | 368 return true; |
356 } | 369 } |
357 | 370 |
358 const XmlElement* reason_tag = | 371 const XmlElement* reason_tag = |
359 jingle_tag->FirstNamed(QName(kJingleNamespace, "reason")); | 372 jingle_tag->FirstNamed(QName(kJingleNamespace, "reason")); |
360 if (reason_tag && reason_tag->FirstElement()) { | 373 if (reason_tag && reason_tag->FirstElement()) { |
361 if (!NameToValue(kReasons, reason_tag->FirstElement()->Name().LocalPart(), | 374 if (!NameToValue(kReasons, reason_tag->FirstElement()->Name().LocalPart(), |
362 &reason)) { | 375 &reason)) { |
363 reason = UNKNOWN_REASON; | 376 reason = UNKNOWN_REASON; |
(...skipping 25 matching lines...) Expand all Loading... | |
389 *error = "Unexpected content name: " + content_name; | 402 *error = "Unexpected content name: " + content_name; |
390 return false; | 403 return false; |
391 } | 404 } |
392 | 405 |
393 const XmlElement* webrtc_transport_tag = content_tag->FirstNamed( | 406 const XmlElement* webrtc_transport_tag = content_tag->FirstNamed( |
394 QName(kWebrtcTransportNamespace, "transport")); | 407 QName(kWebrtcTransportNamespace, "transport")); |
395 if (webrtc_transport_tag) { | 408 if (webrtc_transport_tag) { |
396 transport_info.reset(new buzz::XmlElement(*webrtc_transport_tag)); | 409 transport_info.reset(new buzz::XmlElement(*webrtc_transport_tag)); |
397 } | 410 } |
398 | 411 |
399 description.reset(nullptr); | 412 description.reset(); |
400 if (action == SESSION_INITIATE || action == SESSION_ACCEPT) { | 413 if (action == SESSION_INITIATE || action == SESSION_ACCEPT) { |
401 const XmlElement* description_tag = content_tag->FirstNamed( | 414 const XmlElement* description_tag = content_tag->FirstNamed( |
402 QName(kChromotingXmlNamespace, "description")); | 415 QName(kChromotingXmlNamespace, "description")); |
403 if (!description_tag) { | 416 if (!description_tag) { |
404 *error = "Missing chromoting content description"; | 417 *error = "Missing chromoting content description"; |
405 return false; | 418 return false; |
406 } | 419 } |
407 | 420 |
408 description = ContentDescription::ParseXml(description_tag, | 421 description = ContentDescription::ParseXml(description_tag, |
409 webrtc_transport_tag != nullptr); | 422 webrtc_transport_tag != nullptr); |
(...skipping 26 matching lines...) Expand all Loading... | |
436 root->AddElement(jingle_tag); | 449 root->AddElement(jingle_tag); |
437 jingle_tag->AddAttr(QName(kEmptyNamespace, "sid"), sid); | 450 jingle_tag->AddAttr(QName(kEmptyNamespace, "sid"), sid); |
438 SetAddress(root.get(), jingle_tag, to, false); | 451 SetAddress(root.get(), jingle_tag, to, false); |
439 SetAddress(root.get(), jingle_tag, from, true); | 452 SetAddress(root.get(), jingle_tag, from, true); |
440 | 453 |
441 const char* action_attr = ValueToName(kActionTypes, action); | 454 const char* action_attr = ValueToName(kActionTypes, action); |
442 if (!action_attr) | 455 if (!action_attr) |
443 LOG(FATAL) << "Invalid action value " << action; | 456 LOG(FATAL) << "Invalid action value " << action; |
444 jingle_tag->AddAttr(QName(kEmptyNamespace, "action"), action_attr); | 457 jingle_tag->AddAttr(QName(kEmptyNamespace, "action"), action_attr); |
445 | 458 |
459 if (attachments) { | |
Sergey Ulanov
2016/12/15 19:18:25
nit: remove {} for consistency with other single-l
Hzj_jie
2016/12/15 22:41:19
Ditto.
| |
460 jingle_tag->AddElement(new XmlElement(*attachments)); | |
461 } | |
462 | |
446 if (action == SESSION_INFO) { | 463 if (action == SESSION_INFO) { |
447 if (info.get()) | 464 if (info.get()) |
448 jingle_tag->AddElement(new XmlElement(*info.get())); | 465 jingle_tag->AddElement(new XmlElement(*info.get())); |
449 return root; | 466 return root; |
450 } | 467 } |
451 | 468 |
452 if (action == SESSION_INITIATE) | 469 if (action == SESSION_INITIATE) |
453 jingle_tag->AddAttr(QName(kEmptyNamespace, "initiator"), initiator); | 470 jingle_tag->AddAttr(QName(kEmptyNamespace, "initiator"), initiator); |
454 | 471 |
455 if (reason != UNKNOWN_REASON) { | 472 if (reason != UNKNOWN_REASON) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 result->AddElement(FormatIceCredentials(credentials)); | 656 result->AddElement(FormatIceCredentials(credentials)); |
640 } | 657 } |
641 for (const NamedCandidate& candidate : candidates) { | 658 for (const NamedCandidate& candidate : candidates) { |
642 result->AddElement(FormatIceCandidate(candidate)); | 659 result->AddElement(FormatIceCandidate(candidate)); |
643 } | 660 } |
644 return result; | 661 return result; |
645 } | 662 } |
646 | 663 |
647 } // namespace protocol | 664 } // namespace protocol |
648 } // namespace remoting | 665 } // namespace remoting |
OLD | NEW |