From 940cb5e744564ec15b805a9e5388e1fa5c60d703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sat, 22 Jan 2011 14:31:54 +0100 Subject: Renaming SessionStream::onError to SessionStream::onClosed. diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index d4cf065..9400b56 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -62,7 +62,7 @@ ClientSession::~ClientSession() { void ClientSession::start() { stream->onStreamStartReceived.connect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1)); stream->onElementReceived.connect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1)); - stream->onError.connect(boost::bind(&ClientSession::handleStreamError, shared_from_this(), _1)); + stream->onClosed.connect(boost::bind(&ClientSession::handleStreamFinished, shared_from_this(), _1)); stream->onTLSEncrypted.connect(boost::bind(&ClientSession::handleTLSEncrypted, shared_from_this())); assert(state == Initial); @@ -367,7 +367,7 @@ void ClientSession::continueAfterTLSEncrypted() { sendStreamHeader(); } -void ClientSession::handleStreamError(boost::shared_ptr error) { +void ClientSession::handleStreamFinished(boost::shared_ptr error) { finishSession(error); } @@ -393,7 +393,7 @@ void ClientSession::finishSession(boost::shared_ptr error) { stream->setWhitespacePingEnabled(false); stream->onStreamStartReceived.disconnect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1)); stream->onElementReceived.disconnect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1)); - stream->onError.disconnect(boost::bind(&ClientSession::handleStreamError, shared_from_this(), _1)); + stream->onClosed.disconnect(boost::bind(&ClientSession::handleStreamFinished, shared_from_this(), _1)); stream->onTLSEncrypted.disconnect(boost::bind(&ClientSession::handleTLSEncrypted, shared_from_this())); if (stream->isAvailable()) { stream->writeFooter(); diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index b779735..f35c298 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -115,7 +115,7 @@ namespace Swift { void handleElement(boost::shared_ptr); void handleStreamStart(const ProtocolHeader&); - void handleStreamError(boost::shared_ptr); + void handleStreamFinished(boost::shared_ptr); void handleTLSEncrypted(); diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp index 358e308..2b0241a 100644 --- a/Swiften/Client/UnitTest/ClientSessionTest.cpp +++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp @@ -349,11 +349,11 @@ class ClientSessionTest : public CppUnit::TestFixture { } void breakConnection() { - onError(boost::shared_ptr(new SessionStream::Error(SessionStream::Error::ConnectionReadError))); + onClosed(boost::shared_ptr(new SessionStream::Error(SessionStream::Error::ConnectionReadError))); } void breakTLS() { - onError(boost::shared_ptr(new SessionStream::Error(SessionStream::Error::TLSError))); + onClosed(boost::shared_ptr(new SessionStream::Error(SessionStream::Error::TLSError))); } diff --git a/Swiften/Component/ComponentSession.cpp b/Swiften/Component/ComponentSession.cpp index d15d51c..967e68d 100644 --- a/Swiften/Component/ComponentSession.cpp +++ b/Swiften/Component/ComponentSession.cpp @@ -24,7 +24,7 @@ ComponentSession::~ComponentSession() { void ComponentSession::start() { stream->onStreamStartReceived.connect(boost::bind(&ComponentSession::handleStreamStart, shared_from_this(), _1)); stream->onElementReceived.connect(boost::bind(&ComponentSession::handleElement, shared_from_this(), _1)); - stream->onError.connect(boost::bind(&ComponentSession::handleStreamError, shared_from_this(), _1)); + stream->onClosed.connect(boost::bind(&ComponentSession::handleStreamError, shared_from_this(), _1)); assert(state == Initial); state = WaitingForStreamStart; @@ -98,7 +98,7 @@ void ComponentSession::finishSession(boost::shared_ptr error) { stream->setWhitespacePingEnabled(false); stream->onStreamStartReceived.disconnect(boost::bind(&ComponentSession::handleStreamStart, shared_from_this(), _1)); stream->onElementReceived.disconnect(boost::bind(&ComponentSession::handleElement, shared_from_this(), _1)); - stream->onError.disconnect(boost::bind(&ComponentSession::handleStreamError, shared_from_this(), _1)); + stream->onClosed.disconnect(boost::bind(&ComponentSession::handleStreamError, shared_from_this(), _1)); if (stream->isAvailable()) { stream->writeFooter(); } diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp index ac24778..3ad52f9 100644 --- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp +++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp @@ -148,7 +148,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { } void breakConnection() { - onError(boost::shared_ptr(new SessionStream::Error(SessionStream::Error::ConnectionReadError))); + onClosed(boost::shared_ptr(new SessionStream::Error(SessionStream::Error::ConnectionReadError))); } void sendStreamStart() { diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp index 3f06315..5377e6c 100644 --- a/Swiften/Session/BasicSessionStream.cpp +++ b/Swiften/Session/BasicSessionStream.cpp @@ -43,7 +43,7 @@ BasicSessionStream::BasicSessionStream( xmppLayer->onDataRead.connect(boost::bind(&BasicSessionStream::handleDataRead, this, _1)); xmppLayer->onWriteData.connect(boost::bind(&BasicSessionStream::handleDataWritten, this, _1)); - connection->onDisconnected.connect(boost::bind(&BasicSessionStream::handleConnectionError, this, _1)); + connection->onDisconnected.connect(boost::bind(&BasicSessionStream::handleConnectionFinished, this, _1)); connectionLayer = new ConnectionLayer(connection); streamStack = new StreamStack(xmppLayer, connectionLayer); @@ -62,7 +62,7 @@ BasicSessionStream::~BasicSessionStream() { delete whitespacePingLayer; delete streamStack; - connection->onDisconnected.disconnect(boost::bind(&BasicSessionStream::handleConnectionError, this, _1)); + connection->onDisconnected.disconnect(boost::bind(&BasicSessionStream::handleConnectionFinished, this, _1)); delete connectionLayer; xmppLayer->onStreamStart.disconnect(boost::bind(&BasicSessionStream::handleStreamStartReceived, this, _1)); @@ -100,7 +100,7 @@ void BasicSessionStream::addTLSEncryption() { assert(available); tlsLayer = new TLSLayer(tlsContextFactory); if (hasTLSCertificate() && !tlsLayer->setClientCertificate(getTLSCertificate())) { - onError(boost::shared_ptr(new Error(Error::InvalidTLSCertificateError))); + onClosed(boost::shared_ptr(new Error(Error::InvalidTLSCertificateError))); } else { streamStack->addLayer(tlsLayer); @@ -158,7 +158,7 @@ void BasicSessionStream::handleElementReceived(boost::shared_ptr elemen void BasicSessionStream::handleXMPPError() { available = false; - onError(boost::shared_ptr(new Error(Error::ParseError))); + onClosed(boost::shared_ptr(new Error(Error::ParseError))); } void BasicSessionStream::handleTLSConnected() { @@ -167,16 +167,19 @@ void BasicSessionStream::handleTLSConnected() { void BasicSessionStream::handleTLSError() { available = false; - onError(boost::shared_ptr(new Error(Error::TLSError))); + onClosed(boost::shared_ptr(new Error(Error::TLSError))); } -void BasicSessionStream::handleConnectionError(const boost::optional& error) { +void BasicSessionStream::handleConnectionFinished(const boost::optional& error) { available = false; if (error == Connection::ReadError) { - onError(boost::shared_ptr(new Error(Error::ConnectionReadError))); + onClosed(boost::shared_ptr(new Error(Error::ConnectionReadError))); + } + else if (error) { + onClosed(boost::shared_ptr(new Error(Error::ConnectionWriteError))); } else { - onError(boost::shared_ptr(new Error(Error::ConnectionWriteError))); + onClosed(boost::shared_ptr()); } } diff --git a/Swiften/Session/BasicSessionStream.h b/Swiften/Session/BasicSessionStream.h index 35b5481..330db9d 100644 --- a/Swiften/Session/BasicSessionStream.h +++ b/Swiften/Session/BasicSessionStream.h @@ -56,7 +56,7 @@ namespace Swift { virtual void resetXMPPParser(); private: - void handleConnectionError(const boost::optional& error); + void handleConnectionFinished(const boost::optional& error); void handleXMPPError(); void handleTLSConnected(); void handleTLSError(); diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h index d3d3ebb..55082f4 100644 --- a/Swiften/Session/SessionStream.h +++ b/Swiften/Session/SessionStream.h @@ -67,7 +67,7 @@ namespace Swift { boost::signal onStreamStartReceived; boost::signal)> onElementReceived; - boost::signal)> onError; + boost::signal)> onClosed; boost::signal onTLSEncrypted; boost::signal onDataRead; boost::signal onDataWritten; -- cgit v0.10.2-6-g49f6