summaryrefslogtreecommitdiffstats
blob: 727755f1bfd54942f8dfa0fdd4a254edfca6fe90 (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
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include <boost/shared_ptr.hpp>

#include "Swiften/Base/String.h"
#include "Swiften/Base/ByteArray.h"
#include "Swiften/Elements/Payload.h"

namespace Swift {
	class IBB : public Payload {
		public:
			typedef boost::shared_ptr<IBB> ref;

			enum Action {
				Open,
				Close,
				Data,
			};
			enum StanzaType {
				IQStanza,
				MessageStanza,
			};

			IBB(Action action = Open, const String& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) {
			}

			static IBB::ref createIBBOpen(const String& streamID, int blockSize) {
				IBB::ref result(new IBB(Open, streamID));
				result->setBlockSize(blockSize);
				return result;
			}

			static IBB::ref createIBBData(const String& streamID, int sequenceNumber, const ByteArray& data) {
				IBB::ref result(new IBB(Data, streamID));
				result->setSequenceNumber(sequenceNumber);
				result->setData(data);
				return result;
			}

			static IBB::ref createIBBClose(const String& streamID) {
				return IBB::ref(new IBB(Close, streamID));
			}

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

			Action getAction() const {
				return action;
			}

			void setStanzaType(StanzaType stanzaType) {
				this->stanzaType = stanzaType;
			}

			StanzaType getStanzaType() const {
				return stanzaType;
			}

			void setStreamID(const String& id) {
				streamID = id;
			}

			const String& getStreamID() const {
				return streamID;
			}

			const ByteArray& getData() const {
				return data;
			}

			void setData(const ByteArray& data) {
				this->data = data;
			}

			int getBlockSize() const {
				return blockSize;
			}

			void setBlockSize(int blockSize) {
				this->blockSize = blockSize;
			}

			int getSequenceNumber() const {
				return sequenceNumber;
			}

			void setSequenceNumber(int i) {
				sequenceNumber = i;
			}

		private:
			Action action;
			String streamID;
			ByteArray data;
			StanzaType stanzaType;
			int blockSize;
			int sequenceNumber;
	};
}