diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-10-09 09:52:51 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-10-09 14:20:47 (GMT) |
commit | c5bb67eab6f97ae0f5f7e673ff0ba9b1111191f4 (patch) | |
tree | ad17bd2ee34263af472340a839a4757859ddaea1 /Swiften/Queries/Requests | |
parent | 0a84186a22fd48485deed77bc067877ac332d0b4 (diff) | |
download | swift-contrib-c5bb67eab6f97ae0f5f7e673ff0ba9b1111191f4.zip swift-contrib-c5bb67eab6f97ae0f5f7e673ff0ba9b1111191f4.tar.bz2 |
Added EchoBot walkthrough example.
Diffstat (limited to 'Swiften/Queries/Requests')
9 files changed, 64 insertions, 13 deletions
diff --git a/Swiften/Queries/Requests/GetDiscoInfoRequest.h b/Swiften/Queries/Requests/GetDiscoInfoRequest.h index 9ec1050..d1ed279 100644 --- a/Swiften/Queries/Requests/GetDiscoInfoRequest.h +++ b/Swiften/Queries/Requests/GetDiscoInfoRequest.h @@ -10,8 +10,17 @@ #include "Swiften/Elements/DiscoInfo.h" namespace Swift { - class GetDiscoInfoRequest : public GenericRequest<DiscoInfo> { + 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) { } diff --git a/Swiften/Queries/Requests/GetDiscoItemsRequest.h b/Swiften/Queries/Requests/GetDiscoItemsRequest.h index 453eab4..ed565ac 100644 --- a/Swiften/Queries/Requests/GetDiscoItemsRequest.h +++ b/Swiften/Queries/Requests/GetDiscoItemsRequest.h @@ -10,8 +10,13 @@ #include "Swiften/Elements/DiscoItems.h" namespace Swift { - class GetDiscoItemsRequest : public GenericRequest<DiscoItems> { + 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/GetPrivateStorageRequest.h b/Swiften/Queries/Requests/GetPrivateStorageRequest.h index d44d5d8..b593495 100644 --- a/Swiften/Queries/Requests/GetPrivateStorageRequest.h +++ b/Swiften/Queries/Requests/GetPrivateStorageRequest.h @@ -17,6 +17,13 @@ namespace Swift { template<typename PAYLOAD_TYPE> class GetPrivateStorageRequest : public Request { public: + typedef boost::shared_ptr<GetPrivateStorageRequest<PAYLOAD_TYPE> > ref; + + static ref create(IQRouter* router) { + return ref(new GetPrivateStorageRequest(router)); + } + + private: GetPrivateStorageRequest(IQRouter* router) : Request(IQ::Get, JID(), boost::shared_ptr<PrivateStorage>(new PrivateStorage(boost::shared_ptr<Payload>(new PAYLOAD_TYPE()))), router) { } diff --git a/Swiften/Queries/Requests/GetRosterRequest.h b/Swiften/Queries/Requests/GetRosterRequest.h index 59cefe4..271b2fb 100644 --- a/Swiften/Queries/Requests/GetRosterRequest.h +++ b/Swiften/Queries/Requests/GetRosterRequest.h @@ -8,10 +8,16 @@ #include "Swiften/Queries/GenericRequest.h" #include "Swiften/Elements/RosterPayload.h" +#include "Swiften/Base/Shared.h" namespace Swift { - class GetRosterRequest : public GenericRequest<RosterPayload> { + 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/GetSecurityLabelsCatalogRequest.h b/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h index 41225fb..ec04f80 100644 --- a/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h +++ b/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h @@ -8,10 +8,16 @@ #include "Swiften/Queries/GenericRequest.h" #include "Swiften/Elements/SecurityLabelsCatalog.h" +#include "Swiften/Base/Shared.h" namespace Swift { - class GetSecurityLabelsCatalogRequest : public GenericRequest<SecurityLabelsCatalog> { + class GetSecurityLabelsCatalogRequest : public GenericRequest<SecurityLabelsCatalog>, public Shared<GetSecurityLabelsCatalogRequest> { public: + static ref create(const JID& recipient, IQRouter* router) { + return ref(new GetSecurityLabelsCatalogRequest(recipient, router)); + } + + private: GetSecurityLabelsCatalogRequest( const JID& recipient, IQRouter* router) : diff --git a/Swiften/Queries/Requests/GetVCardRequest.h b/Swiften/Queries/Requests/GetVCardRequest.h index f369cdc..2c40cd1 100644 --- a/Swiften/Queries/Requests/GetVCardRequest.h +++ b/Swiften/Queries/Requests/GetVCardRequest.h @@ -13,6 +13,11 @@ 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/SetPrivateStorageRequest.h b/Swiften/Queries/Requests/SetPrivateStorageRequest.h index ebdfca8..1931f3a 100644 --- a/Swiften/Queries/Requests/SetPrivateStorageRequest.h +++ b/Swiften/Queries/Requests/SetPrivateStorageRequest.h @@ -17,6 +17,13 @@ namespace Swift { template<typename PAYLOAD_TYPE> class SetPrivateStorageRequest : public Request { public: + typedef boost::shared_ptr<SetPrivateStorageRequest<PAYLOAD_TYPE> > ref; + + static ref create(boost::shared_ptr<PAYLOAD_TYPE> payload, IQRouter* router) { + return ref(new SetPrivateStorageRequest<PAYLOAD_TYPE>(payload, router)); + } + + private: SetPrivateStorageRequest(boost::shared_ptr<PAYLOAD_TYPE> payload, IQRouter* router) : Request(IQ::Set, JID(), boost::shared_ptr<PrivateStorage>(new PrivateStorage(payload)), router) { } diff --git a/Swiften/Queries/Requests/SetRosterRequest.h b/Swiften/Queries/Requests/SetRosterRequest.h index 1f47cfe..7b1bf8c 100644 --- a/Swiften/Queries/Requests/SetRosterRequest.h +++ b/Swiften/Queries/Requests/SetRosterRequest.h @@ -11,10 +11,16 @@ #include "Swiften/Queries/Request.h" #include "Swiften/Elements/RosterPayload.h" +#include "Swiften/Base/Shared.h" namespace Swift { - class SetRosterRequest : public Request { + 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) { } diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp index d90a114..fe8b0a0 100644 --- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp +++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp @@ -45,8 +45,8 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture } void testSend() { - GetPrivateStorageRequest<MyPayload> request(router); - request.send(); + GetPrivateStorageRequest<MyPayload>::ref request = GetPrivateStorageRequest<MyPayload>::create(router); + request->send(); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->iqs_.size())); CPPUNIT_ASSERT_EQUAL(JID(), channel->iqs_[0]->getTo()); @@ -58,9 +58,9 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture } void testHandleResponse() { - GetPrivateStorageRequest<MyPayload> testling(router); - testling.onResponse.connect(boost::bind(&GetPrivateStorageRequestTest::handleResponse, this, _1, _2)); - testling.send(); + GetPrivateStorageRequest<MyPayload>::ref testling = GetPrivateStorageRequest<MyPayload>::create(router); + testling->onResponse.connect(boost::bind(&GetPrivateStorageRequestTest::handleResponse, this, _1, _2)); + testling->send(); channel->onIQReceived(createResponse("test-id", "foo")); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(responses.size())); @@ -68,9 +68,9 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture } void testHandleResponse_Error() { - GetPrivateStorageRequest<MyPayload> testling(router); - testling.onResponse.connect(boost::bind(&GetPrivateStorageRequestTest::handleResponse, this, _1, _2)); - testling.send(); + GetPrivateStorageRequest<MyPayload>::ref testling = GetPrivateStorageRequest<MyPayload>::create(router); + testling->onResponse.connect(boost::bind(&GetPrivateStorageRequestTest::handleResponse, this, _1, _2)); + testling->send(); channel->onIQReceived(createError("test-id")); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(responses.size())); |