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 /Slimber
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 'Slimber')
-rw-r--r--Slimber/FileVCardCollection.cpp11
-rw-r--r--Slimber/FileVCardCollection.h7
-rw-r--r--Slimber/LinkLocalPresenceManager.cpp16
-rw-r--r--Slimber/LinkLocalPresenceManager.h13
-rw-r--r--Slimber/MainController.h5
-rw-r--r--Slimber/Server.cpp72
-rw-r--r--Slimber/Server.h42
-rw-r--r--Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp46
-rw-r--r--Slimber/VCardCollection.h8
9 files changed, 111 insertions, 109 deletions
diff --git a/Slimber/FileVCardCollection.cpp b/Slimber/FileVCardCollection.cpp
index af8d57d..ff2edc4 100644
--- a/Slimber/FileVCardCollection.cpp
+++ b/Slimber/FileVCardCollection.cpp
@@ -6,8 +6,9 @@
#include <Slimber/FileVCardCollection.h>
+#include <memory>
+
#include <boost/filesystem/fstream.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Elements/VCard.h>
@@ -20,7 +21,7 @@ namespace Swift {
FileVCardCollection::FileVCardCollection(boost::filesystem::path dir) : vcardsPath(dir) {
}
-boost::shared_ptr<VCard> FileVCardCollection::getOwnVCard() const {
+std::shared_ptr<VCard> FileVCardCollection::getOwnVCard() const {
if (boost::filesystem::exists(vcardsPath / std::string("vcard.xml"))) {
ByteArray data;
readByteArrayFromFile(data, boost::filesystem::path(vcardsPath / std::string("vcard.xml")).string());
@@ -28,14 +29,14 @@ boost::shared_ptr<VCard> FileVCardCollection::getOwnVCard() const {
VCardParser parser;
PayloadParserTester tester(&parser);
tester.parse(byteArrayToString(data));
- return boost::dynamic_pointer_cast<VCard>(parser.getPayload());
+ return std::dynamic_pointer_cast<VCard>(parser.getPayload());
}
else {
- return boost::make_shared<VCard>();
+ return std::make_shared<VCard>();
}
}
-void FileVCardCollection::setOwnVCard(boost::shared_ptr<VCard> v) {
+void FileVCardCollection::setOwnVCard(std::shared_ptr<VCard> v) {
boost::filesystem::ofstream file(vcardsPath / std::string("vcard.xml"));
file << VCardSerializer().serializePayload(v);
file.close();
diff --git a/Slimber/FileVCardCollection.h b/Slimber/FileVCardCollection.h
index c05c4f4..ff4a91b 100644
--- a/Slimber/FileVCardCollection.h
+++ b/Slimber/FileVCardCollection.h
@@ -6,8 +6,9 @@
#pragma once
+#include <memory>
+
#include <boost/filesystem.hpp>
-#include <boost/shared_ptr.hpp>
#include <Slimber/VCardCollection.h>
@@ -16,8 +17,8 @@ namespace Swift {
public:
FileVCardCollection(boost::filesystem::path dir);
- boost::shared_ptr<VCard> getOwnVCard() const;
- void setOwnVCard(boost::shared_ptr<VCard> vcard);
+ std::shared_ptr<VCard> getOwnVCard() const;
+ void setOwnVCard(std::shared_ptr<VCard> vcard);
private:
boost::filesystem::path vcardsPath;
diff --git a/Slimber/LinkLocalPresenceManager.cpp b/Slimber/LinkLocalPresenceManager.cpp
index 200e98f..f166b38 100644
--- a/Slimber/LinkLocalPresenceManager.cpp
+++ b/Slimber/LinkLocalPresenceManager.cpp
@@ -34,7 +34,7 @@ boost::optional<LinkLocalService> LinkLocalPresenceManager::getServiceForJID(con
}
void LinkLocalPresenceManager::handleServiceAdded(const LinkLocalService& service) {
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+ std::shared_ptr<RosterPayload> roster(new RosterPayload());
roster->addItem(getRosterItem(service));
onRosterChanged(roster);
onPresenceChanged(getPresence(service));
@@ -45,21 +45,21 @@ void LinkLocalPresenceManager::handleServiceChanged(const LinkLocalService& serv
}
void LinkLocalPresenceManager::handleServiceRemoved(const LinkLocalService& service) {
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+ std::shared_ptr<RosterPayload> roster(new RosterPayload());
roster->addItem(RosterItemPayload(service.getJID(), "", RosterItemPayload::Remove));
onRosterChanged(roster);
}
-boost::shared_ptr<RosterPayload> LinkLocalPresenceManager::getRoster() const {
- boost::shared_ptr<RosterPayload> roster(new RosterPayload());
+std::shared_ptr<RosterPayload> LinkLocalPresenceManager::getRoster() const {
+ std::shared_ptr<RosterPayload> roster(new RosterPayload());
foreach(const LinkLocalService& service, browser->getServices()) {
roster->addItem(getRosterItem(service));
}
return roster;
}
-std::vector<boost::shared_ptr<Presence> > LinkLocalPresenceManager::getAllPresence() const {
- std::vector<boost::shared_ptr<Presence> > result;
+std::vector<std::shared_ptr<Presence> > LinkLocalPresenceManager::getAllPresence() const {
+ std::vector<std::shared_ptr<Presence> > result;
foreach(const LinkLocalService& service, browser->getServices()) {
result.push_back(getPresence(service));
}
@@ -88,8 +88,8 @@ std::string LinkLocalPresenceManager::getRosterName(const LinkLocalService& serv
return "";
}
-boost::shared_ptr<Presence> LinkLocalPresenceManager::getPresence(const LinkLocalService& service) const {
- boost::shared_ptr<Presence> presence(new Presence());
+std::shared_ptr<Presence> LinkLocalPresenceManager::getPresence(const LinkLocalService& service) const {
+ std::shared_ptr<Presence> presence(new Presence());
presence->setFrom(service.getJID());
switch (service.getInfo().getStatus()) {
case LinkLocalServiceInfo::Available:
diff --git a/Slimber/LinkLocalPresenceManager.h b/Slimber/LinkLocalPresenceManager.h
index 83df624..6858c70 100644
--- a/Slimber/LinkLocalPresenceManager.h
+++ b/Slimber/LinkLocalPresenceManager.h
@@ -6,10 +6,9 @@
#pragma once
+#include <memory>
#include <string>
-#include <boost/shared_ptr.hpp>
-
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Elements/RosterItemPayload.h>
#include <Swiften/JID/JID.h>
@@ -24,13 +23,13 @@ namespace Swift {
public:
LinkLocalPresenceManager(LinkLocalServiceBrowser*);
- boost::shared_ptr<RosterPayload> getRoster() const;
- std::vector<boost::shared_ptr<Presence> > getAllPresence() const;
+ std::shared_ptr<RosterPayload> getRoster() const;
+ std::vector<std::shared_ptr<Presence> > getAllPresence() const;
boost::optional<LinkLocalService> getServiceForJID(const JID&) const;
- boost::signal<void (boost::shared_ptr<RosterPayload>)> onRosterChanged;
- boost::signal<void (boost::shared_ptr<Presence>)> onPresenceChanged;
+ boost::signal<void (std::shared_ptr<RosterPayload>)> onRosterChanged;
+ boost::signal<void (std::shared_ptr<Presence>)> onPresenceChanged;
private:
void handleServiceAdded(const LinkLocalService&);
@@ -39,7 +38,7 @@ namespace Swift {
RosterItemPayload getRosterItem(const LinkLocalService& service) const;
std::string getRosterName(const LinkLocalService& service) const;
- boost::shared_ptr<Presence> getPresence(const LinkLocalService& service) const;
+ std::shared_ptr<Presence> getPresence(const LinkLocalService& service) const;
private:
LinkLocalServiceBrowser* browser;
diff --git a/Slimber/MainController.h b/Slimber/MainController.h
index 8f4e981..9989b4d 100644
--- a/Slimber/MainController.h
+++ b/Slimber/MainController.h
@@ -6,8 +6,9 @@
#pragma once
+#include <memory>
+
#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
#include <Slimber/ServerError.h>
@@ -37,7 +38,7 @@ class MainController {
void stop();
private:
- boost::shared_ptr<Swift::DNSSDQuerier> dnsSDQuerier;
+ std::shared_ptr<Swift::DNSSDQuerier> dnsSDQuerier;
Swift::LinkLocalServiceBrowser* linkLocalServiceBrowser;
Swift::VCardCollection* vCardCollection;
Swift::Server* server;
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp
index d1afc23..a06fda2 100644
--- a/Slimber/Server.cpp
+++ b/Slimber/Server.cpp
@@ -111,11 +111,11 @@ void Server::stop(boost::optional<ServerError> e) {
serverFromClientSession->finishSession();
}
serverFromClientSession.reset();
- foreach(boost::shared_ptr<Session> session, linkLocalSessions) {
+ foreach(std::shared_ptr<Session> session, linkLocalSessions) {
session->finishSession();
}
linkLocalSessions.clear();
- foreach(boost::shared_ptr<LinkLocalConnector> connector, connectors) {
+ foreach(std::shared_ptr<LinkLocalConnector> connector, connectors) {
connector->cancel();
}
connectors.clear();
@@ -142,11 +142,11 @@ void Server::stop(boost::optional<ServerError> e) {
onStopped(e);
}
-void Server::handleNewClientConnection(boost::shared_ptr<Connection> connection) {
+void Server::handleNewClientConnection(std::shared_ptr<Connection> connection) {
if (serverFromClientSession) {
connection->disconnect();
}
- serverFromClientSession = boost::shared_ptr<ServerFromClientSession>(
+ serverFromClientSession = std::shared_ptr<ServerFromClientSession>(
new ServerFromClientSession(idGenerator.generateID(), connection,
&payloadParserFactories, &payloadSerializers, &xmlParserFactory, &userRegistry));
serverFromClientSession->setAllowSASLEXTERNAL();
@@ -158,7 +158,7 @@ void Server::handleNewClientConnection(boost::shared_ptr<Connection> connection)
serverFromClientSession->onSessionFinished.connect(
boost::bind(&Server::handleSessionFinished, this,
serverFromClientSession));
- //tracers.push_back(boost::shared_ptr<SessionTracer>(
+ //tracers.push_back(std::shared_ptr<SessionTracer>(
// new SessionTracer(serverFromClientSession)));
serverFromClientSession->startSession();
}
@@ -167,7 +167,7 @@ void Server::handleSessionStarted() {
onSelfConnected(true);
}
-void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession>) {
+void Server::handleSessionFinished(std::shared_ptr<ServerFromClientSession>) {
serverFromClientSession.reset();
unregisterService();
selfJID = JID();
@@ -183,8 +183,8 @@ void Server::unregisterService() {
}
}
-void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<ServerFromClientSession> session) {
- boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element);
+void Server::handleElementReceived(std::shared_ptr<ToplevelElement> element, std::shared_ptr<ServerFromClientSession> session) {
+ std::shared_ptr<Stanza> stanza = std::dynamic_pointer_cast<Stanza>(element);
if (!stanza) {
return;
}
@@ -194,7 +194,7 @@ void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, b
stanza->setTo(session->getLocalJID());
}
- if (boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(stanza)) {
+ if (std::shared_ptr<Presence> presence = std::dynamic_pointer_cast<Presence>(stanza)) {
if (presence->getType() == Presence::Available) {
if (!linkLocalServiceRegistered) {
linkLocalServiceRegistered = true;
@@ -213,12 +213,12 @@ void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, b
}
}
else if (!stanza->getTo().isValid() || stanza->getTo() == session->getLocalJID() || stanza->getTo() == session->getRemoteJID().toBare()) {
- if (boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(stanza)) {
+ if (std::shared_ptr<IQ> iq = std::dynamic_pointer_cast<IQ>(stanza)) {
if (iq->getPayload<RosterPayload>()) {
if (iq->getType() == IQ::Get) {
session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), presenceManager->getRoster()));
rosterRequested = true;
- foreach(const boost::shared_ptr<Presence> presence, presenceManager->getAllPresence()) {
+ foreach(const std::shared_ptr<Presence> presence, presenceManager->getAllPresence()) {
session->sendElement(presence);
}
}
@@ -226,7 +226,7 @@ void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, b
session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::Forbidden, ErrorPayload::Cancel));
}
}
- if (boost::shared_ptr<VCard> vcard = iq->getPayload<VCard>()) {
+ if (std::shared_ptr<VCard> vcard = iq->getPayload<VCard>()) {
if (iq->getType() == IQ::Get) {
session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), vCardCollection->getOwnVCard()));
}
@@ -245,7 +245,7 @@ void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, b
}
else {
JID toJID = stanza->getTo();
- boost::shared_ptr<Session> outgoingSession =
+ std::shared_ptr<Session> outgoingSession =
getLinkLocalSessionForJID(toJID);
if (outgoingSession) {
outgoingSession->sendElement(stanza);
@@ -254,10 +254,10 @@ void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, b
boost::optional<LinkLocalService> service =
presenceManager->getServiceForJID(toJID);
if (service) {
- boost::shared_ptr<LinkLocalConnector> connector =
+ std::shared_ptr<LinkLocalConnector> connector =
getLinkLocalConnectorForJID(toJID);
if (!connector) {
- connector = boost::shared_ptr<LinkLocalConnector>(
+ connector = std::shared_ptr<LinkLocalConnector>(
new LinkLocalConnector(
*service,
linkLocalServiceBrowser->getQuerier(),
@@ -278,23 +278,23 @@ void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, b
}
}
-void Server::handleNewLinkLocalConnection(boost::shared_ptr<Connection> connection) {
- boost::shared_ptr<IncomingLinkLocalSession> session(
+void Server::handleNewLinkLocalConnection(std::shared_ptr<Connection> connection) {
+ std::shared_ptr<IncomingLinkLocalSession> session(
new IncomingLinkLocalSession(
selfJID, connection,
&payloadParserFactories, &payloadSerializers, &xmlParserFactory));
registerLinkLocalSession(session);
}
-void Server::handleLinkLocalSessionFinished(boost::shared_ptr<Session> session) {
+void Server::handleLinkLocalSessionFinished(std::shared_ptr<Session> session) {
//std::cout << "Link local session from " << session->getRemoteJID() << " ended" << std::endl;
linkLocalSessions.erase(
std::remove(linkLocalSessions.begin(), linkLocalSessions.end(), session),
linkLocalSessions.end());
}
-void Server::handleLinkLocalElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<Session> session) {
- if (boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element)) {
+void Server::handleLinkLocalElementReceived(std::shared_ptr<ToplevelElement> element, std::shared_ptr<Session> session) {
+ if (std::shared_ptr<Stanza> stanza = std::dynamic_pointer_cast<Stanza>(element)) {
JID fromJID = session->getRemoteJID();
if (!presenceManager->getServiceForJID(fromJID.toBare())) {
return; // TODO: Send error back
@@ -304,17 +304,17 @@ void Server::handleLinkLocalElementReceived(boost::shared_ptr<ToplevelElement> e
}
}
-void Server::handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connector, bool error) {
+void Server::handleConnectFinished(std::shared_ptr<LinkLocalConnector> connector, bool error) {
if (error) {
std::cerr << "Error connecting" << std::endl;
// TODO: Send back queued stanzas
}
else {
- boost::shared_ptr<OutgoingLinkLocalSession> outgoingSession(
+ std::shared_ptr<OutgoingLinkLocalSession> outgoingSession(
new OutgoingLinkLocalSession(
selfJID, connector->getService().getJID(), connector->getConnection(),
&payloadParserFactories, &payloadSerializers, &xmlParserFactory));
- foreach(const boost::shared_ptr<ToplevelElement> element, connector->getQueuedElements()) {
+ foreach(const std::shared_ptr<ToplevelElement> element, connector->getQueuedElements()) {
outgoingSession->queueElement(element);
}
registerLinkLocalSession(outgoingSession);
@@ -322,42 +322,42 @@ void Server::handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connect
connectors.erase(std::remove(connectors.begin(), connectors.end(), connector), connectors.end());
}
-void Server::registerLinkLocalSession(boost::shared_ptr<Session> session) {
+void Server::registerLinkLocalSession(std::shared_ptr<Session> session) {
session->onSessionFinished.connect(
boost::bind(&Server::handleLinkLocalSessionFinished, this, session));
session->onElementReceived.connect(
boost::bind(&Server::handleLinkLocalElementReceived, this, _1, session));
linkLocalSessions.push_back(session);
- //tracers.push_back(boost::make_shared<SessionTracer>(session));
+ //tracers.push_back(std::make_shared<SessionTracer>(session));
session->startSession();
}
-boost::shared_ptr<Session> Server::getLinkLocalSessionForJID(const JID& jid) {
- foreach(const boost::shared_ptr<Session> session, linkLocalSessions) {
+std::shared_ptr<Session> Server::getLinkLocalSessionForJID(const JID& jid) {
+ foreach(const std::shared_ptr<Session> session, linkLocalSessions) {
if (session->getRemoteJID() == jid) {
return session;
}
}
- return boost::shared_ptr<Session>();
+ return std::shared_ptr<Session>();
}
-boost::shared_ptr<LinkLocalConnector> Server::getLinkLocalConnectorForJID(const JID& jid) {
- foreach(const boost::shared_ptr<LinkLocalConnector> connector, connectors) {
+std::shared_ptr<LinkLocalConnector> Server::getLinkLocalConnectorForJID(const JID& jid) {
+ foreach(const std::shared_ptr<LinkLocalConnector> connector, connectors) {
if (connector->getService().getJID() == jid) {
return connector;
}
}
- return boost::shared_ptr<LinkLocalConnector>();
+ return std::shared_ptr<LinkLocalConnector>();
}
void Server::handleServiceRegistered(const DNSSDServiceID& service) {
selfJID = JID(service.getName());
}
-void Server::handleRosterChanged(boost::shared_ptr<RosterPayload> roster) {
+void Server::handleRosterChanged(std::shared_ptr<RosterPayload> roster) {
if (rosterRequested) {
assert(serverFromClientSession);
- boost::shared_ptr<IQ> iq = IQ::createRequest(
+ std::shared_ptr<IQ> iq = IQ::createRequest(
IQ::Set, serverFromClientSession->getRemoteJID(),
idGenerator.generateID(), roster);
iq->setFrom(serverFromClientSession->getRemoteJID().toBare());
@@ -365,7 +365,7 @@ void Server::handleRosterChanged(boost::shared_ptr<RosterPayload> roster) {
}
}
-void Server::handlePresenceChanged(boost::shared_ptr<Presence> presence) {
+void Server::handlePresenceChanged(std::shared_ptr<Presence> presence) {
if (rosterRequested) {
serverFromClientSession->sendElement(presence);
}
@@ -399,9 +399,9 @@ void Server::handleLinkLocalConnectionServerStopped(boost::optional<BoostConnect
}
}
-LinkLocalServiceInfo Server::getLinkLocalServiceInfo(boost::shared_ptr<Presence> presence) {
+LinkLocalServiceInfo Server::getLinkLocalServiceInfo(std::shared_ptr<Presence> presence) {
LinkLocalServiceInfo info;
- boost::shared_ptr<VCard> vcard = vCardCollection->getOwnVCard();
+ std::shared_ptr<VCard> vcard = vCardCollection->getOwnVCard();
if (!vcard->getFamilyName().empty() || !vcard->getGivenName().empty()) {
info.setFirstName(vcard->getGivenName());
info.setLastName(vcard->getFamilyName());
diff --git a/Slimber/Server.h b/Slimber/Server.h
index 7037cdb..725ad05 100644
--- a/Slimber/Server.h
+++ b/Slimber/Server.h
@@ -6,10 +6,10 @@
#pragma once
+#include <memory>
#include <vector>
#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
#include <Swiften/Base/IDGenerator.h>
#include <Swiften/JID/JID.h>
@@ -65,26 +65,26 @@ namespace Swift {
private:
void stop(boost::optional<ServerError>);
- void handleNewClientConnection(boost::shared_ptr<Connection> c);
+ void handleNewClientConnection(std::shared_ptr<Connection> c);
void handleSessionStarted();
- void handleSessionFinished(boost::shared_ptr<ServerFromClientSession>);
- void handleElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<ServerFromClientSession> session);
- void handleRosterChanged(boost::shared_ptr<RosterPayload> roster);
- void handlePresenceChanged(boost::shared_ptr<Presence> presence);
+ void handleSessionFinished(std::shared_ptr<ServerFromClientSession>);
+ void handleElementReceived(std::shared_ptr<ToplevelElement> element, std::shared_ptr<ServerFromClientSession> session);
+ void handleRosterChanged(std::shared_ptr<RosterPayload> roster);
+ void handlePresenceChanged(std::shared_ptr<Presence> presence);
void handleServiceRegistered(const DNSSDServiceID& service);
- void handleNewLinkLocalConnection(boost::shared_ptr<Connection> connection);
- void handleLinkLocalSessionFinished(boost::shared_ptr<Session> session);
- void handleLinkLocalElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<Session> session);
- void handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connector, bool error);
+ void handleNewLinkLocalConnection(std::shared_ptr<Connection> connection);
+ void handleLinkLocalSessionFinished(std::shared_ptr<Session> session);
+ void handleLinkLocalElementReceived(std::shared_ptr<ToplevelElement> element, std::shared_ptr<Session> session);
+ void handleConnectFinished(std::shared_ptr<LinkLocalConnector> connector, bool error);
void handleClientConnectionServerStopped(
boost::optional<BoostConnectionServer::Error>);
void handleLinkLocalConnectionServerStopped(
boost::optional<BoostConnectionServer::Error>);
- boost::shared_ptr<Session> getLinkLocalSessionForJID(const JID& jid);
- boost::shared_ptr<LinkLocalConnector> getLinkLocalConnectorForJID(const JID& jid);
- void registerLinkLocalSession(boost::shared_ptr<Session> session);
+ std::shared_ptr<Session> getLinkLocalSessionForJID(const JID& jid);
+ std::shared_ptr<LinkLocalConnector> getLinkLocalConnectorForJID(const JID& jid);
+ void registerLinkLocalSession(std::shared_ptr<Session> session);
void unregisterService();
- LinkLocalServiceInfo getLinkLocalServiceInfo(boost::shared_ptr<Presence> presence);
+ LinkLocalServiceInfo getLinkLocalServiceInfo(std::shared_ptr<Presence> presence);
private:
class DummyUserRegistry : public UserRegistry {
@@ -112,15 +112,15 @@ namespace Swift {
EventLoop* eventLoop;
LinkLocalPresenceManager* presenceManager;
bool stopping;
- boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer;
+ std::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer;
std::vector<boost::bsignals::connection> serverFromClientConnectionServerSignalConnections;
- boost::shared_ptr<ServerFromClientSession> serverFromClientSession;
- boost::shared_ptr<Presence> lastPresence;
+ std::shared_ptr<ServerFromClientSession> serverFromClientSession;
+ std::shared_ptr<Presence> lastPresence;
JID selfJID;
- boost::shared_ptr<BoostConnectionServer> serverFromNetworkConnectionServer;
+ std::shared_ptr<BoostConnectionServer> serverFromNetworkConnectionServer;
std::vector<boost::bsignals::connection> serverFromNetworkConnectionServerSignalConnections;
- std::vector< boost::shared_ptr<Session> > linkLocalSessions;
- std::vector< boost::shared_ptr<LinkLocalConnector> > connectors;
- std::vector< boost::shared_ptr<SessionTracer> > tracers;
+ std::vector< std::shared_ptr<Session> > linkLocalSessions;
+ std::vector< std::shared_ptr<LinkLocalConnector> > connectors;
+ std::vector< std::shared_ptr<SessionTracer> > tracers;
};
}
diff --git a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp
index 45bc2aa..c8e7700 100644
--- a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp
+++ b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp
@@ -45,7 +45,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
public:
void setUp() {
eventLoop = new DummyEventLoop();
- querier = boost::make_shared<FakeDNSSDQuerier>("wonderland.lit", eventLoop);
+ querier = std::make_shared<FakeDNSSDQuerier>("wonderland.lit", eventLoop);
browser = new LinkLocalServiceBrowser(querier);
browser->start();
}
@@ -59,14 +59,14 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
void testConstructor() {
addService("alice@wonderland");
addService("rabbit@teaparty");
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(testling->getRoster()->getItems().size()));
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(testling->getAllPresence().size()));
}
void testServiceAdded() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland", "Alice");
@@ -82,7 +82,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testServiceRemoved() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland");
removeService("alice@wonderland");
@@ -95,7 +95,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testServiceChanged() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland");
updateServicePresence("alice@wonderland", LinkLocalServiceInfo::Away, "I'm Away");
@@ -108,13 +108,13 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetAllPresence() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland");
addService("rabbit@teaparty");
updateServicePresence("rabbit@teaparty", LinkLocalServiceInfo::Away, "Partying");
- std::vector<boost::shared_ptr<Presence> > presences = testling->getAllPresence();
+ std::vector<std::shared_ptr<Presence> > presences = testling->getAllPresence();
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(presences.size()));
// The order doesn't matter
CPPUNIT_ASSERT(JID("rabbit@teaparty") == presences[0]->getFrom());
@@ -124,12 +124,12 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetRoster() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland", "Alice");
addService("rabbit@teaparty", "Rabbit");
- boost::shared_ptr<RosterPayload> roster = testling->getRoster();
+ std::shared_ptr<RosterPayload> roster = testling->getRoster();
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(roster->getItems().size()));
boost::optional<RosterItemPayload> item;
item = roster->getItem(JID("alice@wonderland"));
@@ -143,7 +143,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetRoster_InfoWithNick() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland", "Alice", "Alice In", "Wonderland");
@@ -152,7 +152,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetRoster_InfoWithFirstName() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland", "", "Alice In", "");
@@ -161,7 +161,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetRoster_InfoWithLastName() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland", "", "", "Wonderland");
@@ -170,7 +170,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetRoster_InfoWithFirstAndLastName() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland", "", "Alice In", "Wonderland");
@@ -179,7 +179,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetRoster_NoInfo() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland");
@@ -188,7 +188,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetServiceForJID() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland");
addService("rabbit@teaparty");
@@ -200,7 +200,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
void testGetServiceForJID_NoMatch() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
+ std::shared_ptr<LinkLocalPresenceManager> testling(createTestling());
addService("alice@wonderland");
addService("queen@garden");
@@ -209,8 +209,8 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
}
private:
- boost::shared_ptr<LinkLocalPresenceManager> createTestling() {
- boost::shared_ptr<LinkLocalPresenceManager> testling(
+ std::shared_ptr<LinkLocalPresenceManager> createTestling() {
+ std::shared_ptr<LinkLocalPresenceManager> testling(
new LinkLocalPresenceManager(browser));
testling->onRosterChanged.connect(boost::bind(
&LinkLocalPresenceManagerTest::handleRosterChanged, this, _1));
@@ -245,20 +245,20 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
eventLoop->processEvents();
}
- void handleRosterChanged(boost::shared_ptr<RosterPayload> payload) {
+ void handleRosterChanged(std::shared_ptr<RosterPayload> payload) {
rosterChanges.push_back(payload);
}
- void handlePresenceChanged(boost::shared_ptr<Presence> presence) {
+ void handlePresenceChanged(std::shared_ptr<Presence> presence) {
presenceChanges.push_back(presence);
}
private:
DummyEventLoop* eventLoop;
- boost::shared_ptr<FakeDNSSDQuerier> querier;
+ std::shared_ptr<FakeDNSSDQuerier> querier;
LinkLocalServiceBrowser* browser;
- std::vector< boost::shared_ptr<RosterPayload> > rosterChanges;
- std::vector< boost::shared_ptr<Presence> > presenceChanges;
+ std::vector< std::shared_ptr<RosterPayload> > rosterChanges;
+ std::vector< std::shared_ptr<Presence> > presenceChanges;
};
CPPUNIT_TEST_SUITE_REGISTRATION(LinkLocalPresenceManagerTest);
diff --git a/Slimber/VCardCollection.h b/Slimber/VCardCollection.h
index 3295039..50147ec 100644
--- a/Slimber/VCardCollection.h
+++ b/Slimber/VCardCollection.h
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include <Swiften/Elements/VCard.h>
@@ -15,7 +15,7 @@ namespace Swift {
public:
virtual ~VCardCollection();
- virtual boost::shared_ptr<VCard> getOwnVCard() const = 0;
- virtual void setOwnVCard(boost::shared_ptr<VCard> vcard) = 0;
+ virtual std::shared_ptr<VCard> getOwnVCard() const = 0;
+ virtual void setOwnVCard(std::shared_ptr<VCard> vcard) = 0;
};
}