summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-03-26 10:09:46 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:40 (GMT)
commitbb37c9f89e4135f3128fc98c23ea19eea945c4cd (patch)
tree92e9504a27d6eaa8182bb0bab8a7556825a46ad7 /Swiften/Elements/JingleContentPayload.h
parent039636edc1b151431cba21a28986ff2be66b5349 (diff)
downloadswift-bb37c9f89e4135f3128fc98c23ea19eea945c4cd.zip
swift-bb37c9f89e4135f3128fc98c23ea19eea945c4cd.tar.bz2
Jingle refactoring.
Diffstat (limited to 'Swiften/Elements/JingleContentPayload.h')
-rw-r--r--Swiften/Elements/JingleContentPayload.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/Swiften/Elements/JingleContentPayload.h b/Swiften/Elements/JingleContentPayload.h
new file mode 100644
index 0000000..c44a806
--- /dev/null
+++ b/Swiften/Elements/JingleContentPayload.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2011 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <vector>
+#include <boost/optional.hpp>
+#include <string>
+
+#include <Swiften/JID/JID.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/Elements/JingleDescription.h>
+#include <Swiften/Elements/JingleTransportPayload.h>
+
+namespace Swift {
+ class JingleContentPayload : public Payload {
+ public:
+ typedef boost::shared_ptr<JingleContentPayload> ref;
+
+ enum Creator {
+ InitiatorCreator,
+ ResponderCreator,
+ };
+
+ /*enum Senders {
+ NoSenders,
+ InitiatorSender,
+ ResponderSender,
+ BothSenders,
+ };*/
+
+ Creator getCreator() const {
+ return creator;
+ }
+
+ void setCreator(Creator creator) {
+ this->creator = creator;
+ }
+
+ const std::string& getName() const {
+ return name;
+ }
+
+ void setName(const std::string& name) {
+ this->name = name;
+ }
+
+ const std::vector<JingleDescription::ref>& getDescriptions() const {
+ return descriptions;
+ }
+
+ void addDescription(JingleDescription::ref description) {
+ descriptions.push_back(description);
+ }
+
+ const std::vector<boost::shared_ptr<JingleTransportPayload> >& getTransports() const {
+ return transports;
+ }
+
+ void addTransport(boost::shared_ptr<JingleTransportPayload> transport) {
+ transports.push_back(transport);
+ }
+
+ template<typename T>
+ boost::shared_ptr<T> getDescription() const {
+ for (size_t i = 0; i < descriptions.size(); ++i) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(descriptions[i]));
+ if (result) {
+ return result;
+ }
+ }
+ return boost::shared_ptr<T>();
+ }
+
+ template<typename T>
+ boost::shared_ptr<T> getTransport() const {
+ for (size_t i = 0; i < transports.size(); ++i) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(transports[i]));
+ if (result) {
+ return result;
+ }
+ }
+ return boost::shared_ptr<T>();
+ }
+
+ private:
+ Creator creator;
+ std::string name;
+ //Senders senders;
+ std::vector<JingleDescription::ref> descriptions;
+ std::vector<boost::shared_ptr<JingleTransportPayload> > transports;
+ };
+}