diff options
Diffstat (limited to 'Swiften/Parser')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 23 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.h | 4 |
2 files changed, 20 insertions, 7 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index 94b67e5..4306497 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -5,19 +5,16 @@ */ #include <Swiften/Parser/PayloadParsers/WhiteboardParser.h> +#include <boost/optional.hpp> namespace Swift { WhiteboardParser::WhiteboardParser() : level_(0) { } + void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level_ == 0) { - std::string type = attributes.getAttribute("type"); - if (type.empty()) { - getPayloadInternal()->setType(WhiteboardPayload::Data); - } - else if (type == "request") { - getPayloadInternal()->setType(WhiteboardPayload::SessionRequest); - } +// std::string type = attributes.getAttribute("type"); + getPayloadInternal()->setType(stringToType(attributes.getAttributeValue("type").get_value_or(""))); } ++level_; } @@ -32,4 +29,16 @@ namespace Swift { void WhiteboardParser::handleCharacterData(const std::string& data) { data_ += data; } + + WhiteboardPayload::Type WhiteboardParser::stringToType(const std::string& type) const { + if (type.empty()) { + return WhiteboardPayload::Data; + } else if (type == "session-request") { + return WhiteboardPayload::SessionRequest; + } else if (type == "session-accept") { + return WhiteboardPayload::SessionAccept; + } else if (type == "session-terminate") { + return WhiteboardPayload::SessionTerminate; + } + } } diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.h b/Swiften/Parser/PayloadParsers/WhiteboardParser.h index 265e12d..faa698b 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.h +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.h @@ -17,6 +17,10 @@ namespace Swift { virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); virtual void handleEndElement(const std::string& element, const std::string&); virtual void handleCharacterData(const std::string& data); + + private: + WhiteboardPayload::Type stringToType(const std::string& type) const; + private: int level_; std::string data_; |