summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Queries')
-rw-r--r--Swiften/Queries/Requests/GetDiscoInfoRequest.h33
-rw-r--r--Swiften/Queries/Requests/GetDiscoItemsRequest.h24
-rw-r--r--Swiften/Queries/Requests/GetRosterRequest.h25
-rw-r--r--Swiften/Queries/Requests/GetVCardRequest.h24
-rw-r--r--Swiften/Queries/Requests/SetRosterRequest.h34
-rw-r--r--Swiften/Queries/Responders/DiscoInfoResponder.cpp42
-rw-r--r--Swiften/Queries/Responders/DiscoInfoResponder.h34
-rw-r--r--Swiften/Queries/Responders/RosterPushResponder.h29
-rw-r--r--Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp96
9 files changed, 0 insertions, 341 deletions
diff --git a/Swiften/Queries/Requests/GetDiscoInfoRequest.h b/Swiften/Queries/Requests/GetDiscoInfoRequest.h
deleted file mode 100644
index d1ed279..0000000
--- a/Swiften/Queries/Requests/GetDiscoInfoRequest.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Queries/GenericRequest.h"
-#include "Swiften/Elements/DiscoInfo.h"
-
-namespace Swift {
- class GetDiscoInfoRequest : public GenericRequest<DiscoInfo>, public Shared<GetDiscoInfoRequest> {
- public:
- static ref create(const JID& jid, IQRouter* router) {
- return ref(new GetDiscoInfoRequest(jid, router));
- }
-
- static ref create(const JID& jid, const String& node, IQRouter* router) {
- return ref(new GetDiscoInfoRequest(jid, node, router));
- }
-
- private:
- GetDiscoInfoRequest(const JID& jid, IQRouter* router) :
- GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) {
- }
-
- GetDiscoInfoRequest(const JID& jid, const String& node, IQRouter* router) :
- GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) {
- getPayloadGeneric()->setNode(node);
- }
- };
-}
diff --git a/Swiften/Queries/Requests/GetDiscoItemsRequest.h b/Swiften/Queries/Requests/GetDiscoItemsRequest.h
deleted file mode 100644
index ed565ac..0000000
--- a/Swiften/Queries/Requests/GetDiscoItemsRequest.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Queries/GenericRequest.h"
-#include "Swiften/Elements/DiscoItems.h"
-
-namespace Swift {
- class GetDiscoItemsRequest : public GenericRequest<DiscoItems>, public Shared<GetDiscoItemsRequest> {
- public:
- static ref create(const JID& jid, IQRouter* router) {
- return ref(new GetDiscoItemsRequest(jid, router));
- }
-
- private:
- GetDiscoItemsRequest(const JID& jid, IQRouter* router) :
- GenericRequest<DiscoItems>(IQ::Get, jid, boost::shared_ptr<DiscoItems>(new DiscoItems()), router) {
- }
- };
-}
diff --git a/Swiften/Queries/Requests/GetRosterRequest.h b/Swiften/Queries/Requests/GetRosterRequest.h
deleted file mode 100644
index 271b2fb..0000000
--- a/Swiften/Queries/Requests/GetRosterRequest.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Queries/GenericRequest.h"
-#include "Swiften/Elements/RosterPayload.h"
-#include "Swiften/Base/Shared.h"
-
-namespace Swift {
- class GetRosterRequest : public GenericRequest<RosterPayload>, public Shared<GetRosterRequest> {
- public:
- static ref create(IQRouter* router) {
- return ref(new GetRosterRequest(router));
- }
-
- private:
- GetRosterRequest(IQRouter* router) :
- GenericRequest<RosterPayload>(IQ::Get, JID(), boost::shared_ptr<Payload>(new RosterPayload()), router) {
- }
- };
-}
diff --git a/Swiften/Queries/Requests/GetVCardRequest.h b/Swiften/Queries/Requests/GetVCardRequest.h
deleted file mode 100644
index 2c40cd1..0000000
--- a/Swiften/Queries/Requests/GetVCardRequest.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Queries/GenericRequest.h"
-#include "Swiften/Elements/VCard.h"
-#include "Swiften/Base/Shared.h"
-
-namespace Swift {
- class GetVCardRequest : public GenericRequest<VCard>, public Shared<GetVCardRequest> {
- public:
- static ref create(const JID& jid, IQRouter* router) {
- return ref(new GetVCardRequest(jid, router));
- }
-
- private:
- GetVCardRequest(const JID& jid, IQRouter* router) : GenericRequest<VCard>(IQ::Get, jid, boost::shared_ptr<Payload>(new VCard()), router) {
- }
- };
-}
diff --git a/Swiften/Queries/Requests/SetRosterRequest.h b/Swiften/Queries/Requests/SetRosterRequest.h
deleted file mode 100644
index 7b1bf8c..0000000
--- a/Swiften/Queries/Requests/SetRosterRequest.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Base/boost_bsignals.h"
-#include <boost/shared_ptr.hpp>
-
-#include "Swiften/Queries/Request.h"
-#include "Swiften/Elements/RosterPayload.h"
-#include "Swiften/Base/Shared.h"
-
-namespace Swift {
- class SetRosterRequest : public Request, public Shared<SetRosterRequest> {
- public:
- static ref create(RosterPayload::ref payload, IQRouter* router) {
- return ref(new SetRosterRequest(payload, router));
- }
-
- private:
- SetRosterRequest(boost::shared_ptr<RosterPayload> payload, IQRouter* router) : Request(IQ::Set, JID(), boost::shared_ptr<RosterPayload>(payload), router) {
- }
-
- virtual void handleResponse(boost::shared_ptr<Payload> /*payload*/, boost::optional<ErrorPayload> error) {
- onResponse(error);
- }
-
- public:
- boost::signal<void (const boost::optional<ErrorPayload>&)> onResponse;
- };
-}
diff --git a/Swiften/Queries/Responders/DiscoInfoResponder.cpp b/Swiften/Queries/Responders/DiscoInfoResponder.cpp
deleted file mode 100644
index 63014c7..0000000
--- a/Swiften/Queries/Responders/DiscoInfoResponder.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#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, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
- }
- }
- return true;
-}
-
-}
diff --git a/Swiften/Queries/Responders/DiscoInfoResponder.h b/Swiften/Queries/Responders/DiscoInfoResponder.h
deleted file mode 100644
index 4a7d271..0000000
--- a/Swiften/Queries/Responders/DiscoInfoResponder.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#ifndef SWIFTEN_DiscoInfoResponder_H
-#define SWIFTEN_DiscoInfoResponder_H
-
-#include <map>
-
-#include "Swiften/Queries/GetResponder.h"
-#include "Swiften/Elements/DiscoInfo.h"
-
-namespace Swift {
- class IQRouter;
-
- class DiscoInfoResponder : public GetResponder<DiscoInfo> {
- public:
- DiscoInfoResponder(IQRouter* router);
-
- void setDiscoInfo(const DiscoInfo& info);
- void setDiscoInfo(const String& node, const DiscoInfo& info);
-
- private:
- virtual bool handleGetRequest(const JID& from, const String& id, boost::shared_ptr<DiscoInfo> payload);
-
- private:
- DiscoInfo info_;
- std::map<String, DiscoInfo> nodeInfo_;
- };
-}
-
-#endif
diff --git a/Swiften/Queries/Responders/RosterPushResponder.h b/Swiften/Queries/Responders/RosterPushResponder.h
deleted file mode 100644
index 48111a7..0000000
--- a/Swiften/Queries/Responders/RosterPushResponder.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/Base/boost_bsignals.h"
-
-#include "Swiften/Queries/SetResponder.h"
-#include "Swiften/Elements/RosterPayload.h"
-
-namespace Swift {
- class RosterPushResponder : public SetResponder<RosterPayload> {
- public:
- RosterPushResponder(IQRouter* router) : SetResponder<RosterPayload>(router) {}
-
- public:
- boost::signal<void (boost::shared_ptr<RosterPayload>)> onRosterReceived;
-
- private:
- virtual bool handleSetRequest(const JID& from, const String& id, boost::shared_ptr<RosterPayload> payload) {
- onRosterReceived(payload);
- sendResponse(from, id, boost::shared_ptr<RosterPayload>());
- return true;
- }
- };
-}
diff --git a/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp b/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp
deleted file mode 100644
index 20fa9ff..0000000
--- a/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <typeinfo>
-
-#include "Swiften/Queries/Responders/DiscoInfoResponder.h"
-#include "Swiften/Queries/IQRouter.h"
-#include "Swiften/Queries/DummyIQChannel.h"
-
-using namespace Swift;
-
-class DiscoInfoResponderTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DiscoInfoResponderTest);
- CPPUNIT_TEST(testHandleRequest_GetToplevelInfo);
- CPPUNIT_TEST(testHandleRequest_GetNodeInfo);
- CPPUNIT_TEST(testHandleRequest_GetInvalidNodeInfo);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- DiscoInfoResponderTest() {}
-
- void setUp() {
- channel_ = new DummyIQChannel();
- router_ = new IQRouter(channel_);
- }
-
- void tearDown() {
- delete router_;
- delete channel_;
- }
-
- void testHandleRequest_GetToplevelInfo() {
- DiscoInfoResponder testling(router_);
- testling.start();
- DiscoInfo discoInfo;
- discoInfo.addFeature("foo");
- testling.setDiscoInfo(discoInfo);
-
- boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
- channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
- boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode());
- CPPUNIT_ASSERT(payload->hasFeature("foo"));
-
- testling.stop();
- }
-
- void testHandleRequest_GetNodeInfo() {
- DiscoInfoResponder testling(router_);
- testling.start();
- DiscoInfo discoInfo;
- discoInfo.addFeature("foo");
- testling.setDiscoInfo(discoInfo);
- DiscoInfo discoInfoBar;
- discoInfoBar.addFeature("bar");
- testling.setDiscoInfo("bar-node", discoInfoBar);
-
- boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
- query->setNode("bar-node");
- channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
- boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode());
- CPPUNIT_ASSERT(payload->hasFeature("bar"));
-
- testling.stop();
- }
-
- void testHandleRequest_GetInvalidNodeInfo() {
- DiscoInfoResponder testling(router_);
-
- boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
- query->setNode("bar-node");
- channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
- boost::shared_ptr<ErrorPayload> payload(channel_->iqs_[0]->getPayload<ErrorPayload>());
- CPPUNIT_ASSERT(payload);
- }
-
- private:
- IQRouter* router_;
- DummyIQChannel* channel_;
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoResponderTest);