Files
@ 73bb99cf4331
Branch filter:
Location: libtransport.git/src/discoitemsresponder.cpp - annotation
73bb99cf4331
2.9 KiB
text/x-c++hdr
Merge branch 'libtwitcurl_fix'
a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc 8a66baabcb99 a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc 8a66baabcb99 8a66baabcb99 3201977efb6a a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc 8a66baabcb99 8a66baabcb99 8a66baabcb99 8a66baabcb99 8a66baabcb99 8a66baabcb99 22679e921b90 22679e921b90 3201977efb6a 3201977efb6a a6253712ccbc a6253712ccbc a6253712ccbc 3201977efb6a a6253712ccbc a6253712ccbc 8a66baabcb99 8a66baabcb99 389f066d9e2d 8a66baabcb99 8a66baabcb99 22679e921b90 3201977efb6a 3201977efb6a 3201977efb6a 3201977efb6a 3201977efb6a 22679e921b90 22679e921b90 22679e921b90 22679e921b90 3201977efb6a 3201977efb6a 3201977efb6a 3201977efb6a 3201977efb6a 22679e921b90 22679e921b90 8a66baabcb99 a6253712ccbc 8a66baabcb99 8a66baabcb99 8a66baabcb99 8a66baabcb99 8a66baabcb99 22679e921b90 a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc a6253712ccbc | /**
* 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 "transport/discoitemsresponder.h"
#include <iostream>
#include <boost/bind.hpp>
#include "Swiften/Queries/IQRouter.h"
#include "transport/transport.h"
#include "transport/logging.h"
#include "discoinforesponder.h"
using namespace Swift;
using namespace boost;
namespace Transport {
DEFINE_LOGGER(logger, "DiscoItemsResponder");
DiscoItemsResponder::DiscoItemsResponder(Component *component) : Swift::GetResponder<DiscoItems>(component->getIQRouter()) {
m_component = component;
m_commands = boost::shared_ptr<DiscoItems>(new DiscoItems());
m_commands->setNode("http://jabber.org/protocol/commands");
m_rooms = boost::shared_ptr<DiscoItems>(new DiscoItems());
m_discoInfoResponder = new DiscoInfoResponder(component->getIQRouter(), component->getConfig());
m_discoInfoResponder->start();
}
DiscoItemsResponder::~DiscoItemsResponder() {
delete m_discoInfoResponder;
}
void DiscoItemsResponder::addAdHocCommand(const std::string &node, const std::string &name) {
m_commands->addItem(DiscoItems::Item(name, m_component->getJID(), node));
m_discoInfoResponder->addAdHocCommand(node, name);
}
void DiscoItemsResponder::addRoom(const std::string &node, const std::string &name) {
if (m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
return;
}
m_rooms->addItem(DiscoItems::Item(name, node));
m_discoInfoResponder->addRoom(node, name);
}
void DiscoItemsResponder::clearRooms() {
m_rooms = boost::shared_ptr<DiscoItems>(new DiscoItems());
m_discoInfoResponder->clearRooms();
}
Swift::CapsInfo &DiscoItemsResponder::getBuddyCapsInfo() {
return m_discoInfoResponder->getBuddyCapsInfo();
}
bool DiscoItemsResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::DiscoItems> info) {
LOG4CXX_INFO(logger, "get request received with node " << info->getNode());
if (info->getNode() == "http://jabber.org/protocol/commands") {
sendResponse(from, id, m_commands);
}
else if (to.getNode().empty()) {
sendResponse(from, id, m_rooms);
}
else {
sendResponse(from, id, boost::shared_ptr<DiscoItems>(new DiscoItems()));
}
return true;
}
}
|