summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Jingle')
-rw-r--r--Swiften/Jingle/AbstractJingleSessionListener.cpp28
-rw-r--r--Swiften/Jingle/AbstractJingleSessionListener.h24
-rw-r--r--Swiften/Jingle/FakeJingleSession.cpp39
-rw-r--r--Swiften/Jingle/FakeJingleSession.h179
-rw-r--r--Swiften/Jingle/IncomingJingleSessionHandler.h10
-rw-r--r--Swiften/Jingle/Jingle.h24
-rw-r--r--Swiften/Jingle/JingleContentID.h32
-rw-r--r--Swiften/Jingle/JingleResponder.cpp81
-rw-r--r--Swiften/Jingle/JingleResponder.h28
-rw-r--r--Swiften/Jingle/JingleSession.cpp14
-rw-r--r--Swiften/Jingle/JingleSession.h73
-rw-r--r--Swiften/Jingle/JingleSessionImpl.cpp281
-rw-r--r--Swiften/Jingle/JingleSessionImpl.h72
-rw-r--r--Swiften/Jingle/JingleSessionListener.h50
-rw-r--r--Swiften/Jingle/JingleSessionManager.cpp44
-rw-r--r--Swiften/Jingle/JingleSessionManager.h75
-rw-r--r--Swiften/Jingle/SConscript18
17 files changed, 537 insertions, 535 deletions
diff --git a/Swiften/Jingle/AbstractJingleSessionListener.cpp b/Swiften/Jingle/AbstractJingleSessionListener.cpp
index c533f12..20edf15 100644
--- a/Swiften/Jingle/AbstractJingleSessionListener.cpp
+++ b/Swiften/Jingle/AbstractJingleSessionListener.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,32 +10,32 @@
using namespace Swift;
-void AbstractJingleSessionListener::handleSessionAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleDescription>, boost::shared_ptr<JingleTransportPayload>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+void AbstractJingleSessionListener::handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) {
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
-void AbstractJingleSessionListener::handleSessionInfoReceived(boost::shared_ptr<JinglePayload>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+void AbstractJingleSessionListener::handleSessionInfoReceived(std::shared_ptr<JinglePayload>) {
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
void AbstractJingleSessionListener::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
-void AbstractJingleSessionListener::handleTransportAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+void AbstractJingleSessionListener::handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) {
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
-void AbstractJingleSessionListener::handleTransportInfoReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+void AbstractJingleSessionListener::handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) {
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
-void AbstractJingleSessionListener::handleTransportRejectReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+void AbstractJingleSessionListener::handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) {
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
-void AbstractJingleSessionListener::handleTransportReplaceReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) {
- SWIFT_LOG(warning) << "Unimplemented" << std::endl;
+void AbstractJingleSessionListener::handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) {
+ SWIFT_LOG(warning) << "Unimplemented" << std::endl;
}
void AbstractJingleSessionListener::handleTransportInfoAcknowledged(const std::string&) {
diff --git a/Swiften/Jingle/AbstractJingleSessionListener.h b/Swiften/Jingle/AbstractJingleSessionListener.h
index 6256506..590cd14 100644
--- a/Swiften/Jingle/AbstractJingleSessionListener.h
+++ b/Swiften/Jingle/AbstractJingleSessionListener.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,16 +11,16 @@
#include <Swiften/Jingle/JingleSessionListener.h>
namespace Swift {
- class SWIFTEN_API AbstractJingleSessionListener : public JingleSessionListener {
- public:
- virtual void handleSessionAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleDescription>, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleSessionInfoReceived(boost::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE;
- virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) SWIFTEN_OVERRIDE;
- virtual void handleTransportAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportInfoReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportRejectReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportReplaceReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
- virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE;
- };
+ class SWIFTEN_API AbstractJingleSessionListener : public JingleSessionListener {
+ public:
+ virtual void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
+ virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) SWIFTEN_OVERRIDE;
+ virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) SWIFTEN_OVERRIDE;
+ virtual void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
+ virtual void handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
+ virtual void handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
+ virtual void handleTransportReplaceReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>) SWIFTEN_OVERRIDE;
+ virtual void handleTransportInfoAcknowledged(const std::string& id) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Swiften/Jingle/FakeJingleSession.cpp b/Swiften/Jingle/FakeJingleSession.cpp
index 864dd53..6b88477 100644
--- a/Swiften/Jingle/FakeJingleSession.cpp
+++ b/Swiften/Jingle/FakeJingleSession.cpp
@@ -5,15 +5,16 @@
*/
/*
- * Copyright (c) 2014-2015 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Jingle/FakeJingleSession.h>
-#include <Swiften/Jingle/JingleSessionListener.h>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
+#include <Swiften/Jingle/JingleSessionListener.h>
namespace Swift {
@@ -25,56 +26,56 @@ FakeJingleSession::~FakeJingleSession() {
}
void FakeJingleSession::sendInitiate(const JingleContentID& id, JingleDescription::ref desc, JingleTransportPayload::ref payload) {
- calledCommands.push_back(InitiateCall(id, desc, payload));
+ calledCommands.push_back(InitiateCall(id, desc, payload));
}
void FakeJingleSession::sendTerminate(JinglePayload::Reason::Type reason) {
- calledCommands.push_back(TerminateCall(reason));
+ calledCommands.push_back(TerminateCall(reason));
}
-void FakeJingleSession::sendInfo(boost::shared_ptr<Payload> payload) {
- calledCommands.push_back(InfoCall(payload));
+void FakeJingleSession::sendInfo(std::shared_ptr<Payload> payload) {
+ calledCommands.push_back(InfoCall(payload));
}
void FakeJingleSession::sendAccept(const JingleContentID& id, JingleDescription::ref desc, JingleTransportPayload::ref payload) {
- calledCommands.push_back(AcceptCall(id, desc, payload));
+ calledCommands.push_back(AcceptCall(id, desc, payload));
}
std::string FakeJingleSession::sendTransportInfo(const JingleContentID& id, JingleTransportPayload::ref payload) {
- calledCommands.push_back(InfoTransportCall(id, payload));
- return idGenerator.generateID();
+ calledCommands.push_back(InfoTransportCall(id, payload));
+ return idGenerator.generateID();
}
void FakeJingleSession::sendTransportAccept(const JingleContentID& id, JingleTransportPayload::ref payload) {
- calledCommands.push_back(AcceptTransportCall(id, payload));
+ calledCommands.push_back(AcceptTransportCall(id, payload));
}
void FakeJingleSession::sendTransportReject(const JingleContentID& id, JingleTransportPayload::ref payload) {
- calledCommands.push_back(RejectTransportCall(id, payload));
+ calledCommands.push_back(RejectTransportCall(id, payload));
}
void FakeJingleSession::sendTransportReplace(const JingleContentID& id, JingleTransportPayload::ref payload) {
- calledCommands.push_back(ReplaceTransportCall(id, payload));
+ calledCommands.push_back(ReplaceTransportCall(id, payload));
}
void FakeJingleSession::handleTransportReplaceReceived(const JingleContentID& contentID, JingleTransportPayload::ref transport) {
- notifyListeners(&JingleSessionListener::handleTransportReplaceReceived, contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportReplaceReceived, contentID, transport);
}
void FakeJingleSession::handleTransportAcceptReceived(const JingleContentID& contentID, JingleTransportPayload::ref transport) {
- notifyListeners(&JingleSessionListener::handleTransportAcceptReceived, contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportAcceptReceived, contentID, transport);
}
void FakeJingleSession::handleTransportInfoReceived(const JingleContentID& contentID, JingleTransportPayload::ref transport) {
- notifyListeners(&JingleSessionListener::handleTransportInfoReceived, contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportInfoReceived, contentID, transport);
}
void FakeJingleSession::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) {
- notifyListeners(&JingleSessionListener::handleSessionTerminateReceived, reason);
+ notifyListeners(&JingleSessionListener::handleSessionTerminateReceived, reason);
}
-void FakeJingleSession::handleSessionAcceptReceived(const JingleContentID& contentID, boost::shared_ptr<JingleDescription> desc, boost::shared_ptr<JingleTransportPayload> payload) {
- notifyListeners(&JingleSessionListener::handleSessionAcceptReceived, contentID, desc, payload);
+void FakeJingleSession::handleSessionAcceptReceived(const JingleContentID& contentID, std::shared_ptr<JingleDescription> desc, std::shared_ptr<JingleTransportPayload> payload) {
+ notifyListeners(&JingleSessionListener::handleSessionAcceptReceived, contentID, desc, payload);
}
}
diff --git a/Swiften/Jingle/FakeJingleSession.h b/Swiften/Jingle/FakeJingleSession.h
index f250b1a..6218544 100644
--- a/Swiften/Jingle/FakeJingleSession.h
+++ b/Swiften/Jingle/FakeJingleSession.h
@@ -5,109 +5,110 @@
*/
/*
- * Copyright (c) 2013-2015 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include <string>
#include <vector>
+
+#include <boost/signals2.hpp>
#include <boost/variant.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/SimpleIDGenerator.h>
-#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Base/Override.h>
-#include <Swiften/JID/JID.h>
+#include <Swiften/Base/SimpleIDGenerator.h>
#include <Swiften/Elements/JinglePayload.h>
-#include <Swiften/Jingle/JingleSession.h>
+#include <Swiften/JID/JID.h>
#include <Swiften/Jingle/JingleContentID.h>
+#include <Swiften/Jingle/JingleSession.h>
namespace Swift {
- class JingleContentID;
-
- class SWIFTEN_API FakeJingleSession : public JingleSession {
- public:
- struct InitiateCall {
- InitiateCall(JingleContentID contentId, JingleDescription::ref desc, JingleTransportPayload::ref payL) : id(contentId), description(desc), payload(payL) {}
- JingleContentID id;
- JingleDescription::ref description;
- JingleTransportPayload::ref payload;
- };
-
- struct TerminateCall {
- TerminateCall(JinglePayload::Reason::Type r) : reason(r) {}
- JinglePayload::Reason::Type reason;
- };
-
- struct InfoCall {
- InfoCall(boost::shared_ptr<Payload> info) : payload(info) {}
- boost::shared_ptr<Payload> payload;
- };
-
- struct AcceptCall {
- AcceptCall(JingleContentID contentId, JingleDescription::ref desc, JingleTransportPayload::ref payL) : id(contentId), description(desc), payload(payL) {}
- JingleContentID id;
- JingleDescription::ref description;
- JingleTransportPayload::ref payload;
- };
-
- struct InfoTransportCall {
- InfoTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
- JingleContentID id;
- JingleTransportPayload::ref payload;
- };
-
- struct AcceptTransportCall {
- AcceptTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
- JingleContentID id;
- JingleTransportPayload::ref payload;
- };
-
- struct RejectTransportCall {
- RejectTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
- JingleContentID id;
- JingleTransportPayload::ref payload;
- };
-
- struct ReplaceTransportCall {
- ReplaceTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
- JingleContentID id;
- JingleTransportPayload::ref payload;
- };
-
- typedef boost::variant<InitiateCall, TerminateCall, AcceptCall, InfoCall, InfoTransportCall, AcceptTransportCall, RejectTransportCall, ReplaceTransportCall> Command;
-
- public:
- typedef boost::shared_ptr<FakeJingleSession> ref;
-
- FakeJingleSession(const JID& initiator, const std::string& id);
- virtual ~FakeJingleSession();
-
- virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTerminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE;
- virtual void sendInfo(boost::shared_ptr<Payload>) SWIFTEN_OVERRIDE;
- virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) SWIFTEN_OVERRIDE;
- virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
- virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
-
- void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>);
- void handleSessionAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleDescription>, boost::shared_ptr<JingleTransportPayload>);
- void handleSessionInfoReceived(boost::shared_ptr<JinglePayload>);
-
- void handleTransportReplaceReceived(const JingleContentID&, JingleTransportPayload::ref);
- void handleTransportAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>);
- void handleTransportInfoReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>);
- void handleTransportRejectReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>);
- void handleTransportInfoAcknowledged(const std::string& id);
-
- public:
- std::vector<Command> calledCommands;
- SimpleIDGenerator idGenerator;
- };
+ class JingleContentID;
+
+ class SWIFTEN_API FakeJingleSession : public JingleSession {
+ public:
+ struct InitiateCall {
+ InitiateCall(JingleContentID contentId, JingleDescription::ref desc, JingleTransportPayload::ref payL) : id(contentId), description(desc), payload(payL) {}
+ JingleContentID id;
+ JingleDescription::ref description;
+ JingleTransportPayload::ref payload;
+ };
+
+ struct TerminateCall {
+ TerminateCall(JinglePayload::Reason::Type r) : reason(r) {}
+ JinglePayload::Reason::Type reason;
+ };
+
+ struct InfoCall {
+ InfoCall(std::shared_ptr<Payload> info) : payload(info) {}
+ std::shared_ptr<Payload> payload;
+ };
+
+ struct AcceptCall {
+ AcceptCall(JingleContentID contentId, JingleDescription::ref desc, JingleTransportPayload::ref payL) : id(contentId), description(desc), payload(payL) {}
+ JingleContentID id;
+ JingleDescription::ref description;
+ JingleTransportPayload::ref payload;
+ };
+
+ struct InfoTransportCall {
+ InfoTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
+ JingleContentID id;
+ JingleTransportPayload::ref payload;
+ };
+
+ struct AcceptTransportCall {
+ AcceptTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
+ JingleContentID id;
+ JingleTransportPayload::ref payload;
+ };
+
+ struct RejectTransportCall {
+ RejectTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
+ JingleContentID id;
+ JingleTransportPayload::ref payload;
+ };
+
+ struct ReplaceTransportCall {
+ ReplaceTransportCall(JingleContentID contentId, JingleTransportPayload::ref payL) : id(contentId), payload(payL) {}
+ JingleContentID id;
+ JingleTransportPayload::ref payload;
+ };
+
+ typedef boost::variant<InitiateCall, TerminateCall, AcceptCall, InfoCall, InfoTransportCall, AcceptTransportCall, RejectTransportCall, ReplaceTransportCall> Command;
+
+ public:
+ typedef std::shared_ptr<FakeJingleSession> ref;
+
+ FakeJingleSession(const JID& initiator, const std::string& id);
+ virtual ~FakeJingleSession();
+
+ virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual void sendTerminate(JinglePayload::Reason::Type reason) SWIFTEN_OVERRIDE;
+ virtual void sendInfo(std::shared_ptr<Payload>) SWIFTEN_OVERRIDE;
+ virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) SWIFTEN_OVERRIDE;
+ virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+ virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) SWIFTEN_OVERRIDE;
+
+ void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>);
+ void handleSessionAcceptReceived(const JingleContentID&, std::shared_ptr<JingleDescription>, std::shared_ptr<JingleTransportPayload>);
+ void handleSessionInfoReceived(std::shared_ptr<JinglePayload>);
+
+ void handleTransportReplaceReceived(const JingleContentID&, JingleTransportPayload::ref);
+ void handleTransportAcceptReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>);
+ void handleTransportInfoReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>);
+ void handleTransportRejectReceived(const JingleContentID&, std::shared_ptr<JingleTransportPayload>);
+ void handleTransportInfoAcknowledged(const std::string& id);
+
+ public:
+ std::vector<Command> calledCommands;
+ SimpleIDGenerator idGenerator;
+ };
}
diff --git a/Swiften/Jingle/IncomingJingleSessionHandler.h b/Swiften/Jingle/IncomingJingleSessionHandler.h
index fba9acc..4c30f7c 100644
--- a/Swiften/Jingle/IncomingJingleSessionHandler.h
+++ b/Swiften/Jingle/IncomingJingleSessionHandler.h
@@ -10,10 +10,10 @@
#include <Swiften/Jingle/JingleSession.h>
namespace Swift {
- class SWIFTEN_API IncomingJingleSessionHandler {
- public:
- virtual ~IncomingJingleSessionHandler();
+ class SWIFTEN_API IncomingJingleSessionHandler {
+ public:
+ virtual ~IncomingJingleSessionHandler();
- virtual bool handleIncomingJingleSession(JingleSession::ref, const std::vector<JingleContentPayload::ref>& contents, const JID& recipient) = 0;
- };
+ virtual bool handleIncomingJingleSession(JingleSession::ref, const std::vector<JingleContentPayload::ref>& contents, const JID& recipient) = 0;
+ };
}
diff --git a/Swiften/Jingle/Jingle.h b/Swiften/Jingle/Jingle.h
index bf05b1c..0cd1a23 100644
--- a/Swiften/Jingle/Jingle.h
+++ b/Swiften/Jingle/Jingle.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,15 +11,15 @@
#include <Swiften/Elements/JingleContentPayload.h>
namespace Swift {
- namespace Jingle {
- template<typename T>
- JingleContentPayload::ref getContentWithDescription(const std::vector<JingleContentPayload::ref>& contents) {
- for (size_t i = 0; i < contents.size(); ++i) {
- if (contents[i]->getDescription<T>()) {
- return contents[i];
- }
- }
- return JingleContentPayload::ref();
- }
- }
+ namespace Jingle {
+ template<typename T>
+ JingleContentPayload::ref getContentWithDescription(const std::vector<JingleContentPayload::ref>& contents) {
+ for (const auto& content : contents) {
+ if (content->getDescription<T>()) {
+ return content;
+ }
+ }
+ return JingleContentPayload::ref();
+ }
+ }
}
diff --git a/Swiften/Jingle/JingleContentID.h b/Swiften/Jingle/JingleContentID.h
index 2d842fa..60f412b 100644
--- a/Swiften/Jingle/JingleContentID.h
+++ b/Swiften/Jingle/JingleContentID.h
@@ -12,21 +12,21 @@
#include <Swiften/Elements/JingleContentPayload.h>
namespace Swift {
- class SWIFTEN_API JingleContentID {
- public:
- JingleContentID(const std::string& name, JingleContentPayload::Creator creator) : name(name), creator(creator) {
- }
-
- const std::string getName() const {
- return this->name;
- }
-
- JingleContentPayload::Creator getCreator() const {
- return this->creator;
- }
+ class SWIFTEN_API JingleContentID {
+ public:
+ JingleContentID(const std::string& name, JingleContentPayload::Creator creator) : name(name), creator(creator) {
+ }
- private:
- std::string name;
- JingleContentPayload::Creator creator;
- };
+ const std::string getName() const {
+ return this->name;
+ }
+
+ JingleContentPayload::Creator getCreator() const {
+ return this->creator;
+ }
+
+ private:
+ std::string name;
+ JingleContentPayload::Creator creator;
+ };
}
diff --git a/Swiften/Jingle/JingleResponder.cpp b/Swiften/Jingle/JingleResponder.cpp
index b0caa74..09bb234 100644
--- a/Swiften/Jingle/JingleResponder.cpp
+++ b/Swiften/Jingle/JingleResponder.cpp
@@ -1,17 +1,16 @@
/*
- * Copyright (c) 2011-2014 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Jingle/JingleResponder.h>
-#include <boost/smart_ptr/make_shared.hpp>
-
-#include <Swiften/Jingle/JingleSessionManager.h>
-#include <Swiften/Jingle/JingleSessionImpl.h>
+#include <memory>
#include <Swiften/Base/Log.h>
+#include <Swiften/Jingle/JingleSessionImpl.h>
+#include <Swiften/Jingle/JingleSessionManager.h>
namespace Swift {
@@ -21,42 +20,42 @@ JingleResponder::JingleResponder(JingleSessionManager* sessionManager, IQRouter*
JingleResponder::~JingleResponder() {
}
-bool JingleResponder::handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<JinglePayload> payload) {
- if (payload->getAction() == JinglePayload::SessionInitiate) {
- if (sessionManager->getSession(from, payload->getSessionID())) {
- // TODO: Add tie-break error
- sendError(from, id, ErrorPayload::Conflict, ErrorPayload::Cancel);
- }
- else {
- sendResponse(from, id, boost::shared_ptr<JinglePayload>());
- if (!payload->getInitiator().isBare()) {
- JingleSessionImpl::ref session = boost::make_shared<JingleSessionImpl>(payload->getInitiator(), from, payload->getSessionID(), router);
- sessionManager->handleIncomingSession(from, to, session, payload->getContents());
- } else {
- SWIFT_LOG(debug) << "Unable to create Jingle session due to initiator not being a full JID." << std::endl;
- }
- }
- }
- else {
- JingleSessionImpl::ref session;
- if (payload->getInitiator().isValid()) {
- SWIFT_LOG(debug) << "Lookup session by initiator." << std::endl;
- session = sessionManager->getSession(payload->getInitiator(), payload->getSessionID());
- } else {
- SWIFT_LOG(debug) << "Lookup session by from attribute." << std::endl;
- session = sessionManager->getSession(from, payload->getSessionID());
- }
- if (session) {
- session->handleIncomingAction(payload);
- sendResponse(from, id, boost::shared_ptr<JinglePayload>());
- }
- else {
- SWIFT_LOG(warning) << "Didn't find jingle session!";
- // TODO: Add jingle-specific error
- sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
- }
- }
- return true;
+bool JingleResponder::handleSetRequest(const JID& from, const JID& to, const std::string& id, std::shared_ptr<JinglePayload> payload) {
+ if (payload->getAction() == JinglePayload::SessionInitiate) {
+ if (sessionManager->getSession(from, payload->getSessionID())) {
+ // TODO: Add tie-break error
+ sendError(from, id, ErrorPayload::Conflict, ErrorPayload::Cancel);
+ }
+ else {
+ sendResponse(from, id, std::shared_ptr<JinglePayload>());
+ if (!payload->getInitiator().isBare()) {
+ JingleSessionImpl::ref session = std::make_shared<JingleSessionImpl>(payload->getInitiator(), from, payload->getSessionID(), router);
+ sessionManager->handleIncomingSession(from, to, session, payload->getContents());
+ } else {
+ SWIFT_LOG(debug) << "Unable to create Jingle session due to initiator not being a full JID." << std::endl;
+ }
+ }
+ }
+ else {
+ JingleSessionImpl::ref session;
+ if (payload->getInitiator().isValid()) {
+ SWIFT_LOG(debug) << "Lookup session by initiator." << std::endl;
+ session = sessionManager->getSession(payload->getInitiator(), payload->getSessionID());
+ } else {
+ SWIFT_LOG(debug) << "Lookup session by from attribute." << std::endl;
+ session = sessionManager->getSession(from, payload->getSessionID());
+ }
+ if (session) {
+ session->handleIncomingAction(payload);
+ sendResponse(from, id, std::shared_ptr<JinglePayload>());
+ }
+ else {
+ SWIFT_LOG(warning) << "Didn't find jingle session!";
+ // TODO: Add jingle-specific error
+ sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
+ }
+ }
+ return true;
}
}
diff --git a/Swiften/Jingle/JingleResponder.h b/Swiften/Jingle/JingleResponder.h
index cf01e6f..cb9220c 100644
--- a/Swiften/Jingle/JingleResponder.h
+++ b/Swiften/Jingle/JingleResponder.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2015 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,22 +7,22 @@
#pragma once
#include <Swiften/Base/API.h>
-#include <Swiften/Queries/SetResponder.h>
#include <Swiften/Elements/JinglePayload.h>
+#include <Swiften/Queries/SetResponder.h>
namespace Swift {
- class IQRouter;
- class JingleSessionManager;
+ class IQRouter;
+ class JingleSessionManager;
- class SWIFTEN_API JingleResponder : public SetResponder<JinglePayload> {
- public:
- JingleResponder(JingleSessionManager* sessionManager, IQRouter* router);
- virtual ~JingleResponder();
- private:
- virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<JinglePayload> payload);
+ class SWIFTEN_API JingleResponder : public SetResponder<JinglePayload> {
+ public:
+ JingleResponder(JingleSessionManager* sessionManager, IQRouter* router);
+ virtual ~JingleResponder();
+ private:
+ virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, std::shared_ptr<JinglePayload> payload);
- private:
- JingleSessionManager* sessionManager;
- IQRouter* router;
- };
+ private:
+ JingleSessionManager* sessionManager;
+ IQRouter* router;
+ };
}
diff --git a/Swiften/Jingle/JingleSession.cpp b/Swiften/Jingle/JingleSession.cpp
index bb3ce10..b5cfbef 100644
--- a/Swiften/Jingle/JingleSession.cpp
+++ b/Swiften/Jingle/JingleSession.cpp
@@ -1,23 +1,23 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Jingle/JingleSession.h>
-#include <boost/smart_ptr/make_shared.hpp>
#include <algorithm>
-#include <boost/function.hpp>
+#include <cassert>
+#include <memory>
-#include <Swiften/Base/foreach.h>
+#include <boost/function.hpp>
using namespace Swift;
JingleSession::JingleSession(const JID& initiator, const std::string& id) : initiator(initiator), id(id) {
- // initiator must always be a full JID; session lookup based on it wouldn't work otherwise
- // this is checked on an upper level so that the assert never fails
- assert(!initiator.isBare());
+ // initiator must always be a full JID; session lookup based on it wouldn't work otherwise
+ // this is checked on an upper level so that the assert never fails
+ assert(!initiator.isBare());
}
JingleSession::~JingleSession() {
diff --git a/Swiften/Jingle/JingleSession.h b/Swiften/Jingle/JingleSession.h
index 7d7d45e..22e6901 100644
--- a/Swiften/Jingle/JingleSession.h
+++ b/Swiften/Jingle/JingleSession.h
@@ -1,53 +1,54 @@
/*
- * Copyright (c) 2011-2015 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
+#include <memory>
#include <string>
#include <vector>
-#include <boost/shared_ptr.hpp>
+
#include <boost/optional.hpp>
+#include <boost/signals2.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Base/Listenable.h>
-#include <Swiften/Base/boost_bsignals.h>
-#include <Swiften/JID/JID.h>
#include <Swiften/Elements/JinglePayload.h>
+#include <Swiften/JID/JID.h>
namespace Swift {
- class JingleSessionListener;
- class JingleContentID;
-
- class SWIFTEN_API JingleSession : public Listenable<JingleSessionListener> {
- public:
- typedef boost::shared_ptr<JingleSession> ref;
-
- JingleSession(const JID& initiator, const std::string& id);
- virtual ~JingleSession();
-
- const JID& getInitiator() const {
- return initiator;
- }
-
- const std::string& getID() const {
- return id;
- }
-
- virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) = 0;
- virtual void sendTerminate(JinglePayload::Reason::Type reason) = 0;
- virtual void sendInfo(boost::shared_ptr<Payload>) = 0;
- virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) = 0;
- virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) = 0;
- virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) = 0;
- virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) = 0;
- virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) = 0;
-
- private:
- JID initiator;
- std::string id;
- std::vector<JingleSessionListener*> listeners;
- };
+ class JingleSessionListener;
+ class JingleContentID;
+
+ class SWIFTEN_API JingleSession : public Listenable<JingleSessionListener> {
+ public:
+ typedef std::shared_ptr<JingleSession> ref;
+
+ JingleSession(const JID& initiator, const std::string& id);
+ virtual ~JingleSession();
+
+ const JID& getInitiator() const {
+ return initiator;
+ }
+
+ const std::string& getID() const {
+ return id;
+ }
+
+ virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref) = 0;
+ virtual void sendTerminate(JinglePayload::Reason::Type reason) = 0;
+ virtual void sendInfo(std::shared_ptr<Payload>) = 0;
+ virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref = JingleTransportPayload::ref()) = 0;
+ virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref) = 0;
+ virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref) = 0;
+ virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref) = 0;
+ virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref) = 0;
+
+ private:
+ JID initiator;
+ std::string id;
+ std::vector<JingleSessionListener*> listeners;
+ };
}
diff --git a/Swiften/Jingle/JingleSessionImpl.cpp b/Swiften/Jingle/JingleSessionImpl.cpp
index a5273d6..06aa039 100644
--- a/Swiften/Jingle/JingleSessionImpl.cpp
+++ b/Swiften/Jingle/JingleSessionImpl.cpp
@@ -1,208 +1,207 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Jingle/JingleSessionImpl.h>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <boost/bind.hpp>
#include <algorithm>
+#include <memory>
-#include <Swiften/Parser/PayloadParsers/JingleParser.h>
+#include <boost/bind.hpp>
+
+#include <Swiften/Base/Log.h>
+#include <Swiften/Elements/JingleContentPayload.h>
#include <Swiften/Jingle/JingleContentID.h>
#include <Swiften/Jingle/JingleSessionListener.h>
-#include <Swiften/Elements/JingleContentPayload.h>
-#include <Swiften/Queries/Request.h>
+#include <Swiften/Parser/PayloadParsers/JingleParser.h>
#include <Swiften/Queries/GenericRequest.h>
-
-#include <Swiften/Base/Log.h>
-
+#include <Swiften/Queries/Request.h>
#include <Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h>
namespace Swift {
JingleSessionImpl::JingleSessionImpl(const JID& initiator, const JID& peerJID, const std::string& id, IQRouter* router) : JingleSession(initiator, id), iqRouter(router), peerJID(peerJID) {
- SWIFT_LOG(debug) << "initiator: " << initiator << ", peerJID: " << peerJID << std::endl;
+ SWIFT_LOG(debug) << "initiator: " << initiator << ", peerJID: " << peerJID << std::endl;
}
void JingleSessionImpl::handleIncomingAction(JinglePayload::ref action) {
- if (action->getAction() == JinglePayload::SessionTerminate) {
- notifyListeners(&JingleSessionListener::handleSessionTerminateReceived, action->getReason());
- return;
- }
- if (action->getAction() == JinglePayload::SessionInfo) {
- notifyListeners(&JingleSessionListener::handleSessionInfoReceived, action);
- return;
- }
-
- JingleContentPayload::ref content = action->getPayload<JingleContentPayload>();
- if (!content) {
- SWIFT_LOG(debug) << "no content payload!" << std::endl;
- return;
- }
- JingleContentID contentID(content->getName(), content->getCreator());
- JingleDescription::ref description = content->getDescriptions().empty() ? JingleDescription::ref() : content->getDescriptions()[0];
- JingleTransportPayload::ref transport = content->getTransports().empty() ? JingleTransportPayload::ref() : content->getTransports()[0];
- switch(action->getAction()) {
- case JinglePayload::SessionAccept:
- notifyListeners(&JingleSessionListener::handleSessionAcceptReceived, contentID, description, transport);
- return;
- case JinglePayload::TransportAccept:
- notifyListeners(&JingleSessionListener::handleTransportAcceptReceived, contentID, transport);
- return;
- case JinglePayload::TransportInfo:
- notifyListeners(&JingleSessionListener::handleTransportInfoReceived, contentID, transport);
- return;
- case JinglePayload::TransportReject:
- notifyListeners(&JingleSessionListener::handleTransportRejectReceived, contentID, transport);
- return;
- case JinglePayload::TransportReplace:
- notifyListeners(&JingleSessionListener::handleTransportReplaceReceived, contentID, transport);
- return;
- // following unused Jingle actions
- case JinglePayload::ContentAccept:
- case JinglePayload::ContentAdd:
- case JinglePayload::ContentModify:
- case JinglePayload::ContentReject:
- case JinglePayload::ContentRemove:
- case JinglePayload::DescriptionInfo:
- case JinglePayload::SecurityInfo:
-
- // handled elsewhere
- case JinglePayload::SessionInitiate:
- case JinglePayload::SessionInfo:
- case JinglePayload::SessionTerminate:
-
- case JinglePayload::UnknownAction:
- return;
- }
- assert(false);
+ if (action->getAction() == JinglePayload::SessionTerminate) {
+ notifyListeners(&JingleSessionListener::handleSessionTerminateReceived, action->getReason());
+ return;
+ }
+ if (action->getAction() == JinglePayload::SessionInfo) {
+ notifyListeners(&JingleSessionListener::handleSessionInfoReceived, action);
+ return;
+ }
+
+ JingleContentPayload::ref content = action->getPayload<JingleContentPayload>();
+ if (!content) {
+ SWIFT_LOG(debug) << "no content payload!" << std::endl;
+ return;
+ }
+ JingleContentID contentID(content->getName(), content->getCreator());
+ JingleDescription::ref description = content->getDescriptions().empty() ? JingleDescription::ref() : content->getDescriptions()[0];
+ JingleTransportPayload::ref transport = content->getTransports().empty() ? JingleTransportPayload::ref() : content->getTransports()[0];
+ switch(action->getAction()) {
+ case JinglePayload::SessionAccept:
+ notifyListeners(&JingleSessionListener::handleSessionAcceptReceived, contentID, description, transport);
+ return;
+ case JinglePayload::TransportAccept:
+ notifyListeners(&JingleSessionListener::handleTransportAcceptReceived, contentID, transport);
+ return;
+ case JinglePayload::TransportInfo:
+ notifyListeners(&JingleSessionListener::handleTransportInfoReceived, contentID, transport);
+ return;
+ case JinglePayload::TransportReject:
+ notifyListeners(&JingleSessionListener::handleTransportRejectReceived, contentID, transport);
+ return;
+ case JinglePayload::TransportReplace:
+ notifyListeners(&JingleSessionListener::handleTransportReplaceReceived, contentID, transport);
+ return;
+ // following unused Jingle actions
+ case JinglePayload::ContentAccept:
+ case JinglePayload::ContentAdd:
+ case JinglePayload::ContentModify:
+ case JinglePayload::ContentReject:
+ case JinglePayload::ContentRemove:
+ case JinglePayload::DescriptionInfo:
+ case JinglePayload::SecurityInfo:
+
+ // handled elsewhere
+ case JinglePayload::SessionInitiate:
+ case JinglePayload::SessionInfo:
+ case JinglePayload::SessionTerminate:
+
+ case JinglePayload::UnknownAction:
+ return;
+ }
+ assert(false);
}
void JingleSessionImpl::sendInitiate(const JingleContentID& id, JingleDescription::ref description, JingleTransportPayload::ref transport) {
- JinglePayload::ref payload = boost::make_shared<JinglePayload>(JinglePayload::SessionInitiate, getID());
- payload->setInitiator(getInitiator());
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(id.getCreator());
- content->setName(id.getName());
- content->addDescription(description);
- content->addTransport(transport);
- payload->addPayload(content);
-
- sendSetRequest(payload);
+ JinglePayload::ref payload = std::make_shared<JinglePayload>(JinglePayload::SessionInitiate, getID());
+ payload->setInitiator(getInitiator());
+ JingleContentPayload::ref content = std::make_shared<JingleContentPayload>();
+ content->setCreator(id.getCreator());
+ content->setName(id.getName());
+ content->addDescription(description);
+ content->addTransport(transport);
+ payload->addPayload(content);
+
+ sendSetRequest(payload);
}
void JingleSessionImpl::sendTerminate(JinglePayload::Reason::Type reason) {
- JinglePayload::ref payload = boost::make_shared<JinglePayload>(JinglePayload::SessionTerminate, getID());
- payload->setReason(JinglePayload::Reason(reason));
- payload->setInitiator(getInitiator());
- sendSetRequest(payload);
+ JinglePayload::ref payload = std::make_shared<JinglePayload>(JinglePayload::SessionTerminate, getID());
+ payload->setReason(JinglePayload::Reason(reason));
+ payload->setInitiator(getInitiator());
+ sendSetRequest(payload);
}
-void JingleSessionImpl::sendInfo(boost::shared_ptr<Payload> info) {
- JinglePayload::ref payload = boost::make_shared<JinglePayload>(JinglePayload::SessionInfo, getID());
- payload->addPayload(info);
+void JingleSessionImpl::sendInfo(std::shared_ptr<Payload> info) {
+ JinglePayload::ref payload = std::make_shared<JinglePayload>(JinglePayload::SessionInfo, getID());
+ payload->addPayload(info);
- sendSetRequest(payload);
+ sendSetRequest(payload);
}
void JingleSessionImpl::sendAccept(const JingleContentID& id, JingleDescription::ref description, JingleTransportPayload::ref transPayload) {
- JinglePayload::ref payload = createPayload();
-
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(id.getCreator());
- content->setName(id.getName());
- content->addTransport(transPayload);
- content->addDescription(description);
- payload->setAction(JinglePayload::SessionAccept);
- payload->addPayload(content);
-
- // put into IQ:set and send it away
- sendSetRequest(payload);
+ JinglePayload::ref payload = createPayload();
+
+ JingleContentPayload::ref content = std::make_shared<JingleContentPayload>();
+ content->setCreator(id.getCreator());
+ content->setName(id.getName());
+ content->addTransport(transPayload);
+ content->addDescription(description);
+ payload->setAction(JinglePayload::SessionAccept);
+ payload->addPayload(content);
+
+ // put into IQ:set and send it away
+ sendSetRequest(payload);
}
void JingleSessionImpl::sendTransportAccept(const JingleContentID& id, JingleTransportPayload::ref transPayload) {
- JinglePayload::ref payload = createPayload();
+ JinglePayload::ref payload = createPayload();
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(id.getCreator());
- content->setName(id.getName());
- content->addTransport(transPayload);
- payload->setAction(JinglePayload::TransportAccept);
- payload->addPayload(content);
+ JingleContentPayload::ref content = std::make_shared<JingleContentPayload>();
+ content->setCreator(id.getCreator());
+ content->setName(id.getName());
+ content->addTransport(transPayload);
+ payload->setAction(JinglePayload::TransportAccept);
+ payload->addPayload(content);
- // put into IQ:set and send it away
- sendSetRequest(payload);
+ // put into IQ:set and send it away
+ sendSetRequest(payload);
}
std::string JingleSessionImpl::sendTransportInfo(const JingleContentID& id, JingleTransportPayload::ref transPayload) {
- JinglePayload::ref payload = createPayload();
+ JinglePayload::ref payload = createPayload();
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(id.getCreator());
- content->setName(id.getName());
- content->addTransport(transPayload);
- payload->setAction(JinglePayload::TransportInfo);
- payload->addPayload(content);
+ JingleContentPayload::ref content = std::make_shared<JingleContentPayload>();
+ content->setCreator(id.getCreator());
+ content->setName(id.getName());
+ content->addTransport(transPayload);
+ payload->setAction(JinglePayload::TransportInfo);
+ payload->addPayload(content);
- return sendSetRequest(payload);
+ return sendSetRequest(payload);
}
void JingleSessionImpl::sendTransportReject(const JingleContentID& id, JingleTransportPayload::ref transPayload) {
- JinglePayload::ref payload = createPayload();
+ JinglePayload::ref payload = createPayload();
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(id.getCreator());
- content->setName(id.getName());
- content->addTransport(transPayload);
- payload->setAction(JinglePayload::TransportReject);
- payload->addPayload(content);
+ JingleContentPayload::ref content = std::make_shared<JingleContentPayload>();
+ content->setCreator(id.getCreator());
+ content->setName(id.getName());
+ content->addTransport(transPayload);
+ payload->setAction(JinglePayload::TransportReject);
+ payload->addPayload(content);
- sendSetRequest(payload);
+ sendSetRequest(payload);
}
void JingleSessionImpl::sendTransportReplace(const JingleContentID& id, JingleTransportPayload::ref transPayload) {
- JinglePayload::ref payload = createPayload();
+ JinglePayload::ref payload = createPayload();
- JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
- content->setCreator(id.getCreator());
- content->setName(id.getName());
- content->addTransport(transPayload);
- payload->setAction(JinglePayload::TransportReplace);
- payload->addContent(content);
+ JingleContentPayload::ref content = std::make_shared<JingleContentPayload>();
+ content->setCreator(id.getCreator());
+ content->setName(id.getName());
+ content->addTransport(transPayload);
+ payload->setAction(JinglePayload::TransportReplace);
+ payload->addContent(content);
- sendSetRequest(payload);
+ sendSetRequest(payload);
}
std::string JingleSessionImpl::sendSetRequest(JinglePayload::ref payload) {
- boost::shared_ptr<GenericRequest<JinglePayload> > request = boost::make_shared<GenericRequest<JinglePayload> >(
- IQ::Set, peerJID, payload, iqRouter);
- pendingRequests.insert(std::make_pair(
- request,
- request->onResponse.connect(boost::bind(&JingleSessionImpl::handleRequestResponse, this, request))));
- return request->send();
+ std::shared_ptr<GenericRequest<JinglePayload> > request = std::make_shared<GenericRequest<JinglePayload> >(
+ IQ::Set, peerJID, payload, iqRouter);
+ pendingRequests.insert(std::make_pair(
+ request,
+ request->onResponse.connect(boost::bind(&JingleSessionImpl::handleRequestResponse, this, request))));
+ return request->send();
}
JinglePayload::ref JingleSessionImpl::createPayload() const {
- JinglePayload::ref payload = boost::make_shared<JinglePayload>();
- payload->setSessionID(getID());
- payload->setInitiator(getInitiator());
- return payload;
+ JinglePayload::ref payload = std::make_shared<JinglePayload>();
+ payload->setSessionID(getID());
+ payload->setInitiator(getInitiator());
+ return payload;
}
void JingleSessionImpl::handleRequestResponse(RequestRef request) {
- RequestsMap::iterator i = pendingRequests.find(request);
- assert(i != pendingRequests.end());
- if (i->first->getPayloadGeneric()->getAction() == JinglePayload::TransportInfo) {
- notifyListeners(&JingleSessionListener::handleTransportInfoAcknowledged, i->first->getID());
- }
- i->second.disconnect();
- pendingRequests.erase(i);
+ RequestsMap::iterator i = pendingRequests.find(request);
+ assert(i != pendingRequests.end());
+ if (i->first->getPayloadGeneric()->getAction() == JinglePayload::TransportInfo) {
+ notifyListeners(&JingleSessionListener::handleTransportInfoAcknowledged, i->first->getID());
+ }
+ i->second.disconnect();
+ pendingRequests.erase(i);
}
diff --git a/Swiften/Jingle/JingleSessionImpl.h b/Swiften/Jingle/JingleSessionImpl.h
index 4c455a5..b42b790 100644
--- a/Swiften/Jingle/JingleSessionImpl.h
+++ b/Swiften/Jingle/JingleSessionImpl.h
@@ -1,50 +1,50 @@
/*
- * Copyright (c) 2011-2013 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <boost/shared_ptr.hpp>
#include <map>
+#include <memory>
#include <Swiften/Jingle/JingleSession.h>
#include <Swiften/Queries/GenericRequest.h>
namespace Swift {
- class IQRouter;
- class Request;
-
- class JingleSessionImpl : public JingleSession {
- friend class JingleResponder;
- public:
- typedef boost::shared_ptr<JingleSessionImpl> ref;
-
- JingleSessionImpl(const JID& initiator, const JID&, const std::string& id, IQRouter* router);
-
- virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref);
- virtual void sendTerminate(JinglePayload::Reason::Type reason);
- virtual void sendInfo(boost::shared_ptr<Payload>);
- virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref);
- virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref);
- virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref);
- virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref);
- virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref);
-
- private:
- typedef boost::shared_ptr<GenericRequest<JinglePayload> > RequestRef;
-
- void handleIncomingAction(JinglePayload::ref);
-
- std::string sendSetRequest(JinglePayload::ref payload);
- JinglePayload::ref createPayload() const;
- void handleRequestResponse(RequestRef);
-
- private:
- IQRouter *iqRouter;
- JID peerJID;
- typedef std::map<RequestRef, boost::bsignals::connection > RequestsMap;
- RequestsMap pendingRequests;
- };
+ class IQRouter;
+ class Request;
+
+ class JingleSessionImpl : public JingleSession {
+ friend class JingleResponder;
+ public:
+ typedef std::shared_ptr<JingleSessionImpl> ref;
+
+ JingleSessionImpl(const JID& initiator, const JID&, const std::string& id, IQRouter* router);
+
+ virtual void sendInitiate(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref);
+ virtual void sendTerminate(JinglePayload::Reason::Type reason);
+ virtual void sendInfo(std::shared_ptr<Payload>);
+ virtual void sendAccept(const JingleContentID&, JingleDescription::ref, JingleTransportPayload::ref);
+ virtual std::string sendTransportInfo(const JingleContentID&, JingleTransportPayload::ref);
+ virtual void sendTransportAccept(const JingleContentID&, JingleTransportPayload::ref);
+ virtual void sendTransportReject(const JingleContentID&, JingleTransportPayload::ref);
+ virtual void sendTransportReplace(const JingleContentID&, JingleTransportPayload::ref);
+
+ private:
+ typedef std::shared_ptr<GenericRequest<JinglePayload> > RequestRef;
+
+ void handleIncomingAction(JinglePayload::ref);
+
+ std::string sendSetRequest(JinglePayload::ref payload);
+ JinglePayload::ref createPayload() const;
+ void handleRequestResponse(RequestRef);
+
+ private:
+ IQRouter *iqRouter;
+ JID peerJID;
+ typedef std::map<RequestRef, boost::signals2::connection > RequestsMap;
+ RequestsMap pendingRequests;
+ };
}
diff --git a/Swiften/Jingle/JingleSessionListener.h b/Swiften/Jingle/JingleSessionListener.h
index dabeb05..7c015f0 100644
--- a/Swiften/Jingle/JingleSessionListener.h
+++ b/Swiften/Jingle/JingleSessionListener.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,31 +10,31 @@
#include <Swiften/Elements/JinglePayload.h>
namespace Swift {
- class JingleContentID;
- class JingleTransportPayload;
- class JingleDescription;
+ class JingleContentID;
+ class JingleTransportPayload;
+ class JingleDescription;
- class SWIFTEN_API JingleSessionListener {
- public:
- virtual ~JingleSessionListener();
+ class SWIFTEN_API JingleSessionListener {
+ public:
+ virtual ~JingleSessionListener();
- virtual void handleSessionAcceptReceived(
- const JingleContentID&,
- boost::shared_ptr<JingleDescription>,
- boost::shared_ptr<JingleTransportPayload>) = 0;
- virtual void handleSessionInfoReceived(boost::shared_ptr<JinglePayload>) = 0;
- virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) = 0;
- virtual void handleTransportAcceptReceived(
- const JingleContentID&,
- boost::shared_ptr<JingleTransportPayload>) = 0;
- virtual void handleTransportInfoReceived(
- const JingleContentID&,
- boost::shared_ptr<JingleTransportPayload>) = 0;
- virtual void handleTransportRejectReceived(
- const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) = 0;
- virtual void handleTransportReplaceReceived(
- const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) = 0;
+ virtual void handleSessionAcceptReceived(
+ const JingleContentID&,
+ std::shared_ptr<JingleDescription>,
+ std::shared_ptr<JingleTransportPayload>) = 0;
+ virtual void handleSessionInfoReceived(std::shared_ptr<JinglePayload>) = 0;
+ virtual void handleSessionTerminateReceived(boost::optional<JinglePayload::Reason>) = 0;
+ virtual void handleTransportAcceptReceived(
+ const JingleContentID&,
+ std::shared_ptr<JingleTransportPayload>) = 0;
+ virtual void handleTransportInfoReceived(
+ const JingleContentID&,
+ std::shared_ptr<JingleTransportPayload>) = 0;
+ virtual void handleTransportRejectReceived(
+ const JingleContentID&, std::shared_ptr<JingleTransportPayload>) = 0;
+ virtual void handleTransportReplaceReceived(
+ const JingleContentID&, std::shared_ptr<JingleTransportPayload>) = 0;
- virtual void handleTransportInfoAcknowledged(const std::string& id) = 0;
- };
+ virtual void handleTransportInfoAcknowledged(const std::string& id) = 0;
+ };
}
diff --git a/Swiften/Jingle/JingleSessionManager.cpp b/Swiften/Jingle/JingleSessionManager.cpp
index 2a94413..f7ed58e 100644
--- a/Swiften/Jingle/JingleSessionManager.cpp
+++ b/Swiften/Jingle/JingleSessionManager.cpp
@@ -1,54 +1,54 @@
/*
- * Copyright (c) 2011-2013 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Jingle/JingleSessionManager.h>
-#include <Swiften/Jingle/JingleResponder.h>
-#include <Swiften/Jingle/IncomingJingleSessionHandler.h>
-#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
+
#include <Swiften/Base/Algorithm.h>
+#include <Swiften/Base/Log.h>
+#include <Swiften/Jingle/IncomingJingleSessionHandler.h>
+#include <Swiften/Jingle/JingleResponder.h>
namespace Swift {
JingleSessionManager::JingleSessionManager(IQRouter* router) : router(router) {
- responder = new JingleResponder(this, router);
- responder->start();
+ responder = new JingleResponder(this, router);
+ responder->start();
}
JingleSessionManager::~JingleSessionManager() {
- responder->stop();
- delete responder;
+ responder->stop();
+ delete responder;
}
JingleSessionImpl::ref JingleSessionManager::getSession(const JID& jid, const std::string& id) const {
- SessionMap::const_iterator i = sessions.find(JIDSession(jid, id));
- return i != sessions.end() ? i->second : JingleSessionImpl::ref();
+ SessionMap::const_iterator i = sessions.find(JIDSession(jid, id));
+ return i != sessions.end() ? i->second : JingleSessionImpl::ref();
}
void JingleSessionManager::addIncomingSessionHandler(IncomingJingleSessionHandler* handler) {
- incomingSessionHandlers.push_back(handler);
+ incomingSessionHandlers.push_back(handler);
}
void JingleSessionManager::removeIncomingSessionHandler(IncomingJingleSessionHandler* handler) {
- erase(incomingSessionHandlers, handler);
+ erase(incomingSessionHandlers, handler);
}
void JingleSessionManager::registerOutgoingSession(const JID& initiator, JingleSessionImpl::ref session) {
- sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session));
- SWIFT_LOG(debug) << "Added session " << session->getID() << " for initiator " << initiator.toString() << std::endl;
+ sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session));
+ SWIFT_LOG(debug) << "Added session " << session->getID() << " for initiator " << initiator.toString() << std::endl;
}
void JingleSessionManager::handleIncomingSession(const JID& initiator, const JID& recipient, JingleSessionImpl::ref session, const std::vector<JingleContentPayload::ref>& contents) {
- sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session));
- foreach (IncomingJingleSessionHandler* handler, incomingSessionHandlers) {
- if (handler->handleIncomingJingleSession(session, contents, recipient)) {
- return;
- }
- }
- // TODO: Finish session
+ sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session));
+ for (auto handler : incomingSessionHandlers) {
+ if (handler->handleIncomingJingleSession(session, contents, recipient)) {
+ return;
+ }
+ }
+ // TODO: Finish session
}
diff --git a/Swiften/Jingle/JingleSessionManager.h b/Swiften/Jingle/JingleSessionManager.h
index ad47f84..f67a0fe 100644
--- a/Swiften/Jingle/JingleSessionManager.h
+++ b/Swiften/Jingle/JingleSessionManager.h
@@ -1,51 +1,52 @@
/*
- * Copyright (c) 2011 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <boost/shared_ptr.hpp>
#include <map>
+#include <memory>
+
+#include <boost/signals2.hpp>
#include <Swiften/Base/API.h>
-#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Jingle/JingleSessionImpl.h>
namespace Swift {
- class IQRouter;
- class JingleResponder;
- class IncomingJingleSessionHandler;
-
- class SWIFTEN_API JingleSessionManager {
- friend class JingleResponder;
- public:
- JingleSessionManager(IQRouter* router);
- ~JingleSessionManager();
-
- JingleSessionImpl::ref getSession(const JID& jid, const std::string& id) const;
-
- void addIncomingSessionHandler(IncomingJingleSessionHandler* handler);
- void removeIncomingSessionHandler(IncomingJingleSessionHandler* handler);
-
- void registerOutgoingSession(const JID& initiator, JingleSessionImpl::ref);
- protected:
- void handleIncomingSession(const JID& initiator, const JID& recipient, JingleSessionImpl::ref, const std::vector<JingleContentPayload::ref>& contents);
-
- private:
- IQRouter* router;
- JingleResponder* responder;
- std::vector<IncomingJingleSessionHandler*> incomingSessionHandlers;
- struct JIDSession {
- JIDSession(const JID& initiator, const std::string& session) : initiator(initiator), session(session) {}
- bool operator<(const JIDSession& o) const {
- return initiator == o.initiator ? session < o.session : initiator < o.initiator;
- }
- JID initiator;
- std::string session;
- };
- typedef std::map<JIDSession, JingleSessionImpl::ref> SessionMap;
- SessionMap sessions;
- };
+ class IQRouter;
+ class JingleResponder;
+ class IncomingJingleSessionHandler;
+
+ class SWIFTEN_API JingleSessionManager {
+ friend class JingleResponder;
+ public:
+ JingleSessionManager(IQRouter* router);
+ ~JingleSessionManager();
+
+ JingleSessionImpl::ref getSession(const JID& jid, const std::string& id) const;
+
+ void addIncomingSessionHandler(IncomingJingleSessionHandler* handler);
+ void removeIncomingSessionHandler(IncomingJingleSessionHandler* handler);
+
+ void registerOutgoingSession(const JID& initiator, JingleSessionImpl::ref);
+ protected:
+ void handleIncomingSession(const JID& initiator, const JID& recipient, JingleSessionImpl::ref, const std::vector<JingleContentPayload::ref>& contents);
+
+ private:
+ IQRouter* router;
+ JingleResponder* responder;
+ std::vector<IncomingJingleSessionHandler*> incomingSessionHandlers;
+ struct JIDSession {
+ JIDSession(const JID& initiator, const std::string& session) : initiator(initiator), session(session) {}
+ bool operator<(const JIDSession& o) const {
+ return initiator == o.initiator ? session < o.session : initiator < o.initiator;
+ }
+ JID initiator;
+ std::string session;
+ };
+ typedef std::map<JIDSession, JingleSessionImpl::ref> SessionMap;
+ SessionMap sessions;
+ };
}
diff --git a/Swiften/Jingle/SConscript b/Swiften/Jingle/SConscript
index 546c1b2..4d25a78 100644
--- a/Swiften/Jingle/SConscript
+++ b/Swiften/Jingle/SConscript
@@ -1,14 +1,14 @@
Import("swiften_env")
sources = [
- "JingleSession.cpp",
- "JingleSessionListener.cpp",
- "AbstractJingleSessionListener.cpp",
- "JingleSessionImpl.cpp",
- "IncomingJingleSessionHandler.cpp",
- "JingleSessionManager.cpp",
- "JingleResponder.cpp",
- "FakeJingleSession.cpp",
- ]
+ "JingleSession.cpp",
+ "JingleSessionListener.cpp",
+ "AbstractJingleSessionListener.cpp",
+ "JingleSessionImpl.cpp",
+ "IncomingJingleSessionHandler.cpp",
+ "JingleSessionManager.cpp",
+ "JingleResponder.cpp",
+ "FakeJingleSession.cpp",
+ ]
swiften_env.Append(SWIFTEN_OBJECTS = swiften_env.SwiftenObject(sources))