diff options
| author | Mili Verma <mili.verma@isode.com> | 2015-06-23 13:27:08 (GMT) |
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2015-06-29 14:52:08 (GMT) |
| commit | ac45f360be049242a89ae80258e4ea8350f909ba (patch) | |
| tree | 3e3b5fb80edaaa867adfb7873550d934f0b60298 | |
| parent | ea41bd07a0e014c12cce144b421abac9f21d1269 (diff) | |
| download | swift-ac45f360be049242a89ae80258e4ea8350f909ba.zip swift-ac45f360be049242a89ae80258e4ea8350f909ba.tar.bz2 | |
Pass an optional error code
This patch creates and passes on an optional boost::system::error_code variable
which contains more error info which can be displayed in case of an error.
Test-information:
Tested using WIP code on Windows.
Change-Id: I285b8aec5e9c00d3a8e0d8cc0d5e7b4c5d94c099
| -rw-r--r-- | Swift/Controllers/MainController.cpp | 4 | ||||
| -rw-r--r-- | Swiften/Client/ClientError.h | 10 | ||||
| -rw-r--r-- | Swiften/Client/ClientSession.h | 3 | ||||
| -rw-r--r-- | Swiften/Client/CoreClient.cpp | 1 |
4 files changed, 16 insertions, 2 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index c6b6dfc..95094f2 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp | |||
| @@ -662,6 +662,10 @@ void MainController::handleDisconnected(const boost::optional<ClientError>& erro | |||
| 662 | } | 662 | } |
| 663 | } | 663 | } |
| 664 | 664 | ||
| 665 | if (!message.empty() && error->getErrorCode()) { | ||
| 666 | message = str(format(QT_TRANSLATE_NOOP("", "%1% (%2%)")) % message % error->getErrorCode()->message()); | ||
| 667 | } | ||
| 668 | |||
| 665 | if (forceReconnectAfterCertificateTrust && settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) { | 669 | if (forceReconnectAfterCertificateTrust && settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) { |
| 666 | forceReconnectAfterCertificateTrust = false; | 670 | forceReconnectAfterCertificateTrust = false; |
| 667 | forceSignout = true; | 671 | forceSignout = true; |
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h index 5277a0e..19de42b 100644 --- a/Swiften/Client/ClientError.h +++ b/Swiften/Client/ClientError.h | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #pragma once | 7 | #pragma once |
| 8 | 8 | ||
| 9 | #include <boost/shared_ptr.hpp> | ||
| 10 | #include <boost/system/system_error.hpp> | ||
| 11 | |||
| 9 | namespace Swift { | 12 | namespace Swift { |
| 10 | class ClientError { | 13 | class ClientError { |
| 11 | public: | 14 | public: |
| @@ -51,7 +54,12 @@ namespace Swift { | |||
| 51 | 54 | ||
| 52 | Type getType() const { return type_; } | 55 | Type getType() const { return type_; } |
| 53 | 56 | ||
| 57 | void setErrorCode(boost::shared_ptr<boost::system::error_code> errorCode) { errorCode_ = errorCode; } | ||
| 58 | |||
| 59 | boost::shared_ptr<boost::system::error_code> getErrorCode() const { return errorCode_; } | ||
| 60 | |||
| 54 | private: | 61 | private: |
| 55 | Type type_; | 62 | Type type_; |
| 63 | boost::shared_ptr<boost::system::error_code> errorCode_; | ||
| 56 | }; | 64 | }; |
| 57 | } | 65 | } |
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index 61de014..9bbc3f2 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2014 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -57,6 +57,7 @@ namespace Swift { | |||
| 57 | TLSError, | 57 | TLSError, |
| 58 | StreamError | 58 | StreamError |
| 59 | } type; | 59 | } type; |
| 60 | boost::shared_ptr<boost::system::error_code> errorCode; | ||
| 60 | Error(Type type) : type(type) {} | 61 | Error(Type type) : type(type) {} |
| 61 | }; | 62 | }; |
| 62 | 63 | ||
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index c91e5c5..baebd4a 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp | |||
| @@ -259,6 +259,7 @@ void CoreClient::handleSessionFinished(boost::shared_ptr<Error> error) { | |||
| 259 | clientError = ClientError(ClientError::StreamError); | 259 | clientError = ClientError(ClientError::StreamError); |
| 260 | break; | 260 | break; |
| 261 | } | 261 | } |
| 262 | clientError.setErrorCode(actualError->errorCode); | ||
| 262 | } | 263 | } |
| 263 | else if (boost::shared_ptr<TLSError> actualError = boost::dynamic_pointer_cast<TLSError>(error)) { | 264 | else if (boost::shared_ptr<TLSError> actualError = boost::dynamic_pointer_cast<TLSError>(error)) { |
| 264 | switch(actualError->getType()) { | 265 | switch(actualError->getType()) { |
Swift