summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Queries/Responder.h
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Queries/Responder.h')
-rw-r--r--Swiften/Queries/Responder.h242
1 files changed, 121 insertions, 121 deletions
diff --git a/Swiften/Queries/Responder.h b/Swiften/Queries/Responder.h
index 836207f..94195f8 100644
--- a/Swiften/Queries/Responder.h
+++ b/Swiften/Queries/Responder.h
@@ -12,125 +12,125 @@
#include <Swiften/Queries/IQRouter.h>
namespace Swift {
- /**
- * A class for handling incoming IQ Get and Set requests of a specific payload type.
- *
- * Concrete subclasses of this class need to implement handleGetRequest() and handleSetRequest() to
- * implement the behavior of the responder.
- *
- * \tparam PAYLOAD_TYPE The type of payload this Responder handles. Only IQ requests containing this
- * payload type will be passed to handleGetRequest() and handleSetRequest()
- */
- template<typename PAYLOAD_TYPE>
- class SWIFTEN_API Responder : public IQHandler {
- public:
- Responder(IQRouter* router) : router_(router), isFinalResonder_(true) {
- }
-
- ~Responder() {
- }
-
- /**
- * Starts the responder.
- *
- * After the responder has started, it will start receiving and responding to requests.
- *
- * \see stop()
- */
- void start() {
- router_->addHandler(this);
- }
-
- /**
- * Stops the responder.
- *
- * When the responder is stopped, it will no longer receive incoming requests.
- *
- * \see start()
- */
- void stop() {
- router_->removeHandler(this);
- }
-
- protected:
- /**
- * Handle an incoming IQ-Get request containing a payload of class PAYLOAD_TYPE.
- *
- * This method is implemented in the concrete subclasses.
- */
- virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
-
- /**
- * Handle an incoming IQ-Set request containing a payload of class PAYLOAD_TYPE.
- *
- * This method is implemented in the concrete subclasses.
- */
- virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
-
- /**
- * Convenience function for sending an IQ response.
- */
- void sendResponse(const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) {
- router_->sendIQ(IQ::createResult(to, id, payload));
- }
-
- /**
- * Convenience function for sending an IQ response, with a specific from address.
- */
- void sendResponse(const JID& to, const JID& from, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) {
- router_->sendIQ(IQ::createResult(to, from, id, payload));
- }
-
- /**
- * Convenience function for responding with an error.
- */
- void sendError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type, Payload::ref payload = Payload::ref()) {
- router_->sendIQ(IQ::createError(to, id, condition, type, payload));
- }
-
- /**
- * Convenience function for responding with an error from a specific from address.
- */
- void sendError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type, Payload::ref payload = Payload::ref()) {
- router_->sendIQ(IQ::createError(to, from, id, condition, type, payload));
- }
-
- IQRouter* getIQRouter() const {
- return router_;
- }
-
- void setFinal(bool isFinal) {
- isFinalResonder_ = isFinal;
- }
-
- private:
- virtual bool handleIQ(boost::shared_ptr<IQ> iq) {
- if (iq->getType() == IQ::Set || iq->getType() == IQ::Get) {
- boost::shared_ptr<PAYLOAD_TYPE> payload(iq->getPayload<PAYLOAD_TYPE>());
- if (payload) {
- bool result;
- if (iq->getType() == IQ::Set) {
- result = handleSetRequest(iq->getFrom(), iq->getTo(), iq->getID(), payload);
- }
- else {
- result = handleGetRequest(iq->getFrom(), iq->getTo(), iq->getID(), payload);
- }
- if (!result) {
- if (isFinalResonder_) {
- router_->sendIQ(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::NotAllowed, ErrorPayload::Cancel));
- }
- else {
- return false;
- }
- }
- return true;
- }
- }
- return false;
- }
-
- private:
- IQRouter* router_;
- bool isFinalResonder_;
- };
+ /**
+ * A class for handling incoming IQ Get and Set requests of a specific payload type.
+ *
+ * Concrete subclasses of this class need to implement handleGetRequest() and handleSetRequest() to
+ * implement the behavior of the responder.
+ *
+ * \tparam PAYLOAD_TYPE The type of payload this Responder handles. Only IQ requests containing this
+ * payload type will be passed to handleGetRequest() and handleSetRequest()
+ */
+ template<typename PAYLOAD_TYPE>
+ class SWIFTEN_API Responder : public IQHandler {
+ public:
+ Responder(IQRouter* router) : router_(router), isFinalResonder_(true) {
+ }
+
+ ~Responder() {
+ }
+
+ /**
+ * Starts the responder.
+ *
+ * After the responder has started, it will start receiving and responding to requests.
+ *
+ * \see stop()
+ */
+ void start() {
+ router_->addHandler(this);
+ }
+
+ /**
+ * Stops the responder.
+ *
+ * When the responder is stopped, it will no longer receive incoming requests.
+ *
+ * \see start()
+ */
+ void stop() {
+ router_->removeHandler(this);
+ }
+
+ protected:
+ /**
+ * Handle an incoming IQ-Get request containing a payload of class PAYLOAD_TYPE.
+ *
+ * This method is implemented in the concrete subclasses.
+ */
+ virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
+
+ /**
+ * Handle an incoming IQ-Set request containing a payload of class PAYLOAD_TYPE.
+ *
+ * This method is implemented in the concrete subclasses.
+ */
+ virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
+
+ /**
+ * Convenience function for sending an IQ response.
+ */
+ void sendResponse(const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) {
+ router_->sendIQ(IQ::createResult(to, id, payload));
+ }
+
+ /**
+ * Convenience function for sending an IQ response, with a specific from address.
+ */
+ void sendResponse(const JID& to, const JID& from, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) {
+ router_->sendIQ(IQ::createResult(to, from, id, payload));
+ }
+
+ /**
+ * Convenience function for responding with an error.
+ */
+ void sendError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type, Payload::ref payload = Payload::ref()) {
+ router_->sendIQ(IQ::createError(to, id, condition, type, payload));
+ }
+
+ /**
+ * Convenience function for responding with an error from a specific from address.
+ */
+ void sendError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type, Payload::ref payload = Payload::ref()) {
+ router_->sendIQ(IQ::createError(to, from, id, condition, type, payload));
+ }
+
+ IQRouter* getIQRouter() const {
+ return router_;
+ }
+
+ void setFinal(bool isFinal) {
+ isFinalResonder_ = isFinal;
+ }
+
+ private:
+ virtual bool handleIQ(boost::shared_ptr<IQ> iq) {
+ if (iq->getType() == IQ::Set || iq->getType() == IQ::Get) {
+ boost::shared_ptr<PAYLOAD_TYPE> payload(iq->getPayload<PAYLOAD_TYPE>());
+ if (payload) {
+ bool result;
+ if (iq->getType() == IQ::Set) {
+ result = handleSetRequest(iq->getFrom(), iq->getTo(), iq->getID(), payload);
+ }
+ else {
+ result = handleGetRequest(iq->getFrom(), iq->getTo(), iq->getID(), payload);
+ }
+ if (!result) {
+ if (isFinalResonder_) {
+ router_->sendIQ(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::NotAllowed, ErrorPayload::Cancel));
+ }
+ else {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private:
+ IQRouter* router_;
+ bool isFinalResonder_;
+ };
}