diff options
Diffstat (limited to 'Swiften/Component/ComponentSession.cpp')
-rw-r--r-- | Swiften/Component/ComponentSession.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Swiften/Component/ComponentSession.cpp b/Swiften/Component/ComponentSession.cpp index 51d9d15..826451d 100644 --- a/Swiften/Component/ComponentSession.cpp +++ b/Swiften/Component/ComponentSession.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -11,4 +11,5 @@ #include <Swiften/Elements/ProtocolHeader.h> +#include <Swiften/Elements/StreamFeatures.h> #include <Swiften/Elements/ComponentHandshake.h> #include <Swiften/Session/SessionStream.h> @@ -17,5 +18,5 @@ namespace Swift { -ComponentSession::ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> stream) : jid(jid), secret(secret), stream(stream), state(Initial) { +ComponentSession::ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> stream, CryptoProvider* crypto) : jid(jid), secret(secret), stream(stream), crypto(crypto), state(Initial) { } @@ -46,8 +47,8 @@ void ComponentSession::handleStreamStart(const ProtocolHeader& header) { checkState(WaitingForStreamStart); state = Authenticating; - stream->writeElement(ComponentHandshake::ref(new ComponentHandshake(ComponentHandshakeGenerator::getHandshake(header.getID(), secret)))); + stream->writeElement(ComponentHandshake::ref(new ComponentHandshake(ComponentHandshakeGenerator::getHandshake(header.getID(), secret, crypto)))); } -void ComponentSession::handleElement(boost::shared_ptr<Element> element) { +void ComponentSession::handleElement(boost::shared_ptr<ToplevelElement> element) { if (boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element)) { if (getState() == Initialized) { @@ -67,7 +68,12 @@ void ComponentSession::handleElement(boost::shared_ptr<Element> element) { } else if (getState() == Authenticating) { + if (boost::dynamic_pointer_cast<StreamFeatures>(element)) { + // M-Link sends stream features, so swallow that. + } + else { // FIXME: We should actually check the element received finishSession(Error::AuthenticationFailedError); } + } else { finishSession(Error::UnexpectedElementError); |