diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-11-10 22:06:59 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-11-10 22:06:59 (GMT) |
commit | f76e39f30966279a10a9ba97271cebdc3cba2c4d (patch) | |
tree | 486514e62ce717b607b9af8a13db3b0fceddf46c | |
parent | 80a67051508b7a2f59e0ded9d1dd4df490d44ec2 (diff) | |
download | swift-f76e39f30966279a10a9ba97271cebdc3cba2c4d.zip swift-f76e39f30966279a10a9ba97271cebdc3cba2c4d.tar.bz2 |
Fix error messages.
-rw-r--r-- | Swiften/Client/Client.cpp | 79 | ||||
-rw-r--r-- | Swiften/Client/ClientSession.cpp | 7 | ||||
-rw-r--r-- | Swiften/Client/ClientSession.h | 1 | ||||
-rw-r--r-- | Swiften/Session/BasicSessionStream.cpp | 9 | ||||
-rw-r--r-- | Swiften/Session/SessionStream.h | 3 |
5 files changed, 59 insertions, 40 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index 9e38626..1b662f5 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -126,43 +126,50 @@ void Client::setCertificate(const String& certificate) { void Client::handleSessionFinished(boost::shared_ptr<Error> error) { if (error) { ClientError clientError; - /* - switch (*error) { - case Session::ConnectionReadError: - clientError = ClientError(ClientError::ConnectionReadError); - break; - case Session::ConnectionWriteError: - clientError = ClientError(ClientError::ConnectionWriteError); - break; - case Session::XMLError: - clientError = ClientError(ClientError::XMLError); - break; - case Session::AuthenticationFailedError: - clientError = ClientError(ClientError::AuthenticationFailedError); - break; - case Session::NoSupportedAuthMechanismsError: - clientError = ClientError(ClientError::NoSupportedAuthMechanismsError); - break; - case Session::UnexpectedElementError: - clientError = ClientError(ClientError::UnexpectedElementError); - break; - case Session::ResourceBindError: - clientError = ClientError(ClientError::ResourceBindError); - break; - case Session::SessionStartError: - clientError = ClientError(ClientError::SessionStartError); - break; - case Session::TLSError: - clientError = ClientError(ClientError::TLSError); - break; - case Session::ClientCertificateLoadError: - clientError = ClientError(ClientError::ClientCertificateLoadError); - break; - case Session::ClientCertificateError: - clientError = ClientError(ClientError::ClientCertificateError); - break; + if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) { + switch(actualError->type) { + case ClientSession::Error::AuthenticationFailedError: + clientError = ClientError(ClientError::AuthenticationFailedError); + break; + case ClientSession::Error::NoSupportedAuthMechanismsError: + clientError = ClientError(ClientError::NoSupportedAuthMechanismsError); + break; + case ClientSession::Error::UnexpectedElementError: + clientError = ClientError(ClientError::UnexpectedElementError); + break; + case ClientSession::Error::ResourceBindError: + clientError = ClientError(ClientError::ResourceBindError); + break; + case ClientSession::Error::SessionStartError: + clientError = ClientError(ClientError::SessionStartError); + break; + case ClientSession::Error::TLSError: + clientError = ClientError(ClientError::TLSError); + break; + case ClientSession::Error::TLSClientCertificateError: + clientError = ClientError(ClientError::ClientCertificateError); + break; + } + } + else if (boost::shared_ptr<SessionStream::Error> actualError = boost::dynamic_pointer_cast<SessionStream::Error>(error)) { + switch(actualError->type) { + case SessionStream::Error::ParseError: + clientError = ClientError(ClientError::XMLError); + break; + case SessionStream::Error::TLSError: + clientError = ClientError(ClientError::TLSError); + break; + case SessionStream::Error::InvalidTLSCertificateError: + clientError = ClientError(ClientError::ClientCertificateLoadError); + break; + case SessionStream::Error::ConnectionReadError: + clientError = ClientError(ClientError::ConnectionReadError); + break; + case SessionStream::Error::ConnectionWriteError: + clientError = ClientError(ClientError::ConnectionWriteError); + break; + } } - */ onError(clientError); } } diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index a185ea0..f7fc073 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -67,9 +67,14 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) { stream->writeElement(boost::shared_ptr<StartTLSRequest>(new StartTLSRequest())); } else if (streamFeatures->hasAuthenticationMechanisms()) { - if (stream->hasTLSCertificate() && streamFeatures->hasAuthenticationMechanism("EXTERNAL")) { + if (stream->hasTLSCertificate()) { + if (streamFeatures->hasAuthenticationMechanism("EXTERNAL")) { state = Authenticating; stream->writeElement(boost::shared_ptr<Element>(new AuthRequest("EXTERNAL", ""))); + } + else { + finishSession(Error::TLSClientCertificateError); + } } else if (streamFeatures->hasAuthenticationMechanism("PLAIN")) { state = WaitingForCredentials; diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index e09861b..795a09e 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -36,6 +36,7 @@ namespace Swift { UnexpectedElementError, ResourceBindError, SessionStartError, + TLSClientCertificateError, TLSError, } type; Error(Type type) : type(type) {} diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp index 807470e..e0fbce7 100644 --- a/Swiften/Session/BasicSessionStream.cpp +++ b/Swiften/Session/BasicSessionStream.cpp @@ -113,9 +113,14 @@ void BasicSessionStream::handleTLSError() { onError(boost::shared_ptr<Error>(new Error(Error::TLSError))); } -void BasicSessionStream::handleConnectionError(const boost::optional<Connection::Error>&) { +void BasicSessionStream::handleConnectionError(const boost::optional<Connection::Error>& error) { available = false; - onError(boost::shared_ptr<Error>(new Error(Error::ConnectionError))); + if (error == Connection::ReadError) { + onError(boost::shared_ptr<Error>(new Error(Error::ConnectionReadError))); + } + else { + onError(boost::shared_ptr<Error>(new Error(Error::ConnectionWriteError))); + } } void BasicSessionStream::handleDataRead(const ByteArray& data) { diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h index 6bba237..1252c5a 100644 --- a/Swiften/Session/SessionStream.h +++ b/Swiften/Session/SessionStream.h @@ -17,7 +17,8 @@ namespace Swift { ParseError, TLSError, InvalidTLSCertificateError, - ConnectionError + ConnectionReadError, + ConnectionWriteError }; Error(Type type) : type(type) {} |