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* plugin_tag = | |
346 jingle_tag->FirstNamed(QName(kChromotingXmlNamespace, "plugin")); | |
347 if (plugin_tag) { | |
348 plugin_message.reset(new XmlElement(*plugin_tag)); | |
349 } else { | |
350 plugin_message.reset(nullptr); | |
Sergey Ulanov
2016/12/14 01:31:50
don't need nullptr.
Hzj_jie
2016/12/14 20:03:48
Done, also several other resets.
| |
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 == plugin_tag) { | |
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(nullptr); |
354 } | 367 } |
355 return true; | 368 return true; |
356 } | 369 } |
357 | 370 |
358 const XmlElement* reason_tag = | 371 const XmlElement* reason_tag = |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 (plugin_message) { | |
460 jingle_tag->AddElement(new XmlElement(*plugin_message)); | |
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 |