summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-20 09:43:31 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-23 10:52:55 (GMT)
commit6bd72c67896a20041556519548650590553f47c9 (patch)
tree20f6a3895647ad67adfe29ef688a618bf7c30a6a /Swiften/Serializer
parentbfe07e82cd79d56f1327425ce3e6c8a84908421b (diff)
downloadswift-contrib-6bd72c67896a20041556519548650590553f47c9.zip
swift-contrib-6bd72c67896a20041556519548650590553f47c9.tar.bz2
Add XEP-0203 (Delay) support.
Puts delay warnings in the chat log. Not optional yet.
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp30
-rw-r--r--Swiften/Serializer/PayloadSerializers/DelaySerializer.h21
-rw-r--r--Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp2
3 files changed, 53 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
new file mode 100644
index 0000000..041165f
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Serializer/PayloadSerializers/DelaySerializer.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Serializer/XML/XMLElement.h"
+
+namespace Swift {
+
+DelaySerializer::DelaySerializer() : GenericPayloadSerializer<Delay>() {
+}
+
+String DelaySerializer::serializePayload(boost::shared_ptr<Delay> delay) const {
+ XMLElement delayElement("delay", "urn:xmpp:delay");
+ if (delay->getFrom()) {
+ delayElement.setAttribute("from", delay->getFrom()->toString());
+ }
+ String stampString = String(boost::posix_time::to_iso_extended_string(delay->getStamp()));
+ stampString.replaceAll(',', ".");
+ stampString += "Z";
+ delayElement.setAttribute("stamp", stampString);
+ return delayElement.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
new file mode 100644
index 0000000..949b084
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/Serializer/GenericPayloadSerializer.h"
+#include "Swiften/Elements/Delay.h"
+
+namespace Swift {
+ class DelaySerializer : public GenericPayloadSerializer<Delay> {
+ public:
+ DelaySerializer();
+
+ virtual String serializePayload(boost::shared_ptr<Delay>) const;
+ };
+}
+
+
diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
index 8c83c09..8dc9d86 100644
--- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
+++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp
@@ -27,6 +27,7 @@
#include "Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/StorageSerializer.h"
#include "Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h"
+#include "Swiften/Serializer/PayloadSerializers/DelaySerializer.h"
namespace Swift {
@@ -50,6 +51,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() {
serializers_.push_back(new VCardUpdateSerializer());
serializers_.push_back(new RawXMLPayloadSerializer());
serializers_.push_back(new StorageSerializer());
+ serializers_.push_back(new DelaySerializer());
serializers_.push_back(new PrivateStorageSerializer(this));
foreach(PayloadSerializer* serializer, serializers_) {
addSerializer(serializer);