summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp')
-rw-r--r--Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
index bd44040..824569a 100644
--- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp
@@ -25,51 +25,51 @@ namespace Swift {
StreamInitiationSerializer::StreamInitiationSerializer() {
}
-std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInitiation> streamInitiation) const {
- assert(streamInitiation->getIsFileTransfer());
+std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInitiation> streamInitiation) const {
+ assert(streamInitiation->getIsFileTransfer());
- XMLElement siElement("si", "http://jabber.org/protocol/si");
- if (!streamInitiation->getID().empty()) {
- siElement.setAttribute("id", streamInitiation->getID());
- }
- siElement.setAttribute("profile", FILE_TRANSFER_NS);
+ XMLElement siElement("si", "http://jabber.org/protocol/si");
+ if (!streamInitiation->getID().empty()) {
+ siElement.setAttribute("id", streamInitiation->getID());
+ }
+ siElement.setAttribute("profile", FILE_TRANSFER_NS);
- 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::make_shared<XMLTextNode>(file.getDescription()));
- fileElement->addNode(descElement);
- }
- siElement.addNode(fileElement);
- }
+ 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::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));
- FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
- field->setName("stream-method");
- foreach(const std::string& method, streamInitiation->getProvidedMethods()) {
- field->addOption(FormField::Option("", method));
- }
- form->addField(field);
- featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
- else if (!streamInitiation->getRequestedMethod().empty()) {
- Form::ref form(new Form(Form::SubmitType));
- FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
- field->addValue(streamInitiation->getRequestedMethod());
- field->setName("stream-method");
- form->addField(field);
- featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
- }
- siElement.addNode(featureElement);
- return siElement.serialize();
+ boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature", FEATURE_NEG_NS));
+ if (streamInitiation->getProvidedMethods().size() > 0) {
+ Form::ref form(new Form(Form::FormType));
+ FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
+ field->setName("stream-method");
+ foreach(const std::string& method, streamInitiation->getProvidedMethods()) {
+ field->addOption(FormField::Option("", method));
+ }
+ form->addField(field);
+ featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
+ else if (!streamInitiation->getRequestedMethod().empty()) {
+ Form::ref form(new Form(Form::SubmitType));
+ FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
+ field->addValue(streamInitiation->getRequestedMethod());
+ field->setName("stream-method");
+ form->addField(field);
+ featureElement->addNode(boost::make_shared<XMLRawTextNode>(FormSerializer().serialize(form)));
+ }
+ siElement.addNode(featureElement);
+ return siElement.serialize();
}
}