00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <vector>
00010 #include <boost/optional.hpp>
00011 #include <string>
00012
00013 #include <Swiften/JID/JID.h>
00014 #include <Swiften/Elements/Payload.h>
00015 #include <Swiften/Elements/JingleDescription.h>
00016 #include <Swiften/Elements/JingleTransportPayload.h>
00017
00018 namespace Swift {
00019 class JingleContentPayload : public Payload {
00020 public:
00021 typedef boost::shared_ptr<JingleContentPayload> ref;
00022
00023 enum Creator {
00024 UnknownCreator,
00025 InitiatorCreator,
00026 ResponderCreator,
00027 };
00028
00029
00030
00031
00032
00033
00034
00035
00036 Creator getCreator() const {
00037 return creator;
00038 }
00039
00040 void setCreator(Creator creator) {
00041 this->creator = creator;
00042 }
00043
00044 const std::string& getName() const {
00045 return name;
00046 }
00047
00048 void setName(const std::string& name) {
00049 this->name = name;
00050 }
00051
00052 const std::vector<JingleDescription::ref>& getDescriptions() const {
00053 return descriptions;
00054 }
00055
00056 void addDescription(JingleDescription::ref description) {
00057 descriptions.push_back(description);
00058 }
00059
00060 const std::vector<boost::shared_ptr<JingleTransportPayload> >& getTransports() const {
00061 return transports;
00062 }
00063
00064 void addTransport(boost::shared_ptr<JingleTransportPayload> transport) {
00065 transports.push_back(transport);
00066 }
00067
00068 template<typename T>
00069 boost::shared_ptr<T> getDescription() const {
00070 for (size_t i = 0; i < descriptions.size(); ++i) {
00071 boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(descriptions[i]));
00072 if (result) {
00073 return result;
00074 }
00075 }
00076 return boost::shared_ptr<T>();
00077 }
00078
00079 template<typename T>
00080 boost::shared_ptr<T> getTransport() const {
00081 for (size_t i = 0; i < transports.size(); ++i) {
00082 boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(transports[i]));
00083 if (result) {
00084 return result;
00085 }
00086 }
00087 return boost::shared_ptr<T>();
00088 }
00089
00090 private:
00091 Creator creator;
00092 std::string name;
00093
00094 std::vector<JingleDescription::ref> descriptions;
00095 std::vector<boost::shared_ptr<JingleTransportPayload> > transports;
00096 };
00097 }