Chromium Code Reviews| 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 <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 13 #include "third_party/webrtc/p2p/base/candidate.h" | 13 #include "third_party/webrtc/p2p/base/candidate.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 namespace protocol { | 16 namespace protocol { |
| 17 | 17 |
| 18 class ContentDescription; | 18 class ContentDescription; |
| 19 | 19 |
| 20 // Represents an address of a Chromoting endpoint and its routing channel. | |
| 21 struct Address { | |
|
Sergey Ulanov
2016/05/18 07:00:42
I think this belongs to remoting/signaling. Potent
kelvinp
2016/05/18 23:43:29
Done.
| |
| 22 enum Channel { | |
|
Sergey Ulanov
2016/05/18 07:00:42
enum class please, here and for enums below
kelvinp
2016/05/18 23:43:29
Done.
| |
| 23 LCS, | |
| 24 XMPP | |
| 25 }; | |
| 26 | |
| 27 enum Role { | |
|
Sergey Ulanov
2016/05/18 07:00:42
this enum is confusing. I suggest removing it and
kelvinp
2016/05/18 23:43:28
Removed.
| |
| 28 FROM, | |
| 29 TO | |
| 30 }; | |
| 31 | |
| 32 // Represents the XML attrbute names for the various address fields in the | |
| 33 // iq stanza. | |
| 34 enum Attribute { | |
| 35 JID, | |
| 36 CHANNEL, | |
| 37 ENDPOINT_ID | |
| 38 }; | |
| 39 | |
| 40 Address(); | |
| 41 explicit Address(const std::string& jid); | |
| 42 | |
| 43 // Represents the |to| or |from| field in an IQ stanza. | |
| 44 std::string jid; | |
| 45 | |
| 46 // Represents the identifier of an endpoint. In XMPP, this is the JID. In | |
|
Sergey Ulanov
2016/05/18 07:00:42
It feels wrong that we duplicate JID for XMPP. Why
kelvinp
2016/05/18 23:43:29
Done.
| |
| 47 // LCS, this is the LCS address encoded in a JID like format | |
| 48 // e.g.user@gmail.com/ResourceID. However,the resource ID can contain invalid | |
| 49 // JID characters (e.g. =), since LCS addresses are base64 encoded). | |
| 50 std::string endpoint_id; | |
| 51 Channel channel; | |
| 52 | |
| 53 // Parses |stanza|. Caller keeps ownership of |stanza|. If the parsing | |
| 54 // fails, false is returned and |error| is set the error message for | |
| 55 // debugging. Returns true for empty address fields. | |
| 56 bool ParseXml(const buzz::XmlElement* stanza, Role role, std::string* error); | |
|
Sergey Ulanov
2016/05/18 07:00:41
I don't think these two functions need to be class
kelvinp
2016/05/18 23:43:29
Removed.
| |
| 57 | |
| 58 // Populates the corresponding address fields in |stanza| for |role|. Caller | |
| 59 // keeps ownership of |stanza|. | |
| 60 void toXml(buzz::XmlElement* iqElement, Role role) const; | |
|
Sergey Ulanov
2016/05/18 07:00:42
I don't think toXml() is a good name as it doesn't
kelvinp
2016/05/18 23:43:29
Removed.
| |
| 61 | |
| 62 bool empty() const; | |
|
Sergey Ulanov
2016/05/18 07:00:41
is_empty().
inline this method?
kelvinp
2016/05/18 23:43:29
Done.
| |
| 63 | |
| 64 static buzz::QName GetQName(Role role, Attribute attr); | |
| 65 | |
| 66 bool operator==(const Address& other); | |
| 67 bool operator!=(const Address& other); | |
| 68 }; | |
| 69 | |
| 20 struct JingleMessage { | 70 struct JingleMessage { |
| 21 enum ActionType { | 71 enum ActionType { |
| 22 UNKNOWN_ACTION, | 72 UNKNOWN_ACTION, |
| 23 SESSION_INITIATE, | 73 SESSION_INITIATE, |
| 24 SESSION_ACCEPT, | 74 SESSION_ACCEPT, |
| 25 SESSION_TERMINATE, | 75 SESSION_TERMINATE, |
| 26 SESSION_INFO, | 76 SESSION_INFO, |
| 27 TRANSPORT_INFO, | 77 TRANSPORT_INFO, |
| 28 }; | 78 }; |
| 29 | 79 |
| 30 enum Reason { | 80 enum Reason { |
| 31 UNKNOWN_REASON, | 81 UNKNOWN_REASON, |
| 32 SUCCESS, | 82 SUCCESS, |
| 33 DECLINE, | 83 DECLINE, |
| 34 CANCEL, | 84 CANCEL, |
| 35 EXPIRED, | 85 EXPIRED, |
| 36 GENERAL_ERROR, | 86 GENERAL_ERROR, |
| 37 FAILED_APPLICATION, | 87 FAILED_APPLICATION, |
| 38 INCOMPATIBLE_PARAMETERS, | 88 INCOMPATIBLE_PARAMETERS, |
| 39 }; | 89 }; |
| 40 | 90 |
| 41 | 91 |
| 42 JingleMessage(); | 92 JingleMessage(); |
| 43 JingleMessage(const std::string& to_value, | 93 JingleMessage(const Address& to, |
| 44 ActionType action_value, | 94 ActionType action_value, |
| 45 const std::string& sid_value); | 95 const std::string& sid_value); |
| 46 ~JingleMessage(); | 96 ~JingleMessage(); |
| 47 | 97 |
| 48 // Caller keeps ownership of |stanza|. | 98 // Caller keeps ownership of |stanza|. |
| 49 static bool IsJingleMessage(const buzz::XmlElement* stanza); | 99 static bool IsJingleMessage(const buzz::XmlElement* stanza); |
| 50 static std::string GetActionName(ActionType action); | 100 static std::string GetActionName(ActionType action); |
| 51 | 101 |
| 52 // Caller keeps ownership of |stanza|. |error| is set to debug error | 102 // Caller keeps ownership of |stanza|. |error| is set to debug error |
| 53 // message when parsing fails. | 103 // message when parsing fails. |
| 54 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); | 104 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); |
| 55 | 105 |
| 56 std::unique_ptr<buzz::XmlElement> ToXml() const; | 106 std::unique_ptr<buzz::XmlElement> ToXml() const; |
| 57 | 107 |
| 58 std::string from; | 108 Address from; |
| 59 std::string to; | 109 Address to; |
| 60 ActionType action = UNKNOWN_ACTION; | 110 ActionType action = UNKNOWN_ACTION; |
| 61 std::string sid; | 111 std::string sid; |
| 62 | 112 |
| 63 std::string initiator; | 113 std::string initiator; |
| 64 | 114 |
| 65 std::unique_ptr<ContentDescription> description; | 115 std::unique_ptr<ContentDescription> description; |
| 66 | 116 |
| 67 std::unique_ptr<buzz::XmlElement> transport_info; | 117 std::unique_ptr<buzz::XmlElement> transport_info; |
| 68 | 118 |
| 69 // Content of session-info messages. | 119 // Content of session-info messages. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 std::unique_ptr<buzz::XmlElement> ToXml() const; | 184 std::unique_ptr<buzz::XmlElement> ToXml() const; |
| 135 | 185 |
| 136 std::list<IceCredentials> ice_credentials; | 186 std::list<IceCredentials> ice_credentials; |
| 137 std::list<NamedCandidate> candidates; | 187 std::list<NamedCandidate> candidates; |
| 138 }; | 188 }; |
| 139 | 189 |
| 140 } // protocol | 190 } // protocol |
| 141 } // remoting | 191 } // remoting |
| 142 | 192 |
| 143 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 193 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
| OLD | NEW |