diff --git a/include/Swiften/Parser/PayloadParsers/PubSubSubscriptionPayloadParser.cpp b/include/Swiften/Parser/PayloadParsers/PubSubSubscriptionPayloadParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c964762dcbe790eba52263a3c5ccad4ee698108 --- /dev/null +++ b/include/Swiften/Parser/PayloadParsers/PubSubSubscriptionPayloadParser.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012 Jan Kaluza + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include + +#include + +#include +#include +#include +#include +#include + +namespace Swift { + +void PubSubSubscriptionPayloadParser::handleTree(ParserElement::ref root) { + std::string node = root->getAttributes().getAttribute("node"); + if (!node.empty()) { + getPayloadInternal()->setNode(node); + } + + std::string jid = root->getAttributes().getAttribute("jid"); + if (!jid.empty()) { + getPayloadInternal()->setJID(jid); + } + + std::string id = root->getAttributes().getAttribute("subid"); + if (!id.empty()) { + getPayloadInternal()->setId(id); + } + + std::string type = root->getAttributes().getAttribute("subscription"); + if (type == "none") { + getPayloadInternal()->setType(PubSubSubscriptionPayload::None); + } + else if (type == "subscribed") { + getPayloadInternal()->setType(PubSubSubscriptionPayload::Subscribed); + } + else if (type == "pending") { + getPayloadInternal()->setType(PubSubSubscriptionPayload::Pending); + } + else if (type == "unconfigured") { + getPayloadInternal()->setType(PubSubSubscriptionPayload::Unconfigured); + } + +} + +}