summaryrefslogtreecommitdiffstats
blob: b3d977f4a87aa4bb50f8a6a2f79eedb26e202f20 (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
/*
 * 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 <Swiften/JID/JID.h>
#include <boost/date_time/posix_time/posix_time_types.hpp>

namespace Swift {
	class HistoryMessage {
		public:
			enum Type {
				Chat = 0,
				Groupchat = 1,
				PrivateMessage = 2
			};

			HistoryMessage(
				const std::string& message,
				const JID& fromJID,
				const JID& toJID,
				Type type,
				const boost::posix_time::ptime& time,
				int utcOffset = 0) :
					message_(message),
					fromJID_(fromJID),
					toJID_(toJID),
					type_(type),
					time_(time),
					utcOffset_(utcOffset) {
			}

			const std::string& getMessage() const {
				return message_;
			}

			const JID& getFromJID() const {
				return fromJID_;
			}

			const JID& getToJID() const {
				return toJID_;
			}

			Type getType() const {
				return type_;
			}

			boost::posix_time::ptime getTime() const {
				return time_;
			}

			int getOffset() const {
				return utcOffset_;
			}

			bool operator==(const HistoryMessage& o) const {
				return message_ == o.message_ && fromJID_ == o.fromJID_ && toJID_ == o.toJID_ && type_ == o.type_ && time_ == o.time_;
			}

		private:
			std::string message_;
			JID fromJID_;
			JID toJID_;
			Type type_;
			boost::posix_time::ptime time_;
			int utcOffset_;
	};
}