summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2012-03-20 00:05:55 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-03-20 19:13:43 (GMT)
commit3d6694b0c698fff63d11f8bb4aa995c1df882315 (patch)
treea46ccace647f23a65100cf69c951345aa6dea7ab /Swiften/Disco
parent3d27d98ccc232ae7bfacfd5a3f85f44b6c2e9cc9 (diff)
downloadswift-contrib-3d6694b0c698fff63d11f8bb4aa995c1df882315.zip
swift-contrib-3d6694b0c698fff63d11f8bb4aa995c1df882315.tar.bz2
boost::shared_ptr<?>(new ?(...)) -> boost::make_shared<?>(...) transformation where possible.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/Disco')
-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
6 files changed, 28 insertions, 20 deletions
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();