diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-10-17 12:13:36 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-10-21 18:25:00 (GMT) |
commit | 1b58ef2af54456004390a0888c3edf104e3baa99 (patch) | |
tree | dbe4ae29de1b765a88ea704dfaa1c03af4b196b3 /Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp | |
parent | 07402c4e3451f2084a1c3ddc5bacfb38a66899a7 (diff) | |
download | swift-contrib-1b58ef2af54456004390a0888c3edf104e3baa99.zip swift-contrib-1b58ef2af54456004390a0888c3edf104e3baa99.tar.bz2 |
Added beginnings of outgoing file transfer to Swiften.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp new file mode 100644 index 0000000..9acabee --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp @@ -0,0 +1,41 @@ +/* + * 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/BytestreamsSerializer.h" + +#include <boost/shared_ptr.hpp> +#include <boost/lexical_cast.hpp> + +#include "Swiften/Base/foreach.h" +#include "Swiften/Serializer/XML/XMLElement.h" +#include "Swiften/Serializer/PayloadSerializerCollection.h" + + +namespace Swift { + +BytestreamsSerializer::BytestreamsSerializer() { +} + +String BytestreamsSerializer::serializePayload(boost::shared_ptr<Bytestreams> bytestreams) const { + XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams"); + queryElement.setAttribute("sid", bytestreams->getStreamID()); + foreach(const Bytestreams::StreamHost& streamHost, bytestreams->getStreamHosts()) { + boost::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost")); + streamHostElement->setAttribute("host", streamHost.host); + streamHostElement->setAttribute("jid", streamHost.jid.toString()); + streamHostElement->setAttribute("port", boost::lexical_cast<std::string>(streamHost.port)); + queryElement.addNode(streamHostElement); + } + + if (bytestreams->getUsedStreamHost()) { + boost::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost-used")); + streamHostElement->setAttribute("jid", *bytestreams->getUsedStreamHost()); + queryElement.addNode(streamHostElement); + } + return queryElement.serialize(); +} + +} |