summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-11-09 21:06:28 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-11-09 21:23:39 (GMT)
commitb23637e59839f5f28258f518ac234b2ff62b6da2 (patch)
tree260bb79caa0858d271959159a5913de121687a99 /Swiften/Serializer/PayloadSerializers
parentf4d1b6494d5c537ba4a086d61ea86b1dd6843e4b (diff)
downloadswift-b23637e59839f5f28258f518ac234b2ff62b6da2.zip
swift-b23637e59839f5f28258f518ac234b2ff62b6da2.tar.bz2
Only request new MUC context when rejoining.
Resolves: #542 Release-Notes: On reconnects, existing MUC history now won't be replayed.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r--Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp26
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();
}