summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Limber/Server/ServerFromClientSession.cpp5
-rw-r--r--Limber/main.cpp2
-rw-r--r--Slimber/FileVCardCollection.cpp3
-rw-r--r--Slimber/Server.cpp2
-rw-r--r--Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp2
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp3
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp3
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp3
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp4
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp3
-rw-r--r--Swift/Controllers/MainController.cpp6
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterTest.cpp4
-rw-r--r--Swift/Controllers/StatusTracker.cpp8
-rw-r--r--Swift/QtUI/EventViewer/main.cpp2
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp2
-rw-r--r--Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp2
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp20
-rw-r--r--Swiften/Component/ComponentSession.cpp3
-rw-r--r--Swiften/Component/UnitTest/ComponentSessionTest.cpp4
-rw-r--r--Swiften/Disco/DiscoInfoResponder.cpp6
-rw-r--r--Swiften/Disco/GetDiscoInfoRequest.h6
-rw-r--r--Swiften/Disco/GetDiscoItemsRequest.h6
-rw-r--r--Swiften/Disco/JIDDiscoInfoResponder.cpp6
-rw-r--r--Swiften/Disco/UnitTest/CapsManagerTest.cpp12
-rw-r--r--Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp12
-rw-r--r--Swiften/Elements/UnitTest/StanzaTest.cpp66
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp2
-rw-r--r--Swiften/FileTransfer/OutgoingSIFileTransfer.cpp3
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp4
-rw-r--r--Swiften/LinkLocal/IncomingLinkLocalSession.cpp3
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp5
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp3
-rw-r--r--Swiften/MUC/MUCBookmarkManager.cpp3
-rw-r--r--Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp4
-rw-r--r--Swiften/Parser/UnitTest/StanzaParserTest.cpp2
-rw-r--r--Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp4
-rw-r--r--Swiften/Queries/Requests/GetPrivateStorageRequest.h3
-rw-r--r--Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h4
-rw-r--r--Swiften/Queries/Requests/SetPrivateStorageRequest.h3
-rw-r--r--Swiften/Queries/Responders/SoftwareVersionResponder.cpp4
-rw-r--r--Swiften/Queries/UnitTest/IQRouterTest.cpp23
-rw-r--r--Swiften/Queries/UnitTest/RequestTest.cpp2
-rw-r--r--Swiften/Queries/UnitTest/ResponderTest.cpp5
-rw-r--r--Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp7
-rw-r--r--Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/FormSerializer.cpp7
-rw-r--r--Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp5
-rw-r--r--Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp5
-rw-r--r--Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp3
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp8
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/StatusSerializer.h4
-rw-r--r--Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp5
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp7
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp31
-rw-r--r--Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp3
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.cpp12
-rw-r--r--Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp6
-rw-r--r--Swiften/Session/BOSHSessionStream.cpp2
-rw-r--r--Swiften/Session/BasicSessionStream.cpp11
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp2
71 files changed, 241 insertions, 184 deletions
diff --git a/Limber/Server/ServerFromClientSession.cpp b/Limber/Server/ServerFromClientSession.cpp
index fd361b7..71a8fef 100644
--- a/Limber/Server/ServerFromClientSession.cpp
+++ b/Limber/Server/ServerFromClientSession.cpp
@@ -1,17 +1,18 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Limber/Server/ServerFromClientSession.h"
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/bind.hpp>
#include "Swiften/Elements/ProtocolHeader.h"
#include "Limber/Server/UserRegistry.h"
#include "Swiften/Network/Connection.h"
#include "Swiften/StreamStack/XMPPLayer.h"
#include "Swiften/Elements/StreamFeatures.h"
#include "Swiften/Elements/ResourceBind.h"
#include "Swiften/Elements/StartSession.h"
@@ -41,26 +42,26 @@ ServerFromClientSession::ServerFromClientSession(
void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) {
if (isInitialized()) {
onElementReceived(element);
}
else {
if (AuthRequest* authRequest = dynamic_cast<AuthRequest*>(element.get())) {
if (authRequest->getMechanism() == "PLAIN" || (allowSASLEXTERNAL && authRequest->getMechanism() == "EXTERNAL")) {
if (authRequest->getMechanism() == "EXTERNAL") {
- getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
+ getXMPPLayer()->writeElement(boost::make_shared<AuthSuccess>());
authenticated_ = true;
getXMPPLayer()->resetParser();
}
else {
PLAINMessage plainMessage(authRequest->getMessage() ? *authRequest->getMessage() : createSafeByteArray(""));
if (userRegistry_->isValidUserPassword(JID(plainMessage.getAuthenticationID(), getLocalJID().getDomain()), plainMessage.getPassword())) {
- getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
+ getXMPPLayer()->writeElement(boost::make_shared<AuthSuccess>());
user_ = plainMessage.getAuthenticationID();
authenticated_ = true;
getXMPPLayer()->resetParser();
}
else {
getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
finishSession(AuthenticationFailedError);
}
}
diff --git a/Limber/main.cpp b/Limber/main.cpp
index 350b357..3db3092 100644
--- a/Limber/main.cpp
+++ b/Limber/main.cpp
@@ -55,19 +55,19 @@ class Server {
return;
}
stanza->setFrom(session->getRemoteJID());
if (!stanza->getTo().isValid()) {
stanza->setTo(JID(session->getLocalJID()));
}
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 (iq->getPayload<RosterPayload>()) {
- session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::shared_ptr<RosterPayload>(new RosterPayload())));
+ session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::make_shared<RosterPayload>())));
}
if (iq->getPayload<VCard>()) {
if (iq->getType() == IQ::Get) {
boost::shared_ptr<VCard> vcard(new VCard());
vcard->setNickname(iq->getFrom().getNode());
session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), vcard));
}
else {
session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::Forbidden, ErrorPayload::Cancel));
diff --git a/Slimber/FileVCardCollection.cpp b/Slimber/FileVCardCollection.cpp
index 97ade08..24249d4 100644
--- a/Slimber/FileVCardCollection.cpp
+++ b/Slimber/FileVCardCollection.cpp
@@ -1,17 +1,18 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Slimber/FileVCardCollection.h"
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/filesystem/fstream.hpp>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Elements/VCard.h>
#include <Swiften/Serializer/PayloadSerializers/VCardSerializer.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h>
#include <Swiften/Parser/PayloadParsers/VCardParser.h>
namespace Swift {
@@ -24,19 +25,19 @@ boost::shared_ptr<VCard> FileVCardCollection::getOwnVCard() const {
ByteArray data;
readByteArrayFromFile(data, boost::filesystem::path(vcardsPath / std::string("vcard.xml")).string());
VCardParser parser;
PayloadParserTester tester(&parser);
tester.parse(byteArrayToString(data));
return boost::dynamic_pointer_cast<VCard>(parser.getPayload());
}
else {
- return boost::shared_ptr<VCard>(new VCard());
+ return boost::make_shared<VCard>();
}
}
void FileVCardCollection::setOwnVCard(boost::shared_ptr<VCard> v) {
boost::filesystem::ofstream file(vcardsPath / std::string("vcard.xml"));
file << VCardSerializer().serializePayload(v);
file.close();
}
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp
index 769217f..b63ca67 100644
--- a/Slimber/Server.cpp
+++ b/Slimber/Server.cpp
@@ -321,19 +321,19 @@ 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) {
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::shared_ptr<SessionTracer>(new SessionTracer(session)));
+ //tracers.push_back(boost::make_shared<SessionTracer>(session));
session->startSession();
}
boost::shared_ptr<Session> Server::getLinkLocalSessionForJID(const JID& jid) {
foreach(const boost::shared_ptr<Session> session, linkLocalSessions) {
if (session->getRemoteJID() == jid) {
return session;
}
}
diff --git a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp
index e45861b..c138b2c 100644
--- a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp
+++ b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp
@@ -36,19 +36,19 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testGetRoster_InfoWithFirstAndLastName);
CPPUNIT_TEST(testGetRoster_NoInfo);
CPPUNIT_TEST(testGetServiceForJID);
CPPUNIT_TEST(testGetServiceForJID_NoMatch);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
eventLoop = new DummyEventLoop();
- querier = boost::shared_ptr<FakeDNSSDQuerier>(new FakeDNSSDQuerier("wonderland.lit", eventLoop));
+ querier = boost::make_shared<FakeDNSSDQuerier>("wonderland.lit", eventLoop);
browser = new LinkLocalServiceBrowser(querier);
browser->start();
}
void tearDown() {
browser->stop();
delete browser;
delete eventLoop;
}
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index ea0e8ea..610c8e8 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010-2012 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swift/Controllers/Chat/ChatController.h"
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <stdio.h>
#include <Swift/Controllers/Intl.h>
#include <Swiften/Base/format.h>
#include <Swiften/Base/Algorithm.h>
#include <Swiften/Avatars/AvatarManager.h>
#include <Swiften/Chat/ChatStateNotifier.h>
#include <Swiften/Chat/ChatStateTracker.h>
#include <Swiften/Client/StanzaChannel.h>
@@ -315,19 +316,19 @@ void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresenc
me = true;
}
} else if (toJID_.equals(newPresence->getFrom(), JID::WithResource)) {
me = true;
}
if (!me) {
return;
}
if (!newPresence) {
- newPresence = boost::shared_ptr<Presence>(new Presence());
+ newPresence = boost::make_shared<Presence>();
newPresence->setType(Presence::Unavailable);
}
lastShownStatus_ = newPresence->getShow();
chatStateTracker_->handlePresenceChange(newPresence);
chatStateNotifier_->setContactIsOnline(newPresence->getType() == Presence::Available);
std::string newStatusChangeString = getStatusChangeString(newPresence);
if (newStatusChangeString != lastStatusChangeString_) {
if (lastWasPresence_) {
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index db71397..f590ffd 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -5,18 +5,19 @@
*/
#include "Swift/Controllers/Chat/ChatControllerBase.h"
#include <sstream>
#include <map>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/algorithm/string.hpp>
#include <Swift/Controllers/Intl.h>
#include <Swiften/Base/format.h>
#include <Swiften/Base/String.h>
#include <Swiften/Client/StanzaChannel.h>
#include <Swiften/Elements/Delay.h>
#include <Swiften/Elements/MUCInvitationPayload.h>
@@ -114,19 +115,19 @@ void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool
if (labelsEnabled_) {
SecurityLabelsCatalog::Item labelItem = chatWindow_->getSelectedSecurityLabel();
if (labelItem.getLabel()) {
message->addPayload(labelItem.getLabel());
}
}
preSendMessageRequest(message);
if (useDelayForLatency_) {
boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
- message->addPayload(boost::shared_ptr<Delay>(new Delay(now, selfJID_)));
+ message->addPayload(boost::make_shared<Delay>(now, selfJID_));
}
if (isCorrectionMessage) {
message->addPayload(boost::shared_ptr<Replace> (new Replace(lastSentMessageStanzaID_)));
}
message->setID(lastSentMessageStanzaID_ = idGenerator_.generateID());
stanzaChannel_->sendMessage(message);
postSendMessage(message->getBody(), boost::dynamic_pointer_cast<Stanza>(message));
onActivity(message->getBody());
}
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 118f1e8..aea5ef4 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -2,18 +2,19 @@
* Copyright (c) 2010-2011 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swift/Controllers/Chat/ChatsManager.h"
#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swift/Controllers/Chat/ChatController.h>
#include <Swift/Controllers/Chat/ChatControllerBase.h>
#include <Swift/Controllers/Chat/MUCSearchController.h>
#include <Swift/Controllers/XMPPEvents/EventController.h>
#include <Swift/Controllers/Chat/MUCController.h>
#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h>
#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>
@@ -83,19 +84,19 @@ ChatsManager::ChatsManager(
settings_(settings) {
timerFactory_ = timerFactory;
eventController_ = eventController;
stanzaChannel_ = stanzaChannel;
iqRouter_ = iqRouter;
chatWindowFactory_ = chatWindowFactory;
nickResolver_ = nickResolver;
presenceOracle_ = presenceOracle;
avatarManager_ = NULL;
- serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ serverDiscoInfo_ = boost::make_shared<DiscoInfo>();
presenceSender_ = presenceSender;
uiEventStream_ = uiEventStream;
mucBookmarkManager_ = NULL;
profileSettings_ = profileSettings;
presenceOracle_->onPresenceChange.connect(boost::bind(&ChatsManager::handlePresenceChange, this, _1));
uiEventConnection_ = uiEventStream_->onUIEvent.connect(boost::bind(&ChatsManager::handleUIEvent, this, _1));
chatListWindow_ = chatListWindowFactory->createChatListWindow(uiEventStream_);
chatListWindow_->onMUCBookmarkActivated.connect(boost::bind(&ChatsManager::handleMUCBookmarkActivated, this, _1));
diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index cd868e6..bbfb22f 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -81,19 +81,19 @@ public:
iqRouter_ = new IQRouter(iqChannel_);
capsProvider_ = new DummyCapsProvider();
eventController_ = new EventController();
chatWindowFactory_ = mocks_->InterfaceMock<ChatWindowFactory>();
joinMUCWindowFactory_ = mocks_->InterfaceMock<JoinMUCWindowFactory>();
xmppRoster_ = new XMPPRosterImpl();
mucRegistry_ = new MUCRegistry();
nickResolver_ = new NickResolver(jid_.toBare(), xmppRoster_, NULL, mucRegistry_);
presenceOracle_ = new PresenceOracle(stanzaChannel_);
- serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ serverDiscoInfo_ = boost::make_shared<DiscoInfo>();
presenceSender_ = new StanzaChannelPresenceSender(stanzaChannel_);
directedPresenceSender_ = new DirectedPresenceSender(presenceSender_);
mucManager_ = new MUCManager(stanzaChannel_, iqRouter_, directedPresenceSender_, mucRegistry_);
uiEventStream_ = new UIEventStream();
entityCapsManager_ = new EntityCapsManager(capsProvider_, stanzaChannel_);
chatListWindowFactory_ = mocks_->InterfaceMock<ChatListWindowFactory>();
mucSearchWindowFactory_ = mocks_->InterfaceMock<MUCSearchWindowFactory>();
settings_ = new DummySettingsProvider();
profileSettings_ = new ProfileSettingsProvider("a", settings_);
@@ -251,19 +251,19 @@ public:
}
/**
* Test that MUC PMs get opened in the right windows
*/
void testThreeMUCWindows() {
JID muc("testling@test.com");
ChatWindow* mucWindow = new MockChatWindow();
mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(muc, uiEventStream_).Return(mucWindow);
- uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(new JoinMUCUIEvent(muc, std::string("nick"))));
+ uiEventStream_->send(boost::make_shared<JoinMUCUIEvent>(muc, std::string("nick")));
std::string messageJIDString1("testling@test.com/1");
ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1);
uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1))));
std::string messageJIDString2("testling@test.com/2");
ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp
index d6a920d..af962e9 100644
--- a/Swift/Controllers/Chat/UserSearchController.cpp
+++ b/Swift/Controllers/Chat/UserSearchController.cpp
@@ -2,18 +2,19 @@
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swift/Controllers/Chat/UserSearchController.h>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Disco/GetDiscoInfoRequest.h>
#include <Swiften/Disco/GetDiscoItemsRequest.h>
#include <Swiften/Disco/DiscoServiceWalker.h>
#include <Swiften/VCards/VCardManager.h>
#include <Swift/Controllers/ContactEditController.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
#include <Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h>
@@ -98,19 +99,19 @@ void UserSearchController::handleDiscoServiceFound(const JID& jid, boost::shared
&& identity.getType() == "user")) {
//isUserDirectory = true;
}
}
std::vector<std::string> features = info->getFeatures();
supports55 = std::find(features.begin(), features.end(), DiscoInfo::JabberSearchFeature) != features.end();
if (/*isUserDirectory && */supports55) { //FIXME: once M-Link correctly advertises directoryness.
/* Abort further searches.*/
endDiscoWalker();
- boost::shared_ptr<GenericRequest<SearchPayload> > searchRequest(new GenericRequest<SearchPayload>(IQ::Get, jid, boost::shared_ptr<SearchPayload>(new SearchPayload()), iqRouter_));
+ boost::shared_ptr<GenericRequest<SearchPayload> > searchRequest(new GenericRequest<SearchPayload>(IQ::Get, jid, boost::make_shared<SearchPayload>(), iqRouter_));
searchRequest->onResponse.connect(boost::bind(&UserSearchController::handleFormResponse, this, _1, _2));
searchRequest->send();
}
}
void UserSearchController::handleFormResponse(boost::shared_ptr<SearchPayload> fields, ErrorPayload::ref error) {
if (error || !fields) {
window_->setServerSupportsSearch(false);
return;
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index cd7e673..e923cff 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -375,19 +375,19 @@ void MainController::handleChangeStatusRequest(StatusShow::Type show, const std:
void MainController::sendPresence(boost::shared_ptr<Presence> presence) {
rosterController_->getWindow()->setMyStatusType(presence->getShow());
rosterController_->getWindow()->setMyStatusText(presence->getStatus());
systemTrayController_->setMyStatusType(presence->getShow());
notifier_->setTemporarilyDisabled(presence->getShow() == StatusShow::DND);
// Add information and send
if (!vCardPhotoHash_.empty()) {
- presence->updatePayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(vCardPhotoHash_)));
+ presence->updatePayload(boost::make_shared<VCardUpdate>(vCardPhotoHash_));
}
client_->getPresenceSender()->sendPresence(presence);
if (presence->getType() == Presence::Unavailable) {
logout();
}
}
void MainController::handleInputIdleChanged(bool idle) {
if (!statusTracker_) {
@@ -576,19 +576,19 @@ void MainController::handleDisconnected(const boost::optional<ClientError>& erro
if (!offlineRequested_) {
setReconnectTimer();
}
if (lastDisconnectError_) {
message = str(format(QT_TRANSLATE_NOOP("", "Reconnect to %1% failed: %2%. Will retry in %3% seconds.")) % jid_.getDomain() % message % boost::lexical_cast<std::string>(timeBeforeNextReconnect_));
lastDisconnectError_->conclude();
} else {
message = str(format(QT_TRANSLATE_NOOP("", "Disconnected from %1%: %2%.")) % jid_.getDomain() % message);
}
- lastDisconnectError_ = boost::shared_ptr<ErrorEvent>(new ErrorEvent(JID(jid_.getDomain()), message));
+ lastDisconnectError_ = boost::make_shared<ErrorEvent>(JID(jid_.getDomain()), message);
eventController_->handleIncomingEvent(lastDisconnectError_);
}
}
}
else if (!rosterController_) { //hasn't been logged in yet
loginWindow_->setIsLoggingIn(false);
}
}
@@ -669,19 +669,19 @@ void MainController::handleVCardReceived(const JID& jid, VCard::ref vCard) {
sendPresence(statusTracker_->getNextPresence());
}
}
}
void MainController::handleNotificationClicked(const JID& jid) {
assert(chatsManager_);
if (clientInitialized_) {
if (client_->getMUCRegistry()->isMUC(jid)) {
- uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(new JoinMUCUIEvent(jid)));
+ uiEventStream_->send(boost::make_shared<JoinMUCUIEvent>(jid));
}
else {
uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(jid)));
}
}
}
void MainController::handleQuitRequest() {
if (client_ && client_->isActive()) {
diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
index 4444e8a..0c3e769 100644
--- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
@@ -92,31 +92,31 @@ class RosterTest : public CppUnit::TestFixture {
boost::shared_ptr<Presence> presence(new Presence());
presence->setShow(StatusShow::DND);
presence->setFrom(jid4a);
roster_->applyOnItems(SetPresence(presence, JID::WithResource));
presence->setFrom(jid4b);
roster_->applyOnItems(SetPresence(presence, JID::WithResource));
presence->setFrom(jid4c);
roster_->applyOnItems(SetPresence(presence, JID::WithResource));
- presence = boost::shared_ptr<Presence>(new Presence());
+ presence = boost::make_shared<Presence>();
presence->setFrom(jid4b);
presence->setShow(StatusShow::Online);
roster_->applyOnItems(SetPresence(presence, JID::WithResource));
std::vector<RosterItem*> children = static_cast<GroupRosterItem*>(roster_->getRoot()->getDisplayedChildren()[0])->getDisplayedChildren();
CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(children.size()));
/* Check order */
CPPUNIT_ASSERT_EQUAL(std::string("Ernie"), children[0]->getDisplayName());
CPPUNIT_ASSERT_EQUAL(std::string("Bert"), children[1]->getDisplayName());
CPPUNIT_ASSERT_EQUAL(std::string("Bird"), children[2]->getDisplayName());
- presence = boost::shared_ptr<Presence>(new Presence());
+ presence = boost::make_shared<Presence>();
presence->setFrom(jid4c);
presence->setType(Presence::Unavailable);
roster_->removeContact(jid4c);
roster_->applyOnItems(SetPresence(presence, JID::WithResource));
}
void testReSortLikeMUC() {
JID jid4a("a@b/c");
diff --git a/Swift/Controllers/StatusTracker.cpp b/Swift/Controllers/StatusTracker.cpp
index 8f67b9f..0c88f4d 100644
--- a/Swift/Controllers/StatusTracker.cpp
+++ b/Swift/Controllers/StatusTracker.cpp
@@ -1,41 +1,43 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "Swift/Controllers/StatusTracker.h"
+#include <boost/smart_ptr/make_shared.hpp>
+
namespace Swift {
StatusTracker::StatusTracker() {
isAutoAway_ = false;
- queuedPresence_ = boost::shared_ptr<Presence>(new Presence());
+ queuedPresence_ = boost::make_shared<Presence>();
}
boost::shared_ptr<Presence> StatusTracker::getNextPresence() {
boost::shared_ptr<Presence> presence;
if (isAutoAway_) {
- presence = boost::shared_ptr<Presence>(new Presence());
+ presence = boost::make_shared<Presence>();
presence->setShow(StatusShow::Away);
presence->setStatus(queuedPresence_->getStatus());
} else {
presence = queuedPresence_;
}
return presence;
}
void StatusTracker::setRequestedPresence(boost::shared_ptr<Presence> presence) {
isAutoAway_ = false;
queuedPresence_ = presence;
// if (presence->getType() == Presence::Unavailable) {
-// queuedPresence_ = boost::shared_ptr<Presence>(new Presence());
+// queuedPresence_ = boost::make_shared<Presence>();
// }
}
bool StatusTracker::goAutoAway() {
if (queuedPresence_->getShow() != StatusShow::Online) {
return false;
}
isAutoAway_ = true;
return true;
diff --git a/Swift/QtUI/EventViewer/main.cpp b/Swift/QtUI/EventViewer/main.cpp
index afdb442..07a437c 100644
--- a/Swift/QtUI/EventViewer/main.cpp
+++ b/Swift/QtUI/EventViewer/main.cpp
@@ -20,12 +20,12 @@ int main(int argc, char *argv[])
Swift::QtEventWindow* viewer = new Swift::QtEventWindow(&eventStream);
viewer->show();
boost::shared_ptr<Swift::Message> message1(new Swift::Message());
message1->setBody("Oooh, shiny");
boost::shared_ptr<Swift::MessageEvent> event1(new Swift::MessageEvent(message1));
viewer->addEvent(boost::dynamic_pointer_cast<Swift::StanzaEvent>(event1), true);
for (int i = 0; i < 100; i++) {
viewer->addEvent(boost::dynamic_pointer_cast<Swift::StanzaEvent>(event1), false);
}
- viewer->addEvent(boost::dynamic_pointer_cast<Swift::StanzaEvent>(boost::shared_ptr<Swift::ErrorEvent>(new Swift::ErrorEvent(Swift::JID("me@example.com"), "Something bad did happen to you."))), true);
+ viewer->addEvent(boost::dynamic_pointer_cast<Swift::StanzaEvent>(boost::make_shared<Swift::ErrorEvent>(Swift::JID("me@example.com"), "Something bad did happen to you.")), true);
return app.exec();
}
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index a3b7837..dc6001b 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -399,19 +399,19 @@ void QtLoginWindow::handleAbout() {
}
else {
aboutDialog_->show();
aboutDialog_->raise();
aboutDialog_->activateWindow();
}
}
void QtLoginWindow::handleShowXMLConsole() {
- uiEventStream_->send(boost::shared_ptr<RequestXMLConsoleUIEvent>(new RequestXMLConsoleUIEvent()));
+ uiEventStream_->send(boost::make_shared<RequestXMLConsoleUIEvent>());
}
void QtLoginWindow::handleShowFileTransferOverview() {
uiEventStream_->send(boost::make_shared<RequestFileTransferListUIEvent>());
}
void QtLoginWindow::handleToggleSounds(bool enabled) {
settings_->storeSetting(SettingConstants::PLAY_SOUNDS, enabled);
}
diff --git a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp
index 821412b..60e76f8 100644
--- a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp
+++ b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp
@@ -152,19 +152,19 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture {
boost::shared_ptr<VCardUpdateAvatarManager> createManager() {
boost::shared_ptr<VCardUpdateAvatarManager> result(new VCardUpdateAvatarManager(vcardManager, stanzaChannel, avatarStorage, mucRegistry));
result->onAvatarChanged.connect(boost::bind(&VCardUpdateAvatarManagerTest::handleAvatarChanged, this, _1));
return result;
}
boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const std::string& hash) {
boost::shared_ptr<Presence> presence(new Presence());
presence->setFrom(jid);
- presence->addPayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(hash)));
+ presence->addPayload(boost::make_shared<VCardUpdate>(hash));
return presence;
}
IQ::ref createVCardResult(const ByteArray& avatar) {
VCard::ref vcard(new VCard());
if (!avatar.empty()) {
vcard->setPhoto(avatar);
}
return IQ::createResult(JID("baz@fum.com"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), vcard);
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index 22db8fc..a6d5a3a 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -60,19 +60,19 @@ class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testSessionStart_AfterResourceBind);
CPPUNIT_TEST(testWhitespacePing);
CPPUNIT_TEST(testReceiveElementAfterSessionStarted);
CPPUNIT_TEST(testSendElement);
*/
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
- server = boost::shared_ptr<MockSessionStream>(new MockSessionStream());
+ server = boost::make_shared<MockSessionStream>();
sessionFinishedReceived = false;
needCredentials = false;
blindCertificateTrustChecker = new BlindCertificateTrustChecker();
}
void tearDown() {
delete blindCertificateTrustChecker;
}
@@ -414,23 +414,23 @@ class ClientSessionTest : public CppUnit::TestFixture {
virtual void setWhitespacePingEnabled(bool enabled) {
whitespacePingEnabled = enabled;
}
virtual void resetXMPPParser() {
resetCount++;
}
void breakConnection() {
- onClosed(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::ConnectionReadError)));
+ onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::ConnectionReadError));
}
void breakTLS() {
- onClosed(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::TLSError)));
+ onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::TLSError));
}
void sendStreamStart() {
ProtocolHeader header;
header.setTo("foo.com");
return onStreamStartReceived(header);
}
@@ -439,23 +439,23 @@ class ClientSessionTest : public CppUnit::TestFixture {
streamFeatures->setHasStartTLS();
onElementReceived(streamFeatures);
}
void sendStreamError() {
onElementReceived(boost::make_shared<StreamError>());
}
void sendTLSProceed() {
- onElementReceived(boost::shared_ptr<TLSProceed>(new TLSProceed()));
+ onElementReceived(boost::make_shared<TLSProceed>());
}
void sendTLSFailure() {
- onElementReceived(boost::shared_ptr<StartTLSFailure>(new StartTLSFailure()));
+ onElementReceived(boost::make_shared<StartTLSFailure>());
}
void sendStreamFeaturesWithMultipleAuthentication() {
boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
streamFeatures->addAuthenticationMechanism("PLAIN");
streamFeatures->addAuthenticationMechanism("DIGEST-MD5");
streamFeatures->addAuthenticationMechanism("SCRAM-SHA1");
onElementReceived(streamFeatures);
}
@@ -478,31 +478,31 @@ class ClientSessionTest : public CppUnit::TestFixture {
streamFeatures->setHasStreamManagement();
onElementReceived(streamFeatures);
}
void sendEmptyStreamFeatures() {
onElementReceived(boost::make_shared<StreamFeatures>());
}
void sendAuthSuccess() {
- onElementReceived(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
+ onElementReceived(boost::make_shared<AuthSuccess>());
}
void sendAuthFailure() {
- onElementReceived(boost::shared_ptr<AuthFailure>(new AuthFailure()));
+ onElementReceived(boost::make_shared<AuthFailure>());
}
void sendStreamManagementEnabled() {
- onElementReceived(boost::shared_ptr<StreamManagementEnabled>(new StreamManagementEnabled()));
+ onElementReceived(boost::make_shared<StreamManagementEnabled>());
}
void sendStreamManagementFailed() {
- onElementReceived(boost::shared_ptr<StreamManagementFailed>(new StreamManagementFailed()));
+ onElementReceived(boost::make_shared<StreamManagementFailed>());
}
void sendBindResult() {
boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
resourceBind->setJID(JID("foo@bar.com/bla"));
boost::shared_ptr<IQ> iq = IQ::createResult(JID("foo@bar.com"), bindID, resourceBind);
onElementReceived(iq);
}
@@ -749,19 +749,19 @@ CPPUNIT_TEST_SUITE_REGISTRATION(ClientSessionTest);
void testReceiveElementAfterSessionStarted() {
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
getMockServer()->expectStreamStart();
getMockServer()->sendStreamStart();
getMockServer()->sendStreamFeatures();
session->startSession();
processEvents();
getMockServer()->expectMessage();
- session->sendElement(boost::shared_ptr<Message>(new Message()));
+ session->sendElement(boost::make_shared<Message>()));
}
void testSendElement() {
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
session->onElementReceived.connect(boost::bind(&ClientSessionTest::addReceivedElement, this, _1));
getMockServer()->expectStreamStart();
getMockServer()->sendStreamStart();
getMockServer()->sendStreamFeatures();
getMockServer()->sendMessage();
diff --git a/Swiften/Component/ComponentSession.cpp b/Swiften/Component/ComponentSession.cpp
index af11146..51d9d15 100644
--- a/Swiften/Component/ComponentSession.cpp
+++ b/Swiften/Component/ComponentSession.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Component/ComponentSession.h>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Elements/ProtocolHeader.h>
#include <Swiften/Elements/ComponentHandshake.h>
#include <Swiften/Session/SessionStream.h>
#include <Swiften/Component/ComponentHandshakeGenerator.h>
namespace Swift {
ComponentSession::ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> stream) : jid(jid), secret(secret), stream(stream), state(Initial) {
@@ -95,19 +96,19 @@ void ComponentSession::handleStreamClosed(boost::shared_ptr<Swift::Error> stream
onFinished(streamError);
}
}
void ComponentSession::finish() {
finishSession(boost::shared_ptr<Error>());
}
void ComponentSession::finishSession(Error::Type error) {
- finishSession(boost::shared_ptr<Swift::ComponentSession::Error>(new Swift::ComponentSession::Error(error)));
+ finishSession(boost::make_shared<Swift::ComponentSession::Error>(error));
}
void ComponentSession::finishSession(boost::shared_ptr<Swift::Error> finishError) {
state = Finishing;
error = finishError;
assert(stream->isOpen());
stream->writeFooter();
stream->close();
}
diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp
index 1541cce..9763c7f 100644
--- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp
@@ -20,19 +20,19 @@ using namespace Swift;
class ComponentSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ComponentSessionTest);
CPPUNIT_TEST(testStart);
CPPUNIT_TEST(testStart_Error);
CPPUNIT_TEST(testStart_Unauthorized);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
- server = boost::shared_ptr<MockSessionStream>(new MockSessionStream());
+ server = boost::make_shared<MockSessionStream>();
sessionFinishedReceived = false;
}
void testStart() {
boost::shared_ptr<ComponentSession> session(createSession());
session->start();
server->receiveStreamStart();
server->sendStreamStart();
server->receiveHandshake();
@@ -153,19 +153,19 @@ class ComponentSessionTest : public CppUnit::TestFixture {
virtual void setWhitespacePingEnabled(bool enabled) {
whitespacePingEnabled = enabled;
}
virtual void resetXMPPParser() {
resetCount++;
}
void breakConnection() {
- onClosed(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::ConnectionReadError)));
+ onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::ConnectionReadError));
}
void sendStreamStart() {
ProtocolHeader header;
header.setFrom("service.foo.com");
return onStreamStartReceived(header);
}
void sendHandshakeResponse() {
diff --git a/Swiften/Disco/DiscoInfoResponder.cpp b/Swiften/Disco/DiscoInfoResponder.cpp
index a8dd9f0..9e58bff 100644
--- a/Swiften/Disco/DiscoInfoResponder.cpp
+++ b/Swiften/Disco/DiscoInfoResponder.cpp
@@ -1,15 +1,17 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Disco/DiscoInfoResponder.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Elements/DiscoInfo.h>
namespace Swift {
DiscoInfoResponder::DiscoInfoResponder(IQRouter* router) : GetResponder<DiscoInfo>(router) {
}
@@ -24,24 +26,24 @@ void DiscoInfoResponder::setDiscoInfo(const DiscoInfo& info) {
void DiscoInfoResponder::setDiscoInfo(const std::string& node, const DiscoInfo& info) {
DiscoInfo newInfo(info);
newInfo.setNode(node);
nodeInfo_[node] = newInfo;
}
bool DiscoInfoResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<DiscoInfo> info) {
if (info->getNode().empty()) {
- sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(info_)));
+ sendResponse(from, id, boost::make_shared<DiscoInfo>(info_));
}
else {
std::map<std::string,DiscoInfo>::const_iterator i = nodeInfo_.find(info->getNode());
if (i != nodeInfo_.end()) {
- sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo((*i).second)));
+ sendResponse(from, id, boost::make_shared<DiscoInfo>((*i).second));
}
else {
sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
}
}
return true;
}
}
diff --git a/Swiften/Disco/GetDiscoInfoRequest.h b/Swiften/Disco/GetDiscoInfoRequest.h
index e211632..c9a4c97 100644
--- a/Swiften/Disco/GetDiscoInfoRequest.h
+++ b/Swiften/Disco/GetDiscoInfoRequest.h
@@ -1,35 +1,37 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Queries/GenericRequest.h>
#include <Swiften/Elements/DiscoInfo.h>
namespace Swift {
class GetDiscoInfoRequest : public GenericRequest<DiscoInfo> {
public:
typedef boost::shared_ptr<GetDiscoInfoRequest> ref;
static ref create(const JID& jid, IQRouter* router) {
return ref(new GetDiscoInfoRequest(jid, router));
}
static ref create(const JID& jid, const std::string& node, IQRouter* router) {
return ref(new GetDiscoInfoRequest(jid, node, router));
}
private:
GetDiscoInfoRequest(const JID& jid, IQRouter* router) :
- GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) {
+ GenericRequest<DiscoInfo>(IQ::Get, jid, boost::make_shared<DiscoInfo>(), router) {
}
GetDiscoInfoRequest(const JID& jid, const std::string& node, IQRouter* router) :
- GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) {
+ GenericRequest<DiscoInfo>(IQ::Get, jid, boost::make_shared<DiscoInfo>(), router) {
getPayloadGeneric()->setNode(node);
}
};
}
diff --git a/Swiften/Disco/GetDiscoItemsRequest.h b/Swiften/Disco/GetDiscoItemsRequest.h
index 20d18f8..c4ed579 100644
--- a/Swiften/Disco/GetDiscoItemsRequest.h
+++ b/Swiften/Disco/GetDiscoItemsRequest.h
@@ -1,35 +1,37 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Queries/GenericRequest.h>
#include <Swiften/Elements/DiscoItems.h>
namespace Swift {
class GetDiscoItemsRequest : public GenericRequest<DiscoItems> {
public:
typedef boost::shared_ptr<GetDiscoItemsRequest> ref;
static ref create(const JID& jid, IQRouter* router) {
return ref(new GetDiscoItemsRequest(jid, router));
}
static ref create(const JID& jid, const std::string& node, IQRouter* router) {
return ref(new GetDiscoItemsRequest(jid, node, router));
}
private:
GetDiscoItemsRequest(const JID& jid, IQRouter* router) :
- GenericRequest<DiscoItems>(IQ::Get, jid, boost::shared_ptr<DiscoItems>(new DiscoItems()), router) {
+ GenericRequest<DiscoItems>(IQ::Get, jid, boost::make_shared<DiscoItems>(), router) {
}
GetDiscoItemsRequest(const JID& jid, const std::string& node, IQRouter* router) :
- GenericRequest<DiscoItems>(IQ::Get, jid, boost::shared_ptr<DiscoItems>(new DiscoItems()), router) {
+ GenericRequest<DiscoItems>(IQ::Get, jid, boost::make_shared<DiscoItems>(), router) {
getPayloadGeneric()->setNode(node);
}
};
}
diff --git a/Swiften/Disco/JIDDiscoInfoResponder.cpp b/Swiften/Disco/JIDDiscoInfoResponder.cpp
index 0a25bef..4aed254 100644
--- a/Swiften/Disco/JIDDiscoInfoResponder.cpp
+++ b/Swiften/Disco/JIDDiscoInfoResponder.cpp
@@ -1,15 +1,17 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Disco/JIDDiscoInfoResponder.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Elements/DiscoInfo.h>
namespace Swift {
JIDDiscoInfoResponder::JIDDiscoInfoResponder(IQRouter* router) : GetResponder<DiscoInfo>(router) {
}
@@ -27,24 +29,24 @@ void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const std::string& node
DiscoInfo newInfo(discoInfo);
newInfo.setNode(node);
i->second.nodeDiscoInfo[node] = newInfo;
}
bool JIDDiscoInfoResponder::handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> discoInfo) {
JIDDiscoInfoMap::const_iterator i = info.find(to);
if (i != info.end()) {
if (discoInfo->getNode().empty()) {
- sendResponse(from, to, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(i->second.discoInfo)));
+ sendResponse(from, to, id, boost::make_shared<DiscoInfo>(i->second.discoInfo));
}
else {
std::map<std::string,DiscoInfo>::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode());
if (j != i->second.nodeDiscoInfo.end()) {
- sendResponse(from, to, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(j->second)));
+ sendResponse(from, to, id, boost::make_shared<DiscoInfo>(j->second));
}
else {
sendError(from, to, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
}
}
}
else {
sendError(from, to, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
}
diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
index 0681569..ca55c48 100644
--- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
@@ -39,28 +39,28 @@ class CapsManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testReconnectResetsRequests);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
stanzaChannel = new DummyStanzaChannel();
iqRouter = new IQRouter(stanzaChannel);
storage = new CapsMemoryStorage();
user1 = JID("user1@bar.com/bla");
- discoInfo1 = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ discoInfo1 = boost::make_shared<DiscoInfo>();
discoInfo1->addFeature("http://swift.im/feature1");
- capsInfo1 = boost::shared_ptr<CapsInfo>(new CapsInfo(CapsInfoGenerator("http://node1.im").generateCapsInfo(*discoInfo1.get())));
- capsInfo1alt = boost::shared_ptr<CapsInfo>(new CapsInfo(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo1.get())));
+ capsInfo1 = boost::make_shared<CapsInfo>(CapsInfoGenerator("http://node1.im").generateCapsInfo(*discoInfo1.get()));
+ capsInfo1alt = boost::make_shared<CapsInfo>(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo1.get()));
user2 = JID("user2@foo.com/baz");
- discoInfo2 = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ discoInfo2 = boost::make_shared<DiscoInfo>();
discoInfo2->addFeature("http://swift.im/feature2");
- capsInfo2 = boost::shared_ptr<CapsInfo>(new CapsInfo(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo2.get())));
+ capsInfo2 = boost::make_shared<CapsInfo>(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo2.get()));
user3 = JID("user3@foo.com/baz");
- legacyCapsInfo = boost::shared_ptr<CapsInfo>(new CapsInfo("http://swift.im", "ver1", ""));
+ legacyCapsInfo = boost::make_shared<CapsInfo>("http://swift.im", "ver1", "");
}
void tearDown() {
delete storage;
delete iqRouter;
delete stanzaChannel;
}
void testReceiveNewHashRequestsDisco() {
diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
index 7b61cb5..0fd966d 100644
--- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
@@ -28,28 +28,28 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testHashAvailable);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
stanzaChannel = new DummyStanzaChannel();
capsProvider = new DummyCapsProvider();
user1 = JID("user1@bar.com/bla");
- discoInfo1 = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ discoInfo1 = boost::make_shared<DiscoInfo>();
discoInfo1->addFeature("http://swift.im/feature1");
- capsInfo1 = boost::shared_ptr<CapsInfo>(new CapsInfo(CapsInfoGenerator("http://node1.im").generateCapsInfo(*discoInfo1.get())));
- capsInfo1alt = boost::shared_ptr<CapsInfo>(new CapsInfo(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo1.get())));
+ capsInfo1 = boost::make_shared<CapsInfo>(CapsInfoGenerator("http://node1.im").generateCapsInfo(*discoInfo1.get()));
+ capsInfo1alt = boost::make_shared<CapsInfo>(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo1.get()));
user2 = JID("user2@foo.com/baz");
- discoInfo2 = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
+ discoInfo2 = boost::make_shared<DiscoInfo>();
discoInfo2->addFeature("http://swift.im/feature2");
- capsInfo2 = boost::shared_ptr<CapsInfo>(new CapsInfo(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo2.get())));
+ capsInfo2 = boost::make_shared<CapsInfo>(CapsInfoGenerator("http://node2.im").generateCapsInfo(*discoInfo2.get()));
user3 = JID("user3@foo.com/baz");
- legacyCapsInfo = boost::shared_ptr<CapsInfo>(new CapsInfo("http://swift.im", "ver1", ""));
+ legacyCapsInfo = boost::make_shared<CapsInfo>("http://swift.im", "ver1", "");
}
void tearDown() {
delete capsProvider;
delete stanzaChannel;
}
void testReceiveKnownHash() {
boost::shared_ptr<EntityCapsManager> testling = createManager();
diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp
index 0319b52..4bb59b1 100644
--- a/Swiften/Elements/UnitTest/StanzaTest.cpp
+++ b/Swiften/Elements/UnitTest/StanzaTest.cpp
@@ -63,169 +63,169 @@ class StanzaTest : public CppUnit::TestFixture
(*alive_) = false;
}
private:
bool* alive_;
};
void testConstructor_Copy() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>());
Message copy(m);
CPPUNIT_ASSERT(copy.getPayload<MyPayload1>());
CPPUNIT_ASSERT(copy.getPayload<MyPayload2>());
}
void testDestructor() {
bool payloadAlive = true;
{
Message m;
- m.addPayload(boost::shared_ptr<DestroyingPayload>(new DestroyingPayload(&payloadAlive)));
+ m.addPayload(boost::make_shared<DestroyingPayload>(&payloadAlive));
}
CPPUNIT_ASSERT(!payloadAlive);
}
void testDestructor_Copy() {
bool payloadAlive = true;
Message* m1 = new Message();
- m1->addPayload(boost::shared_ptr<DestroyingPayload>(new DestroyingPayload(&payloadAlive)));
+ m1->addPayload(boost::make_shared<DestroyingPayload>(&payloadAlive));
Message* m2 = new Message(*m1);
delete m1;
CPPUNIT_ASSERT(payloadAlive);
delete m2;
CPPUNIT_ASSERT(!payloadAlive);
}
void testGetPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>());
+ m.addPayload(boost::make_shared<MyPayload3>());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT(p);
}
void testGetPayload_NoSuchPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload3>());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT(!p);
}
void testGetPayloads() {
Message m;
boost::shared_ptr<MyPayload2> payload1(new MyPayload2());
boost::shared_ptr<MyPayload2> payload2(new MyPayload2());
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
+ m.addPayload(boost::make_shared<MyPayload1>());
m.addPayload(payload1);
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload3>());
m.addPayload(payload2);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m.getPayloads<MyPayload2>().size());
CPPUNIT_ASSERT_EQUAL(payload1, m.getPayloads<MyPayload2>()[0]);
CPPUNIT_ASSERT_EQUAL(payload2, m.getPayloads<MyPayload2>()[1]);
}
void testUpdatePayload_ExistingPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2("foo")));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>("foo"));
+ m.addPayload(boost::make_shared<MyPayload3>());
- m.updatePayload(boost::shared_ptr<MyPayload2>(new MyPayload2("bar")));
+ m.updatePayload(boost::make_shared<MyPayload2>("bar"));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT_EQUAL(std::string("bar"), p->text_);
}
void testUpdatePayload_NewPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload3>());
- m.updatePayload(boost::shared_ptr<MyPayload2>(new MyPayload2("bar")));
+ m.updatePayload(boost::make_shared<MyPayload2>("bar"));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT_EQUAL(std::string("bar"), p->text_);
}
void testGetPayloadOfSameType() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2("foo")));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>("foo"));
+ m.addPayload(boost::make_shared<MyPayload3>());
- boost::shared_ptr<MyPayload2> payload(boost::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(boost::shared_ptr<MyPayload2>(new MyPayload2("bar")))));
+ boost::shared_ptr<MyPayload2> payload(boost::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(boost::make_shared<MyPayload2>("bar"))));
CPPUNIT_ASSERT(payload);
CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->text_);
}
void testGetPayloadOfSameType_NoSuchPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload3>());
- CPPUNIT_ASSERT(!m.getPayloadOfSameType(boost::shared_ptr<MyPayload2>(new MyPayload2("bar"))));
+ CPPUNIT_ASSERT(!m.getPayloadOfSameType(boost::make_shared<MyPayload2>("bar")));
}
void testGetTimestamp() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1)));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestamp();
CPPUNIT_ASSERT(timestamp);
CPPUNIT_ASSERT_EQUAL(std::string("1970-Jan-01 00:00:01"), boost::posix_time::to_simple_string(*timestamp));
}
void testGetTimestamp_TimestampWithFrom() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1), JID("foo@bar.com"))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestamp();
CPPUNIT_ASSERT(timestamp);
CPPUNIT_ASSERT_EQUAL(std::string("1970-Jan-01 00:00:01"), boost::posix_time::to_simple_string(*timestamp));
}
void testGetTimestamp_NoDelay() {
Message m;
CPPUNIT_ASSERT(!m.getTimestamp());
}
void testGetTimestampFrom() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(0))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1), JID("foo1@bar.com"))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(2), JID("foo2@bar.com"))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(3), JID("foo3@bar.com"))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(0)));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo1@bar.com")));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(2), JID("foo2@bar.com")));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(3), JID("foo3@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestampFrom(JID("foo2@bar.com"));
CPPUNIT_ASSERT(timestamp);
CPPUNIT_ASSERT_EQUAL(std::string("1970-Jan-01 00:00:02"), boost::posix_time::to_simple_string(*timestamp));
}
void testGetTimestampFrom_Fallsback() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1), JID("foo1@bar.com"))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(3), JID("foo3@bar.com"))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo1@bar.com")));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(3), JID("foo3@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestampFrom(JID("foo2@bar.com"));
CPPUNIT_ASSERT(timestamp);
CPPUNIT_ASSERT_EQUAL(std::string("1970-Jan-01 00:00:01"), boost::posix_time::to_simple_string(*timestamp));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(StanzaTest);
diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp
index 9b2105b..df3cea4 100644
--- a/Swiften/Examples/SendFile/SendFile.cpp
+++ b/Swiften/Examples/SendFile/SendFile.cpp
@@ -73,19 +73,19 @@ class FileSender {
// gather file information
/*StreamInitiationFileInfo fileInfo;
fileInfo.setName(file.filename());
fileInfo.setSize(boost::filesystem::file_size(file));
fileInfo.setDescription("Some file!");
fileInfo.setDate(boost::posix_time::from_time_t(boost::filesystem::last_write_time(file)));*/
//fileInfo.setHash(Hexify::hexify(MD5::getHash(fileData)));
/*
- transfer = new OutgoingSIFileTransfer("myid", client->getJID(), recipient, file.filename(), boost::filesystem::file_size(file), "A file", boost::shared_ptr<FileReadBytestream>(new FileReadBytestream(file)), client->getIQRouter(), socksBytestreamServer);
+ transfer = new OutgoingSIFileTransfer("myid", client->getJID(), recipient, file.filename(), boost::filesystem::file_size(file), "A file", boost::make_shared<FileReadBytestream>(file)), client->getIQRouter(), socksBytestreamServer);
transfer->onFinished.connect(boost::bind(&FileSender::handleFileTransferFinished, this, _1));
transfer->start();
*/
}
void handleCapsChanged(JID jid) {
if (jid.toBare() == recipient) {
// create ReadBytestream from file
boost::shared_ptr<FileReadBytestream> fileStream = boost::make_shared<FileReadBytestream>(file);
diff --git a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
index 8a8237a..fc0a551 100644
--- a/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingSIFileTransfer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/FileTransfer/OutgoingSIFileTransfer.h>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/FileTransfer/StreamInitiationRequest.h>
#include <Swiften/FileTransfer/BytestreamsRequest.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
#include <Swiften/FileTransfer/IBBSendSession.h>
namespace Swift {
OutgoingSIFileTransfer::OutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) {
@@ -42,19 +43,19 @@ void OutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamInitiat
Bytestreams::ref bytestreams(new Bytestreams());
bytestreams->setStreamID(id);
HostAddressPort addressPort = socksServer->getAddressPort();
bytestreams->addStreamHost(Bytestreams::StreamHost(addressPort.getAddress().toString(), from, addressPort.getPort()));
BytestreamsRequest::ref request = BytestreamsRequest::create(to, bytestreams, iqRouter);
request->onResponse.connect(boost::bind(&OutgoingSIFileTransfer::handleBytestreamsRequestResponse, this, _1, _2));
request->send();
}
else if (response->getRequestedMethod() == "http://jabber.org/protocol/ibb") {
- ibbSession = boost::shared_ptr<IBBSendSession>(new IBBSendSession(id, from, to, bytestream, iqRouter));
+ ibbSession = boost::make_shared<IBBSendSession>(id, from, to, bytestream, iqRouter);
ibbSession->onFinished.connect(boost::bind(&OutgoingSIFileTransfer::handleIBBSessionFinished, this, _1));
ibbSession->start();
}
}
}
void OutgoingSIFileTransfer::handleBytestreamsRequestResponse(Bytestreams::ref, ErrorPayload::ref error) {
if (error) {
finish(FileTransferError());
diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
index d12f99e..13b73bb 100644
--- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
@@ -31,19 +31,19 @@ class IBBSendSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testDataStreamResumeBeforePauseDoesNotSendData);
CPPUNIT_TEST(testDataStreamResumeAfterResumeDoesNotSendData);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
stanzaChannel = new DummyStanzaChannel();
iqRouter = new IQRouter(stanzaChannel);
- bytestream = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg")));
+ bytestream = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"));
finished = false;
}
void tearDown() {
delete iqRouter;
delete stanzaChannel;
}
void testStart() {
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 527e0ca..bb0d9b6 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -51,19 +51,19 @@ public:
SOCKS5BytestreamClientSessionTest() : destinationAddressPort(HostAddressPort(HostAddress("127.0.0.1"), 8888)),
destination(SOCKS5BytestreamRegistry::getHostname("foo", JID("requester@example.com/test"), JID("target@example.com/test"))), eventLoop(NULL), timerFactory(NULL) { }
void setUp() {
randomGen.seed(time(NULL));
eventLoop = new DummyEventLoop();
timerFactory = new DummyTimerFactory();
connection = boost::make_shared<MockeryConnection>(failingPorts, true, eventLoop);
//connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
- //stream1 = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg")));
+ //stream1 = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")));
// connection->onDataRead.connect(boost::bind(&SOCKS5BytestreamClientSessionTest::handleDataRead, this, _1));
}
void tearDown() {
//connection.reset();
delete timerFactory;
delete eventLoop;
}
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
index 4fe72c0..e6df862 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
@@ -29,21 +29,21 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testReceiveData);
CPPUNIT_TEST(testReceiveData_Chunked);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
receivedDataChunks = 0;
eventLoop = new DummyEventLoop();
bytestreams = new SOCKS5BytestreamRegistry();
- connection = boost::shared_ptr<DummyConnection>(new DummyConnection(eventLoop));
+ connection = boost::make_shared<DummyConnection>(eventLoop);
connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
- stream1 = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg")));
+ stream1 = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"));
}
void tearDown() {
connection.reset();
delete bytestreams;
delete eventLoop;
}
void testAuthenticate() {
diff --git a/Swiften/LinkLocal/IncomingLinkLocalSession.cpp b/Swiften/LinkLocal/IncomingLinkLocalSession.cpp
index b89de81..610b28b 100644
--- a/Swiften/LinkLocal/IncomingLinkLocalSession.cpp
+++ b/Swiften/LinkLocal/IncomingLinkLocalSession.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/LinkLocal/IncomingLinkLocalSession.h>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Elements/ProtocolHeader.h>
#include <Swiften/Network/Connection.h>
#include <Swiften/StreamStack/StreamStack.h>
#include <Swiften/StreamStack/ConnectionLayer.h>
#include <Swiften/StreamStack/XMPPLayer.h>
#include <Swiften/Elements/StreamFeatures.h>
#include <Swiften/Elements/IQ.h>
@@ -35,19 +36,19 @@ void IncomingLinkLocalSession::handleStreamStart(const ProtocolHeader& incomingH
finishSession();
return;
}
ProtocolHeader header;
header.setFrom(getLocalJID());
getXMPPLayer()->writeHeader(header);
if (incomingHeader.getVersion() == "1.0") {
- getXMPPLayer()->writeElement(boost::shared_ptr<StreamFeatures>(new StreamFeatures()));
+ getXMPPLayer()->writeElement(boost::make_shared<StreamFeatures>());
}
else {
setInitialized();
}
}
void IncomingLinkLocalSession::handleElement(boost::shared_ptr<Element> element) {
boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element);
// If we get our first stanza before streamfeatures, our session is implicitly
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
index 474c772..dd5e884 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
@@ -25,21 +25,20 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testConnect_UnableToResolve);
CPPUNIT_TEST(testConnect_UnableToConnect);
CPPUNIT_TEST(testCancel_DuringResolve);
CPPUNIT_TEST(testCancel_DuringConnect);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
eventLoop = new DummyEventLoop();
- querier = boost::shared_ptr<FakeDNSSDQuerier>(
- new FakeDNSSDQuerier("rabbithole.local", eventLoop));
- connection = boost::shared_ptr<FakeConnection>(new FakeConnection(eventLoop));
+ querier = boost::make_shared<FakeDNSSDQuerier>("rabbithole.local", eventLoop);
+ connection = boost::make_shared<FakeConnection>(eventLoop);
connectFinished = false;
}
void tearDown() {
querier->clearAllQueriesEverRun();
delete eventLoop;
}
void testConnect() {
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
index c0fd248..93deea5 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <map>
#include <Swiften/LinkLocal/LinkLocalServiceBrowser.h>
#include <Swiften/LinkLocal/LinkLocalService.h>
#include <Swiften/LinkLocal/DNSSD/DNSSDServiceID.h>
#include <Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h>
#include <Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h>
#include <Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h>
#include <Swiften/EventLoop/DummyEventLoop.h>
@@ -36,19 +37,19 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testRegisterService);
CPPUNIT_TEST(testRegisterService_Error);
CPPUNIT_TEST(testRegisterService_Reregister);
CPPUNIT_TEST(testUpdateService);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
eventLoop = new DummyEventLoop();
- querier = boost::shared_ptr<FakeDNSSDQuerier>(new FakeDNSSDQuerier("wonderland.lit", eventLoop));
+ querier = boost::make_shared<FakeDNSSDQuerier>("wonderland.lit", eventLoop);
aliceServiceID = new DNSSDServiceID("alice", "wonderland.lit");
aliceServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.wonderland.lit", "xmpp.wonderland.lit", 1234, LinkLocalServiceInfo().toTXTRecord());
testServiceID = new DNSSDServiceID("foo", "bar.local");
testServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.bar.local", "xmpp.bar.local", 1234, LinkLocalServiceInfo().toTXTRecord());
testServiceInfo2 = new DNSSDResolveServiceQuery::Result("_presence.tcp.bar.local", "xmpp.foo.local", 2345, LinkLocalServiceInfo().toTXTRecord());
errorStopReceived = false;
normalStopReceived = false;
}
diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp
index 643a8c4..8a63745 100644
--- a/Swiften/MUC/MUCBookmarkManager.cpp
+++ b/Swiften/MUC/MUCBookmarkManager.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "MUCBookmarkManager.h"
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <iostream>
#include <Swiften/Base/foreach.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Queries/Requests/GetPrivateStorageRequest.h>
#include <Swiften/Queries/Requests/SetPrivateStorageRequest.h>
namespace Swift {
@@ -92,19 +93,19 @@ void MUCBookmarkManager::removeBookmark(const MUCBookmark& bookmark) {
onBookmarkRemoved(bookmark);
break;
}
}
flush();
}
void MUCBookmarkManager::flush() {
if (!storage) {
- storage = boost::shared_ptr<Storage>(new Storage());
+ storage = boost::make_shared<Storage>();
}
// Update the storage element
storage->clearRooms();
foreach(const MUCBookmark& bookmark, bookmarks_) {
storage->addRoom(bookmark.toStorage());
}
// Send an iq to save the storage element
SetPrivateStorageRequest<Storage>::ref request = SetPrivateStorageRequest<Storage>::create(storage, iqRouter_);
diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
index e90573f..922a00e 100644
--- a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
+++ b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp
@@ -1,15 +1,17 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h>
#include <Swiften/Parser/PayloadParsers/SecurityLabelParserFactory.h>
#include <Swiften/Parser/PayloadParsers/SecurityLabelParser.h>
namespace Swift {
SecurityLabelsCatalogParser::SecurityLabelsCatalogParser() : level_(TopLevel), labelParser_(0) {
labelParserFactory_ = new SecurityLabelParserFactory();
}
@@ -20,19 +22,19 @@ SecurityLabelsCatalogParser::~SecurityLabelsCatalogParser() {
void SecurityLabelsCatalogParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
++level_;
if (level_ == PayloadLevel) {
getPayloadInternal()->setTo(JID(attributes.getAttribute("to")));
getPayloadInternal()->setName(attributes.getAttribute("name"));
getPayloadInternal()->setDescription(attributes.getAttribute("desc"));
}
else if (level_ == ItemLevel && element == "item" && ns == "urn:xmpp:sec-label:catalog:2") {
- currentItem_ = boost::shared_ptr<SecurityLabelsCatalog::Item>(new SecurityLabelsCatalog::Item());
+ currentItem_ = boost::make_shared<SecurityLabelsCatalog::Item>();
currentItem_->setSelector(attributes.getAttribute("selector"));
currentItem_->setIsDefault(attributes.getBoolAttribute("default", false));
}
else if (level_ == LabelLevel) {
assert(!labelParser_);
if (labelParserFactory_->canParse(element, ns, attributes)) {
labelParser_ = dynamic_cast<SecurityLabelParser*>(labelParserFactory_->createPayloadParser());
assert(labelParser_);
}
diff --git a/Swiften/Parser/UnitTest/StanzaParserTest.cpp b/Swiften/Parser/UnitTest/StanzaParserTest.cpp
index b2ddb39..88e6dec 100644
--- a/Swiften/Parser/UnitTest/StanzaParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StanzaParserTest.cpp
@@ -187,19 +187,19 @@ class StanzaParserTest : public CppUnit::TestFixture {
public:
MyStanza() {}
};
class MyStanzaParser : public StanzaParser
{
public:
MyStanzaParser(PayloadParserFactoryCollection* collection) : StanzaParser(collection)
{
- stanza_ = boost::shared_ptr<MyStanza>(new MyStanza());
+ stanza_ = boost::make_shared<MyStanza>();
}
virtual boost::shared_ptr<Element> getElement() const {
return stanza_;
}
private:
boost::shared_ptr<MyStanza> stanza_;
};
diff --git a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
index 5b385c2..0da78e6 100644
--- a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
+++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
@@ -22,21 +22,21 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testAddDirectedPresenceReceiver_WithoutSendingPresence);
CPPUNIT_TEST(testAddDirectedPresenceReceiver_AfterSendingDirectedPresence);
CPPUNIT_TEST(testRemoveDirectedPresenceReceiver);
CPPUNIT_TEST(testRemoveDirectedPresenceReceiver_WithoutSendingPresence);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
channel = new DummyStanzaChannel();
- testPresence = boost::shared_ptr<Presence>(new Presence());
+ testPresence = boost::make_shared<Presence>();
testPresence->setStatus("Foo");
- secondTestPresence = boost::shared_ptr<Presence>(new Presence());
+ secondTestPresence = boost::make_shared<Presence>();
secondTestPresence->setStatus("Bar");
stanzaChannelPresenceSender = new StanzaChannelPresenceSender(channel);
}
void tearDown() {
delete stanzaChannelPresenceSender;
delete channel;
}
diff --git a/Swiften/Queries/Requests/GetPrivateStorageRequest.h b/Swiften/Queries/Requests/GetPrivateStorageRequest.h
index b0eefb2..b5fd97f 100644
--- a/Swiften/Queries/Requests/GetPrivateStorageRequest.h
+++ b/Swiften/Queries/Requests/GetPrivateStorageRequest.h
@@ -2,35 +2,36 @@
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <Swiften/Base/boost_bsignals.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Queries/Request.h>
#include <Swiften/Elements/PrivateStorage.h>
#include <Swiften/Elements/ErrorPayload.h>
namespace Swift {
template<typename PAYLOAD_TYPE>
class GetPrivateStorageRequest : public Request {
public:
typedef boost::shared_ptr<GetPrivateStorageRequest<PAYLOAD_TYPE> > ref;
static ref create(IQRouter* router) {
return ref(new GetPrivateStorageRequest(router));
}
private:
- GetPrivateStorageRequest(IQRouter* router) : Request(IQ::Get, JID(), boost::shared_ptr<PrivateStorage>(new PrivateStorage(boost::shared_ptr<Payload>(new PAYLOAD_TYPE()))), router) {
+ GetPrivateStorageRequest(IQRouter* router) : Request(IQ::Get, JID(), boost::make_shared<PrivateStorage>(boost::shared_ptr<Payload>(new PAYLOAD_TYPE())), router) {
}
virtual void handleResponse(boost::shared_ptr<Payload> payload, ErrorPayload::ref error) {
boost::shared_ptr<PrivateStorage> storage = boost::dynamic_pointer_cast<PrivateStorage>(payload);
if (storage) {
onResponse(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(storage->getPayload()), error);
}
else {
onResponse(boost::shared_ptr<PAYLOAD_TYPE>(), error);
diff --git a/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h b/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h
index a6f782b..943adef 100644
--- a/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h
+++ b/Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h
@@ -1,30 +1,32 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Queries/GenericRequest.h>
#include <Swiften/Elements/SecurityLabelsCatalog.h>
namespace Swift {
class GetSecurityLabelsCatalogRequest : public GenericRequest<SecurityLabelsCatalog> {
public:
typedef boost::shared_ptr<GetSecurityLabelsCatalogRequest> ref;
static ref create(const JID& recipient, IQRouter* router) {
return ref(new GetSecurityLabelsCatalogRequest(recipient, router));
}
private:
GetSecurityLabelsCatalogRequest(
const JID& recipient,
IQRouter* router) :
GenericRequest<SecurityLabelsCatalog>(
- IQ::Get, JID(), boost::shared_ptr<SecurityLabelsCatalog>(new SecurityLabelsCatalog(recipient)), router) {
+ IQ::Get, JID(), boost::make_shared<SecurityLabelsCatalog>(recipient), router) {
}
};
}
diff --git a/Swiften/Queries/Requests/SetPrivateStorageRequest.h b/Swiften/Queries/Requests/SetPrivateStorageRequest.h
index f795742..f65f819 100644
--- a/Swiften/Queries/Requests/SetPrivateStorageRequest.h
+++ b/Swiften/Queries/Requests/SetPrivateStorageRequest.h
@@ -2,35 +2,36 @@
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <Swiften/Base/boost_bsignals.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Queries/Request.h>
#include <Swiften/Elements/PrivateStorage.h>
#include <Swiften/Elements/ErrorPayload.h>
namespace Swift {
template<typename PAYLOAD_TYPE>
class SetPrivateStorageRequest : public Request {
public:
typedef boost::shared_ptr<SetPrivateStorageRequest<PAYLOAD_TYPE> > ref;
static ref create(boost::shared_ptr<PAYLOAD_TYPE> payload, IQRouter* router) {
return ref(new SetPrivateStorageRequest<PAYLOAD_TYPE>(payload, router));
}
private:
- SetPrivateStorageRequest(boost::shared_ptr<PAYLOAD_TYPE> payload, IQRouter* router) : Request(IQ::Set, JID(), boost::shared_ptr<PrivateStorage>(new PrivateStorage(payload)), router) {
+ SetPrivateStorageRequest(boost::shared_ptr<PAYLOAD_TYPE> payload, IQRouter* router) : Request(IQ::Set, JID(), boost::make_shared<PrivateStorage>(payload), router) {
}
virtual void handleResponse(boost::shared_ptr<Payload>, ErrorPayload::ref error) {
onResponse(error);
}
public:
boost::signal<void (ErrorPayload::ref)> onResponse;
};
diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp
index 3f9616a..55328fb 100644
--- a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp
+++ b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp
@@ -1,26 +1,28 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Queries/Responders/SoftwareVersionResponder.h>
#include <Swiften/Queries/IQRouter.h>
namespace Swift {
SoftwareVersionResponder::SoftwareVersionResponder(IQRouter* router) : GetResponder<SoftwareVersion>(router) {
}
void SoftwareVersionResponder::setVersion(const std::string& client, const std::string& version, const std::string& os) {
this->client = client;
this->version = version;
this->os = os;
}
bool SoftwareVersionResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<SoftwareVersion>) {
- sendResponse(from, id, boost::shared_ptr<SoftwareVersion>(new SoftwareVersion(client, version, os)));
+ sendResponse(from, id, boost::make_shared<SoftwareVersion>(client, version, os));
return true;
}
}
diff --git a/Swiften/Queries/UnitTest/IQRouterTest.cpp b/Swiften/Queries/UnitTest/IQRouterTest.cpp
index f06b967..ee27a67 100644
--- a/Swiften/Queries/UnitTest/IQRouterTest.cpp
+++ b/Swiften/Queries/UnitTest/IQRouterTest.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/bind.hpp>
#include <Swiften/Queries/IQHandler.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Queries/DummyIQChannel.h>
using namespace Swift;
class IQRouterTest : public CppUnit::TestFixture {
@@ -37,107 +38,107 @@ class IQRouterTest : public CppUnit::TestFixture {
delete channel_;
}
void testRemoveHandler() {
IQRouter testling(channel_);
DummyIQHandler handler1(true, &testling);
DummyIQHandler handler2(true, &testling);
testling.removeHandler(&handler1);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(0, handler1.called);
CPPUNIT_ASSERT_EQUAL(1, handler2.called);
}
void testRemoveHandler_AfterHandleIQ() {
IQRouter testling(channel_);
DummyIQHandler handler2(true, &testling);
DummyIQHandler handler1(true, &testling);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
testling.removeHandler(&handler1);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(1, handler1.called);
CPPUNIT_ASSERT_EQUAL(1, handler2.called);
}
void testHandleIQ_SuccesfulHandlerFirst() {
IQRouter testling(channel_);
DummyIQHandler handler2(false, &testling);
DummyIQHandler handler1(true, &testling);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(1, handler1.called);
CPPUNIT_ASSERT_EQUAL(0, handler2.called);
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(channel_->iqs_.size()));
}
void testHandleIQ_SuccesfulHandlerLast() {
IQRouter testling(channel_);
DummyIQHandler handler2(true, &testling);
DummyIQHandler handler1(false, &testling);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(1, handler1.called);
CPPUNIT_ASSERT_EQUAL(1, handler2.called);
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(channel_->iqs_.size()));
}
void testHandleIQ_NoSuccesfulHandler() {
IQRouter testling(channel_);
DummyIQHandler handler(false, &testling);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
CPPUNIT_ASSERT(channel_->iqs_[0]->getPayload<ErrorPayload>());
}
void testHandleIQ_HandlerRemovedDuringHandle() {
IQRouter testling(channel_);
DummyIQHandler handler2(true, &testling);
RemovingIQHandler handler1(&testling);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(1, handler1.called);
CPPUNIT_ASSERT_EQUAL(2, handler2.called);
}
void testSendIQ_WithFrom() {
IQRouter testling(channel_);
testling.setFrom(JID("foo@bar.com/baz"));
- testling.sendIQ(boost::shared_ptr<IQ>(new IQ()));
+ testling.sendIQ(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom());
}
void testSendIQ_WithoutFrom() {
IQRouter testling(channel_);
- testling.sendIQ(boost::shared_ptr<IQ>(new IQ()));
+ testling.sendIQ(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(JID(), channel_->iqs_[0]->getFrom());
}
void testHandleIQ_WithFrom() {
IQRouter testling(channel_);
testling.setFrom(JID("foo@bar.com/baz"));
DummyIQHandler handler(false, &testling);
- channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ()));
+ channel_->onIQReceived(boost::make_shared<IQ>());
CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom());
}
private:
struct DummyIQHandler : public IQHandler {
DummyIQHandler(bool handle, IQRouter* router) : handle(handle), router(router), called(0) {
router->addHandler(this);
}
diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp
index 52d62fb..cf9b381 100644
--- a/Swiften/Queries/UnitTest/RequestTest.cpp
+++ b/Swiften/Queries/UnitTest/RequestTest.cpp
@@ -124,19 +124,19 @@ class RequestTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
}
void testHandleIQ_Error() {
MyRequest testling(IQ::Get, JID("foo@bar.com/baz"), payload_, router_);
testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2));
testling.send();
boost::shared_ptr<IQ> error = createError(JID("foo@bar.com/baz"),"test-id");
- boost::shared_ptr<Payload> errorPayload = boost::shared_ptr<ErrorPayload>(new ErrorPayload(ErrorPayload::InternalServerError));
+ boost::shared_ptr<Payload> errorPayload = boost::make_shared<ErrorPayload>(ErrorPayload::InternalServerError);
error->addPayload(errorPayload);
channel_->onIQReceived(error);
CPPUNIT_ASSERT_EQUAL(0, responsesReceived_);
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(receivedErrors.size()));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
CPPUNIT_ASSERT_EQUAL(ErrorPayload::InternalServerError, receivedErrors[0].getCondition());
}
diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp
index a256346..6d40b6c 100644
--- a/Swiften/Queries/UnitTest/ResponderTest.cpp
+++ b/Swiften/Queries/UnitTest/ResponderTest.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/bind.hpp>
#include <Swiften/Queries/Responder.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Queries/DummyIQChannel.h>
#include <Swiften/Elements/SoftwareVersion.h>
using namespace Swift;
@@ -26,19 +27,19 @@ class ResponderTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testHandleIQ_Error);
CPPUNIT_TEST(testHandleIQ_Result);
CPPUNIT_TEST(testHandleIQ_NoPayload);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
channel_ = new DummyIQChannel();
router_ = new IQRouter(channel_);
- payload_ = boost::shared_ptr<SoftwareVersion>(new SoftwareVersion("foo"));
+ payload_ = boost::make_shared<SoftwareVersion>("foo");
}
void tearDown() {
delete router_;
delete channel_;
}
void testConstructor() {
MyResponder testling(router_);
@@ -102,19 +103,19 @@ class ResponderTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(createRequest(IQ::Result)));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.getPayloads_.size()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.setPayloads_.size()));
}
void testHandleIQ_NoPayload() {
MyResponder testling(router_);
- CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(boost::shared_ptr<IQ>(new IQ(IQ::Get))));
+ CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(boost::make_shared<IQ>(IQ::Get)));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.getPayloads_.size()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.setPayloads_.size()));
}
private:
boost::shared_ptr<IQ> createRequest(IQ::Type type) {
boost::shared_ptr<IQ> iq(new IQ(type));
iq->addPayload(payload_);
diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp
index 2fb86b0..40acd8e 100644
--- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/CommandSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
namespace Swift {
@@ -48,39 +49,39 @@ std::string CommandSerializer::serializePayload(boost::shared_ptr<Command> comma
std::string executeAction = actionToString(command->getExecuteAction());
if (!executeAction.empty()) {
actions += " execute='" + executeAction + "'";
}
actions += ">";
foreach (Command::Action action, command->getAvailableActions()) {
actions += "<" + actionToString(action) + "/>";
}
actions += "</actions>";
- commandElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(actions)));
+ commandElement.addNode(boost::make_shared<XMLRawTextNode>(actions));
}
foreach (Command::Note note, command->getNotes()) {
boost::shared_ptr<XMLElement> noteElement(new XMLElement("note"));
std::string type;
switch (note.type) {
case Command::Note::Info: type = "info"; break;
case Command::Note::Warn: type = "warn"; break;
case Command::Note::Error: type = "error"; break;
}
if (!type.empty()) {
noteElement->setAttribute("type", type);
}
- noteElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(note.note)));
+ noteElement->addNode(boost::make_shared<XMLTextNode>(note.note));
commandElement.addNode(noteElement);
}
Form::ref form = command->getForm();
if (form) {
- commandElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form))));
+ commandElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
}
return commandElement.serialize();
}
std::string CommandSerializer::actionToString(Command::Action action) const {
std::string string;
switch (action) {
case Command::Cancel: string = "cancel"; break;
case Command::Execute: string = "execute"; break;
diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp
index e2c6f59..03b3eb2 100644
--- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
namespace Swift {
DiscoInfoSerializer::DiscoInfoSerializer() : GenericPayloadSerializer<DiscoInfo>() {
@@ -33,15 +34,15 @@ std::string DiscoInfoSerializer::serializePayload(boost::shared_ptr<DiscoInfo> d
identityElement->setAttribute("type", identity.getType());
queryElement.addNode(identityElement);
}
foreach(const std::string& feature, discoInfo->getFeatures()) {
boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature"));
featureElement->setAttribute("var", feature);
queryElement.addNode(featureElement);
}
foreach(const Form::ref extension, discoInfo->getExtensions()) {
- queryElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(extension))));
+ queryElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(extension)));
}
return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
index 15c4f32..ba658e3 100644
--- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <iostream>
#include <string>
#include <Swiften/Base/String.h>
#include <Swiften/Base/Algorithm.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
@@ -75,23 +76,23 @@ std::string FormSerializer::serializePayload(boost::shared_ptr<Form> form) cons
boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormField> field, bool withTypeAttribute) const {
boost::shared_ptr<XMLElement> fieldElement(new XMLElement("field"));
if (!field->getName().empty()) {
fieldElement->setAttribute("var", field->getName());
}
if (!field->getLabel().empty()) {
fieldElement->setAttribute("label", field->getLabel());
}
if (field->getRequired()) {
- fieldElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("required")));
+ fieldElement->addNode(boost::make_shared<XMLElement>("required"));
}
if (!field->getDescription().empty()) {
boost::shared_ptr<XMLElement> descriptionElement(new XMLElement("desc"));
- descriptionElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(field->getDescription())));
+ descriptionElement->addNode(boost::make_shared<XMLTextNode>(field->getDescription()));
fieldElement->addNode(descriptionElement);
}
// Set the value and type
std::string fieldType;
if (boost::dynamic_pointer_cast<BooleanFormField>(field)) {
fieldType = "boolean";
boost::shared_ptr<XMLElement> valueElement(new XMLElement("value"));
valueElement->addNode(XMLTextNode::create(boost::dynamic_pointer_cast<BooleanFormField>(field)->getValue() ? "1" : "0"));
@@ -168,15 +169,15 @@ boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormF
return fieldElement;
}
void FormSerializer::multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr<XMLElement> element) const {
std::string unRdText(text);
erase(unRdText, '\r');
std::vector<std::string> lines = String::split(unRdText, '\n');
foreach (std::string line, lines) {
boost::shared_ptr<XMLElement> lineElement(new XMLElement(elementName));
- lineElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(line)));
+ lineElement->addNode(boost::make_shared<XMLTextNode>(line));
element->addNode(lineElement);
}
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp
index f3dad80..e78cdb4 100644
--- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/IBBSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/lexical_cast.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/StringCodecs/Base64.h>
namespace Swift {
@@ -21,19 +22,19 @@ IBBSerializer::IBBSerializer() {
std::string IBBSerializer::serializePayload(boost::shared_ptr<IBB> ibb) const {
switch(ibb->getAction()) {
case IBB::Data: {
XMLElement ibbElement("data", "http://jabber.org/protocol/ibb");
ibbElement.setAttribute("sid", ibb->getStreamID());
if (ibb->getSequenceNumber() >= 0) {
ibbElement.setAttribute("seq", boost::lexical_cast<std::string>(ibb->getSequenceNumber()));
}
- ibbElement.addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(Base64::encode(ibb->getData()))));
+ ibbElement.addNode(boost::make_shared<XMLTextNode>(Base64::encode(ibb->getData())));
return ibbElement.serialize();
}
case IBB::Open: {
XMLElement ibbElement("open", "http://jabber.org/protocol/ibb");
ibbElement.setAttribute("sid", ibb->getStreamID());
switch (ibb->getStanzaType()) {
case IBB::IQStanza: ibbElement.setAttribute("stanza", "iq"); break;
case IBB::MessageStanza: ibbElement.setAttribute("stanza", "message"); break;
}
diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
index 12b1bb5..0db546e 100644
--- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
namespace Swift {
InBandRegistrationPayloadSerializer::InBandRegistrationPayloadSerializer() {
@@ -97,16 +98,16 @@ std::string InBandRegistrationPayloadSerializer::serializePayload(boost::shared_
if (registration->getText()) {
registerElement.addNode(XMLElement::ref(new XMLElement("text", "", *registration->getText())));
}
if (registration->getKey()) {
registerElement.addNode(XMLElement::ref(new XMLElement("key", "", *registration->getKey())));
}
if (Form::ref form = registration->getForm()) {
- registerElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form))));
+ registerElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
}
return registerElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp
index c16a2e4..a04687b 100644
--- a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp
@@ -37,19 +37,19 @@ std::string JinglePayloadSerializer::serializePayload(boost::shared_ptr<JinglePa
jinglePayload.setAttribute("action", actionToString(payload->getAction()));
jinglePayload.setAttribute("initiator", payload->getInitiator());
jinglePayload.setAttribute("sid", payload->getSessionID());
std::vector<boost::shared_ptr<Payload> > payloads = payload->getPayloads();
if (!payloads.empty()) {
foreach(boost::shared_ptr<Payload> subPayload, payloads) {
PayloadSerializer* serializer = serializers->getPayloadSerializer(subPayload);
if (serializer) {
- jinglePayload.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializer->serialize(subPayload))));
+ jinglePayload.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(subPayload)));
}
}
}
if (payload->getReason().is_initialized()) {
boost::shared_ptr<XMLElement> reason = boost::make_shared<XMLElement>("reason");
reason->addNode(boost::make_shared<XMLElement>(reasonTypeToString(payload->getReason()->type)));
if (!payload->getReason()->text.empty()) {
reason->addNode(boost::make_shared<XMLElement>("desc", "", payload->getReason()->text));
diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp
index f86b59e..3cb8cf6 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp
@@ -1,30 +1,32 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Serializer/PayloadSerializerCollection.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
namespace Swift {
MUCOwnerPayloadSerializer::MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer<MUCOwnerPayload>(), serializers(serializers) {
}
std::string MUCOwnerPayloadSerializer::serializePayload(boost::shared_ptr<MUCOwnerPayload> mucOwner) const {
XMLElement mucElement("query", "http://jabber.org/protocol/muc#owner");
boost::shared_ptr<Payload> payload = mucOwner->getPayload();
if (payload) {
PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
if (serializer) {
- mucElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializer->serialize(payload))));
+ mucElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(payload)));
}
}
return mucElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp
index 66ca5d0..2e60654 100644
--- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp
@@ -3,18 +3,19 @@
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h>
#include <sstream>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h>
#include <Swiften/Serializer/PayloadSerializerCollection.h>
namespace Swift {
@@ -54,19 +55,19 @@ std::string MUCUserPayloadSerializer::serializePayload(boost::shared_ptr<MUCUser
reasonElement->addNode(boost::make_shared<XMLTextNode>(invite.reason));
}
mucElement.addNode(inviteElement);
}
boost::shared_ptr<Payload> childPayload = payload->getPayload();
if (childPayload) {
PayloadSerializer* serializer = serializers->getPayloadSerializer(childPayload);
if (serializer) {
- mucElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializer->serialize(childPayload))));
+ mucElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(childPayload)));
}
}
return mucElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
index 38a5db5..33385b0 100644
--- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp
@@ -1,25 +1,26 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/NicknameSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
NicknameSerializer::NicknameSerializer() : GenericPayloadSerializer<Nickname>() {
}
std::string NicknameSerializer::serializePayload(boost::shared_ptr<Nickname> nick) const {
XMLElement nickElement("nick", "http://jabber.org/protocol/nick");
- nickElement.addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(nick->getNickname())));
+ nickElement.addNode(boost::make_shared<XMLTextNode>(nick->getNickname()));
return nickElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
index 6cb226c..cfba552 100644
--- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp
@@ -1,34 +1,35 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializerCollection.h>
namespace Swift {
PrivateStorageSerializer::PrivateStorageSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
}
std::string PrivateStorageSerializer::serializePayload(boost::shared_ptr<PrivateStorage> storage) const {
XMLElement storageElement("query", "jabber:iq:private");
boost::shared_ptr<Payload> payload = storage->getPayload();
if (payload) {
PayloadSerializer* serializer = serializers->getPayloadSerializer(payload);
if (serializer) {
- storageElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializer->serialize(payload))));
+ storageElement.addNode(boost::make_shared<XMLRawTextNode>(serializer->serialize(payload)));
}
}
return storageElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp
index af0c609..c72734b 100644
--- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp
@@ -1,34 +1,35 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
ResourceBindSerializer::ResourceBindSerializer() : GenericPayloadSerializer<ResourceBind>() {
}
std::string ResourceBindSerializer::serializePayload(boost::shared_ptr<ResourceBind> resourceBind) const {
XMLElement bindElement("bind", "urn:ietf:params:xml:ns:xmpp-bind");
if (resourceBind->getJID().isValid()) {
boost::shared_ptr<XMLElement> jidNode(new XMLElement("jid"));
- jidNode->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(resourceBind->getJID().toString())));
+ jidNode->addNode(boost::make_shared<XMLTextNode>(resourceBind->getJID().toString()));
bindElement.addNode(jidNode);
}
else if (!resourceBind->getResource().empty()) {
boost::shared_ptr<XMLElement> resourceNode(new XMLElement("resource"));
- resourceNode->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(resourceBind->getResource())));
+ resourceNode->addNode(boost::make_shared<XMLTextNode>(resourceBind->getResource()));
bindElement.addNode(resourceNode);
}
return bindElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp
index b60db12..39eaf7d 100644
--- a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2011 Jan Kaluza
* Licensed under the Simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
RosterItemExchangeSerializer::RosterItemExchangeSerializer() : GenericPayloadSerializer<RosterItemExchangePayload>() {
@@ -27,19 +28,19 @@ std::string RosterItemExchangeSerializer::serializePayload(boost::shared_ptr<Ros
switch (item.getAction()) {
case RosterItemExchangePayload::Item::Add: itemElement->setAttribute("action", "add"); break;
case RosterItemExchangePayload::Item::Modify: itemElement->setAttribute("action", "modify"); break;
case RosterItemExchangePayload::Item::Delete: itemElement->setAttribute("action", "delete"); break;
}
foreach(const std::string& group, item.getGroups()) {
boost::shared_ptr<XMLElement> groupElement(new XMLElement("group"));
- groupElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(group)));
+ groupElement->addNode(boost::make_shared<XMLTextNode>(group));
itemElement->addNode(groupElement);
}
queryElement.addNode(itemElement);
}
return queryElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp
index 84f36d2..d2d143d 100644
--- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/RosterSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
RosterSerializer::RosterSerializer() : GenericPayloadSerializer<RosterPayload>() {
@@ -36,24 +37,24 @@ std::string RosterSerializer::serializePayload(boost::shared_ptr<RosterPayload>
case RosterItemPayload::None: itemElement->setAttribute("subscription", "none"); break;
}
if (item.getSubscriptionRequested()) {
itemElement->setAttribute("ask", "subscribe");
}
foreach(const std::string& group, item.getGroups()) {
boost::shared_ptr<XMLElement> groupElement(new XMLElement("group"));
- groupElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(group)));
+ groupElement->addNode(boost::make_shared<XMLTextNode>(group));
itemElement->addNode(groupElement);
}
if (!item.getUnknownContent().empty()) {
- itemElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(item.getUnknownContent())));
+ itemElement->addNode(boost::make_shared<XMLRawTextNode>(item.getUnknownContent()));
}
queryElement.addNode(itemElement);
}
return queryElement.serialize();
}
diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp
index a5cd634..07dd8de 100644
--- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
namespace Swift {
SearchPayloadSerializer::SearchPayloadSerializer() {
@@ -47,16 +48,16 @@ std::string SearchPayloadSerializer::serializePayload(boost::shared_ptr<SearchPa
itemElement->addNode(XMLElement::ref(new XMLElement("first", "", item.first)));
itemElement->addNode(XMLElement::ref(new XMLElement("last", "", item.last)));
itemElement->addNode(XMLElement::ref(new XMLElement("nick", "", item.nick)));
itemElement->addNode(XMLElement::ref(new XMLElement("email", "", item.email)));
searchElement.addNode(itemElement);
}
if (Form::ref form = searchPayload->getForm()) {
- searchElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form))));
+ searchElement.addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
}
return searchElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
index 51079ee..7a0b513 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
@@ -1,15 +1,17 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
namespace Swift {
SecurityLabelSerializer::SecurityLabelSerializer() : GenericPayloadSerializer<SecurityLabel>() {
@@ -19,26 +21,26 @@ std::string SecurityLabelSerializer::serializePayload(boost::shared_ptr<Security
XMLElement element("securitylabel", "urn:xmpp:sec-label:0");
if (!label->getDisplayMarking().empty()) {
boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking"));
if (!label->getForegroundColor().empty()) {
displayMarking->setAttribute("fgcolor", label->getForegroundColor());
}
if (!label->getBackgroundColor().empty()) {
displayMarking->setAttribute("bgcolor", label->getBackgroundColor());
}
- displayMarking->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(label->getDisplayMarking())));
+ displayMarking->addNode(boost::make_shared<XMLTextNode>(label->getDisplayMarking()));
element.addNode(displayMarking);
}
boost::shared_ptr<XMLElement> labelElement(new XMLElement("label"));
- labelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(label->getLabel())));
+ labelElement->addNode(boost::make_shared<XMLRawTextNode>(label->getLabel()));
element.addNode(labelElement);
foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) {
boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel"));
- equivalentLabelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(equivalentLabel)));
+ equivalentLabelElement->addNode(boost::make_shared<XMLRawTextNode>(equivalentLabel));
element.addNode(equivalentLabelElement);
}
return element.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp
index 1078292..8871eff 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp
@@ -1,15 +1,17 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h>
namespace Swift {
SecurityLabelsCatalogSerializer::SecurityLabelsCatalogSerializer() : GenericPayloadSerializer<SecurityLabelsCatalog>() {
@@ -28,17 +30,17 @@ std::string SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr<
}
foreach (const SecurityLabelsCatalog::Item& item, catalog->getItems()) {
boost::shared_ptr<XMLElement> itemElement(new XMLElement("item"));
itemElement->setAttribute("selector", item.getSelector());
if (item.getIsDefault()) {
itemElement->setAttribute("default", "true");
}
if (item.getLabel()) {
std::string serializedLabel = SecurityLabelSerializer().serialize(item.getLabel());
- itemElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializedLabel)));
+ itemElement->addNode(boost::make_shared<XMLRawTextNode>(serializedLabel));
}
element.addNode(itemElement);
}
return element.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h
index a8de26f..bd076ae 100644
--- a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h
+++ b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h
@@ -1,25 +1,27 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Elements/Status.h>
namespace Swift {
class StatusSerializer : public GenericPayloadSerializer<Status> {
public:
StatusSerializer() : GenericPayloadSerializer<Status>() {}
virtual std::string serializePayload(boost::shared_ptr<Status> status) const {
XMLElement element("status");
- element.addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(status->getText())));
+ element.addNode(boost::make_shared<XMLTextNode>(status->getText()));
return element.serialize();
}
};
}
diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
index 77fb3c0..296d5dd 100644
--- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/StorageSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
StorageSerializer::StorageSerializer() : GenericPayloadSerializer<Storage>() {
}
@@ -21,24 +22,24 @@ std::string StorageSerializer::serializePayload(boost::shared_ptr<Storage> stora
XMLElement storageElement("storage", "storage:bookmarks");
foreach(const Storage::Room& room, storage->getRooms()) {
boost::shared_ptr<XMLElement> conferenceElement(new XMLElement("conference"));
conferenceElement->setAttribute("name", room.name);
conferenceElement->setAttribute("jid", room.jid);
conferenceElement->setAttribute("autojoin", room.autoJoin ? "1" : "0");
if (!room.nick.empty()) {
boost::shared_ptr<XMLElement> nickElement(new XMLElement("nick"));
- nickElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(room.nick)));
+ nickElement->addNode(boost::make_shared<XMLTextNode>(room.nick));
conferenceElement->addNode(nickElement);
}
if (room.password) {
boost::shared_ptr<XMLElement> passwordElement(new XMLElement("password"));
- passwordElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(*room.password)));
+ passwordElement->addNode(boost::make_shared<XMLTextNode>(*room.password));
conferenceElement->addNode(passwordElement);
}
storageElement.addNode(conferenceElement);
}
foreach(const Storage::URL& url, storage->getURLs()) {
boost::shared_ptr<XMLElement> urlElement(new XMLElement("url"));
urlElement->setAttribute("name", url.name);
urlElement->setAttribute("url", url.url);
diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
index 9ccfab2..030b024 100644
--- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <boost/lexical_cast.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/PayloadSerializers/FormSerializer.h>
@@ -36,38 +37,38 @@ std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr<Strea
if (streamInitiation->getFileInfo()) {
StreamInitiationFileInfo file = *streamInitiation->getFileInfo();
boost::shared_ptr<XMLElement> fileElement(new XMLElement("file", "http://jabber.org/protocol/si/profile/file-transfer"));
fileElement->setAttribute("name", file.getName());
if (file.getSize() != 0) {
fileElement->setAttribute("size", boost::lexical_cast<std::string>(file.getSize()));
}
if (!file.getDescription().empty()) {
boost::shared_ptr<XMLElement> descElement(new XMLElement("desc"));
- descElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(file.getDescription())));
+ descElement->addNode(boost::make_shared<XMLTextNode>(file.getDescription()));
fileElement->addNode(descElement);
}
siElement.addNode(fileElement);
}
boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature", FEATURE_NEG_NS));
if (streamInitiation->getProvidedMethods().size() > 0) {
Form::ref form(new Form(Form::FormType));
ListSingleFormField::ref field = ListSingleFormField::create();
field->setName("stream-method");
foreach(const std::string& method, streamInitiation->getProvidedMethods()) {
field->addOption(FormField::Option("", method));
}
form->addField(field);
- featureElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form))));
+ featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
}
else if (!streamInitiation->getRequestedMethod().empty()) {
Form::ref form(new Form(Form::SubmitType));
ListSingleFormField::ref field = ListSingleFormField::create(streamInitiation->getRequestedMethod());
field->setName("stream-method");
form->addField(field);
- featureElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form))));
+ featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
}
siElement.addNode(featureElement);
return siElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
index 17a6b49..1512c6c 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp
@@ -1,110 +1,111 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/VCardSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/StringCodecs/Base64.h>
#include <Swiften/Base/foreach.h>
namespace Swift {
VCardSerializer::VCardSerializer() : GenericPayloadSerializer<VCard>() {
}
std::string VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const {
XMLElement queryElement("vCard", "vcard-temp");
if (!vcard->getVersion().empty()) {
boost::shared_ptr<XMLElement> versionElement(new XMLElement("VERSION"));
- versionElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getVersion())));
+ versionElement->addNode(boost::make_shared<XMLTextNode>(vcard->getVersion()));
queryElement.addNode(versionElement);
}
if (!vcard->getFullName().empty()) {
boost::shared_ptr<XMLElement> fullNameElement(new XMLElement("FN"));
- fullNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getFullName())));
+ fullNameElement->addNode(boost::make_shared<XMLTextNode>(vcard->getFullName()));
queryElement.addNode(fullNameElement);
}
if (!vcard->getGivenName().empty() || !vcard->getFamilyName().empty() || !vcard->getMiddleName().empty() || !vcard->getPrefix().empty() || !vcard->getSuffix().empty()) {
boost::shared_ptr<XMLElement> nameElement(new XMLElement("N"));
if (!vcard->getFamilyName().empty()) {
boost::shared_ptr<XMLElement> familyNameElement(new XMLElement("FAMILY"));
- familyNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getFamilyName())));
+ familyNameElement->addNode(boost::make_shared<XMLTextNode>(vcard->getFamilyName()));
nameElement->addNode(familyNameElement);
}
if (!vcard->getGivenName().empty()) {
boost::shared_ptr<XMLElement> givenNameElement(new XMLElement("GIVEN"));
- givenNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getGivenName())));
+ givenNameElement->addNode(boost::make_shared<XMLTextNode>(vcard->getGivenName()));
nameElement->addNode(givenNameElement);
}
if (!vcard->getMiddleName().empty()) {
boost::shared_ptr<XMLElement> middleNameElement(new XMLElement("MIDDLE"));
- middleNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getMiddleName())));
+ middleNameElement->addNode(boost::make_shared<XMLTextNode>(vcard->getMiddleName()));
nameElement->addNode(middleNameElement);
}
if (!vcard->getPrefix().empty()) {
boost::shared_ptr<XMLElement> prefixElement(new XMLElement("PREFIX"));
- prefixElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getPrefix())));
+ prefixElement->addNode(boost::make_shared<XMLTextNode>(vcard->getPrefix()));
nameElement->addNode(prefixElement);
}
if (!vcard->getSuffix().empty()) {
boost::shared_ptr<XMLElement> suffixElement(new XMLElement("SUFFIX"));
- suffixElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getSuffix())));
+ suffixElement->addNode(boost::make_shared<XMLTextNode>(vcard->getSuffix()));
nameElement->addNode(suffixElement);
}
queryElement.addNode(nameElement);
}
foreach(const VCard::EMailAddress& emailAddress, vcard->getEMailAddresses()) {
boost::shared_ptr<XMLElement> emailElement(new XMLElement("EMAIL"));
boost::shared_ptr<XMLElement> userIDElement(new XMLElement("USERID"));
- userIDElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(emailAddress.address)));
+ userIDElement->addNode(boost::make_shared<XMLTextNode>(emailAddress.address));
emailElement->addNode(userIDElement);
if (emailAddress.isHome) {
- emailElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("HOME")));
+ emailElement->addNode(boost::make_shared<XMLElement>("HOME"));
}
if (emailAddress.isWork) {
- emailElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("WORK")));
+ emailElement->addNode(boost::make_shared<XMLElement>("WORK"));
}
if (emailAddress.isInternet) {
- emailElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("INTERNET")));
+ emailElement->addNode(boost::make_shared<XMLElement>("INTERNET"));
}
if (emailAddress.isPreferred) {
- emailElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("PREF")));
+ emailElement->addNode(boost::make_shared<XMLElement>("PREF"));
}
if (emailAddress.isX400) {
- emailElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("X400")));
+ emailElement->addNode(boost::make_shared<XMLElement>("X400"));
}
queryElement.addNode(emailElement);
}
if (!vcard->getNickname().empty()) {
boost::shared_ptr<XMLElement> nickElement(new XMLElement("NICKNAME"));
- nickElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getNickname())));
+ nickElement->addNode(boost::make_shared<XMLTextNode>(vcard->getNickname()));
queryElement.addNode(nickElement);
}
if (!vcard->getPhoto().empty() || !vcard->getPhotoType().empty()) {
XMLElement::ref photoElement(new XMLElement("PHOTO"));
if (!vcard->getPhotoType().empty()) {
XMLElement::ref typeElement(new XMLElement("TYPE"));
typeElement->addNode(XMLTextNode::ref(new XMLTextNode(vcard->getPhotoType())));
photoElement->addNode(typeElement);
}
if (!vcard->getPhoto().empty()) {
XMLElement::ref binvalElement(new XMLElement("BINVAL"));
binvalElement->addNode(XMLTextNode::ref(new XMLTextNode(Base64::encode(vcard->getPhoto()))));
photoElement->addNode(binvalElement);
}
queryElement.addNode(photoElement);
}
if (!vcard->getUnknownContent().empty()) {
- queryElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(vcard->getUnknownContent())));
+ queryElement.addNode(boost::make_shared<XMLRawTextNode>(vcard->getUnknownContent()));
}
return queryElement.serialize();
}
}
diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
index c06262f..78c700b 100644
--- a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp
@@ -1,27 +1,28 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
namespace Swift {
VCardUpdateSerializer::VCardUpdateSerializer() : GenericPayloadSerializer<VCardUpdate>() {
}
std::string VCardUpdateSerializer::serializePayload(boost::shared_ptr<VCardUpdate> vcardUpdate) const {
XMLElement updateElement("x", "vcard-temp:x:update");
boost::shared_ptr<XMLElement> photoElement(new XMLElement("photo"));
- photoElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcardUpdate->getPhotoHash())));
+ photoElement->addNode(boost::make_shared<XMLTextNode>(vcardUpdate->getPhotoHash()));
updateElement.addNode(photoElement);
return updateElement.serialize();
}
}
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp
index fb7bb8c..2344349 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.cpp
+++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp
@@ -16,45 +16,45 @@ namespace Swift {
StreamFeaturesSerializer::StreamFeaturesSerializer() {
}
SafeByteArray StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<StreamFeatures> streamFeatures(boost::dynamic_pointer_cast<StreamFeatures>(element));
XMLElement streamFeaturesElement("stream:features");
if (streamFeatures->hasStartTLS()) {
- streamFeaturesElement.addNode(boost::shared_ptr<XMLElement>(new XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls")));
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("starttls", "urn:ietf:params:xml:ns:xmpp-tls"));
}
if (!streamFeatures->getCompressionMethods().empty()) {
boost::shared_ptr<XMLElement> compressionElement(new XMLElement("compression", "http://jabber.org/features/compress"));
foreach(const std::string& method, streamFeatures->getCompressionMethods()) {
boost::shared_ptr<XMLElement> methodElement(new XMLElement("method"));
- methodElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(method)));
+ methodElement->addNode(boost::make_shared<XMLTextNode>(method));
compressionElement->addNode(methodElement);
}
streamFeaturesElement.addNode(compressionElement);
}
if (!streamFeatures->getAuthenticationMechanisms().empty()) {
boost::shared_ptr<XMLElement> mechanismsElement(new XMLElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl"));
foreach(const std::string& mechanism, streamFeatures->getAuthenticationMechanisms()) {
boost::shared_ptr<XMLElement> mechanismElement(new XMLElement("mechanism"));
- mechanismElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(mechanism)));
+ mechanismElement->addNode(boost::make_shared<XMLTextNode>(mechanism));
mechanismsElement->addNode(mechanismElement);
}
streamFeaturesElement.addNode(mechanismsElement);
}
if (streamFeatures->hasResourceBind()) {
- streamFeaturesElement.addNode(boost::shared_ptr<XMLElement>(new XMLElement("bind", "urn:ietf:params:xml:ns:xmpp-bind")));
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("bind", "urn:ietf:params:xml:ns:xmpp-bind"));
}
if (streamFeatures->hasSession()) {
- streamFeaturesElement.addNode(boost::shared_ptr<XMLElement>(new XMLElement("session", "urn:ietf:params:xml:ns:xmpp-session")));
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("session", "urn:ietf:params:xml:ns:xmpp-session"));
}
if (streamFeatures->hasStreamManagement()) {
- streamFeaturesElement.addNode(boost::shared_ptr<XMLElement>(new XMLElement("sm", "urn:xmpp:sm:2")));
+ streamFeaturesElement.addNode(boost::make_shared<XMLElement>("sm", "urn:xmpp:sm:2"));
}
if (streamFeatures->hasRosterVersioning()) {
streamFeaturesElement.addNode(boost::make_shared<XMLElement>("ver", "urn:xmpp:features:rosterver"));
}
return createSafeByteArray(streamFeaturesElement.serialize());
}
}
diff --git a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
index b70128b..a2197b0 100644
--- a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
+++ b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
@@ -1,18 +1,20 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
using namespace Swift;
class XMLElementTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(XMLElementTest);
CPPUNIT_TEST(testSerialize);
@@ -22,22 +24,22 @@ class XMLElementTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_END();
public:
XMLElementTest() {}
void testSerialize() {
XMLElement testling("foo", "http://example.com");
testling.setAttribute("myatt", "myval");
boost::shared_ptr<XMLElement> barElement(new XMLElement("bar"));
- barElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode("Blo")));
+ barElement->addNode(boost::make_shared<XMLTextNode>("Blo"));
testling.addNode(barElement);
boost::shared_ptr<XMLElement> bazElement(new XMLElement("baz"));
- bazElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode("Bli&</stream>")));
+ bazElement->addNode(boost::make_shared<XMLTextNode>("Bli&</stream>"));
testling.addNode(bazElement);
std::string result = testling.serialize();
std::string expectedResult =
"<foo myatt=\"myval\" xmlns=\"http://example.com\">"
"<bar>Blo</bar>"
"<baz>Bli&amp;&lt;/stream&gt;</baz>"
"</foo>";
diff --git a/Swiften/Session/BOSHSessionStream.cpp b/Swiften/Session/BOSHSessionStream.cpp
index d706d43..ce5df35 100644
--- a/Swiften/Session/BOSHSessionStream.cpp
+++ b/Swiften/Session/BOSHSessionStream.cpp
@@ -157,19 +157,19 @@ void BOSHSessionStream::handleStreamStartReceived(const ProtocolHeader& header)
onStreamStartReceived(header);
}
void BOSHSessionStream::handleElementReceived(boost::shared_ptr<Element> element) {
onElementReceived(element);
}
void BOSHSessionStream::handleXMPPError() {
available = false;
- onClosed(boost::shared_ptr<Error>(new Error(Error::ParseError)));
+ onClosed(boost::make_shared<Error>(Error::ParseError));
}
void BOSHSessionStream::handlePoolSessionStarted() {
fakeStreamHeaderReceipt();
}
void BOSHSessionStream::handlePoolSessionTerminated(BOSHError::ref error) {
eventLoop->postEvent(boost::bind(&BOSHSessionStream::fakeStreamFooterReceipt, this, error), shared_from_this());
}
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index 70bbeea..f50c5d5 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -1,18 +1,19 @@
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Session/BasicSessionStream.h>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/StreamStack/XMPPLayer.h>
#include <Swiften/StreamStack/StreamStack.h>
#include <Swiften/StreamStack/ConnectionLayer.h>
#include <Swiften/StreamStack/WhitespacePingLayer.h>
#include <Swiften/StreamStack/CompressionLayer.h>
#include <Swiften/StreamStack/TLSLayer.h>
#include <Swiften/TLS/TLSContextFactory.h>
#include <Swiften/TLS/TLSContext.h>
@@ -104,19 +105,19 @@ bool BasicSessionStream::isOpen() {
bool BasicSessionStream::supportsTLSEncryption() {
return tlsContextFactory && tlsContextFactory->canCreate();
}
void BasicSessionStream::addTLSEncryption() {
assert(available);
tlsLayer = new TLSLayer(tlsContextFactory);
if (hasTLSCertificate() && !tlsLayer->setClientCertificate(getTLSCertificate())) {
- onClosed(boost::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
+ onClosed(boost::make_shared<Error>(Error::InvalidTLSCertificateError));
}
else {
streamStack->addLayer(tlsLayer);
tlsLayer->onError.connect(boost::bind(&BasicSessionStream::handleTLSError, this));
tlsLayer->onConnected.connect(boost::bind(&BasicSessionStream::handleTLSConnected, this));
tlsLayer->connect();
}
}
@@ -166,37 +167,37 @@ void BasicSessionStream::handleStreamStartReceived(const ProtocolHeader& header)
onStreamStartReceived(header);
}
void BasicSessionStream::handleElementReceived(boost::shared_ptr<Element> element) {
onElementReceived(element);
}
void BasicSessionStream::handleXMPPError() {
available = false;
- onClosed(boost::shared_ptr<Error>(new Error(Error::ParseError)));
+ onClosed(boost::make_shared<Error>(Error::ParseError));
}
void BasicSessionStream::handleTLSConnected() {
onTLSEncrypted();
}
void BasicSessionStream::handleTLSError() {
available = false;
- onClosed(boost::shared_ptr<Error>(new Error(Error::TLSError)));
+ onClosed(boost::make_shared<Error>(Error::TLSError));
}
void BasicSessionStream::handleConnectionFinished(const boost::optional<Connection::Error>& error) {
available = false;
if (error == Connection::ReadError) {
- onClosed(boost::shared_ptr<Error>(new Error(Error::ConnectionReadError)));
+ onClosed(boost::make_shared<Error>(Error::ConnectionReadError));
}
else if (error) {
- onClosed(boost::shared_ptr<Error>(new Error(Error::ConnectionWriteError)));
+ onClosed(boost::make_shared<Error>(Error::ConnectionWriteError));
}
else {
onClosed(boost::shared_ptr<Error>());
}
}
void BasicSessionStream::handleDataRead(const SafeByteArray& data) {
onDataRead(data);
}
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
index 8123c00..a6098f1 100644
--- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
+++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
@@ -77,19 +77,19 @@ class XMPPLayerTest : public CppUnit::TestFixture {
void testWriteHeader() {
ProtocolHeader header;
header.setTo("example.com");
testling_->writeHeader(header);
CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" to=\"example.com\" version=\"1.0\">"), lowLayer_->writtenData);
}
void testWriteElement() {
- testling_->writeElement(boost::shared_ptr<Presence>(new Presence()));
+ testling_->writeElement(boost::make_shared<Presence>());
CPPUNIT_ASSERT_EQUAL(std::string("<presence/>"), lowLayer_->writtenData);
}
void testWriteFooter() {
testling_->writeFooter();
CPPUNIT_ASSERT_EQUAL(std::string("</stream:stream>"), lowLayer_->writtenData);
}