diff options
Diffstat (limited to 'Swiften/Presence')
6 files changed, 52 insertions, 51 deletions
diff --git a/Swiften/Presence/DirectedPresenceSender.cpp b/Swiften/Presence/DirectedPresenceSender.cpp index a3deea5..c1ce3a0 100644 --- a/Swiften/Presence/DirectedPresenceSender.cpp +++ b/Swiften/Presence/DirectedPresenceSender.cpp @@ -13,7 +13,7 @@ namespace Swift { DirectedPresenceSender::DirectedPresenceSender(PresenceSender* sender) : sender(sender) { } -void DirectedPresenceSender::sendPresence(boost::shared_ptr<Presence> presence) { +void DirectedPresenceSender::sendPresence(std::shared_ptr<Presence> presence) { if (!sender->isAvailable()) { return; } @@ -21,7 +21,7 @@ void DirectedPresenceSender::sendPresence(boost::shared_ptr<Presence> presence) sender->sendPresence(presence); if (!presence->getTo().isValid()) { - boost::shared_ptr<Presence> presenceCopy(new Presence(*presence)); + std::shared_ptr<Presence> presenceCopy(new Presence(*presence)); foreach(const JID& jid, directedPresenceReceivers) { presenceCopy->setTo(jid); sender->sendPresence(presenceCopy); @@ -48,7 +48,7 @@ void DirectedPresenceSender::addDirectedPresenceReceiver(const JID& jid, SendPre directedPresenceReceivers.insert(jid); if (sendPresence == AndSendPresence && sender->isAvailable()) { if (lastSentUndirectedPresence && (*lastSentUndirectedPresence)->getType() == Presence::Available) { - boost::shared_ptr<Presence> presenceCopy((*lastSentUndirectedPresence)->clone()); + std::shared_ptr<Presence> presenceCopy((*lastSentUndirectedPresence)->clone()); presenceCopy->setTo(jid); sender->sendPresence(presenceCopy); } @@ -63,7 +63,7 @@ void DirectedPresenceSender::addDirectedPresenceReceiver(const JID& jid, SendPre void DirectedPresenceSender::removeDirectedPresenceReceiver(const JID& jid, SendPresence sendPresence) { directedPresenceReceivers.erase(jid); if (sendPresence == AndSendPresence && sender->isAvailable()) { - boost::shared_ptr<Presence> presence(new Presence()); + std::shared_ptr<Presence> presence(new Presence()); presence->setType(Presence::Unavailable); presence->setTo(jid); sender->sendPresence(presence); diff --git a/Swiften/Presence/PayloadAddingPresenceSender.cpp b/Swiften/Presence/PayloadAddingPresenceSender.cpp index 2f55374..e5d2688 100644 --- a/Swiften/Presence/PayloadAddingPresenceSender.cpp +++ b/Swiften/Presence/PayloadAddingPresenceSender.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -34,7 +34,7 @@ bool PayloadAddingPresenceSender::isAvailable() const { return sender->isAvailable(); } -void PayloadAddingPresenceSender::setPayload(boost::shared_ptr<Payload> payload) { +void PayloadAddingPresenceSender::setPayload(std::shared_ptr<Payload> payload) { this->payload = payload; if (lastSentPresence) { sendPresence(lastSentPresence); diff --git a/Swiften/Presence/PayloadAddingPresenceSender.h b/Swiften/Presence/PayloadAddingPresenceSender.h index edb9484..3a55183 100644 --- a/Swiften/Presence/PayloadAddingPresenceSender.h +++ b/Swiften/Presence/PayloadAddingPresenceSender.h @@ -22,7 +22,7 @@ namespace Swift { public: PayloadAddingPresenceSender(PresenceSender*); - void sendPresence(boost::shared_ptr<Presence>); + void sendPresence(std::shared_ptr<Presence>); bool isAvailable() const; /** @@ -31,7 +31,7 @@ namespace Swift { * with an updated payload. Initial presence is reset when unavailable presence is * sent, or when reset() is called. */ - void setPayload(boost::shared_ptr<Payload>); + void setPayload(std::shared_ptr<Payload>); /** * Resets the presence sender. @@ -42,8 +42,8 @@ namespace Swift { void reset(); private: - boost::shared_ptr<Presence> lastSentPresence; + std::shared_ptr<Presence> lastSentPresence; PresenceSender* sender; - boost::shared_ptr<Payload> payload; + std::shared_ptr<Payload> payload; }; } diff --git a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp index 37679a9..2ce67dc 100644 --- a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -28,9 +28,9 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { public: void setUp() { channel = new DummyStanzaChannel(); - testPresence = boost::make_shared<Presence>(); + testPresence = std::make_shared<Presence>(); testPresence->setStatus("Foo"); - secondTestPresence = boost::make_shared<Presence>(); + secondTestPresence = std::make_shared<Presence>(); secondTestPresence->setStatus("Bar"); stanzaChannelPresenceSender = new StanzaChannelPresenceSender(channel); } @@ -41,30 +41,30 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { } void testSendPresence() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->sentStanzas.size())); - boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); + std::shared_ptr<Presence> presence = std::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); CPPUNIT_ASSERT(testPresence == presence); } void testSendPresence_UndirectedPresenceWithDirectedPresenceReceivers() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::AndSendPresence); testling->sendPresence(testPresence); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(channel->sentStanzas.size())); - boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); + std::shared_ptr<Presence> presence = std::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); CPPUNIT_ASSERT(testPresence == presence); - presence = boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[1]); + presence = std::dynamic_pointer_cast<Presence>(channel->sentStanzas[1]); CPPUNIT_ASSERT_EQUAL(testPresence->getStatus(), presence->getStatus()); CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/teaparty"), presence->getTo()); } void testSendPresence_DirectedPresenceWithDirectedPresenceReceivers() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::AndSendPresence); channel->sentStanzas.clear(); @@ -72,25 +72,25 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { testling->sendPresence(testPresence); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->sentStanzas.size())); - boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); + std::shared_ptr<Presence> presence = std::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); CPPUNIT_ASSERT(testPresence == presence); } void testAddDirectedPresenceReceiver() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); channel->sentStanzas.clear(); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::AndSendPresence); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->sentStanzas.size())); - boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); + std::shared_ptr<Presence> presence = std::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); CPPUNIT_ASSERT_EQUAL(testPresence->getStatus(), presence->getStatus()); CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/teaparty"), presence->getTo()); } void testAddDirectedPresenceReceiver_WithoutSendingPresence() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); channel->sentStanzas.clear(); @@ -100,7 +100,7 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { } void testAddDirectedPresenceReceiver_AfterSendingDirectedPresence() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->sendPresence(testPresence); secondTestPresence->setTo(JID("foo@bar.com")); testling->sendPresence(secondTestPresence); @@ -109,25 +109,25 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::AndSendPresence); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->sentStanzas.size())); - boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); + std::shared_ptr<Presence> presence = std::dynamic_pointer_cast<Presence>(channel->sentStanzas[0]); CPPUNIT_ASSERT_EQUAL(testPresence->getStatus(), presence->getStatus()); CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/teaparty"), presence->getTo()); } void testRemoveDirectedPresenceReceiver() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::DontSendPresence); testling->removeDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::AndSendPresence); testling->sendPresence(testPresence); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(channel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(boost::dynamic_pointer_cast<Presence>(channel->sentStanzas[0])->getType(), Presence::Unavailable); + CPPUNIT_ASSERT_EQUAL(std::dynamic_pointer_cast<Presence>(channel->sentStanzas[0])->getType(), Presence::Unavailable); CPPUNIT_ASSERT(channel->sentStanzas[1] == testPresence); } void testRemoveDirectedPresenceReceiver_WithoutSendingPresence() { - boost::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); + std::shared_ptr<DirectedPresenceSender> testling(createPresenceSender()); testling->addDirectedPresenceReceiver(JID("alice@wonderland.lit/teaparty"), DirectedPresenceSender::AndSendPresence); channel->sentStanzas.clear(); @@ -146,8 +146,8 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture { private: DummyStanzaChannel* channel; StanzaChannelPresenceSender* stanzaChannelPresenceSender; - boost::shared_ptr<Presence> testPresence; - boost::shared_ptr<Presence> secondTestPresence; + std::shared_ptr<Presence> testPresence; + std::shared_ptr<Presence> secondTestPresence; }; CPPUNIT_TEST_SUITE_REGISTRATION(DirectedPresenceSenderTest); diff --git a/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp index 84c0838..234f303 100644 --- a/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp @@ -41,7 +41,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSetPayloadAddsPayloadOnPresenceSend() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->setPayload(MyPayload::create("foo")); testling->sendPresence(Presence::create("bar")); @@ -52,7 +52,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSetNullPayloadDoesNotAddPayloadOnPresenceSend() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->setPayload(MyPayload::ref()); testling->sendPresence(Presence::create("bar")); @@ -63,7 +63,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSendPresenceDoesNotAlterOriginalPayload() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->setPayload(MyPayload::create("foo")); Presence::ref presence(Presence::create("bar")); @@ -73,7 +73,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSetPayloadAfterInitialPresenceResendsPresence() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->sendPresence(Presence::create("bar")); testling->setPayload(MyPayload::create("foo")); @@ -84,7 +84,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSetPayloadAfterUnavailablePresenceDoesNotResendPresence() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->sendPresence(Presence::create("bar")); @@ -98,7 +98,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSetPayloadAfterResetDoesNotResendPresence() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->sendPresence(Presence::create("bar")); testling->reset(); @@ -108,7 +108,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } void testSendDirectedPresenceIsNotResent() { - boost::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); + std::shared_ptr<PayloadAddingPresenceSender> testling(createSender()); testling->sendPresence(Presence::create("bar")); Presence::ref directedPresence = Presence::create("baz"); @@ -121,13 +121,13 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { } private: - boost::shared_ptr<PayloadAddingPresenceSender> createSender() { - boost::shared_ptr<PayloadAddingPresenceSender> sender(new PayloadAddingPresenceSender(presenceSender)); + std::shared_ptr<PayloadAddingPresenceSender> createSender() { + std::shared_ptr<PayloadAddingPresenceSender> sender(new PayloadAddingPresenceSender(presenceSender)); return sender; } struct MyPayload : public Payload { - typedef boost::shared_ptr<MyPayload> ref; + typedef std::shared_ptr<MyPayload> ref; MyPayload(const std::string& body) : body(body) {} diff --git a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp index 4f066c7..86a7925 100644 --- a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp +++ b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ +#include <memory> + #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -109,7 +110,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { } void testReceivePresence() { - boost::shared_ptr<Presence> sentPresence(createPresence(user1)); + std::shared_ptr<Presence> sentPresence(createPresence(user1)); stanzaChannel_->onPresenceReceived(sentPresence); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); @@ -119,8 +120,8 @@ class PresenceOracleTest : public CppUnit::TestFixture { } void testReceivePresenceFromDifferentResources() { - boost::shared_ptr<Presence> sentPresence1(createPresence(user1)); - boost::shared_ptr<Presence> sentPresence2(createPresence(user1alt)); + std::shared_ptr<Presence> sentPresence1(createPresence(user1)); + std::shared_ptr<Presence> sentPresence2(createPresence(user1alt)); stanzaChannel_->onPresenceReceived(sentPresence1); stanzaChannel_->onPresenceReceived(sentPresence2); @@ -132,7 +133,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { std::string reasonText = "Because I want to"; JID sentJID = JID("me@example.com"); - boost::shared_ptr<Presence> sentPresence(new Presence()); + std::shared_ptr<Presence> sentPresence(new Presence()); sentPresence->setType(Presence::Subscribe); sentPresence->setFrom(sentJID); sentPresence->setStatus(reasonText); @@ -145,7 +146,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { } void testReconnectResetsPresences() { - boost::shared_ptr<Presence> sentPresence(createPresence(user1)); + std::shared_ptr<Presence> sentPresence(createPresence(user1)); stanzaChannel_->onPresenceReceived(sentPresence); stanzaChannel_->setAvailable(false); stanzaChannel_->setAvailable(true); @@ -189,7 +190,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { private: Presence::ref createPresence(const JID &jid, int priority, Presence::Type type, const StatusShow::Type& statusShow) { - Presence::ref presence = boost::make_shared<Presence>(); + Presence::ref presence = std::make_shared<Presence>(); presence->setFrom(jid); presence->setPriority(priority); presence->setType(type); @@ -212,7 +213,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { return presence; } - void handlePresenceChange(boost::shared_ptr<Presence> newPresence) { + void handlePresenceChange(std::shared_ptr<Presence> newPresence) { changes.push_back(newPresence); } @@ -223,8 +224,8 @@ class PresenceOracleTest : public CppUnit::TestFixture { subscriptionRequests.push_back(subscriptionRequest); } - boost::shared_ptr<Presence> createPresence(const JID& jid) { - boost::shared_ptr<Presence> sentPresence(new Presence("blarb")); + std::shared_ptr<Presence> createPresence(const JID& jid) { + std::shared_ptr<Presence> sentPresence(new Presence("blarb")); sentPresence->setFrom(jid); return sentPresence; } |