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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 const XmlElement* jingle_tag = | 162 const XmlElement* jingle_tag = |
163 stanza->FirstNamed(QName(kJingleNamespace, "jingle")); | 163 stanza->FirstNamed(QName(kJingleNamespace, "jingle")); |
164 if (!jingle_tag) { | 164 if (!jingle_tag) { |
165 *error = "Not a jingle message"; | 165 *error = "Not a jingle message"; |
166 return false; | 166 return false; |
167 } | 167 } |
168 | 168 |
169 from = stanza->Attr(QName(kEmptyNamespace, "from")); | 169 from = stanza->Attr(QName(kEmptyNamespace, "from")); |
170 to = stanza->Attr(QName(kEmptyNamespace, "to")); | 170 to = stanza->Attr(QName(kEmptyNamespace, "to")); |
| 171 initiator = jingle_tag->Attr(QName(kEmptyNamespace, "initiator")); |
171 | 172 |
172 std::string action_str = jingle_tag->Attr(QName(kEmptyNamespace, "action")); | 173 std::string action_str = jingle_tag->Attr(QName(kEmptyNamespace, "action")); |
173 if (action_str.empty()) { | 174 if (action_str.empty()) { |
174 *error = "action attribute is missing"; | 175 *error = "action attribute is missing"; |
175 return false; | 176 return false; |
176 } | 177 } |
177 if (!NameToValue(kActionTypes, action_str, &action)) { | 178 if (!NameToValue(kActionTypes, action_str, &action)) { |
178 *error = "Unknown action " + action_str; | 179 *error = "Unknown action " + action_str; |
179 return false; | 180 return false; |
180 } | 181 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 LOG(FATAL) << "Invalid action value " << action; | 281 LOG(FATAL) << "Invalid action value " << action; |
281 jingle_tag->AddAttr(QName(kEmptyNamespace, "action"), action_attr); | 282 jingle_tag->AddAttr(QName(kEmptyNamespace, "action"), action_attr); |
282 | 283 |
283 if (action == SESSION_INFO) { | 284 if (action == SESSION_INFO) { |
284 if (info.get()) | 285 if (info.get()) |
285 jingle_tag->AddElement(new XmlElement(*info.get())); | 286 jingle_tag->AddElement(new XmlElement(*info.get())); |
286 return root.Pass(); | 287 return root.Pass(); |
287 } | 288 } |
288 | 289 |
289 if (action == SESSION_INITIATE) | 290 if (action == SESSION_INITIATE) |
290 jingle_tag->AddAttr(QName(kEmptyNamespace, "initiator"), from); | 291 jingle_tag->AddAttr(QName(kEmptyNamespace, "initiator"), initiator); |
291 | 292 |
292 if (reason != UNKNOWN_REASON) { | 293 if (reason != UNKNOWN_REASON) { |
293 XmlElement* reason_tag = new XmlElement(QName(kJingleNamespace, "reason")); | 294 XmlElement* reason_tag = new XmlElement(QName(kJingleNamespace, "reason")); |
294 jingle_tag->AddElement(reason_tag); | 295 jingle_tag->AddElement(reason_tag); |
295 const char* reason_string = | 296 const char* reason_string = |
296 ValueToName(kReasons, reason); | 297 ValueToName(kReasons, reason); |
297 if (!reason_string) | 298 if (!reason_string) |
298 LOG(FATAL) << "Invalid reason: " << reason; | 299 LOG(FATAL) << "Invalid reason: " << reason; |
299 reason_tag->AddElement(new XmlElement( | 300 reason_tag->AddElement(new XmlElement( |
300 QName(kJingleNamespace, reason_string))); | 301 QName(kJingleNamespace, reason_string))); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); | 421 text_elem->SetAttr(QName(kXmlNamespace, "lang"), "en"); |
421 text_elem->SetBodyText(error_text); | 422 text_elem->SetBodyText(error_text); |
422 error->AddElement(text_elem); | 423 error->AddElement(text_elem); |
423 } | 424 } |
424 | 425 |
425 return iq.Pass(); | 426 return iq.Pass(); |
426 } | 427 } |
427 | 428 |
428 } // namespace protocol | 429 } // namespace protocol |
429 } // namespace remoting | 430 } // namespace remoting |
OLD | NEW |