summaryrefslogtreecommitdiffstats
blob: e41e09ee155e127c2da4bac0f0d09a34f0036074 (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
/*
 * Copyright (c) 2013-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

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

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

using namespace Swift;

PubSubDefaultSerializer::PubSubDefaultSerializer(PayloadSerializerCollection* /*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 "";
}