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_
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"
19 class ContentDescription
;
21 extern const char kJabberNamespace
[];
22 extern const char kJingleNamespace
[];
23 extern const char kP2PTransportNamespace
[];
25 struct JingleMessage
{
41 INCOMPATIBLE_PARAMETERS
,
44 struct NamedCandidate
{
46 NamedCandidate(const std::string
& name
,
47 const cricket::Candidate
& candidate
);
50 cricket::Candidate candidate
;
54 JingleMessage(const std::string
& to_value
,
55 ActionType action_value
,
56 const std::string
& sid_value
);
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;
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.
88 struct JingleMessageReply
{
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;
114 ErrorType error_type
;
121 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_