| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } // namespace | 134 } // namespace |
| 135 | 135 |
| 136 // static | 136 // static |
| 137 bool JingleMessage::IsJingleMessage(const buzz::XmlElement* stanza) { | 137 bool JingleMessage::IsJingleMessage(const buzz::XmlElement* stanza) { |
| 138 return | 138 return |
| 139 stanza->Name() == QName(kJabberNamespace, "iq") && | 139 stanza->Name() == QName(kJabberNamespace, "iq") && |
| 140 stanza->Attr(QName("", "type")) == "set" && | 140 stanza->Attr(QName("", "type")) == "set" && |
| 141 stanza->FirstNamed(QName(kJingleNamespace, "jingle")) != NULL; | 141 stanza->FirstNamed(QName(kJingleNamespace, "jingle")) != NULL; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // static | |
| 145 std::string JingleMessage::GetActionName(ActionType action) { | |
| 146 return ValueToName(kActionTypes, arraysize(kActionTypes), action); | |
| 147 } | |
| 148 | |
| 149 JingleMessage::JingleMessage() | 144 JingleMessage::JingleMessage() |
| 150 : action(UNKNOWN_ACTION), | 145 : action(UNKNOWN_ACTION), |
| 151 reason(UNKNOWN_REASON) { | 146 reason(UNKNOWN_REASON) { |
| 152 } | 147 } |
| 153 | 148 |
| 154 JingleMessage::JingleMessage( | 149 JingleMessage::JingleMessage( |
| 155 const std::string& to_value, | 150 const std::string& to_value, |
| 156 ActionType action_value, | 151 ActionType action_value, |
| 157 const std::string& sid_value) | 152 const std::string& sid_value) |
| 158 : to(to_value), | 153 : to(to_value), |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 *error = "Failed to parse candidates"; | 261 *error = "Failed to parse candidates"; |
| 267 return false; | 262 return false; |
| 268 } | 263 } |
| 269 candidates.push_back(candidate); | 264 candidates.push_back(candidate); |
| 270 } | 265 } |
| 271 } | 266 } |
| 272 | 267 |
| 273 return true; | 268 return true; |
| 274 } | 269 } |
| 275 | 270 |
| 276 scoped_ptr<buzz::XmlElement> JingleMessage::ToXml() const { | 271 scoped_ptr<buzz::XmlElement> JingleMessage::ToXml() { |
| 277 scoped_ptr<XmlElement> root( | 272 scoped_ptr<XmlElement> root( |
| 278 new XmlElement(QName("jabber:client", "iq"), true)); | 273 new XmlElement(QName("jabber:client", "iq"), true)); |
| 279 | 274 |
| 280 DCHECK(!to.empty()); | 275 DCHECK(!to.empty()); |
| 281 root->AddAttr(QName(kEmptyNamespace, "to"), to); | 276 root->AddAttr(QName(kEmptyNamespace, "to"), to); |
| 282 if (!from.empty()) | 277 if (!from.empty()) |
| 283 root->AddAttr(QName(kEmptyNamespace, "from"), from); | 278 root->AddAttr(QName(kEmptyNamespace, "from"), from); |
| 284 root->SetAttr(QName(kEmptyNamespace, "type"), "set"); | 279 root->SetAttr(QName(kEmptyNamespace, "type"), "set"); |
| 285 | 280 |
| 286 XmlElement* jingle_tag = | 281 XmlElement* jingle_tag = |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); | 429 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); |
| 435 text_elem->SetBodyText(error_text); | 430 text_elem->SetBodyText(error_text); |
| 436 error->AddElement(text_elem); | 431 error->AddElement(text_elem); |
| 437 } | 432 } |
| 438 | 433 |
| 439 return iq.Pass(); | 434 return iq.Pass(); |
| 440 } | 435 } |
| 441 | 436 |
| 442 } // namespace protocol | 437 } // namespace protocol |
| 443 } // namespace remoting | 438 } // namespace remoting |
| OLD | NEW |