summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-03-23 11:54:03 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-23 11:54:03 (GMT)
commit846c4b9d2e7ec3214a3b13bdbbce77f70fede515 (patch)
tree579bf6be3e266c8e28a7469e7547ac88fa9af3fc /Swiften/Session
parent8ccdfd958ba1e7afbeb8c5893c12f09046cb8892 (diff)
downloadswift-contrib-846c4b9d2e7ec3214a3b13bdbbce77f70fede515.zip
swift-contrib-846c4b9d2e7ec3214a3b13bdbbce77f70fede515.tar.bz2
Allow TLS errors to bubble further up the stackks/tlserrors
Diffstat (limited to 'Swiften/Session')
-rw-r--r--Swiften/Session/BOSHSessionStream.cpp2
-rw-r--r--Swiften/Session/BasicSessionStream.cpp16
-rw-r--r--Swiften/Session/BasicSessionStream.h3
-rw-r--r--Swiften/Session/SessionStream.h4
4 files changed, 13 insertions, 12 deletions
diff --git a/Swiften/Session/BOSHSessionStream.cpp b/Swiften/Session/BOSHSessionStream.cpp
index ce5df35..237a394 100644
--- a/Swiften/Session/BOSHSessionStream.cpp
+++ b/Swiften/Session/BOSHSessionStream.cpp
@@ -157,19 +157,19 @@ void BOSHSessionStream::handleStreamStartReceived(const ProtocolHeader& header)
onStreamStartReceived(header);
}
void BOSHSessionStream::handleElementReceived(boost::shared_ptr<Element> element) {
onElementReceived(element);
}
void BOSHSessionStream::handleXMPPError() {
available = false;
- onClosed(boost::make_shared<Error>(Error::ParseError));
+ onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ParseError));
}
void BOSHSessionStream::handlePoolSessionStarted() {
fakeStreamHeaderReceipt();
}
void BOSHSessionStream::handlePoolSessionTerminated(BOSHError::ref error) {
eventLoop->postEvent(boost::bind(&BOSHSessionStream::fakeStreamFooterReceipt, this, error), shared_from_this());
}
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index f50c5d5..b49ffc9 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -105,23 +105,23 @@ bool BasicSessionStream::isOpen() {
bool BasicSessionStream::supportsTLSEncryption() {
return tlsContextFactory && tlsContextFactory->canCreate();
}
void BasicSessionStream::addTLSEncryption() {
assert(available);
tlsLayer = new TLSLayer(tlsContextFactory);
if (hasTLSCertificate() && !tlsLayer->setClientCertificate(getTLSCertificate())) {
- onClosed(boost::make_shared<Error>(Error::InvalidTLSCertificateError));
+ onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::InvalidTLSCertificateError));
}
else {
streamStack->addLayer(tlsLayer);
- tlsLayer->onError.connect(boost::bind(&BasicSessionStream::handleTLSError, this));
+ tlsLayer->onError.connect(boost::bind(&BasicSessionStream::handleTLSError, this, _1));
tlsLayer->onConnected.connect(boost::bind(&BasicSessionStream::handleTLSConnected, this));
tlsLayer->connect();
}
}
bool BasicSessionStream::isTLSEncrypted() {
return tlsLayer;
}
@@ -167,40 +167,40 @@ void BasicSessionStream::handleStreamStartReceived(const ProtocolHeader& header)
onStreamStartReceived(header);
}
void BasicSessionStream::handleElementReceived(boost::shared_ptr<Element> element) {
onElementReceived(element);
}
void BasicSessionStream::handleXMPPError() {
available = false;
- onClosed(boost::make_shared<Error>(Error::ParseError));
+ onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ParseError));
}
void BasicSessionStream::handleTLSConnected() {
onTLSEncrypted();
}
-void BasicSessionStream::handleTLSError() {
+void BasicSessionStream::handleTLSError(boost::shared_ptr<TLSError> error) {
available = false;
- onClosed(boost::make_shared<Error>(Error::TLSError));
+ onClosed(error);
}
void BasicSessionStream::handleConnectionFinished(const boost::optional<Connection::Error>& error) {
available = false;
if (error == Connection::ReadError) {
- onClosed(boost::make_shared<Error>(Error::ConnectionReadError));
+ onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ConnectionReadError));
}
else if (error) {
- onClosed(boost::make_shared<Error>(Error::ConnectionWriteError));
+ onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ConnectionWriteError));
}
else {
- onClosed(boost::shared_ptr<Error>());
+ onClosed(boost::shared_ptr<SessionStreamError>());
}
}
void BasicSessionStream::handleDataRead(const SafeByteArray& data) {
onDataRead(data);
}
void BasicSessionStream::handleDataWritten(const SafeByteArray& data) {
onDataWritten(data);
diff --git a/Swiften/Session/BasicSessionStream.h b/Swiften/Session/BasicSessionStream.h
index b0c4331..e1f32f4 100644
--- a/Swiften/Session/BasicSessionStream.h
+++ b/Swiften/Session/BasicSessionStream.h
@@ -6,18 +6,19 @@
#pragma once
#include <boost/shared_ptr.hpp>
#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/Network/Connection.h>
#include <Swiften/Session/SessionStream.h>
#include <Swiften/Elements/StreamType.h>
+#include <Swiften/TLS/TLSError.h>
namespace Swift {
class TLSContextFactory;
class TLSLayer;
class TimerFactory;
class WhitespacePingLayer;
class PayloadParserFactoryCollection;
class PayloadSerializerCollection;
class StreamStack;
@@ -59,19 +60,19 @@ namespace Swift {
virtual void setWhitespacePingEnabled(bool);
virtual void resetXMPPParser();
private:
void handleConnectionFinished(const boost::optional<Connection::Error>& error);
void handleXMPPError();
void handleTLSConnected();
- void handleTLSError();
+ void handleTLSError(boost::shared_ptr<TLSError>);
void handleStreamStartReceived(const ProtocolHeader&);
void handleElementReceived(boost::shared_ptr<Element>);
void handleDataRead(const SafeByteArray& data);
void handleDataWritten(const SafeByteArray& data);
private:
bool available;
boost::shared_ptr<Connection> connection;
PayloadParserFactoryCollection* payloadParserFactories;
diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h
index 2ff2a56..32cb6b6 100644
--- a/Swiften/Session/SessionStream.h
+++ b/Swiften/Session/SessionStream.h
@@ -15,29 +15,29 @@
#include <Swiften/Base/Error.h>
#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/TLS/CertificateWithKey.h>
#include <Swiften/TLS/Certificate.h>
#include <Swiften/TLS/CertificateVerificationError.h>
namespace Swift {
class SessionStream {
public:
- class Error : public Swift::Error {
+ class SessionStreamError : public Swift::Error {
public:
enum Type {
ParseError,
TLSError,
InvalidTLSCertificateError,
ConnectionReadError,
ConnectionWriteError
};
- Error(Type type) : type(type) {}
+ SessionStreamError(Type type) : type(type) {}
Type type;
};
SessionStream(): certificate() {}
virtual ~SessionStream();
virtual void close() = 0;