diff options
Diffstat (limited to 'Swiften/Serializer')
23 files changed, 80 insertions, 54 deletions
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&</stream></baz>" "</foo>"; |