summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/Client/ClientSession.cpp6
-rw-r--r--Swiften/Client/ClientSession.h2
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp4
-rw-r--r--Swiften/Component/ComponentSession.cpp4
-rw-r--r--Swiften/Component/UnitTest/ComponentSessionTest.cpp2
-rw-r--r--Swiften/Session/BasicSessionStream.cpp19
-rw-r--r--Swiften/Session/BasicSessionStream.h2
-rw-r--r--Swiften/Session/SessionStream.h2
8 files changed, 22 insertions, 19 deletions
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<Swift::Error> error) {
+void ClientSession::handleStreamFinished(boost::shared_ptr<Swift::Error> error) {
finishSession(error);
}
@@ -393,7 +393,7 @@ void ClientSession::finishSession(boost::shared_ptr<Swift::Error> 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<Element>);
void handleStreamStart(const ProtocolHeader&);
- void handleStreamError(boost::shared_ptr<Swift::Error>);
+ void handleStreamFinished(boost::shared_ptr<Swift::Error>);
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<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::ConnectionReadError)));
+ onClosed(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::ConnectionReadError)));
}
void breakTLS() {
- onError(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::TLSError)));
+ onClosed(boost::shared_ptr<SessionStream::Error>(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<Swift::Error> 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<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::ConnectionReadError)));
+ onClosed(boost::shared_ptr<SessionStream::Error>(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<Error>(new Error(Error::InvalidTLSCertificateError)));
+ onClosed(boost::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
}
else {
streamStack->addLayer(tlsLayer);
@@ -158,7 +158,7 @@ void BasicSessionStream::handleElementReceived(boost::shared_ptr<Element> elemen
void BasicSessionStream::handleXMPPError() {
available = false;
- onError(boost::shared_ptr<Error>(new Error(Error::ParseError)));
+ onClosed(boost::shared_ptr<Error>(new Error(Error::ParseError)));
}
void BasicSessionStream::handleTLSConnected() {
@@ -167,16 +167,19 @@ void BasicSessionStream::handleTLSConnected() {
void BasicSessionStream::handleTLSError() {
available = false;
- onError(boost::shared_ptr<Error>(new Error(Error::TLSError)));
+ onClosed(boost::shared_ptr<Error>(new Error(Error::TLSError)));
}
-void BasicSessionStream::handleConnectionError(const boost::optional<Connection::Error>& error) {
+void BasicSessionStream::handleConnectionFinished(const boost::optional<Connection::Error>& error) {
available = false;
if (error == Connection::ReadError) {
- onError(boost::shared_ptr<Error>(new Error(Error::ConnectionReadError)));
+ onClosed(boost::shared_ptr<Error>(new Error(Error::ConnectionReadError)));
+ }
+ else if (error) {
+ onClosed(boost::shared_ptr<Error>(new Error(Error::ConnectionWriteError)));
}
else {
- onError(boost::shared_ptr<Error>(new Error(Error::ConnectionWriteError)));
+ onClosed(boost::shared_ptr<Error>());
}
}
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<Connection::Error>& error);
+ void handleConnectionFinished(const boost::optional<Connection::Error>& 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<void (const ProtocolHeader&)> onStreamStartReceived;
boost::signal<void (boost::shared_ptr<Element>)> onElementReceived;
- boost::signal<void (boost::shared_ptr<Error>)> onError;
+ boost::signal<void (boost::shared_ptr<Error>)> onClosed;
boost::signal<void ()> onTLSEncrypted;
boost::signal<void (const String&)> onDataRead;
boost::signal<void (const String&)> onDataWritten;