summaryrefslogtreecommitdiffstats
blob: 59d3c99c1f49a736059fda14ed5072f4400f0d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright (c) 2011 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include <vector>
#include <boost/optional.hpp>

#include <string>
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/JingleContent.h>


namespace Swift {
	class JinglePayload : public Payload {
		public:
			typedef boost::shared_ptr<JinglePayload> ref;
			struct Reason {
					enum Type {
						AlternativeSession,
						Busy,
						Cancel,
						ConnectivityError,
						Decline,
						Expired,
						FailedApplication,
						FailedTransport,
						GeneralError,
						Gone,
						IncompatibleParameters,
						MediaError,
						SecurityError,
						Success,
						Timeout,
						UnsupportedApplications,
						UnsupportedTransports
					};
					
					Reason(Type type, const std::string& text = "") : type(type), text(text) {}
					Type type;
					std::string text;
			};

			enum Action {
				ContentAccept,
				ContentAdd,
				ContentModify,
				ContentReject,
				ContentRemove,
				DescriptionInfo,
				SecurityInfo,
				SessionAccept,
				SessionInfo,
				SessionInitiate,
				SessionTerminate,
				TransportAccept,
				TransportInfo,
				TransportReject,
				TransportReplace
			};

			JinglePayload(Action action, const std::string& sessionID) : action(action), sessionID(sessionID) {
			}

			void setAction(Action action) {
				this->action = action;
			}

			Action getAction() const {
				return action;
			}

			void setInitiator(const JID& initiator) {
				this->initiator = initiator;
			}

			const JID& getInitiator() const {
				return initiator;
			}

			void setResponder(const JID& responder) {
				this->responder = responder;
			}

			const JID& getResponder() const {
				return responder;
			}

			void setSessionID(const std::string& id) {
				sessionID = id;
			}

			const std::string& getSessionID() const {
				return sessionID;
			}

			void addContent(JingleContent::ref content) {
				this->contents.push_back(content);
			}

			const std::vector<JingleContent::ref> getContents() const {
				return contents;
			}

			void setReason(const Reason& reason) {
				this->reason = reason;
			}

			const boost::optional<Reason>& getReason() const {
				return reason;
			}

		private:
			Action action;
			JID initiator;
			JID responder;
			std::string sessionID;
			std::vector<JingleContent::ref> contents;
			boost::optional<Reason> reason;
	};
}