diff options
Diffstat (limited to 'Swiften/Roster')
-rw-r--r-- | Swiften/Roster/GetRosterRequest.h | 25 | ||||
-rw-r--r-- | Swiften/Roster/RosterPushResponder.h | 29 | ||||
-rw-r--r-- | Swiften/Roster/SetRosterRequest.h | 34 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRosterController.cpp | 2 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRosterController.h | 2 |
5 files changed, 90 insertions, 2 deletions
diff --git a/Swiften/Roster/GetRosterRequest.h b/Swiften/Roster/GetRosterRequest.h new file mode 100644 index 0000000..271b2fb --- /dev/null +++ b/Swiften/Roster/GetRosterRequest.h @@ -0,0 +1,25 @@ +/* + * 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/Roster/RosterPushResponder.h b/Swiften/Roster/RosterPushResponder.h new file mode 100644 index 0000000..48111a7 --- /dev/null +++ b/Swiften/Roster/RosterPushResponder.h @@ -0,0 +1,29 @@ +/* + * 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/Roster/SetRosterRequest.h b/Swiften/Roster/SetRosterRequest.h new file mode 100644 index 0000000..7b1bf8c --- /dev/null +++ b/Swiften/Roster/SetRosterRequest.h @@ -0,0 +1,34 @@ +/* + * 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/Roster/XMPPRosterController.cpp b/Swiften/Roster/XMPPRosterController.cpp index feaa7d4..024cb1d 100644 --- a/Swiften/Roster/XMPPRosterController.cpp +++ b/Swiften/Roster/XMPPRosterController.cpp @@ -11,7 +11,7 @@ #include "Swiften/Base/foreach.h" #include "Swiften/Elements/RosterItemPayload.h" #include "Swiften/Queries/IQRouter.h" -#include "Swiften/Queries/Requests/GetRosterRequest.h" +#include "Swiften/Roster/GetRosterRequest.h" #include "Swiften/EventLoop/MainEventLoop.h" #include "Swiften/Roster/Roster.h" #include "Swiften/Roster/SetPresence.h" diff --git a/Swiften/Roster/XMPPRosterController.h b/Swiften/Roster/XMPPRosterController.h index 22a63ad..d846b86 100644 --- a/Swiften/Roster/XMPPRosterController.h +++ b/Swiften/Roster/XMPPRosterController.h @@ -12,7 +12,7 @@ #include "Swiften/Base/String.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/RosterPayload.h" -#include "Swiften/Queries/Responders/RosterPushResponder.h" +#include "Swiften/Roster/RosterPushResponder.h" #include "Swiften/Base/boost_bsignals.h" namespace Swift { |