summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-30 14:11:35 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-30 17:44:46 (GMT)
commit59be74ec6fc7bc495f2a261b8f274b8555aee306 (patch)
tree915be433534956f9316ba41220c064af77b9da90 /Swift/Controllers
parentc759220a7fcd824a7a842a468c660558fa1a1cf1 (diff)
downloadswift-contrib-59be74ec6fc7bc495f2a261b8f274b8555aee306.zip
swift-contrib-59be74ec6fc7bc495f2a261b8f274b8555aee306.tar.bz2
Changed CoreClient::onError to CoreClient::onDisconnected.
The error parameter is optional.
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp69
-rw-r--r--Swift/Controllers/MainController.h2
2 files changed, 36 insertions, 35 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index c9e6230..eb03e50 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -366,7 +366,7 @@ void MainController::performLoginFromCachedCredentials() {
client_ = new Swift::Client(eventLoop_, jid_, password_, storages_);
client_->onDataRead.connect(boost::bind(&XMLConsoleController::handleDataRead, xmlConsoleController_, _1));
client_->onDataWritten.connect(boost::bind(&XMLConsoleController::handleDataWritten, xmlConsoleController_, _1));
- client_->onError.connect(boost::bind(&MainController::handleError, this, _1));
+ client_->onDisconnected.connect(boost::bind(&MainController::handleDisconnected, this, _1));
client_->onConnected.connect(boost::bind(&MainController::handleConnected, this));
client_->setSoftwareVersion(CLIENT_NAME, buildVersion);
@@ -400,42 +400,43 @@ void MainController::performLoginFromCachedCredentials() {
}
}
-void MainController::handleError(const ClientError& error) {
- String message;
- switch(error.getType()) {
- case ClientError::UnknownError: message = "Unknown Error"; break;
- case ClientError::DomainNameResolveError: message = "Unable to find server"; break;
- case ClientError::ConnectionError: message = "Error connecting to server"; break;
- case ClientError::ConnectionReadError: message = "Error while receiving server data"; break;
- case ClientError::ConnectionWriteError: message = "Error while sending data to the server"; break;
- case ClientError::XMLError: message = "Error parsing server data"; break;
- case ClientError::AuthenticationFailedError: message = "Login/password invalid"; break;
- case ClientError::CompressionFailedError: message = "Error while compressing stream"; break;
- case ClientError::ServerVerificationFailedError: message = "Server verification failed"; break;
- case ClientError::NoSupportedAuthMechanismsError: message = "Authentication mechanisms not supported"; break;
- case ClientError::UnexpectedElementError: message = "Unexpected response"; break;
- case ClientError::ResourceBindError: message = "Error binding resource"; break;
- case ClientError::SessionStartError: message = "Error starting session"; break;
- case ClientError::TLSError: message = "Encryption error"; break;
- case ClientError::ClientCertificateLoadError: message = "Error loading certificate (Invalid password?)"; break;
- case ClientError::ClientCertificateError: message = "Certificate not authorized"; break;
- }
- if (!rosterController_) { //hasn't been logged in yet
- signOut();
- loginWindow_->setMessage(message);
- } else {
- logout();
- setReconnectTimer();
- if (lastDisconnectError_) {
- message = "Reconnect to " + jid_.getDomain() + " failed: " + message + ". Will retry in " + boost::lexical_cast<std::string>(timeBeforeNextReconnect_) + " seconds.";
- lastDisconnectError_->conclude();
+void MainController::handleDisconnected(const boost::optional<ClientError>& error) {
+ if (error) {
+ String message;
+ switch(error->getType()) {
+ case ClientError::UnknownError: message = "Unknown Error"; break;
+ case ClientError::DomainNameResolveError: message = "Unable to find server"; break;
+ case ClientError::ConnectionError: message = "Error connecting to server"; break;
+ case ClientError::ConnectionReadError: message = "Error while receiving server data"; break;
+ case ClientError::ConnectionWriteError: message = "Error while sending data to the server"; break;
+ case ClientError::XMLError: message = "Error parsing server data"; break;
+ case ClientError::AuthenticationFailedError: message = "Login/password invalid"; break;
+ case ClientError::CompressionFailedError: message = "Error while compressing stream"; break;
+ case ClientError::ServerVerificationFailedError: message = "Server verification failed"; break;
+ case ClientError::NoSupportedAuthMechanismsError: message = "Authentication mechanisms not supported"; break;
+ case ClientError::UnexpectedElementError: message = "Unexpected response"; break;
+ case ClientError::ResourceBindError: message = "Error binding resource"; break;
+ case ClientError::SessionStartError: message = "Error starting session"; break;
+ case ClientError::TLSError: message = "Encryption error"; break;
+ case ClientError::ClientCertificateLoadError: message = "Error loading certificate (Invalid password?)"; break;
+ case ClientError::ClientCertificateError: message = "Certificate not authorized"; break;
+ }
+ if (!rosterController_) { //hasn't been logged in yet
+ signOut();
+ loginWindow_->setMessage(message);
} else {
- message = "Disconnected from " + jid_.getDomain() + ": " + message;
+ logout();
+ setReconnectTimer();
+ if (lastDisconnectError_) {
+ message = "Reconnect to " + jid_.getDomain() + " failed: " + message + ". Will retry in " + boost::lexical_cast<std::string>(timeBeforeNextReconnect_) + " seconds.";
+ lastDisconnectError_->conclude();
+ } else {
+ message = "Disconnected from " + jid_.getDomain() + ": " + message;
+ }
+ lastDisconnectError_ = boost::shared_ptr<ErrorEvent>(new ErrorEvent(JID(jid_.getDomain()), message));
+ eventController_->handleIncomingEvent(lastDisconnectError_);
}
- lastDisconnectError_ = boost::shared_ptr<ErrorEvent>(new ErrorEvent(JID(jid_.getDomain()), message));
- eventController_->handleIncomingEvent(lastDisconnectError_);
}
-
}
void MainController::setReconnectTimer() {
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 709bacf..da65567 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -90,7 +90,7 @@ namespace Swift {
void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember, bool loginAutomatically);
void handleCancelLoginRequest();
void handleChangeStatusRequest(StatusShow::Type show, const String &statusText);
- void handleError(const ClientError& error);
+ void handleDisconnected(const boost::optional<ClientError>& error);
void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, const boost::optional<ErrorPayload>&);
void handleEventQueueLengthChange(int count);
void handleVCardReceived(const JID& j, VCard::ref vCard);