diff options
Diffstat (limited to 'Swiften/Jingle')
-rw-r--r-- | Swiften/Jingle/AbstractJingleSessionListener.cpp | 14 | ||||
-rw-r--r-- | Swiften/Jingle/AbstractJingleSessionListener.h | 22 | ||||
-rw-r--r-- | Swiften/Jingle/FakeJingleSession.cpp | 28 | ||||
-rw-r--r-- | Swiften/Jingle/FakeJingleSession.h | 166 | ||||
-rw-r--r-- | Swiften/Jingle/IncomingJingleSessionHandler.h | 10 | ||||
-rw-r--r-- | Swiften/Jingle/Jingle.h | 22 | ||||
-rw-r--r-- | Swiften/Jingle/JingleContentID.h | 32 | ||||
-rw-r--r-- | Swiften/Jingle/JingleResponder.cpp | 70 | ||||
-rw-r--r-- | Swiften/Jingle/JingleResponder.h | 24 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSession.cpp | 6 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSession.h | 64 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSessionImpl.cpp | 262 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSessionImpl.h | 68 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSessionListener.h | 48 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSessionManager.cpp | 34 | ||||
-rw-r--r-- | Swiften/Jingle/JingleSessionManager.h | 68 |
16 files changed, 469 insertions, 469 deletions
diff --git a/Swiften/Jingle/AbstractJingleSessionListener.cpp b/Swiften/Jingle/AbstractJingleSessionListener.cpp index c533f12..791dcb3 100644 --- a/Swiften/Jingle/AbstractJingleSessionListener.cpp +++ b/Swiften/Jingle/AbstractJingleSessionListener.cpp @@ -11,31 +11,31 @@ using namespace Swift; void AbstractJingleSessionListener::handleSessionAcceptReceived(const JingleContentID&, boost::shared_ptr<JingleDescription>, boost::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented" << std::endl; } void AbstractJingleSessionListener::handleSessionInfoReceived(boost::shared_ptr<JinglePayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + 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; + SWIFT_LOG(warning) << "Unimplemented" << std::endl; } void AbstractJingleSessionListener::handleTransportInfoReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented" << std::endl; } void AbstractJingleSessionListener::handleTransportRejectReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + SWIFT_LOG(warning) << "Unimplemented" << std::endl; } void AbstractJingleSessionListener::handleTransportReplaceReceived(const JingleContentID&, boost::shared_ptr<JingleTransportPayload>) { - SWIFT_LOG(warning) << "Unimplemented" << std::endl; + 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..678f173 100644 --- a/Swiften/Jingle/AbstractJingleSessionListener.h +++ b/Swiften/Jingle/AbstractJingleSessionListener.h @@ -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&, 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; + }; } diff --git a/Swiften/Jingle/FakeJingleSession.cpp b/Swiften/Jingle/FakeJingleSession.cpp index fae3425..ec792ab 100644 --- a/Swiften/Jingle/FakeJingleSession.cpp +++ b/Swiften/Jingle/FakeJingleSession.cpp @@ -26,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)); + 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); + notifyListeners(&JingleSessionListener::handleSessionAcceptReceived, contentID, desc, payload); } } diff --git a/Swiften/Jingle/FakeJingleSession.h b/Swiften/Jingle/FakeJingleSession.h index dc7e56a..0107384 100644 --- a/Swiften/Jingle/FakeJingleSession.h +++ b/Swiften/Jingle/FakeJingleSession.h @@ -28,87 +28,87 @@ #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(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; + }; } 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..13c235b 100644 --- a/Swiften/Jingle/Jingle.h +++ b/Swiften/Jingle/Jingle.h @@ -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 (size_t i = 0; i < contents.size(); ++i) { + if (contents[i]->getDescription<T>()) { + return contents[i]; + } + } + 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 16ed1da..d0c2edd 100644 --- a/Swiften/Jingle/JingleResponder.cpp +++ b/Swiften/Jingle/JingleResponder.cpp @@ -21,41 +21,41 @@ 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; + 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; } } diff --git a/Swiften/Jingle/JingleResponder.h b/Swiften/Jingle/JingleResponder.h index 1468a54..1340835 100644 --- a/Swiften/Jingle/JingleResponder.h +++ b/Swiften/Jingle/JingleResponder.h @@ -11,18 +11,18 @@ #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, boost::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 65a68f9..8abbd56 100644 --- a/Swiften/Jingle/JingleSession.cpp +++ b/Swiften/Jingle/JingleSession.cpp @@ -16,9 +16,9 @@ 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 6c76f3c..7a64c47 100644 --- a/Swiften/Jingle/JingleSession.h +++ b/Swiften/Jingle/JingleSession.h @@ -19,36 +19,36 @@ #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 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; + }; } diff --git a/Swiften/Jingle/JingleSessionImpl.cpp b/Swiften/Jingle/JingleSessionImpl.cpp index a19947a..3063242 100644 --- a/Swiften/Jingle/JingleSessionImpl.cpp +++ b/Swiften/Jingle/JingleSessionImpl.cpp @@ -23,185 +23,185 @@ 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 = 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); } 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 = boost::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); + JinglePayload::ref payload = boost::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 = 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); } 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 = boost::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 = boost::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 = boost::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 = boost::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(); + 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(); } JinglePayload::ref JingleSessionImpl::createPayload() const { - JinglePayload::ref payload = boost::make_shared<JinglePayload>(); - payload->setSessionID(getID()); - payload->setInitiator(getInitiator()); - return payload; + JinglePayload::ref payload = boost::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 4d21cd3..eec2370 100644 --- a/Swiften/Jingle/JingleSessionImpl.h +++ b/Swiften/Jingle/JingleSessionImpl.h @@ -14,38 +14,38 @@ #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 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; + }; } diff --git a/Swiften/Jingle/JingleSessionListener.h b/Swiften/Jingle/JingleSessionListener.h index dabeb05..54101b6 100644 --- a/Swiften/Jingle/JingleSessionListener.h +++ b/Swiften/Jingle/JingleSessionListener.h @@ -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&, + 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 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 81014e7..ca6cebb 100644 --- a/Swiften/Jingle/JingleSessionManager.cpp +++ b/Swiften/Jingle/JingleSessionManager.cpp @@ -15,41 +15,41 @@ 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)); + foreach (IncomingJingleSessionHandler* 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 fbfdb50..fea6c73 100644 --- a/Swiften/Jingle/JingleSessionManager.h +++ b/Swiften/Jingle/JingleSessionManager.h @@ -15,38 +15,38 @@ #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; + }; } |