| 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/string_number_conversions.h" | 8 #include "base/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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 JingleMessage::NamedCandidate::NamedCandidate( | 118 JingleMessage::NamedCandidate::NamedCandidate( |
| 119 const std::string& name, | 119 const std::string& name, |
| 120 const cricket::Candidate& candidate) | 120 const cricket::Candidate& candidate) |
| 121 : name(name), | 121 : name(name), |
| 122 candidate(candidate) { | 122 candidate(candidate) { |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | 125 // static |
| 126 bool JingleMessage::IsJingleMessage(const buzz::XmlElement* stanza) { | 126 bool JingleMessage::IsJingleMessage(const buzz::XmlElement* stanza) { |
| 127 return | 127 return stanza->Name() == QName(kJabberNamespace, "iq") && |
| 128 stanza->Name() == QName(kJabberNamespace, "iq") && | 128 stanza->Attr(QName(std::string(), "type")) == "set" && |
| 129 stanza->Attr(QName("", "type")) == "set" && | 129 stanza->FirstNamed(QName(kJingleNamespace, "jingle")) != NULL; |
| 130 stanza->FirstNamed(QName(kJingleNamespace, "jingle")) != NULL; | |
| 131 } | 130 } |
| 132 | 131 |
| 133 // static | 132 // static |
| 134 std::string JingleMessage::GetActionName(ActionType action) { | 133 std::string JingleMessage::GetActionName(ActionType action) { |
| 135 return ValueToName(kActionTypes, action); | 134 return ValueToName(kActionTypes, action); |
| 136 } | 135 } |
| 137 | 136 |
| 138 JingleMessage::JingleMessage() | 137 JingleMessage::JingleMessage() |
| 139 : action(UNKNOWN_ACTION), | 138 : action(UNKNOWN_ACTION), |
| 140 reason(UNKNOWN_REASON) { | 139 reason(UNKNOWN_REASON) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 child != NULL; child = child->NextElement()) { | 365 child != NULL; child = child->NextElement()) { |
| 367 iq->AddElement(new buzz::XmlElement(*child)); | 366 iq->AddElement(new buzz::XmlElement(*child)); |
| 368 } | 367 } |
| 369 | 368 |
| 370 buzz::XmlElement* error = | 369 buzz::XmlElement* error = |
| 371 new buzz::XmlElement(QName(kJabberNamespace, "error")); | 370 new buzz::XmlElement(QName(kJabberNamespace, "error")); |
| 372 iq->AddElement(error); | 371 iq->AddElement(error); |
| 373 | 372 |
| 374 std::string type; | 373 std::string type; |
| 375 std::string error_text; | 374 std::string error_text; |
| 376 QName name(""); | 375 QName name; |
| 377 switch (error_type) { | 376 switch (error_type) { |
| 378 case BAD_REQUEST: | 377 case BAD_REQUEST: |
| 379 type = "modify"; | 378 type = "modify"; |
| 380 name = QName(kJabberNamespace, "bad-request"); | 379 name = QName(kJabberNamespace, "bad-request"); |
| 381 break; | 380 break; |
| 382 case NOT_IMPLEMENTED: | 381 case NOT_IMPLEMENTED: |
| 383 type = "cancel"; | 382 type = "cancel"; |
| 384 name = QName(kJabberNamespace, "feature-bad-request"); | 383 name = QName(kJabberNamespace, "feature-bad-request"); |
| 385 break; | 384 break; |
| 386 case INVALID_SID: | 385 case INVALID_SID: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); | 420 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); |
| 422 text_elem->SetBodyText(error_text); | 421 text_elem->SetBodyText(error_text); |
| 423 error->AddElement(text_elem); | 422 error->AddElement(text_elem); |
| 424 } | 423 } |
| 425 | 424 |
| 426 return iq.Pass(); | 425 return iq.Pass(); |
| 427 } | 426 } |
| 428 | 427 |
| 429 } // namespace protocol | 428 } // namespace protocol |
| 430 } // namespace remoting | 429 } // namespace remoting |
| OLD | NEW |