diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp | 111 |
1 files changed, 53 insertions, 58 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp index 2792a28..39eb149 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp @@ -5,81 +5,76 @@ */ /* -* Copyright (c) 2014 Isode Limited. -* All rights reserved.v3. -* See the COPYING file for more information. -*/ + * Copyright (c) 2014-2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ #include <Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.h> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> -#include <boost/smart_ptr/intrusive_ptr.hpp> +#include <memory> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> -#include <Swiften/Serializer/XML/XMLNode.h> -#include <Swiften/Serializer/XML/XMLElement.h> -#include <Swiften/Serializer/XML/XMLRawTextNode.h> - #include <Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h> - #include <Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h> +#include <Swiften/Serializer/XML/XMLElement.h> +#include <Swiften/Serializer/XML/XMLNode.h> +#include <Swiften/Serializer/XML/XMLRawTextNode.h> namespace Swift { JingleContentPayloadSerializer::JingleContentPayloadSerializer() { } -std::string JingleContentPayloadSerializer::serializePayload(boost::shared_ptr<JingleContentPayload> payload) const { - XMLElement payloadXML("content"); - payloadXML.setAttribute("creator", creatorToString(payload->getCreator())); - payloadXML.setAttribute("name", payload->getName()); - - if (!payload->getDescriptions().empty()) { - // JingleFileTransferDescription - JingleFileTransferDescriptionSerializer ftSerializer; - JingleFileTransferDescription::ref filetransfer; - - foreach(JingleDescription::ref desc, payload->getDescriptions()) { - if ((filetransfer = boost::dynamic_pointer_cast<JingleFileTransferDescription>(desc))) { - payloadXML.addNode(boost::make_shared<XMLRawTextNode>(ftSerializer.serializePayload(filetransfer))); - } - } - } - - if (!payload->getTransports().empty()) { - // JingleIBBTransportPayload - JingleIBBTransportPayloadSerializer ibbSerializer; - JingleIBBTransportPayload::ref ibb; - - // JingleS5BTransportPayload - JingleS5BTransportPayloadSerializer s5bSerializer; - JingleS5BTransportPayload::ref s5b; +std::string JingleContentPayloadSerializer::serializePayload(std::shared_ptr<JingleContentPayload> payload) const { + XMLElement payloadXML("content"); + payloadXML.setAttribute("creator", creatorToString(payload->getCreator())); + payloadXML.setAttribute("name", payload->getName()); + + if (!payload->getDescriptions().empty()) { + // JingleFileTransferDescription + JingleFileTransferDescriptionSerializer ftSerializer; + JingleFileTransferDescription::ref filetransfer; + + for (auto&& desc : payload->getDescriptions()) { + if ((filetransfer = std::dynamic_pointer_cast<JingleFileTransferDescription>(desc))) { + payloadXML.addNode(std::make_shared<XMLRawTextNode>(ftSerializer.serializePayload(filetransfer))); + } + } + } + + if (!payload->getTransports().empty()) { + // JingleIBBTransportPayload + JingleIBBTransportPayloadSerializer ibbSerializer; + JingleIBBTransportPayload::ref ibb; + + // JingleS5BTransportPayload + JingleS5BTransportPayloadSerializer s5bSerializer; + JingleS5BTransportPayload::ref s5b; - foreach(JingleTransportPayload::ref transport, payload->getTransports()) { - if ((ibb = boost::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { - payloadXML.addNode(boost::make_shared<XMLRawTextNode>(ibbSerializer.serializePayload(ibb))); - } else if ((s5b = boost::dynamic_pointer_cast<JingleS5BTransportPayload>(transport))) { - payloadXML.addNode(boost::make_shared<XMLRawTextNode>(s5bSerializer.serializePayload(s5b))); - } - } - } - return payloadXML.serialize(); + for (auto&& transport : payload->getTransports()) { + if ((ibb = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { + payloadXML.addNode(std::make_shared<XMLRawTextNode>(ibbSerializer.serializePayload(ibb))); + } else if ((s5b = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transport))) { + payloadXML.addNode(std::make_shared<XMLRawTextNode>(s5bSerializer.serializePayload(s5b))); + } + } + } + return payloadXML.serialize(); } std::string JingleContentPayloadSerializer::creatorToString(JingleContentPayload::Creator creator) const { - switch(creator) { - case JingleContentPayload::InitiatorCreator: - return "initiator"; - case JingleContentPayload::ResponderCreator: - return "responder"; - case JingleContentPayload::UnknownCreator: - SWIFT_LOG(error) << "Serializing unknown creator value."; - return "ERROR ERROR ERROR"; - } - assert(false); - return ""; + switch(creator) { + case JingleContentPayload::InitiatorCreator: + return "initiator"; + case JingleContentPayload::ResponderCreator: + return "responder"; + case JingleContentPayload::UnknownCreator: + SWIFT_LOG(error) << "Serializing unknown creator value."; + return "ERROR ERROR ERROR"; + } + assert(false); + return ""; } } |