diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp index 4586a74..087dece 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp @@ -13,8 +13,32 @@ namespace Swift { MUCPayloadSerializer::MUCPayloadSerializer() : GenericPayloadSerializer<MUCPayload>() { } -String MUCPayloadSerializer::serializePayload(boost::shared_ptr<MUCPayload>) const { +String MUCPayloadSerializer::serializePayload(boost::shared_ptr<MUCPayload> muc) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc"); + boost::shared_ptr<XMLElement> historyElement(new XMLElement("history")); + bool history = false; + if (muc->getMaxChars() >= 0) { + historyElement->setAttribute("maxchars", boost::lexical_cast<std::string>(muc->getMaxChars())); + history = true; + } + if (muc->getMaxStanzas() >= 0) { + historyElement->setAttribute("maxstanzas", boost::lexical_cast<std::string>(muc->getMaxStanzas())); + history = true; + } + if (muc->getSeconds() >= 0) { + historyElement->setAttribute("seconds", boost::lexical_cast<std::string>(muc->getSeconds())); + history = true; + } + if (muc->getSince() != boost::posix_time::not_a_date_time) { + String sinceString = String(boost::posix_time::to_iso_extended_string(muc->getSince())); + sinceString.replaceAll(',', "."); + sinceString += "Z"; + historyElement->setAttribute("since", sinceString); + history = true; + } + if (history) { + mucElement.addNode(historyElement); + } return mucElement.serialize(); } |