00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <boost/shared_ptr.hpp>
00010 #include <boost/optional.hpp>
00011 #include <boost/enable_shared_from_this.hpp>
00012 #include <string>
00013
00014 #include <Swiften/Base/API.h>
00015 #include <Swiften/Queries/IQHandler.h>
00016 #include <Swiften/Elements/IQ.h>
00017 #include <Swiften/Elements/Payload.h>
00018 #include <Swiften/Elements/ErrorPayload.h>
00019 #include <Swiften/JID/JID.h>
00020
00021 namespace Swift {
00025 class SWIFTEN_API Request : public IQHandler, public boost::enable_shared_from_this<Request> {
00026 public:
00027 void send();
00028
00029 const JID& getReceiver() const {
00030 return receiver_;
00031 }
00032
00033 protected:
00038 Request(
00039 IQ::Type type,
00040 const JID& receiver,
00041 boost::shared_ptr<Payload> payload,
00042 IQRouter* router);
00043
00048 Request(
00049 IQ::Type type,
00050 const JID& sender,
00051 const JID& receiver,
00052 boost::shared_ptr<Payload> payload,
00053 IQRouter* router);
00054
00055
00059 Request(
00060 IQ::Type type,
00061 const JID& receiver,
00062 IQRouter* router);
00063
00067 Request(
00068 IQ::Type type,
00069 const JID& sender,
00070 const JID& receiver,
00071 IQRouter* router);
00072
00073
00074 virtual void setPayload(boost::shared_ptr<Payload> payload) {
00075 payload_ = payload;
00076 }
00077
00078 boost::shared_ptr<Payload> getPayload() const {
00079 return payload_;
00080 }
00081
00082 virtual void handleResponse(boost::shared_ptr<Payload>, boost::shared_ptr<ErrorPayload>) = 0;
00083
00084 private:
00085 bool handleIQ(boost::shared_ptr<IQ>);
00086 bool isCorrectSender(const JID& jid);
00087
00088 private:
00089 IQRouter* router_;
00090 IQ::Type type_;
00091 JID sender_;
00092 JID receiver_;
00093 boost::shared_ptr<Payload> payload_;
00094 std::string id_;
00095 bool sent_;
00096 };
00097 }