blob: a114fbcb4a4f0ac7ffae7c7755749267933bfeac (
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
|
#include "Swiften/Queries/Responders/DiscoInfoResponder.h"
#include "Swiften/Queries/IQRouter.h"
#include "Swiften/Elements/DiscoInfo.h"
namespace Swift {
DiscoInfoResponder::DiscoInfoResponder(IQRouter* router) : GetResponder<DiscoInfo>(router) {
}
void DiscoInfoResponder::setDiscoInfo(const DiscoInfo& info) {
info_ = info;
}
void DiscoInfoResponder::setDiscoInfo(const String& node, const DiscoInfo& info) {
DiscoInfo newInfo(info);
newInfo.setNode(node);
nodeInfo_[node] = newInfo;
}
bool DiscoInfoResponder::handleGetRequest(const JID& from, const String& id, boost::shared_ptr<DiscoInfo> info) {
if (info->getNode().isEmpty()) {
sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(info_)));
}
else {
std::map<String,DiscoInfo>::const_iterator i = nodeInfo_.find(info->getNode());
if (i != nodeInfo_.end()) {
sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo((*i).second)));
}
else {
sendError(from, id, Error::ItemNotFound, Error::Cancel);
}
}
return true;
}
}
|