diff options
Diffstat (limited to 'Swiften/Elements/JinglePayload.h')
-rw-r--r-- | Swiften/Elements/JinglePayload.h | 292 |
1 files changed, 146 insertions, 146 deletions
diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h index 359e3ca..a862c41 100644 --- a/Swiften/Elements/JinglePayload.h +++ b/Swiften/Elements/JinglePayload.h @@ -18,150 +18,150 @@ #include <Swiften/JID/JID.h> namespace Swift { - class SWIFTEN_API JinglePayload : public Payload { - public: - typedef boost::shared_ptr<JinglePayload> ref; - struct Reason : public Payload { - enum Type { - UnknownType, - AlternativeSession, - Busy, - Cancel, - ConnectivityError, - Decline, - Expired, - FailedApplication, - FailedTransport, - GeneralError, - Gone, - IncompatibleParameters, - MediaError, - SecurityError, - Success, - Timeout, - UnsupportedApplications, - UnsupportedTransports - }; - Reason() : type(UnknownType), text("") {} - Reason(Type type, const std::string& text = "") : type(type), text(text) {} - Type type; - std::string text; - }; - - enum Action { - UnknownAction, - ContentAccept, - ContentAdd, - ContentModify, - ContentReject, - ContentRemove, - DescriptionInfo, - SecurityInfo, - SessionAccept, - SessionInfo, - SessionInitiate, - SessionTerminate, - TransportAccept, - TransportInfo, - TransportReject, - TransportReplace - }; - JinglePayload() : action(SessionTerminate), sessionID("") { - } - - JinglePayload(Action action, const std::string& sessionID) : action(action), sessionID(sessionID) { - - } - - void setAction(Action action) { - this->action = action; - } - - Action getAction() const { - return action; - } - - void setInitiator(const JID& initiator) { - this->initiator = initiator; - } - - const JID& getInitiator() const { - return initiator; - } - - void setResponder(const JID& responder) { - this->responder = responder; - } - - const JID& getResponder() const { - return responder; - } - - void setSessionID(const std::string& id) { - sessionID = id; - } - - const std::string& getSessionID() const { - return sessionID; - } - - void addContent(JingleContentPayload::ref content) { - this->payloads.push_back(content); - } - - void addPayload(boost::shared_ptr<Payload> payload) { - this->payloads.push_back(payload); - } - - const std::vector<JingleContentPayload::ref> getContents() const { - return getPayloads<JingleContentPayload>(); - } - - const std::vector<boost::shared_ptr<Payload> > getPayloads() const { - return payloads; - } - - template<typename T> - const std::vector<boost::shared_ptr<T> > getPayloads() const { - std::vector<boost::shared_ptr<T> > matched_payloads; - for (std::vector<boost::shared_ptr<Payload> >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { - boost::shared_ptr<T> result = boost::dynamic_pointer_cast<T>(*i); - if (result) { - matched_payloads.push_back(result); - } - } - - return matched_payloads; - - } - - template<typename T> - const boost::shared_ptr<T> getPayload() const { - boost::shared_ptr<T> result; - for (std::vector<boost::shared_ptr<Payload> >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { - result = boost::dynamic_pointer_cast<T>(*i); - if (result) { - return result; - } - } - - return result; - } - - void setReason(const Reason& reason) { - this->reason = reason; - } - - const boost::optional<Reason>& getReason() const { - return reason; - } - - private: - Action action; - JID initiator; - JID responder; - std::string sessionID; - std::vector<boost::shared_ptr<Payload> > payloads; - boost::optional<Reason> reason; - }; + class SWIFTEN_API JinglePayload : public Payload { + public: + typedef boost::shared_ptr<JinglePayload> ref; + struct Reason : public Payload { + enum Type { + UnknownType, + AlternativeSession, + Busy, + Cancel, + ConnectivityError, + Decline, + Expired, + FailedApplication, + FailedTransport, + GeneralError, + Gone, + IncompatibleParameters, + MediaError, + SecurityError, + Success, + Timeout, + UnsupportedApplications, + UnsupportedTransports + }; + Reason() : type(UnknownType), text("") {} + Reason(Type type, const std::string& text = "") : type(type), text(text) {} + Type type; + std::string text; + }; + + enum Action { + UnknownAction, + ContentAccept, + ContentAdd, + ContentModify, + ContentReject, + ContentRemove, + DescriptionInfo, + SecurityInfo, + SessionAccept, + SessionInfo, + SessionInitiate, + SessionTerminate, + TransportAccept, + TransportInfo, + TransportReject, + TransportReplace + }; + JinglePayload() : action(SessionTerminate), sessionID("") { + } + + JinglePayload(Action action, const std::string& sessionID) : action(action), sessionID(sessionID) { + + } + + void setAction(Action action) { + this->action = action; + } + + Action getAction() const { + return action; + } + + void setInitiator(const JID& initiator) { + this->initiator = initiator; + } + + const JID& getInitiator() const { + return initiator; + } + + void setResponder(const JID& responder) { + this->responder = responder; + } + + const JID& getResponder() const { + return responder; + } + + void setSessionID(const std::string& id) { + sessionID = id; + } + + const std::string& getSessionID() const { + return sessionID; + } + + void addContent(JingleContentPayload::ref content) { + this->payloads.push_back(content); + } + + void addPayload(boost::shared_ptr<Payload> payload) { + this->payloads.push_back(payload); + } + + const std::vector<JingleContentPayload::ref> getContents() const { + return getPayloads<JingleContentPayload>(); + } + + const std::vector<boost::shared_ptr<Payload> > getPayloads() const { + return payloads; + } + + template<typename T> + const std::vector<boost::shared_ptr<T> > getPayloads() const { + std::vector<boost::shared_ptr<T> > matched_payloads; + for (std::vector<boost::shared_ptr<Payload> >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { + boost::shared_ptr<T> result = boost::dynamic_pointer_cast<T>(*i); + if (result) { + matched_payloads.push_back(result); + } + } + + return matched_payloads; + + } + + template<typename T> + const boost::shared_ptr<T> getPayload() const { + boost::shared_ptr<T> result; + for (std::vector<boost::shared_ptr<Payload> >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { + result = boost::dynamic_pointer_cast<T>(*i); + if (result) { + return result; + } + } + + return result; + } + + void setReason(const Reason& reason) { + this->reason = reason; + } + + const boost::optional<Reason>& getReason() const { + return reason; + } + + private: + Action action; + JID initiator; + JID responder; + std::string sessionID; + std::vector<boost::shared_ptr<Payload> > payloads; + boost::optional<Reason> reason; + }; } |