diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-12 10:52:03 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-12 10:52:03 (GMT) |
commit | edd726abb1d0f7532218efbb8067a75a313e9e98 (patch) | |
tree | 7eec4f7912a59bb9a383a61c2c96616d5b5847b6 /Swiften/Parser/PayloadParsers | |
parent | 6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad (diff) | |
download | swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.zip swift-contrib-edd726abb1d0f7532218efbb8067a75a313e9e98.tar.bz2 |
Improved whiteboard session handling
Diffstat (limited to 'Swiften/Parser/PayloadParsers')
-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_; |