summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer/PresenceSerializer.cpp')
-rw-r--r--Swiften/Serializer/PresenceSerializer.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Serializer/PresenceSerializer.cpp b/Swiften/Serializer/PresenceSerializer.cpp
new file mode 100644
index 0000000..f7585d5
--- /dev/null
+++ b/Swiften/Serializer/PresenceSerializer.cpp
@@ -0,0 +1,27 @@
+#include "Swiften/Serializer/PresenceSerializer.h"
+#include "Swiften/Serializer/XML/XMLElement.h"
+
+#include "boost/shared_ptr.hpp"
+
+namespace Swift {
+
+PresenceSerializer::PresenceSerializer(PayloadSerializerCollection* payloadSerializers) :
+ GenericStanzaSerializer<Presence>("presence", payloadSerializers) {
+}
+
+void PresenceSerializer::setStanzaSpecificAttributesGeneric(
+ boost::shared_ptr<Presence> presence,
+ XMLElement& element) const {
+ switch (presence->getType()) {
+ case Presence::Unavailable: element.setAttribute("type","unavailable"); break;
+ case Presence::Probe: element.setAttribute("type","probe"); break;
+ case Presence::Subscribe: element.setAttribute("type","subscribe"); break;
+ case Presence::Subscribed: element.setAttribute("type","subscribed"); break;
+ case Presence::Unsubscribe: element.setAttribute("type","unsubscribe"); break;
+ case Presence::Unsubscribed: element.setAttribute("type","unsubscribed"); break;
+ case Presence::Error: element.setAttribute("type","error"); break;
+ case Presence::Available: break;
+ }
+}
+
+}