blob: 249f9acef18abe41aa9c679270fd08aba38dae6b (
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
|
/*
* 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 <vector>
#include <algorithm>
#include "Swiften/Elements/Payload.h"
#include "Swiften/Base/String.h"
#include "Swiften/Elements/Form.h"
namespace Swift {
class DiscoInfo : public Payload {
public:
typedef boost::shared_ptr<DiscoInfo> ref;
const static std::string SecurityLabels;
class Identity {
public:
Identity(const String& name, const String& category = "client", const String& type = "pc", const String& lang = "") : name_(name), category_(category), type_(type), lang_(lang) {
}
const String& getCategory() const {
return category_;
}
const String& getType() const {
return type_;
}
const String& getLanguage() const {
return lang_;
}
const String& getName() const {
return name_;
}
// Sorted according to XEP-115 rules
bool operator<(const Identity& other) const;
private:
String name_;
String category_;
String type_;
String lang_;
};
DiscoInfo() {
}
const String& getNode() const {
return node_;
}
void setNode(const String& node) {
node_ = node;
}
const std::vector<Identity>& getIdentities() const {
return identities_;
}
void addIdentity(const Identity& identity) {
identities_.push_back(identity);
}
const std::vector<String>& getFeatures() const {
return features_;
}
void addFeature(const String& feature) {
features_.push_back(feature);
}
bool hasFeature(const String& feature) const {
return std::find(features_.begin(), features_.end(), feature) != features_.end();
}
void addExtension(Form::ref form) {
extensions_.push_back(form);
}
const std::vector<Form::ref> getExtensions() const {
return extensions_;
}
private:
String node_;
std::vector<Identity> identities_;
std::vector<String> features_;
std::vector<Form::ref> extensions_;
};
}
|