summaryrefslogtreecommitdiffstats
blob: 79a8cb83bbee3d8f3d4fc01973511b3e65ef33e0 (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
/*
 * 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/optional.hpp>

#include <Swiften/Base/ByteArray.h>
#include <string>
#include <Swiften/JID/JID.h>

namespace Swift {

	class LinkLocalServiceInfo {
		public:
			enum Status { Available, Away, DND };

			LinkLocalServiceInfo() : status(Available) {}

			const std::string& getFirstName() const { return firstName; }
			void setFirstName(const std::string& f) { firstName = f; }

			const std::string& getLastName() const { return lastName; }
			void setLastName(const std::string& l) { lastName = l; }

			const std::string& getEMail() const { return email; }
			void setEMail(const std::string& e) { email = e; }

			const JID& getJID() const { return jid; }
			void setJID(const JID& j) { jid = j; }

			const std::string& getMessage() const { return message; }
			void setMessage(const std::string& m) { message = m; }

			const std::string& getNick() const { return nick; }
			void setNick(const std::string& n) { nick = n; }

			Status getStatus() const { return status; }
			void setStatus(Status s) { status = s; }

			boost::optional<int> getPort() const { return port; }
			void setPort(int p) { port = p; }

			ByteArray toTXTRecord() const;

			static LinkLocalServiceInfo createFromTXTRecord(const ByteArray& record);

		private:
			static ByteArray getEncoded(const std::string&);
			static std::pair<std::string,std::string> readEntry(const ByteArray&, size_t*);

		private:
			std::string firstName;
			std::string lastName;
			std::string email;
			JID jid;
			std::string message;
			std::string nick;
			Status status;
			boost::optional<int> port;
	};
}