[Sync] Test Android passphrase creation UI
[chromium-blink-merge.git] / remoting / protocol / jingle_messages.h
blobc83776ad4f3060215ce74efdfbd02dbafecafe45
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_JINGLE_MESSAGES_H_
6 #define REMOTING_PROTOCOL_JINGLE_MESSAGES_H_
8 #include <list>
9 #include <string>
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
13 #include "third_party/webrtc/p2p/base/candidate.h"
15 namespace remoting {
16 namespace protocol {
18 class ContentDescription;
20 struct JingleMessage {
21 enum ActionType {
22 UNKNOWN_ACTION,
23 SESSION_INITIATE,
24 SESSION_ACCEPT,
25 SESSION_TERMINATE,
26 SESSION_INFO,
27 TRANSPORT_INFO,
30 enum Reason {
31 UNKNOWN_REASON,
32 SUCCESS,
33 DECLINE,
34 CANCEL,
35 GENERAL_ERROR,
36 INCOMPATIBLE_PARAMETERS,
39 struct NamedCandidate {
40 NamedCandidate() = default;
41 NamedCandidate(const std::string& name,
42 const cricket::Candidate& candidate);
44 std::string name;
45 cricket::Candidate candidate;
48 struct IceCredentials {
49 IceCredentials() = default;
50 IceCredentials(std::string channel,
51 std::string ufrag,
52 std::string password);
54 std::string channel;
55 std::string ufrag;
56 std::string password;
59 JingleMessage();
60 JingleMessage(const std::string& to_value,
61 ActionType action_value,
62 const std::string& sid_value);
63 ~JingleMessage();
65 // Caller keeps ownership of |stanza|.
66 static bool IsJingleMessage(const buzz::XmlElement* stanza);
67 static std::string GetActionName(ActionType action);
69 // Caller keeps ownership of |stanza|. |error| is set to debug error
70 // message when parsing fails.
71 bool ParseXml(const buzz::XmlElement* stanza, std::string* error);
73 scoped_ptr<buzz::XmlElement> ToXml() const;
75 std::string from;
76 std::string to;
77 ActionType action = UNKNOWN_ACTION;
78 std::string sid;
80 std::string initiator;
82 scoped_ptr<ContentDescription> description;
84 bool standard_ice = true;
85 std::list<IceCredentials> ice_credentials;
86 std::list<NamedCandidate> candidates;
88 // Content of session-info messages.
89 scoped_ptr<buzz::XmlElement> info;
91 // Value from the <reason> tag if it is present in the
92 // message. Useful mainly for session-terminate messages, but Jingle
93 // spec allows it in any message.
94 Reason reason = UNKNOWN_REASON;
97 struct JingleMessageReply {
98 enum ReplyType {
99 REPLY_RESULT,
100 REPLY_ERROR,
102 enum ErrorType {
103 NONE,
104 BAD_REQUEST,
105 NOT_IMPLEMENTED,
106 INVALID_SID,
107 UNEXPECTED_REQUEST,
108 UNSUPPORTED_INFO,
111 JingleMessageReply();
112 JingleMessageReply(ErrorType error);
113 JingleMessageReply(ErrorType error, const std::string& text);
114 ~JingleMessageReply();
116 // Formats reply stanza for the specified |request_stanza|. Id and
117 // recepient as well as other information needed to generate a valid
118 // reply are taken from |request_stanza|.
119 scoped_ptr<buzz::XmlElement> ToXml(
120 const buzz::XmlElement* request_stanza) const;
122 ReplyType type;
123 ErrorType error_type;
124 std::string text;
127 } // protocol
128 } // remoting
130 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_