summaryrefslogtreecommitdiffstats
blob: 3681dd0492cf777324f373844d83c0389dd1106d (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
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2013-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma clang diagnostic ignored "-Wunused-private-field"

#include <Swiften/Serializer/PayloadSerializers/PubSubDefaultSerializer.h>
#include <Swiften/Serializer/XML/XMLElement.h>


#include <Swiften/Serializer/PayloadSerializerCollection.h>


using namespace Swift;

PubSubDefaultSerializer::PubSubDefaultSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) {
}

PubSubDefaultSerializer::~PubSubDefaultSerializer() {
}

std::string PubSubDefaultSerializer::serializePayload(std::shared_ptr<PubSubDefault> payload) const {
    if (!payload) {
        return "";
    }
    XMLElement element("default", "http://jabber.org/protocol/pubsub");
    if (payload->getNode()) {
        element.setAttribute("node", *payload->getNode());
    }
    element.setAttribute("type", serializeType(payload->getType()));
    return element.serialize();
}

std::string PubSubDefaultSerializer::serializeType(PubSubDefault::Type value) {
    switch (value) {
        case PubSubDefault::None: return "none";
        case PubSubDefault::Collection: return "collection";
        case PubSubDefault::Leaf: return "leaf";
    }
    assert(false);
    return "";
}