summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/Session.cpp14
-rw-r--r--Swiften/Client/Session.h8
-rw-r--r--Swiften/Client/UnitTest/SessionTest.cpp10
3 files changed, 12 insertions, 20 deletions
diff --git a/Swiften/Client/Session.cpp b/Swiften/Client/Session.cpp
index 087880f..dbeddb7 100644
--- a/Swiften/Client/Session.cpp
+++ b/Swiften/Client/Session.cpp
@@ -31,20 +31,12 @@ Session::Session(const JID& jid, ConnectionFactory* connectionFactory, TLSLayerF
payloadSerializers_(payloadSerializers),
state_(Initial),
error_(NoError),
- xmppLayer_(0),
- tlsLayer_(0),
- connectionLayer_(0),
- whitespacePingLayer_(0),
streamStack_(0),
needSessionStart_(false) {
}
Session::~Session() {
delete streamStack_;
- delete whitespacePingLayer_;
- delete connectionLayer_;
- delete tlsLayer_;
- delete xmppLayer_;
}
void Session::start() {
@@ -73,13 +65,13 @@ void Session::sendStreamHeader() {
}
void Session::initializeStreamStack() {
- xmppLayer_ = new XMPPLayer(payloadParserFactories_, payloadSerializers_);
+ xmppLayer_ = boost::shared_ptr<XMPPLayer>(new XMPPLayer(payloadParserFactories_, payloadSerializers_));
xmppLayer_->onStreamStart.connect(boost::bind(&Session::handleStreamStart, this));
xmppLayer_->onElement.connect(boost::bind(&Session::handleElement, this, _1));
xmppLayer_->onError.connect(boost::bind(&Session::setError, this, XMLError));
xmppLayer_->onDataRead.connect(boost::bind(boost::ref(onDataRead), _1));
xmppLayer_->onWriteData.connect(boost::bind(boost::ref(onDataWritten), _1));
- connectionLayer_ = new ConnectionLayer(connection_);
+ connectionLayer_ = boost::shared_ptr<ConnectionLayer>(new ConnectionLayer(connection_));
streamStack_ = new StreamStack(xmppLayer_, connectionLayer_);
}
@@ -144,7 +136,7 @@ void Session::handleElement(boost::shared_ptr<Element> element) {
// Start the session
// Add a whitespace ping layer
- whitespacePingLayer_ = new WhitespacePingLayer();
+ whitespacePingLayer_ = boost::shared_ptr<WhitespacePingLayer>(new WhitespacePingLayer());
streamStack_->addLayer(whitespacePingLayer_);
if (streamFeatures->hasSession()) {
diff --git a/Swiften/Client/Session.h b/Swiften/Client/Session.h
index 72b57bd..1b4d1fe 100644
--- a/Swiften/Client/Session.h
+++ b/Swiften/Client/Session.h
@@ -113,10 +113,10 @@ namespace Swift {
State state_;
SessionError error_;
boost::shared_ptr<Connection> connection_;
- XMPPLayer* xmppLayer_;
- TLSLayer* tlsLayer_;
- ConnectionLayer* connectionLayer_;
- WhitespacePingLayer* whitespacePingLayer_;
+ boost::shared_ptr<XMPPLayer> xmppLayer_;
+ boost::shared_ptr<TLSLayer> tlsLayer_;
+ boost::shared_ptr<ConnectionLayer> connectionLayer_;
+ boost::shared_ptr<WhitespacePingLayer> whitespacePingLayer_;
StreamStack* streamStack_;
bool needSessionStart_;
PKCS12Certificate certificate_;
diff --git a/Swiften/Client/UnitTest/SessionTest.cpp b/Swiften/Client/UnitTest/SessionTest.cpp
index f7f1db0..5d43736 100644
--- a/Swiften/Client/UnitTest/SessionTest.cpp
+++ b/Swiften/Client/UnitTest/SessionTest.cpp
@@ -718,23 +718,23 @@ class SessionTest : public CppUnit::TestFixture {
MockTLSLayerFactory() : haveTLS_(true) {}
void setTLSSupported(bool b) { haveTLS_ = b; }
virtual bool canCreate() const { return haveTLS_; }
- virtual TLSLayer* createTLSLayer() {
+ virtual boost::shared_ptr<TLSLayer> createTLSLayer() {
assert(haveTLS_);
- MockTLSLayer* result = new MockTLSLayer();
+ boost::shared_ptr<MockTLSLayer> result(new MockTLSLayer());
layers_.push_back(result);
return result;
}
- std::vector<MockTLSLayer*> layers_;
+ std::vector< boost::shared_ptr<MockTLSLayer> > layers_;
bool haveTLS_;
};
struct MockSession : public Session {
MockSession(const JID& jid, ConnectionFactory* connectionFactory, TLSLayerFactory* tlsLayerFactory, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers) : Session(jid, connectionFactory, tlsLayerFactory, payloadParserFactories, payloadSerializers) {}
- MockTLSLayer* getTLSLayer() const {
+ boost::shared_ptr<MockTLSLayer> getTLSLayer() const {
return getStreamStack()->getLayer<MockTLSLayer>();
}
- WhitespacePingLayer* getWhitespacePingLayer() const {
+ boost::shared_ptr<WhitespacePingLayer> getWhitespacePingLayer() const {
return getStreamStack()->getLayer<WhitespacePingLayer>();
}
};