diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp index 44aa506..0a8153d 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp @@ -13,7 +13,7 @@ #include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> - +#include <Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h> namespace Swift { @@ -29,46 +29,13 @@ std::string MUCUserPayloadSerializer::serializePayload(boost::shared_ptr<MUCUser statusElement->setAttribute("code", code.str()); mucElement.addNode(statusElement); } - foreach (const MUCUserPayload::Item item, payload->getItems()) { - boost::shared_ptr<XMLElement> itemElement(new XMLElement("item")); - itemElement->setAttribute("affiliation", affiliationToString(item.affiliation)); - itemElement->setAttribute("role", roleToString(item.role)); - if (item.realJID) { - itemElement->setAttribute("jid", item.realJID.get()); - } - if (item.nick) { - itemElement->setAttribute("nick", item.nick.get()); - } - mucElement.addNode(itemElement); + foreach (const MUCItem item, payload->getItems()) { + mucElement.addNode(MUCItemSerializer::itemToElement(item)); } return mucElement.serialize(); } -std::string MUCUserPayloadSerializer::affiliationToString(MUCOccupant::Affiliation affiliation) const { - std::string result; - switch (affiliation) { - case MUCOccupant::Owner: result = "owner"; break; - case MUCOccupant::Admin: result = "admin"; break; - case MUCOccupant::Member: result = "member"; break; - case MUCOccupant::Outcast: result = "outcast"; break; - case MUCOccupant::NoAffiliation: result = "none"; break; - default: assert(false); - } - return result; -} - -std::string MUCUserPayloadSerializer::roleToString(MUCOccupant::Role role) const { - std::string result; - switch (role) { - case MUCOccupant::Moderator: result = "moderator"; break; - case MUCOccupant::NoRole: result = "none"; break; - case MUCOccupant::Participant: result = "participant"; break; - case MUCOccupant::Visitor: result = "visitor"; break; - default: assert(false); - } - return result; -} } |