Files
@ bb4ac38e5089
Branch filter:
Location: libtransport.git/src/discoinforesponder.cpp - annotation
bb4ac38e5089
3.5 KiB
text/x-c++hdr
Fixed tests
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 | c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 3fe27413f536 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 3fe27413f536 3fe27413f536 3fe27413f536 3fe27413f536 3fe27413f536 c5edfd19b1aa 3fe27413f536 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 485d355ea84c c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa 650b89e4bcfc 650b89e4bcfc c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa d0adbddc0ba7 d0adbddc0ba7 d0adbddc0ba7 c5edfd19b1aa c5edfd19b1aa e5fcbf00b799 e5fcbf00b799 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa e5fcbf00b799 d7fb0da49618 d7fb0da49618 d7fb0da49618 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa d7fb0da49618 d7fb0da49618 d7fb0da49618 c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa c5edfd19b1aa | /**
* XMPP - libpurple transport
*
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include "discoinforesponder.h"
#include <iostream>
#include <boost/bind.hpp>
#include "Swiften/Disco/DiscoInfoResponder.h"
#include "Swiften/Queries/IQRouter.h"
#include "Swiften/Elements/DiscoInfo.h"
#include "Swiften/Swiften.h"
#include "transport/config.h"
using namespace Swift;
using namespace boost;
namespace Transport {
DiscoInfoResponder::DiscoInfoResponder(Swift::IQRouter *router, Config *config) : Swift::GetResponder<DiscoInfo>(router) {
m_config = config;
m_transportInfo.addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"),
CONFIG_STRING(m_config, "identity.category"),
CONFIG_STRING(m_config, "identity.type")));
m_buddyInfo.addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"), "client", "pc"));
std::list<std::string> features;
features.push_back("jabber:iq:register");
features.push_back("jabber:iq:gateway");
features.push_back("jabber:iq:private");
features.push_back("http://jabber.org/protocol/disco#info");
features.push_back("http://jabber.org/protocol/commands");
setTransportFeatures(features);
features.clear();
features.push_back("http://jabber.org/protocol/disco#items");
features.push_back("http://jabber.org/protocol/disco#info");
features.push_back("http://jabber.org/protocol/chatstates");
features.push_back("http://jabber.org/protocol/xhtml-im");
setBuddyFeatures(features);
}
DiscoInfoResponder::~DiscoInfoResponder() {
}
void DiscoInfoResponder::setTransportFeatures(std::list<std::string> &features) {
for (std::list<std::string>::iterator it = features.begin(); it != features.end(); it++) {
if (!m_transportInfo.hasFeature(*it)) {
m_transportInfo.addFeature(*it);
}
}
}
void DiscoInfoResponder::setBuddyFeatures(std::list<std::string> &f) {
for (std::list<std::string>::iterator it = f.begin(); it != f.end(); it++) {
if (!m_buddyInfo.hasFeature(*it)) {
m_buddyInfo.addFeature(*it);
}
}
CapsInfoGenerator caps("spectrum");
m_capsInfo = caps.generateCapsInfo(m_buddyInfo);
onBuddyCapsInfoChanged(m_capsInfo);
}
bool DiscoInfoResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::DiscoInfo> info) {
if (!info->getNode().empty()) {
sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
return true;
}
// presence for transport
if (to.getNode().empty()) {
boost::shared_ptr<DiscoInfo> res(new DiscoInfo(m_transportInfo));
res->setNode(info->getNode());
sendResponse(from, id, res);
}
// presence for buddy
else {
boost::shared_ptr<DiscoInfo> res(new DiscoInfo(m_buddyInfo));
res->setNode(info->getNode());
sendResponse(from, to, id, res);
}
return true;
}
}
|