diff options
Diffstat (limited to 'Swiften/Queries')
-rw-r--r-- | Swiften/Queries/GenericRequest.h | 9 | ||||
-rw-r--r-- | Swiften/Queries/Request.cpp | 7 | ||||
-rw-r--r-- | Swiften/Queries/Request.h | 24 |
3 files changed, 40 insertions, 0 deletions
diff --git a/Swiften/Queries/GenericRequest.h b/Swiften/Queries/GenericRequest.h index 64c509c..9fd934f 100644 --- a/Swiften/Queries/GenericRequest.h +++ b/Swiften/Queries/GenericRequest.h @@ -22,6 +22,15 @@ namespace Swift { Request(type, receiver, payload, router) { } + GenericRequest( + IQ::Type type, + const JID& sender, + const JID& receiver, + boost::shared_ptr<Payload> payload, + IQRouter* router) : + Request(type, sender, receiver, payload, router) { + } + virtual void handleResponse(boost::shared_ptr<Payload> payload, ErrorPayload::ref error) { onResponse(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(payload), error); } diff --git a/Swiften/Queries/Request.cpp b/Swiften/Queries/Request.cpp index 382e44c..f3f56c9 100644 --- a/Swiften/Queries/Request.cpp +++ b/Swiften/Queries/Request.cpp @@ -16,6 +16,12 @@ Request::Request(IQ::Type type, const JID& receiver, boost::shared_ptr<Payload> Request::Request(IQ::Type type, const JID& receiver, IQRouter* router) : router_(router), type_(type), receiver_(receiver), sent_(false) { } +Request::Request(IQ::Type type, const JID& sender, const JID& receiver, boost::shared_ptr<Payload> payload, IQRouter* router) : router_(router), type_(type), sender_(sender), receiver_(receiver), payload_(payload), sent_(false) { +} + +Request::Request(IQ::Type type, const JID& sender, const JID& receiver, IQRouter* router) : router_(router), type_(type), sender_(sender), receiver_(receiver), sent_(false) { +} + void Request::send() { assert(payload_); assert(!sent_); @@ -23,6 +29,7 @@ void Request::send() { boost::shared_ptr<IQ> iq(new IQ(type_)); iq->setTo(receiver_); + iq->setFrom(sender_); iq->addPayload(payload_); id_ = router_->getNewIQID(); iq->setID(id_); diff --git a/Swiften/Queries/Request.h b/Swiften/Queries/Request.h index 677a758..668ed04 100644 --- a/Swiften/Queries/Request.h +++ b/Swiften/Queries/Request.h @@ -39,6 +39,19 @@ namespace Swift { const JID& receiver, boost::shared_ptr<Payload> payload, IQRouter* router); + + /** + * Constructs a request of a certain type to a specific receiver from a specific sender, and attaches the given + * payload. + */ + Request( + IQ::Type type, + const JID& sender, + const JID& receiver, + boost::shared_ptr<Payload> payload, + IQRouter* router); + + /** * Constructs a request of a certain type to a specific receiver. */ @@ -47,6 +60,16 @@ namespace Swift { const JID& receiver, IQRouter* router); + /** + * Constructs a request of a certain type to a specific receiver from a specific sender. + */ + Request( + IQ::Type type, + const JID& sender, + const JID& receiver, + IQRouter* router); + + virtual void setPayload(boost::shared_ptr<Payload> payload) { payload_ = payload; } @@ -64,6 +87,7 @@ namespace Swift { private: IQRouter* router_; IQ::Type type_; + JID sender_; JID receiver_; boost::shared_ptr<Payload> payload_; std::string id_; |