summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-01 17:23:49 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-04 08:28:23 (GMT)
commit741c45b74d5f634622eb5f757c49323274fb8937 (patch)
treeb9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swiften/Session
parenteddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff)
downloadswift-741c45b74d5f634622eb5f757c49323274fb8937.zip
swift-741c45b74d5f634622eb5f757c49323274fb8937.tar.bz2
Modernize code to use C++11 shared_ptr instead of Boost's
This change was done by applying the following 'gsed' replacement calls to all source files: 's/\#include <boost\/shared_ptr\.hpp>/\#include <memory>/g' 's/\#include <boost\/enable_shared_from_this\.hpp>/\#include <memory>/g' 's/\#include <boost\/smart_ptr\/make_shared\.hpp>/\#include <memory>/g' 's/\#include <boost\/make_shared\.hpp>/\#include <memory>/g' 's/\#include <boost\/weak_ptr\.hpp>/\#include <memory>/g' 's/boost::make_shared/std::make_shared/g' 's/boost::dynamic_pointer_cast/std::dynamic_pointer_cast/g' 's/boost::shared_ptr/std::shared_ptr/g' 's/boost::weak_ptr/std::weak_ptr/g' 's/boost::enable_shared_from_this/std::enable_shared_from_this/g' The remaining issues have been fixed manually. Test-Information: Code builds on OS X 10.11.4 and unit tests pass. Change-Id: Ia7ae34eab869fb9ad6387a1348426b71ae4acd5f
Diffstat (limited to 'Swiften/Session')
-rw-r--r--Swiften/Session/BOSHSessionStream.cpp10
-rw-r--r--Swiften/Session/BOSHSessionStream.h14
-rw-r--r--Swiften/Session/BasicSessionStream.cpp23
-rw-r--r--Swiften/Session/BasicSessionStream.h14
-rw-r--r--Swiften/Session/Session.cpp4
-rw-r--r--Swiften/Session/Session.h16
-rw-r--r--Swiften/Session/SessionStream.h11
-rw-r--r--Swiften/Session/SessionTracer.cpp2
-rw-r--r--Swiften/Session/SessionTracer.h4
9 files changed, 50 insertions, 48 deletions
diff --git a/Swiften/Session/BOSHSessionStream.cpp b/Swiften/Session/BOSHSessionStream.cpp
index dd6e83a..635fd69 100644
--- a/Swiften/Session/BOSHSessionStream.cpp
+++ b/Swiften/Session/BOSHSessionStream.cpp
@@ -40,7 +40,7 @@ BOSHSessionStream::BOSHSessionStream(const URL& boshURL,
const SafeString& boshHTTPConnectProxyAuthID,
const SafeString& boshHTTPConnectProxyAuthPassword,
const TLSOptions& tlsOptions,
- boost::shared_ptr<HTTPTrafficFilter> trafficFilter) :
+ std::shared_ptr<HTTPTrafficFilter> trafficFilter) :
available(false),
eventLoop(eventLoop),
firstHeader(true) {
@@ -92,7 +92,7 @@ void BOSHSessionStream::handlePoolXMPPDataRead(const SafeByteArray& data) {
xmppLayer->handleDataRead(data);
}
-void BOSHSessionStream::writeElement(boost::shared_ptr<ToplevelElement> element) {
+void BOSHSessionStream::writeElement(std::shared_ptr<ToplevelElement> element) {
assert(available);
xmppLayer->writeElement(element);
}
@@ -134,7 +134,7 @@ std::vector<Certificate::ref> BOSHSessionStream::getPeerCertificateChain() const
return connectionPool->getPeerCertificateChain();
}
-boost::shared_ptr<CertificateVerificationError> BOSHSessionStream::getPeerCertificateVerificationError() const {
+std::shared_ptr<CertificateVerificationError> BOSHSessionStream::getPeerCertificateVerificationError() const {
return connectionPool->getPeerCertificateVerificationError();
}
@@ -162,13 +162,13 @@ void BOSHSessionStream::handleStreamStartReceived(const ProtocolHeader& header)
onStreamStartReceived(header);
}
-void BOSHSessionStream::handleElementReceived(boost::shared_ptr<ToplevelElement> element) {
+void BOSHSessionStream::handleElementReceived(std::shared_ptr<ToplevelElement> element) {
onElementReceived(element);
}
void BOSHSessionStream::handleXMPPError() {
available = false;
- onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ParseError));
+ onClosed(std::make_shared<SessionStreamError>(SessionStreamError::ParseError));
}
void BOSHSessionStream::handlePoolSessionStarted() {
diff --git a/Swiften/Session/BOSHSessionStream.h b/Swiften/Session/BOSHSessionStream.h
index 17292f4..0c26848 100644
--- a/Swiften/Session/BOSHSessionStream.h
+++ b/Swiften/Session/BOSHSessionStream.h
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2011-2015 Isode Limited.
+ * Copyright (c) 2011-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include <Swiften/Base/API.h>
#include <Swiften/Base/SafeByteArray.h>
@@ -30,7 +30,7 @@ namespace Swift {
class XMLParserFactory;
class XMPPLayer;
- class SWIFTEN_API BOSHSessionStream : public SessionStream, public EventOwner, public boost::enable_shared_from_this<BOSHSessionStream> {
+ class SWIFTEN_API BOSHSessionStream : public SessionStream, public EventOwner, public std::enable_shared_from_this<BOSHSessionStream> {
public:
BOSHSessionStream(
const URL& boshURL,
@@ -47,7 +47,7 @@ namespace Swift {
const SafeString& boshHTTPConnectProxyAuthID,
const SafeString& boshHTTPConnectProxyAuthPassword,
const TLSOptions& tlsOptions,
- boost::shared_ptr<HTTPTrafficFilter> trafficFilter
+ std::shared_ptr<HTTPTrafficFilter> trafficFilter
);
virtual ~BOSHSessionStream();
@@ -56,7 +56,7 @@ namespace Swift {
virtual bool isOpen();
virtual void writeHeader(const ProtocolHeader& header);
- virtual void writeElement(boost::shared_ptr<ToplevelElement>);
+ virtual void writeElement(std::shared_ptr<ToplevelElement>);
virtual void writeFooter();
virtual void writeData(const std::string& data);
@@ -68,7 +68,7 @@ namespace Swift {
virtual bool isTLSEncrypted();
virtual Certificate::ref getPeerCertificate() const;
virtual std::vector<Certificate::ref> getPeerCertificateChain() const;
- virtual boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
+ virtual std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
virtual ByteArray getTLSFinishMessage() const;
virtual void setWhitespacePingEnabled(bool);
@@ -78,7 +78,7 @@ namespace Swift {
private:
void handleXMPPError();
void handleStreamStartReceived(const ProtocolHeader&);
- void handleElementReceived(boost::shared_ptr<ToplevelElement>);
+ void handleElementReceived(std::shared_ptr<ToplevelElement>);
void handlePoolXMPPDataRead(const SafeByteArray& data);
void handleXMPPLayerDataWritten(const SafeByteArray& data);
void handlePoolSessionStarted();
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index a6f1421..402f642 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -6,8 +6,9 @@
#include <Swiften/Session/BasicSessionStream.h>
+#include <memory>
+
#include <boost/bind.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/StreamStack/CompressionLayer.h>
#include <Swiften/StreamStack/ConnectionLayer.h>
@@ -22,7 +23,7 @@ namespace Swift {
BasicSessionStream::BasicSessionStream(
StreamType streamType,
- boost::shared_ptr<Connection> connection,
+ std::shared_ptr<Connection> connection,
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
TLSContextFactory* tlsContextFactory,
@@ -79,7 +80,7 @@ void BasicSessionStream::writeHeader(const ProtocolHeader& header) {
xmppLayer->writeHeader(header);
}
-void BasicSessionStream::writeElement(boost::shared_ptr<ToplevelElement> element) {
+void BasicSessionStream::writeElement(std::shared_ptr<ToplevelElement> element) {
assert(available);
xmppLayer->writeElement(element);
}
@@ -110,7 +111,7 @@ void BasicSessionStream::addTLSEncryption() {
assert(available);
tlsLayer = new TLSLayer(tlsContextFactory, tlsOptions_);
if (hasTLSCertificate() && !tlsLayer->setClientCertificate(getTLSCertificate())) {
- onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::InvalidTLSCertificateError));
+ onClosed(std::make_shared<SessionStreamError>(SessionStreamError::InvalidTLSCertificateError));
}
else {
streamStack->addLayer(tlsLayer);
@@ -132,7 +133,7 @@ std::vector<Certificate::ref> BasicSessionStream::getPeerCertificateChain() cons
return tlsLayer->getPeerCertificateChain();
}
-boost::shared_ptr<CertificateVerificationError> BasicSessionStream::getPeerCertificateVerificationError() const {
+std::shared_ptr<CertificateVerificationError> BasicSessionStream::getPeerCertificateVerificationError() const {
return tlsLayer->getPeerCertificateVerificationError();
}
@@ -170,20 +171,20 @@ void BasicSessionStream::handleStreamStartReceived(const ProtocolHeader& header)
onStreamStartReceived(header);
}
-void BasicSessionStream::handleElementReceived(boost::shared_ptr<ToplevelElement> element) {
+void BasicSessionStream::handleElementReceived(std::shared_ptr<ToplevelElement> element) {
onElementReceived(element);
}
void BasicSessionStream::handleXMPPError() {
available = false;
- onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ParseError));
+ onClosed(std::make_shared<SessionStreamError>(SessionStreamError::ParseError));
}
void BasicSessionStream::handleTLSConnected() {
onTLSEncrypted();
}
-void BasicSessionStream::handleTLSError(boost::shared_ptr<TLSError> error) {
+void BasicSessionStream::handleTLSError(std::shared_ptr<TLSError> error) {
available = false;
onClosed(error);
}
@@ -191,13 +192,13 @@ void BasicSessionStream::handleTLSError(boost::shared_ptr<TLSError> error) {
void BasicSessionStream::handleConnectionFinished(const boost::optional<Connection::Error>& error) {
available = false;
if (error == Connection::ReadError) {
- onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ConnectionReadError));
+ onClosed(std::make_shared<SessionStreamError>(SessionStreamError::ConnectionReadError));
}
else if (error) {
- onClosed(boost::make_shared<SessionStreamError>(SessionStreamError::ConnectionWriteError));
+ onClosed(std::make_shared<SessionStreamError>(SessionStreamError::ConnectionWriteError));
}
else {
- onClosed(boost::shared_ptr<SessionStreamError>());
+ onClosed(std::shared_ptr<SessionStreamError>());
}
}
diff --git a/Swiften/Session/BasicSessionStream.h b/Swiften/Session/BasicSessionStream.h
index db4a7e0..1806cef 100644
--- a/Swiften/Session/BasicSessionStream.h
+++ b/Swiften/Session/BasicSessionStream.h
@@ -6,7 +6,7 @@
#pragma once
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include <Swiften/Base/API.h>
#include <Swiften/Base/SafeByteArray.h>
@@ -33,7 +33,7 @@ namespace Swift {
public:
BasicSessionStream(
StreamType streamType,
- boost::shared_ptr<Connection> connection,
+ std::shared_ptr<Connection> connection,
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
TLSContextFactory* tlsContextFactory,
@@ -47,7 +47,7 @@ namespace Swift {
virtual bool isOpen();
virtual void writeHeader(const ProtocolHeader& header);
- virtual void writeElement(boost::shared_ptr<ToplevelElement>);
+ virtual void writeElement(std::shared_ptr<ToplevelElement>);
virtual void writeFooter();
virtual void writeData(const std::string& data);
@@ -60,7 +60,7 @@ namespace Swift {
virtual Certificate::ref getPeerCertificate() const;
virtual std::vector<Certificate::ref> getPeerCertificateChain() const;
- virtual boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
+ virtual std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
virtual ByteArray getTLSFinishMessage() const;
virtual void setWhitespacePingEnabled(bool);
@@ -71,15 +71,15 @@ namespace Swift {
void handleConnectionFinished(const boost::optional<Connection::Error>& error);
void handleXMPPError();
void handleTLSConnected();
- void handleTLSError(boost::shared_ptr<TLSError>);
+ void handleTLSError(std::shared_ptr<TLSError>);
void handleStreamStartReceived(const ProtocolHeader&);
- void handleElementReceived(boost::shared_ptr<ToplevelElement>);
+ void handleElementReceived(std::shared_ptr<ToplevelElement>);
void handleDataRead(const SafeByteArray& data);
void handleDataWritten(const SafeByteArray& data);
private:
bool available;
- boost::shared_ptr<Connection> connection;
+ std::shared_ptr<Connection> connection;
TLSContextFactory* tlsContextFactory;
TimerFactory* timerFactory;
XMPPLayer* xmppLayer;
diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp
index 82514c1..ebdb5d1 100644
--- a/Swiften/Session/Session.cpp
+++ b/Swiften/Session/Session.cpp
@@ -14,7 +14,7 @@
namespace Swift {
Session::Session(
- boost::shared_ptr<Connection> connection,
+ std::shared_ptr<Connection> connection,
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
XMLParserFactory* xmlParserFactory) :
@@ -76,7 +76,7 @@ void Session::initializeStreamStack() {
streamStack = new StreamStack(xmppLayer, connectionLayer);
}
-void Session::sendElement(boost::shared_ptr<ToplevelElement> stanza) {
+void Session::sendElement(std::shared_ptr<ToplevelElement> stanza) {
xmppLayer->writeElement(stanza);
}
diff --git a/Swiften/Session/Session.h b/Swiften/Session/Session.h
index d01833d..911bd34 100644
--- a/Swiften/Session/Session.h
+++ b/Swiften/Session/Session.h
@@ -6,9 +6,9 @@
#pragma once
-#include <boost/enable_shared_from_this.hpp>
+#include <memory>
+
#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Base/SafeByteArray.h>
@@ -28,7 +28,7 @@ namespace Swift {
class XMPPLayer;
class XMLParserFactory;
- class SWIFTEN_API Session : public boost::enable_shared_from_this<Session> {
+ class SWIFTEN_API Session : public std::enable_shared_from_this<Session> {
public:
enum SessionError {
ConnectionReadError,
@@ -45,7 +45,7 @@ namespace Swift {
};
Session(
- boost::shared_ptr<Connection> connection,
+ std::shared_ptr<Connection> connection,
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
XMLParserFactory* xmlParserFactory);
@@ -54,7 +54,7 @@ namespace Swift {
void startSession();
void finishSession();
- void sendElement(boost::shared_ptr<ToplevelElement>);
+ void sendElement(std::shared_ptr<ToplevelElement>);
const JID& getLocalJID() const {
return localJID;
@@ -64,7 +64,7 @@ namespace Swift {
return remoteJID;
}
- boost::signal<void (boost::shared_ptr<ToplevelElement>)> onElementReceived;
+ boost::signal<void (std::shared_ptr<ToplevelElement>)> onElementReceived;
boost::signal<void (const boost::optional<SessionError>&)> onSessionFinished;
boost::signal<void (const SafeByteArray&)> onDataWritten;
boost::signal<void (const SafeByteArray&)> onDataRead;
@@ -82,7 +82,7 @@ namespace Swift {
virtual void handleSessionStarted() {}
virtual void handleSessionFinished(const boost::optional<SessionError>&) {}
- virtual void handleElement(boost::shared_ptr<ToplevelElement>) = 0;
+ virtual void handleElement(std::shared_ptr<ToplevelElement>) = 0;
virtual void handleStreamStart(const ProtocolHeader&) = 0;
void initializeStreamStack();
@@ -103,7 +103,7 @@ namespace Swift {
private:
JID localJID;
JID remoteJID;
- boost::shared_ptr<Connection> connection;
+ std::shared_ptr<Connection> connection;
PayloadParserFactoryCollection* payloadParserFactories;
PayloadSerializerCollection* payloadSerializers;
XMLParserFactory* xmlParserFactory;
diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h
index 18404c6..4b86cee 100644
--- a/Swiften/Session/SessionStream.h
+++ b/Swiften/Session/SessionStream.h
@@ -6,8 +6,9 @@
#pragma once
+#include <memory>
+
#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Base/Error.h>
@@ -46,7 +47,7 @@ namespace Swift {
virtual void writeHeader(const ProtocolHeader& header) = 0;
virtual void writeFooter() = 0;
- virtual void writeElement(boost::shared_ptr<ToplevelElement>) = 0;
+ virtual void writeElement(std::shared_ptr<ToplevelElement>) = 0;
virtual void writeData(const std::string& data) = 0;
virtual bool supportsZLibCompression() = 0;
@@ -69,13 +70,13 @@ namespace Swift {
virtual Certificate::ref getPeerCertificate() const = 0;
virtual std::vector<Certificate::ref> getPeerCertificateChain() const = 0;
- virtual boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const = 0;
+ virtual std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const = 0;
virtual ByteArray getTLSFinishMessage() const = 0;
boost::signal<void (const ProtocolHeader&)> onStreamStartReceived;
- boost::signal<void (boost::shared_ptr<ToplevelElement>)> onElementReceived;
- boost::signal<void (boost::shared_ptr<Error>)> onClosed;
+ boost::signal<void (std::shared_ptr<ToplevelElement>)> onElementReceived;
+ boost::signal<void (std::shared_ptr<Error>)> onClosed;
boost::signal<void ()> onTLSEncrypted;
boost::signal<void (const SafeByteArray&)> onDataRead;
boost::signal<void (const SafeByteArray&)> onDataWritten;
diff --git a/Swiften/Session/SessionTracer.cpp b/Swiften/Session/SessionTracer.cpp
index aa44b9c..49b369d 100644
--- a/Swiften/Session/SessionTracer.cpp
+++ b/Swiften/Session/SessionTracer.cpp
@@ -12,7 +12,7 @@
namespace Swift {
-SessionTracer::SessionTracer(boost::shared_ptr<Session> session) : session(session) {
+SessionTracer::SessionTracer(std::shared_ptr<Session> session) : session(session) {
session->onDataRead.connect(boost::bind(&SessionTracer::printData, this, '<', _1));
session->onDataWritten.connect(boost::bind(&SessionTracer::printData, this, '>', _1));
}
diff --git a/Swiften/Session/SessionTracer.h b/Swiften/Session/SessionTracer.h
index 3993a87..8e73c16 100644
--- a/Swiften/Session/SessionTracer.h
+++ b/Swiften/Session/SessionTracer.h
@@ -15,11 +15,11 @@
namespace Swift {
class SWIFTEN_API SessionTracer {
public:
- SessionTracer(boost::shared_ptr<Session> session);
+ SessionTracer(std::shared_ptr<Session> session);
private:
void printData(char direction, const SafeByteArray& data);
- boost::shared_ptr<Session> session;
+ std::shared_ptr<Session> session;
};
}