summaryrefslogtreecommitdiffstats
blob: fc398a48054516dd7ec18afdefee66c73b920ec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (c) 2010-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <Swiften/Serializer/PresenceSerializer.h>

#include <memory>

#include <Swiften/Base/Log.h>
#include <Swiften/Serializer/XML/XMLElement.h>

namespace Swift {

PresenceSerializer::PresenceSerializer(PayloadSerializerCollection* payloadSerializers, const boost::optional<std::string>& explicitNS) :
        GenericStanzaSerializer<Presence>("presence", payloadSerializers, explicitNS) {

}

void PresenceSerializer::setStanzaSpecificAttributesGeneric(
        std::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;
    }
}

}