summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Queries')
-rw-r--r--Swiften/Queries/GetResponder.h2
-rw-r--r--Swiften/Queries/Responder.h22
-rw-r--r--Swiften/Queries/Responders/SoftwareVersionResponder.cpp2
-rw-r--r--Swiften/Queries/Responders/SoftwareVersionResponder.h2
-rw-r--r--Swiften/Queries/SetResponder.h2
-rw-r--r--Swiften/Queries/UnitTest/ResponderTest.cpp4
6 files changed, 24 insertions, 10 deletions
diff --git a/Swiften/Queries/GetResponder.h b/Swiften/Queries/GetResponder.h
index 3324859..2201b95 100644
--- a/Swiften/Queries/GetResponder.h
+++ b/Swiften/Queries/GetResponder.h
@@ -15,6 +15,6 @@ namespace Swift {
GetResponder(IQRouter* router) : Responder<T>(router) {}
private:
- virtual bool handleSetRequest(const JID&, const String&, boost::shared_ptr<T>) { return false; }
+ virtual bool handleSetRequest(const JID&, const JID&, const String&, boost::shared_ptr<T>) { return false; }
};
}
diff --git a/Swiften/Queries/Responder.h b/Swiften/Queries/Responder.h
index 2333b5f..322ba60 100644
--- a/Swiften/Queries/Responder.h
+++ b/Swiften/Queries/Responder.h
@@ -57,14 +57,14 @@ namespace Swift {
*
* This method is implemented in the concrete subclasses.
*/
- virtual bool handleGetRequest(const JID& from, const String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
+ virtual bool handleGetRequest(const JID& from, const JID& to, const 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 String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
+ virtual bool handleSetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0;
/**
* Convenience function for sending an IQ response.
@@ -74,12 +74,26 @@ namespace Swift {
}
/**
+ * Convenience function for sending an IQ response, with a specific from address.
+ */
+ void sendResponse(const JID& to, const JID& from, const 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 String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) {
router_->sendIQ(IQ::createError(to, id, condition, type));
}
+ /**
+ * Convenience function for responding with an error from a specific from address.
+ */
+ void sendError(const JID& to, const JID& from, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) {
+ router_->sendIQ(IQ::createError(to, from, id, condition, type));
+ }
+
private:
virtual bool handleIQ(boost::shared_ptr<IQ> iq) {
if (iq->getType() == IQ::Set || iq->getType() == IQ::Get) {
@@ -87,10 +101,10 @@ namespace Swift {
if (payload) {
bool result;
if (iq->getType() == IQ::Set) {
- result = handleSetRequest(iq->getFrom(), iq->getID(), payload);
+ result = handleSetRequest(iq->getFrom(), iq->getTo(), iq->getID(), payload);
}
else {
- result = handleGetRequest(iq->getFrom(), iq->getID(), payload);
+ result = handleGetRequest(iq->getFrom(), iq->getTo(), iq->getID(), payload);
}
if (!result) {
router_->sendIQ(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::NotAllowed, ErrorPayload::Cancel));
diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp
index b2e7273..cc58114 100644
--- a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp
+++ b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp
@@ -17,7 +17,7 @@ void SoftwareVersionResponder::setVersion(const String& client, const String& ve
this->version = version;
}
-bool SoftwareVersionResponder::handleGetRequest(const JID& from, const String& id, boost::shared_ptr<SoftwareVersion>) {
+bool SoftwareVersionResponder::handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<SoftwareVersion>) {
sendResponse(from, id, boost::shared_ptr<SoftwareVersion>(new SoftwareVersion(client, version)));
return true;
}
diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.h b/Swiften/Queries/Responders/SoftwareVersionResponder.h
index 7242b4b..9da82b0 100644
--- a/Swiften/Queries/Responders/SoftwareVersionResponder.h
+++ b/Swiften/Queries/Responders/SoftwareVersionResponder.h
@@ -19,7 +19,7 @@ namespace Swift {
void setVersion(const String& client, const String& version);
private:
- virtual bool handleGetRequest(const JID& from, const String& id, boost::shared_ptr<SoftwareVersion> payload);
+ virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<SoftwareVersion> payload);
private:
String client;
diff --git a/Swiften/Queries/SetResponder.h b/Swiften/Queries/SetResponder.h
index 345328c..a04be64 100644
--- a/Swiften/Queries/SetResponder.h
+++ b/Swiften/Queries/SetResponder.h
@@ -15,6 +15,6 @@ namespace Swift {
SetResponder(IQRouter* router) : Responder<T>(router) {}
private:
- virtual bool handleGetRequest(const JID&, const String&, boost::shared_ptr<T>) { return false; }
+ virtual bool handleGetRequest(const JID&, const JID&, const String&, boost::shared_ptr<T>) { return false; }
};
}
diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp
index 9824c98..aba2cb9 100644
--- a/Swiften/Queries/UnitTest/ResponderTest.cpp
+++ b/Swiften/Queries/UnitTest/ResponderTest.cpp
@@ -131,13 +131,13 @@ class ResponderTest : public CppUnit::TestFixture
public:
MyResponder(IQRouter* router) : Responder<SoftwareVersion>(router), getRequestResponse_(true), setRequestResponse_(true) {}
- virtual bool handleGetRequest(const JID& from, const String& id, boost::shared_ptr<SoftwareVersion> payload) {
+ virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<SoftwareVersion> payload) {
CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from);
CPPUNIT_ASSERT_EQUAL(String("myid"), id);
getPayloads_.push_back(payload);
return getRequestResponse_;
}
- virtual bool handleSetRequest(const JID& from, const String& id, boost::shared_ptr<SoftwareVersion> payload) {
+ virtual bool handleSetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<SoftwareVersion> payload) {
CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from);
CPPUNIT_ASSERT_EQUAL(String("myid"), id);
setPayloads_.push_back(payload);