summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Session')
-rw-r--r--Swiften/Session/BasicSessionStream.cpp37
-rw-r--r--Swiften/Session/BasicSessionStream.h10
-rw-r--r--Swiften/Session/Session.cpp9
-rw-r--r--Swiften/Session/Session.h6
4 files changed, 43 insertions, 19 deletions
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index 45489cf..c4d1b6d 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -19,12 +19,29 @@
namespace Swift {
-BasicSessionStream::BasicSessionStream(StreamType streamType, boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers, TLSContextFactory* tlsContextFactory, TimerFactory* timerFactory) : available(false), connection(connection), payloadParserFactories(payloadParserFactories), payloadSerializers(payloadSerializers), tlsContextFactory(tlsContextFactory), timerFactory(timerFactory), streamType(streamType) {
+BasicSessionStream::BasicSessionStream(
+ StreamType streamType,
+ boost::shared_ptr<Connection> connection,
+ PayloadParserFactoryCollection* payloadParserFactories,
+ PayloadSerializerCollection* payloadSerializers,
+ TLSContextFactory* tlsContextFactory,
+ TimerFactory* timerFactory) :
+ available(false),
+ connection(connection),
+ payloadParserFactories(payloadParserFactories),
+ payloadSerializers(payloadSerializers),
+ tlsContextFactory(tlsContextFactory),
+ timerFactory(timerFactory),
+ streamType(streamType),
+ xmppLayer(NULL),
+ connectionLayer(NULL),
+ compressionLayer(NULL),
+ tlsLayer(NULL),
+ whitespacePingLayer(NULL) {
}
void BasicSessionStream::initialize() {
- xmppLayer = boost::shared_ptr<XMPPLayer>(
- new XMPPLayer(payloadParserFactories, payloadSerializers, streamType));
+ xmppLayer = new XMPPLayer(payloadParserFactories, payloadSerializers, streamType);
xmppLayer->onStreamStart.connect(boost::bind(&BasicSessionStream::handleStreamStartReceived, shared_from_this(), _1));
xmppLayer->onElement.connect(boost::bind(&BasicSessionStream::handleElementReceived, shared_from_this(), _1));
xmppLayer->onError.connect(boost::bind(
@@ -33,8 +50,7 @@ void BasicSessionStream::initialize() {
xmppLayer->onWriteData.connect(boost::bind(&BasicSessionStream::handleDataWritten, shared_from_this(), _1));
connection->onDisconnected.connect(boost::bind(&BasicSessionStream::handleConnectionError, shared_from_this(), _1));
- connectionLayer = boost::shared_ptr<ConnectionLayer>(
- new ConnectionLayer(connection));
+ connectionLayer = new ConnectionLayer(connection);
streamStack = new StreamStack(xmppLayer, connectionLayer);
@@ -42,7 +58,12 @@ void BasicSessionStream::initialize() {
}
BasicSessionStream::~BasicSessionStream() {
+ delete compressionLayer;
+ delete tlsLayer;
+ delete whitespacePingLayer;
delete streamStack;
+ delete connectionLayer;
+ delete xmppLayer;
}
void BasicSessionStream::writeHeader(const ProtocolHeader& header) {
@@ -70,7 +91,7 @@ bool BasicSessionStream::supportsTLSEncryption() {
void BasicSessionStream::addTLSEncryption() {
assert(available);
- tlsLayer = boost::shared_ptr<TLSLayer>(new TLSLayer(tlsContextFactory));
+ tlsLayer = new TLSLayer(tlsContextFactory);
if (hasTLSCertificate() && !tlsLayer->setClientCertificate(getTLSCertificate())) {
onError(boost::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
}
@@ -99,14 +120,14 @@ ByteArray BasicSessionStream::getTLSFinishMessage() const {
}
void BasicSessionStream::addZLibCompression() {
- boost::shared_ptr<CompressionLayer> compressionLayer(new CompressionLayer());
+ compressionLayer = new CompressionLayer();
streamStack->addLayer(compressionLayer);
}
void BasicSessionStream::setWhitespacePingEnabled(bool enabled) {
if (enabled) {
if (!whitespacePingLayer) {
- whitespacePingLayer = boost::shared_ptr<WhitespacePingLayer>(new WhitespacePingLayer(timerFactory));
+ whitespacePingLayer = new WhitespacePingLayer(timerFactory);
streamStack->addLayer(whitespacePingLayer);
}
whitespacePingLayer->setActive();
diff --git a/Swiften/Session/BasicSessionStream.h b/Swiften/Session/BasicSessionStream.h
index 6927800..c601792 100644
--- a/Swiften/Session/BasicSessionStream.h
+++ b/Swiften/Session/BasicSessionStream.h
@@ -78,12 +78,12 @@ namespace Swift {
TLSContextFactory* tlsContextFactory;
TimerFactory* timerFactory;
StreamType streamType;
- boost::shared_ptr<XMPPLayer> xmppLayer;
- boost::shared_ptr<ConnectionLayer> connectionLayer;
+ XMPPLayer* xmppLayer;
+ ConnectionLayer* connectionLayer;
+ CompressionLayer* compressionLayer;
+ TLSLayer* tlsLayer;
+ WhitespacePingLayer* whitespacePingLayer;
StreamStack* streamStack;
- boost::shared_ptr<CompressionLayer> compressionLayer;
- boost::shared_ptr<TLSLayer> tlsLayer;
- boost::shared_ptr<WhitespacePingLayer> whitespacePingLayer;
};
}
diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp
index 747d1d9..39fab14 100644
--- a/Swiften/Session/Session.cpp
+++ b/Swiften/Session/Session.cpp
@@ -20,12 +20,16 @@ Session::Session(
connection(connection),
payloadParserFactories(payloadParserFactories),
payloadSerializers(payloadSerializers),
+ xmppLayer(NULL),
+ connectionLayer(NULL),
streamStack(0),
finishing(false) {
}
Session::~Session() {
delete streamStack;
+ delete connectionLayer;
+ delete xmppLayer;
}
void Session::startSession() {
@@ -50,8 +54,7 @@ void Session::finishSession(const SessionError& error) {
}
void Session::initializeStreamStack() {
- xmppLayer = boost::shared_ptr<XMPPLayer>(
- new XMPPLayer(payloadParserFactories, payloadSerializers, ClientStreamType));
+ xmppLayer = new XMPPLayer(payloadParserFactories, payloadSerializers, ClientStreamType);
xmppLayer->onStreamStart.connect(
boost::bind(&Session::handleStreamStart, shared_from_this(), _1));
xmppLayer->onElement.connect(boost::bind(&Session::handleElement, shared_from_this(), _1));
@@ -61,7 +64,7 @@ void Session::initializeStreamStack() {
xmppLayer->onWriteData.connect(boost::bind(boost::ref(onDataWritten), _1));
connection->onDisconnected.connect(
boost::bind(&Session::handleDisconnected, shared_from_this(), _1));
- connectionLayer = boost::shared_ptr<ConnectionLayer>(new ConnectionLayer(connection));
+ connectionLayer = new ConnectionLayer(connection);
streamStack = new StreamStack(xmppLayer, connectionLayer);
}
diff --git a/Swiften/Session/Session.h b/Swiften/Session/Session.h
index d0ebabb..f8c8f0a 100644
--- a/Swiften/Session/Session.h
+++ b/Swiften/Session/Session.h
@@ -84,7 +84,7 @@ namespace Swift {
void initializeStreamStack();
- boost::shared_ptr<XMPPLayer> getXMPPLayer() const {
+ XMPPLayer* getXMPPLayer() const {
return xmppLayer;
}
@@ -103,8 +103,8 @@ namespace Swift {
boost::shared_ptr<Connection> connection;
PayloadParserFactoryCollection* payloadParserFactories;
PayloadSerializerCollection* payloadSerializers;
- boost::shared_ptr<XMPPLayer> xmppLayer;
- boost::shared_ptr<ConnectionLayer> connectionLayer;
+ XMPPLayer* xmppLayer;
+ ConnectionLayer* connectionLayer;
StreamStack* streamStack;
bool finishing;
};