/** * XMPP - libpurple transport * * Copyright (C) 2009, Jan Kaluza * * 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 #include #include "Swiften/Disco/DiscoInfoResponder.h" #include "Swiften/Queries/IQRouter.h" #include "Swiften/Elements/DiscoInfo.h" #include "Swiften/Swiften.h" using namespace Swift; using namespace boost; namespace Transport { DiscoInfoResponder::DiscoInfoResponder(Swift::IQRouter *router) : Swift::GetResponder(router) { m_transportInfo.addIdentity(DiscoInfo::Identity("libtransport", "gateway", "identity")); m_buddyInfo.addIdentity(DiscoInfo::Identity("libtransport", "client", "pc")); std::list features; features.push_back("jabber:iq:register"); features.push_back("jabber:iq:gateway"); 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"); setBuddyFeatures(features); } DiscoInfoResponder::~DiscoInfoResponder() { } void DiscoInfoResponder::setTransportFeatures(std::list &features) { for (std::list::iterator it = features.begin(); it != features.end(); it++) { if (!m_transportInfo.hasFeature(*it)) { m_transportInfo.addFeature(*it); } } } void DiscoInfoResponder::setBuddyFeatures(std::list &f) { for (std::list::iterator it = f.begin(); it != f.end(); it++) { if (!m_buddyInfo.hasFeature(*it)) { m_buddyInfo.addFeature(*it); } } CapsInfoGenerator caps(""); onBuddyCapsInfoChanged(caps.generateCapsInfo(m_buddyInfo)); } bool DiscoInfoResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const Swift::String& id, boost::shared_ptr info) { if (!info->getNode().isEmpty()) { sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel); return true; } // presence for transport if (to.getNode().isEmpty()) { sendResponse(from, id, boost::shared_ptr(new DiscoInfo(m_transportInfo))); } // presence for buddy else { sendResponse(from, id, boost::shared_ptr(new DiscoInfo(m_buddyInfo))); } return true; } }