summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/CoreClient.cpp8
-rw-r--r--Swiften/Client/CoreClient.h7
2 files changed, 9 insertions, 6 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index fa9dca0..9511dfb 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -73,9 +73,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio
connector_->onConnectFinished.disconnect(boost::bind(&CoreClient::handleConnectorFinished, this, _1));
connector_.reset();
if (!connection) {
- if (!disconnectRequested_) {
- onError(ClientError::ConnectionError);
- }
+ onDisconnected(disconnectRequested_ ? boost::optional<ClientError>() : boost::optional<ClientError>(ClientError::ConnectionError));
}
else {
assert(!connection_);
@@ -131,6 +129,7 @@ void CoreClient::handleSessionFinished(boost::shared_ptr<Error> error) {
connection_->disconnect();
connection_.reset();
+ boost::optional<ClientError> actualError;
if (error) {
ClientError clientError;
if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) {
@@ -183,8 +182,9 @@ void CoreClient::handleSessionFinished(boost::shared_ptr<Error> error) {
break;
}
}
- onError(clientError);
+ actualError = boost::optional<ClientError>(clientError);
}
+ onDisconnected(actualError);
}
void CoreClient::handleNeedCredentials() {
diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h
index f6e0b6d..e9e81ec 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -126,9 +126,12 @@ namespace Swift {
public:
/**
- * Emitted when a non-recoverable error occurs.
+ * Emitted when the client was disconnected from the network.
+ *
+ * If the connection was due to a non-recoverable error, the type
+ * of error will be passed as a parameter.
*/
- boost::signal<void (const ClientError&)> onError;
+ boost::signal<void (const boost::optional<ClientError>&)> onDisconnected;
/**
* Emitted when the client is connected and authenticated,