Revert of Revert of Roll android_tools f6e2370:2a860d8 (patchset #1 id:1 of https...
[chromium-blink-merge.git] / remoting / protocol / jingle_messages.h
blobe12c854489ee6755f3117192da02a3cfb717a3fb
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"
16 namespace remoting {
17 namespace protocol {
19 class ContentDescription;
21 extern const char kJabberNamespace[];
22 extern const char kJingleNamespace[];
23 extern const char kP2PTransportNamespace[];
25 struct JingleMessage {
26 enum ActionType {
27 UNKNOWN_ACTION,
28 SESSION_INITIATE,
29 SESSION_ACCEPT,
30 SESSION_TERMINATE,
31 SESSION_INFO,
32 TRANSPORT_INFO,
35 enum Reason {
36 UNKNOWN_REASON,
37 SUCCESS,
38 DECLINE,
39 CANCEL,
40 GENERAL_ERROR,
41 INCOMPATIBLE_PARAMETERS,
44 struct NamedCandidate {
45 NamedCandidate();
46 NamedCandidate(const std::string& name,
47 const cricket::Candidate& candidate);
49 std::string name;
50 cricket::Candidate candidate;
53 JingleMessage();
54 JingleMessage(const std::string& to_value,
55 ActionType action_value,
56 const std::string& sid_value);
57 ~JingleMessage();
59 // Caller keeps ownership of |stanza|.
60 static bool IsJingleMessage(const buzz::XmlElement* stanza);
61 static std::string GetActionName(ActionType action);
63 // Caller keeps ownership of |stanza|. |error| is set to debug error
64 // message when parsing fails.
65 bool ParseXml(const buzz::XmlElement* stanza, std::string* error);
67 scoped_ptr<buzz::XmlElement> ToXml() const;
69 std::string from;
70 std::string to;
71 ActionType action;
72 std::string sid;
74 std::string initiator;
76 scoped_ptr<ContentDescription> description;
77 std::list<NamedCandidate> candidates;
79 // Content of session-info messages.
80 scoped_ptr<buzz::XmlElement> info;
82 // Value from the <reason> tag if it is present in the
83 // message. Useful mainly for session-terminate messages, but Jingle
84 // spec allows it in any message.
85 Reason reason;
88 struct JingleMessageReply {
89 enum ReplyType {
90 REPLY_RESULT,
91 REPLY_ERROR,
93 enum ErrorType {
94 NONE,
95 BAD_REQUEST,
96 NOT_IMPLEMENTED,
97 INVALID_SID,
98 UNEXPECTED_REQUEST,
99 UNSUPPORTED_INFO,
102 JingleMessageReply();
103 JingleMessageReply(ErrorType error);
104 JingleMessageReply(ErrorType error, const std::string& text);
105 ~JingleMessageReply();
107 // Formats reply stanza for the specified |request_stanza|. Id and
108 // recepient as well as other information needed to generate a valid
109 // reply are taken from |request_stanza|.
110 scoped_ptr<buzz::XmlElement> ToXml(
111 const buzz::XmlElement* request_stanza) const;
113 ReplyType type;
114 ErrorType error_type;
115 std::string text;
118 } // protocol
119 } // remoting
121 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_