summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-21 19:44:13 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-21 19:54:06 (GMT)
commitbbb77132775e69b6df7df4ddf38a429aff733d2b (patch)
treea512aaa8292ea4afe175446d672261921c2d27c0 /Swiften/Roster
parent4943167a6451d7a483a2aacb5f3f2bebb82adf0d (diff)
downloadswift-contrib-bbb77132775e69b6df7df4ddf38a429aff733d2b.zip
swift-contrib-bbb77132775e69b6df7df4ddf38a429aff733d2b.tar.bz2
Moving queries & responders around.
Diffstat (limited to 'Swiften/Roster')
-rw-r--r--Swiften/Roster/GetRosterRequest.h25
-rw-r--r--Swiften/Roster/RosterPushResponder.h29
-rw-r--r--Swiften/Roster/SetRosterRequest.h34
-rw-r--r--Swiften/Roster/XMPPRosterController.cpp2
-rw-r--r--Swiften/Roster/XMPPRosterController.h2
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 {