Chromium Code Reviews| Index: remoting/protocol/jingle_messages.cc |
| diff --git a/remoting/protocol/jingle_messages.cc b/remoting/protocol/jingle_messages.cc |
| index 3113873b01280f3e310b165bb005364e44fbaa38..445a02f8235a22d5934d4cf70864edb9b1b1ae8d 100644 |
| --- a/remoting/protocol/jingle_messages.cc |
| +++ b/remoting/protocol/jingle_messages.cc |
| @@ -22,6 +22,8 @@ namespace { |
| const char kJabberNamespace[] = "jabber:client"; |
| const char kJingleNamespace[] = "urn:xmpp:jingle:1"; |
| +const char kRemotingNamespace[] = "google:remoting"; |
|
Sergey Ulanov
2016/06/01 08:52:47
We already have kChromotingXmlNamespace in remotin
Hzj_jie
2016/06/01 23:56:13
Done.
|
| + |
| // Namespace for transport messages when using standard ICE. |
| const char kIceTransportNamespace[] = "google:remoting:ice"; |
| @@ -49,7 +51,6 @@ const NameMapElement<JingleMessage::ActionType> kActionTypes[] = { |
| const NameMapElement<JingleMessage::Reason> kReasons[] = { |
| { JingleMessage::SUCCESS, "success" }, |
| { JingleMessage::DECLINE, "decline" }, |
| - { JingleMessage::SECURITY_ERROR, "security-error" }, |
| { JingleMessage::CANCEL, "cancel" }, |
| { JingleMessage::EXPIRED, "expired" }, |
| { JingleMessage::GENERAL_ERROR, "general-error" }, |
| @@ -57,6 +58,12 @@ const NameMapElement<JingleMessage::Reason> kReasons[] = { |
| { JingleMessage::INCOMPATIBLE_PARAMETERS, "incompatible-parameters" }, |
| }; |
| +const NameMapElement<JingleMessage::ErrorCode> kErrorCodes[] = { |
|
Sergey Ulanov
2016/06/01 08:52:47
We already have ErrorCodeToString() in errors.cc.
Hzj_jie
2016/06/01 23:56:13
Done.
|
| + { JingleMessage::ErrorCode::SESSION_REJECTED, "session-rejected" }, |
| + { JingleMessage::ErrorCode::AUTHENTICATION_FAILED, "authentication-failed" }, |
| + { JingleMessage::ErrorCode::INVALID_ACCOUNT, "invalid-account" }, |
| +}; |
| + |
| bool ParseIceCredentials(const buzz::XmlElement* element, |
| IceTransportInfo::IceCredentials* credentials) { |
| DCHECK(element->Name() == QName(kIceTransportNamespace, "credentials")); |
| @@ -343,6 +350,16 @@ bool JingleMessage::ParseXml(const buzz::XmlElement* stanza, |
| } |
| } |
| + const XmlElement* error_code_tag = |
| + jingle_tag->FirstNamed(QName(kRemotingNamespace, "error-code")); |
| + if (error_code_tag && error_code_tag->FirstElement()) { |
| + if (!NameToValue(kErrorCodes, |
| + error_code_tag->FirstElement()->Name().LocalPart(), |
| + &error_code)) { |
| + error_code = ErrorCode::UNKNOWN; |
| + } |
| + } |
| + |
| if (action == SESSION_TERMINATE) |
| return true; |
| @@ -360,7 +377,7 @@ bool JingleMessage::ParseXml(const buzz::XmlElement* stanza, |
| } |
| const XmlElement* webrtc_transport_tag = content_tag->FirstNamed( |
| - QName("google:remoting:webrtc", "transport")); |
| + QName(kWebrtcTransportNamespace, "transport")); |
| if (webrtc_transport_tag) { |
| transport_info.reset(new buzz::XmlElement(*webrtc_transport_tag)); |
| } |
| @@ -424,12 +441,23 @@ std::unique_ptr<buzz::XmlElement> JingleMessage::ToXml() const { |
| if (reason != UNKNOWN_REASON) { |
| XmlElement* reason_tag = new XmlElement(QName(kJingleNamespace, "reason")); |
| jingle_tag->AddElement(reason_tag); |
| - const char* reason_string = |
| - ValueToName(kReasons, reason); |
| + const char* reason_string = ValueToName(kReasons, reason); |
| if (!reason_string) |
| LOG(FATAL) << "Invalid reason: " << reason; |
| reason_tag->AddElement(new XmlElement( |
| QName(kJingleNamespace, reason_string))); |
| + |
| + if (error_code != ErrorCode::UNKNOWN) { |
| + XmlElement* error_code_tag = |
| + new XmlElement(QName(kRemotingNamespace, "error-code")); |
| + jingle_tag->AddElement(error_code_tag); |
| + const char* error_code_string = ValueToName(kErrorCodes, error_code); |
| + if (!error_code_string) { |
| + LOG(FATAL) << "Invalid error code: " << static_cast<int>(error_code); |
| + } |
| + error_code_tag->AddElement(new XmlElement( |
| + QName(kRemotingNamespace, error_code_string))); |
| + } |
| } |
| if (action != SESSION_TERMINATE) { |