Added basic RosterResponder class
This commit is contained in:
parent
e062a79b1f
commit
07859ef393
5 changed files with 113 additions and 13 deletions
|
@ -2,23 +2,34 @@
|
|||
#include "transport/transport.h"
|
||||
#include "transport/logger.h"
|
||||
#include "Swiften/EventLoop/SimpleEventLoop.h"
|
||||
#include "Swiften/Network/BoostTimerFactory.h"
|
||||
#include "Swiften/Network/BoostIOServiceThread.h"
|
||||
#include "Swiften/Network/BoostNetworkFactories.h"
|
||||
#include "Swiften/Server/UserRegistry.h"
|
||||
#include "Swiften/Server/Server.h"
|
||||
#include "Swiften/Swiften.h"
|
||||
|
||||
using namespace Transport;
|
||||
|
||||
class DummyUserRegistry : public Swift::UserRegistry {
|
||||
public:
|
||||
DummyUserRegistry() {}
|
||||
|
||||
virtual bool isValidUserPassword(const Swift::JID&, const std::string&) const {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Config config;
|
||||
if (!config.load("sample.cfg")) {
|
||||
std::cout << "Can't open sample.cfg configuration file.\n";
|
||||
return 1;
|
||||
}
|
||||
Swift::logging = true;
|
||||
|
||||
Swift::SimpleEventLoop eventLoop;
|
||||
Component transport(&eventLoop, &config);
|
||||
Swift::SimpleEventLoop loop;
|
||||
|
||||
Logger logger(&transport);
|
||||
Swift::BoostNetworkFactories *m_factories = new Swift::BoostNetworkFactories(&loop);
|
||||
DummyUserRegistry dummyregistry;
|
||||
Swift::Server server(&loop, m_factories, &dummyregistry, "localhost", 5222);
|
||||
server.start();
|
||||
|
||||
transport.connect();
|
||||
eventLoop.run();
|
||||
loop.run();
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace Transport {
|
|||
class StorageBackend;
|
||||
class DiscoInfoResponder;
|
||||
class DiscoItemsResponder;
|
||||
class RosterResponder;
|
||||
|
||||
/// Represents one transport instance.
|
||||
|
||||
|
@ -152,7 +153,7 @@ namespace Transport {
|
|||
StorageBackend *m_storageBackend;
|
||||
DiscoInfoResponder *m_discoInfoResponder;
|
||||
DiscoItemsResponder *m_discoItemsResponder;
|
||||
// SpectrumRegisterHandler *m_registerHandler;
|
||||
RosterResponder *m_rosterResponder;
|
||||
int m_reconnectCount;
|
||||
Config* m_config;
|
||||
std::string m_protocol;
|
||||
|
|
44
src/rosterresponder.cpp
Normal file
44
src/rosterresponder.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* 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 "rosterresponder.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/bind.hpp>
|
||||
#include "Swiften/Queries/IQRouter.h"
|
||||
#include "Swiften/Swiften.h"
|
||||
|
||||
using namespace Swift;
|
||||
using namespace boost;
|
||||
|
||||
namespace Transport {
|
||||
|
||||
RosterResponder::RosterResponder(Swift::IQRouter *router) : Swift::GetResponder<RosterPayload>(router) {
|
||||
}
|
||||
|
||||
RosterResponder::~RosterResponder() {
|
||||
}
|
||||
|
||||
bool RosterResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::RosterPayload> payload) {
|
||||
std::cout << "PAYLOAD\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
39
src/rosterresponder.h
Normal file
39
src/rosterresponder.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* libtransport -- C++ library for easy XMPP Transports development
|
||||
*
|
||||
* Copyright (C) 2011, Jan Kaluza <hanzz.k@gmail.com>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "Swiften/Swiften.h"
|
||||
#include "Swiften/Queries/GetResponder.h"
|
||||
#include "Swiften/Elements/RosterPayload.h"
|
||||
|
||||
namespace Transport {
|
||||
|
||||
class RosterResponder : public Swift::GetResponder<Swift::RosterPayload> {
|
||||
public:
|
||||
RosterResponder(Swift::IQRouter *router);
|
||||
~RosterResponder();
|
||||
|
||||
private:
|
||||
virtual bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::RosterPayload> payload);
|
||||
};
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
#include "transport/storagebackend.h"
|
||||
#include "discoinforesponder.h"
|
||||
#include "discoitemsresponder.h"
|
||||
#include "rosterresponder.h"
|
||||
|
||||
using namespace Swift;
|
||||
using namespace boost;
|
||||
|
@ -88,6 +89,10 @@ Component::Component(Swift::EventLoop *loop, Config *config) {
|
|||
|
||||
m_discoItemsResponder = new DiscoItemsResponder(m_iqRouter);
|
||||
m_discoItemsResponder->start();
|
||||
|
||||
m_rosterResponder = new RosterResponder(m_iqRouter);
|
||||
m_rosterResponder->start();
|
||||
|
||||
//
|
||||
// m_registerHandler = new SpectrumRegisterHandler(m_component);
|
||||
// m_registerHandler->start();
|
||||
|
@ -98,8 +103,8 @@ Component::~Component() {
|
|||
delete m_entityCapsManager;
|
||||
delete m_capsManager;
|
||||
delete m_capsMemoryStorage;
|
||||
// delete m_discoInfoResponder;
|
||||
// delete m_registerHandler;
|
||||
delete m_rosterResponder;
|
||||
delete m_discoInfoResponder;
|
||||
if (m_component)
|
||||
delete m_component;
|
||||
if (m_server)
|
||||
|
|
Loading…
Add table
Reference in a new issue