| 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 #ifndef REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
| 6 #define REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" |
| 12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 13 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 13 | 14 |
| 14 namespace cricket { | |
| 15 class Candidate; | |
| 16 } // namespace cricket | |
| 17 | 15 |
| 18 namespace remoting { | 16 namespace remoting { |
| 19 namespace protocol { | 17 namespace protocol { |
| 20 | 18 |
| 21 class ContentDescription; | 19 class ContentDescription; |
| 22 | 20 |
| 23 extern const char kJabberNamespace[]; | 21 extern const char kJabberNamespace[]; |
| 24 extern const char kJingleNamespace[]; | 22 extern const char kJingleNamespace[]; |
| 25 extern const char kP2PTransportNamespace[]; | 23 extern const char kP2PTransportNamespace[]; |
| 26 | 24 |
| 27 struct JingleMessage { | 25 struct JingleMessage { |
| 28 enum ActionType { | 26 enum ActionType { |
| 29 UNKNOWN_ACTION, | 27 UNKNOWN_ACTION, |
| 30 SESSION_INITIATE, | 28 SESSION_INITIATE, |
| 31 SESSION_ACCEPT, | 29 SESSION_ACCEPT, |
| 32 SESSION_TERMINATE, | 30 SESSION_TERMINATE, |
| 33 SESSION_INFO, | 31 SESSION_INFO, |
| 34 TRANSPORT_INFO, | 32 TRANSPORT_INFO, |
| 35 }; | 33 }; |
| 36 | 34 |
| 37 enum Reason { | 35 enum Reason { |
| 38 UNKNOWN_REASON, | 36 UNKNOWN_REASON, |
| 39 SUCCESS, | 37 SUCCESS, |
| 40 DECLINE, | 38 DECLINE, |
| 41 CANCEL, | 39 CANCEL, |
| 42 GENERAL_ERROR, | 40 GENERAL_ERROR, |
| 43 INCOMPATIBLE_PARAMETERS, | 41 INCOMPATIBLE_PARAMETERS, |
| 44 }; | 42 }; |
| 45 | 43 |
| 44 struct NamedCandidate { |
| 45 NamedCandidate(); |
| 46 NamedCandidate(const std::string& name, |
| 47 const cricket::Candidate& candidate); |
| 48 |
| 49 std::string name; |
| 50 cricket::Candidate candidate; |
| 51 }; |
| 52 |
| 46 JingleMessage(); | 53 JingleMessage(); |
| 47 JingleMessage(const std::string& to_value, | 54 JingleMessage(const std::string& to_value, |
| 48 ActionType action_value, | 55 ActionType action_value, |
| 49 const std::string& sid_value); | 56 const std::string& sid_value); |
| 50 ~JingleMessage(); | 57 ~JingleMessage(); |
| 51 | 58 |
| 52 // Caller keeps ownership of |stanza|. | 59 // Caller keeps ownership of |stanza|. |
| 53 static bool IsJingleMessage(const buzz::XmlElement* stanza); | 60 static bool IsJingleMessage(const buzz::XmlElement* stanza); |
| 54 static std::string GetActionName(ActionType action); | 61 static std::string GetActionName(ActionType action); |
| 55 | 62 |
| 56 // Caller keeps ownership of |stanza|. |error| is set to debug error | 63 // Caller keeps ownership of |stanza|. |error| is set to debug error |
| 57 // message when parsing fails. | 64 // message when parsing fails. |
| 58 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); | 65 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); |
| 59 | 66 |
| 60 scoped_ptr<buzz::XmlElement> ToXml() const; | 67 scoped_ptr<buzz::XmlElement> ToXml() const; |
| 61 | 68 |
| 62 std::string from; | 69 std::string from; |
| 63 std::string to; | 70 std::string to; |
| 64 ActionType action; | 71 ActionType action; |
| 65 std::string sid; | 72 std::string sid; |
| 66 | 73 |
| 67 scoped_ptr<ContentDescription> description; | 74 scoped_ptr<ContentDescription> description; |
| 68 std::list<cricket::Candidate> candidates; | 75 std::list<NamedCandidate> candidates; |
| 69 | 76 |
| 70 // Content of session-info messages. | 77 // Content of session-info messages. |
| 71 scoped_ptr<buzz::XmlElement> info; | 78 scoped_ptr<buzz::XmlElement> info; |
| 72 | 79 |
| 73 // Value from the <reason> tag if it is present in the | 80 // Value from the <reason> tag if it is present in the |
| 74 // message. Useful mainly for session-terminate messages, but Jingle | 81 // message. Useful mainly for session-terminate messages, but Jingle |
| 75 // spec allows it in any message. | 82 // spec allows it in any message. |
| 76 Reason reason; | 83 Reason reason; |
| 77 }; | 84 }; |
| 78 | 85 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 | 110 |
| 104 ReplyType type; | 111 ReplyType type; |
| 105 ErrorType error_type; | 112 ErrorType error_type; |
| 106 std::string text; | 113 std::string text; |
| 107 }; | 114 }; |
| 108 | 115 |
| 109 } // protocol | 116 } // protocol |
| 110 } // remoting | 117 } // remoting |
| 111 | 118 |
| 112 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 119 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
| OLD | NEW |