summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/JingleContent.h89
-rw-r--r--Swiften/Elements/JingleDescription.h18
-rw-r--r--Swiften/Elements/JingleFileTransferDescription.h31
-rw-r--r--Swiften/Elements/JingleIBBTransport.h49
-rw-r--r--Swiften/Elements/JinglePayload.h125
-rw-r--r--Swiften/Elements/JingleS5BTransport.h26
-rw-r--r--Swiften/Elements/JingleTransport.h14
-rw-r--r--Swiften/Elements/StreamInitiation.h15
-rw-r--r--Swiften/Elements/StreamInitiationFileInfo.h19
9 files changed, 375 insertions, 11 deletions
diff --git a/Swiften/Elements/JingleContent.h b/Swiften/Elements/JingleContent.h
new file mode 100644
index 0000000..bf419aa
--- /dev/null
+++ b/Swiften/Elements/JingleContent.h
@@ -0,0 +1,89 @@
+/*
+ * 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 <Swiften/Base/String.h>
+#include <Swiften/JID/JID.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/Elements/JingleDescription.h>
+#include <Swiften/Elements/JingleTransport.h>
+#include <Swiften/Base/foreach.h>
+
+namespace Swift {
+ class JingleContent : public Payload {
+ public:
+ typedef boost::shared_ptr<JingleContent> ref;
+
+ enum Creator {
+ InitiatorCreator,
+ ResponderCreator,
+ };
+
+ /*enum Senders {
+ NoSenders,
+ InitiatorSender,
+ ResponderSender,
+ BothSenders,
+ };*/
+
+ void setCreator(Creator creator) {
+ this->creator = creator;
+ }
+
+ void setName(const 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<JingleTransport::ref>& getTransports() const {
+ return transports;
+ }
+
+ void addTransport(JingleTransport::ref transport) {
+ transports.push_back(transport);
+ }
+
+ template<typename T>
+ boost::shared_ptr<T> getDescription() const {
+ foreach (JingleDescription::ref i, descriptions) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ if (result) {
+ return result;
+ }
+ }
+ return boost::shared_ptr<T>();
+ }
+
+ template<typename T>
+ boost::shared_ptr<T> getTransport() const {
+ foreach (JingleTransport::ref i, transports) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ if (result) {
+ return result;
+ }
+ }
+ return boost::shared_ptr<T>();
+ }
+
+ private:
+ Creator creator;
+ String name;
+ //Senders senders;
+ std::vector<JingleDescription::ref> descriptions;
+ std::vector<JingleTransport::ref> transports;
+ };
+}
diff --git a/Swiften/Elements/JingleDescription.h b/Swiften/Elements/JingleDescription.h
new file mode 100644
index 0000000..775c0f7
--- /dev/null
+++ b/Swiften/Elements/JingleDescription.h
@@ -0,0 +1,18 @@
+/*
+ * 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 <boost/shared_ptr.hpp>
+
+#include <Swiften/Elements/Payload.h>
+
+namespace Swift {
+ class JingleDescription : public Payload {
+ public:
+ typedef boost::shared_ptr<JingleDescription> ref;
+ };
+}
diff --git a/Swiften/Elements/JingleFileTransferDescription.h b/Swiften/Elements/JingleFileTransferDescription.h
new file mode 100644
index 0000000..19644bd
--- /dev/null
+++ b/Swiften/Elements/JingleFileTransferDescription.h
@@ -0,0 +1,31 @@
+/*
+ * 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 <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+
+#include <Swiften/Elements/JingleDescription.h>
+#include <Swiften/Elements/StreamInitiationFileInfo.h>
+
+namespace Swift {
+ class JingleFileTransferDescription : public JingleDescription {
+ public:
+ typedef boost::shared_ptr<JingleFileTransferDescription> ref;
+
+ void setOffer(const StreamInitiationFileInfo& offer) {
+ this->offer = offer;
+ }
+
+ const boost::optional<StreamInitiationFileInfo>& getOffer() const {
+ return offer;
+ }
+
+ private:
+ boost::optional<StreamInitiationFileInfo> offer;
+ };
+}
diff --git a/Swiften/Elements/JingleIBBTransport.h b/Swiften/Elements/JingleIBBTransport.h
new file mode 100644
index 0000000..ca3ecc8
--- /dev/null
+++ b/Swiften/Elements/JingleIBBTransport.h
@@ -0,0 +1,49 @@
+/*
+ * 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 <Swiften/Base/String.h>
+#include <Swiften/Elements/JingleTransport.h>
+
+namespace Swift {
+ class JingleIBBTransport : public JingleTransport {
+ public:
+ enum StanzaType {
+ IQStanza,
+ MessageStanza,
+ };
+
+ void setStanzaType(StanzaType stanzaType) {
+ this->stanzaType = stanzaType;
+ }
+
+ StanzaType getStanzaType() const {
+ return stanzaType;
+ }
+
+ void setSessionID(const String& id) {
+ sessionID = id;
+ }
+
+ const String& getSessionID() const {
+ return sessionID;
+ }
+
+ int getBlockSize() const {
+ return blockSize;
+ }
+
+ void setBlockSize(int blockSize) {
+ this->blockSize = blockSize;
+ }
+
+ private:
+ String sessionID;
+ int blockSize;
+ StanzaType stanzaType;
+ };
+}
diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h
new file mode 100644
index 0000000..66b6d43
--- /dev/null
+++ b/Swiften/Elements/JinglePayload.h
@@ -0,0 +1,125 @@
+/*
+ * 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 <Swiften/Base/String.h>
+#include <Swiften/JID/JID.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/Elements/JingleContent.h>
+
+
+namespace Swift {
+ class JinglePayload : public Payload {
+ public:
+ typedef boost::shared_ptr<JinglePayload> ref;
+ struct Reason {
+ enum Type {
+ AlternativeSession,
+ Busy,
+ Cancel,
+ ConnectivityError,
+ Decline,
+ Expired,
+ FailedApplication,
+ FailedTransport,
+ GeneralError,
+ Gone,
+ IncompatibleParameters,
+ MediaError,
+ SecurityError,
+ Success,
+ Timeout,
+ UnsupportedApplications,
+ UnsupportedTransports
+ };
+
+ Reason(Type type, const String& text = "") : type(type), text(text) {}
+ Type type;
+ String text;
+ };
+
+ enum Action {
+ ContentAccept,
+ ContentAdd,
+ ContentModify,
+ ContentReject,
+ ContentRemove,
+ DescriptionInfo,
+ SecurityInfo,
+ SessionAccept,
+ SessionInfo,
+ SessionInitiate,
+ SessionTerminate,
+ TransportAccept,
+ TransportInfo,
+ TransportReject,
+ TransportReplace
+ };
+
+ JinglePayload(Action action, const 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 String& id) {
+ sessionID = id;
+ }
+
+ const String& getSessionID() const {
+ return sessionID;
+ }
+
+ void addContent(JingleContent::ref content) {
+ this->contents.push_back(content);
+ }
+
+ const std::vector<JingleContent::ref> getContents() const {
+ return contents;
+ }
+
+ void setReason(const Reason& reason) {
+ this->reason = reason;
+ }
+
+ const boost::optional<Reason>& getReason() const {
+ return reason;
+ }
+
+ private:
+ Action action;
+ JID initiator;
+ JID responder;
+ String sessionID;
+ std::vector<JingleContent::ref> contents;
+ boost::optional<Reason> reason;
+ };
+}
diff --git a/Swiften/Elements/JingleS5BTransport.h b/Swiften/Elements/JingleS5BTransport.h
new file mode 100644
index 0000000..4522417
--- /dev/null
+++ b/Swiften/Elements/JingleS5BTransport.h
@@ -0,0 +1,26 @@
+/*
+ * 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 <Swiften/Elements/JingleTransport.h>
+#include <Swiften/Elements/Bytestreams.h>
+
+namespace Swift {
+ class JingleS5BTransport : public JingleTransport {
+ public:
+ const Bytestreams& getInfo() const {
+ return info;
+ }
+
+ void setInfo(const Bytestreams& info) {
+ this->info = info;
+ }
+
+ private:
+ Bytestreams info;
+ };
+}
diff --git a/Swiften/Elements/JingleTransport.h b/Swiften/Elements/JingleTransport.h
new file mode 100644
index 0000000..ecd2a34
--- /dev/null
+++ b/Swiften/Elements/JingleTransport.h
@@ -0,0 +1,14 @@
+/*
+ * 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 <Swiften/Elements/Payload.h>
+
+namespace Swift {
+ class JingleTransport : public Payload {
+ };
+}
diff --git a/Swiften/Elements/StreamInitiation.h b/Swiften/Elements/StreamInitiation.h
index 55b6b87..16dfd4d 100644
--- a/Swiften/Elements/StreamInitiation.h
+++ b/Swiften/Elements/StreamInitiation.h
@@ -12,20 +12,13 @@
#include "Swiften/Base/String.h"
#include "Swiften/Elements/Payload.h"
+#include <Swiften/Elements/StreamInitiationFileInfo.h>
namespace Swift {
class StreamInitiation : public Payload {
public:
typedef boost::shared_ptr<StreamInitiation> ref;
- struct FileInfo {
- FileInfo(const String& name = "", const String& description = "", int size = -1) : name(name), description(description), size(size) {}
-
- String name;
- String description;
- int size;
- };
-
StreamInitiation() : isFileTransfer(true) {}
const String& getID() const {
@@ -36,11 +29,11 @@ namespace Swift {
this->id = id;
}
- const boost::optional<FileInfo>& getFileInfo() const {
+ const boost::optional<StreamInitiationFileInfo>& getFileInfo() const {
return fileInfo;
}
- void setFileInfo(const FileInfo& info) {
+ void setFileInfo(const StreamInitiationFileInfo& info) {
fileInfo = info;
}
@@ -71,7 +64,7 @@ namespace Swift {
private:
bool isFileTransfer;
String id;
- boost::optional<FileInfo> fileInfo;
+ boost::optional<StreamInitiationFileInfo> fileInfo;
std::vector<String> providedMethods;
String requestedMethod;
};
diff --git a/Swiften/Elements/StreamInitiationFileInfo.h b/Swiften/Elements/StreamInitiationFileInfo.h
new file mode 100644
index 0000000..15b5a66
--- /dev/null
+++ b/Swiften/Elements/StreamInitiationFileInfo.h
@@ -0,0 +1,19 @@
+/*
+ * 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 <Swiften/Base/String.h>
+
+namespace Swift {
+ struct StreamInitiationFileInfo {
+ StreamInitiationFileInfo(const String& name = "", const String& description = "", int size = -1) : name(name), description(description), size(size) {}
+
+ String name;
+ String description;
+ int size;
+ };
+}