Index: remoting/protocol/jingle_messages.h |
diff --git a/remoting/protocol/jingle_messages.h b/remoting/protocol/jingle_messages.h |
index e81d86237cca6cb624df75b76280721df78c646a..f4631de2f881a035b00fcea4e1def4231b541655 100644 |
--- a/remoting/protocol/jingle_messages.h |
+++ b/remoting/protocol/jingle_messages.h |
@@ -17,6 +17,56 @@ namespace protocol { |
class ContentDescription; |
+// Represents an address of a Chromoting endpoint and its routing channel. |
+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.
|
+ 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.
|
+ LCS, |
+ XMPP |
+ }; |
+ |
+ 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.
|
+ FROM, |
+ TO |
+ }; |
+ |
+ // Represents the XML attrbute names for the various address fields in the |
+ // iq stanza. |
+ enum Attribute { |
+ JID, |
+ CHANNEL, |
+ ENDPOINT_ID |
+ }; |
+ |
+ Address(); |
+ explicit Address(const std::string& jid); |
+ |
+ // Represents the |to| or |from| field in an IQ stanza. |
+ std::string jid; |
+ |
+ // 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.
|
+ // LCS, this is the LCS address encoded in a JID like format |
+ // e.g.user@gmail.com/ResourceID. However,the resource ID can contain invalid |
+ // JID characters (e.g. =), since LCS addresses are base64 encoded). |
+ std::string endpoint_id; |
+ Channel channel; |
+ |
+ // Parses |stanza|. Caller keeps ownership of |stanza|. If the parsing |
+ // fails, false is returned and |error| is set the error message for |
+ // debugging. Returns true for empty address fields. |
+ 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.
|
+ |
+ // Populates the corresponding address fields in |stanza| for |role|. Caller |
+ // keeps ownership of |stanza|. |
+ 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.
|
+ |
+ bool empty() const; |
Sergey Ulanov
2016/05/18 07:00:41
is_empty().
inline this method?
kelvinp
2016/05/18 23:43:29
Done.
|
+ |
+ static buzz::QName GetQName(Role role, Attribute attr); |
+ |
+ bool operator==(const Address& other); |
+ bool operator!=(const Address& other); |
+}; |
+ |
struct JingleMessage { |
enum ActionType { |
UNKNOWN_ACTION, |
@@ -40,7 +90,7 @@ struct JingleMessage { |
JingleMessage(); |
- JingleMessage(const std::string& to_value, |
+ JingleMessage(const Address& to, |
ActionType action_value, |
const std::string& sid_value); |
~JingleMessage(); |
@@ -55,8 +105,8 @@ struct JingleMessage { |
std::unique_ptr<buzz::XmlElement> ToXml() const; |
- std::string from; |
- std::string to; |
+ Address from; |
+ Address to; |
ActionType action = UNKNOWN_ACTION; |
std::string sid; |