diff options
Diffstat (limited to 'Swiften/Parser')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 12 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.h | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index 4306497..ef3c119 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -5,7 +5,9 @@ */ #include <Swiften/Parser/PayloadParsers/WhiteboardParser.h> +#include <Swiften/Whiteboard/Elements/WhiteboardLineElement.h> #include <boost/optional.hpp> +#include <boost/smart_ptr/make_shared.hpp> namespace Swift { WhiteboardParser::WhiteboardParser() : level_(0) { @@ -13,8 +15,16 @@ namespace Swift { void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level_ == 0) { -// std::string type = attributes.getAttribute("type"); getPayloadInternal()->setType(stringToType(attributes.getAttributeValue("type").get_value_or(""))); + } else if (level_ == 1) { + if (element == "line") { + int x1 = std::atoi(attributes.getAttributeValue("x1").get_value_or("0").c_str()); + int y1 = std::atoi(attributes.getAttributeValue("y1").get_value_or("0").c_str()); + int x2 = std::atoi(attributes.getAttributeValue("x2").get_value_or("0").c_str()); + int y2 = std::atoi(attributes.getAttributeValue("y2").get_value_or("0").c_str()); + WhiteboardLineElement::ref whiteboardElement = boost::make_shared<WhiteboardLineElement>(x1, y1, x2, y2); + getPayloadInternal()->setElement(whiteboardElement); + } } ++level_; } diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.h b/Swiften/Parser/PayloadParsers/WhiteboardParser.h index faa698b..79d0f27 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.h +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.h @@ -8,6 +8,7 @@ #include <Swiften/Elements/WhiteboardPayload.h> #include <Swiften/Parser/GenericPayloadParser.h> +#include <Swiften/Whiteboard/Elements/WhiteboardElement.h> namespace Swift { class WhiteboardParser : public Swift::GenericPayloadParser<WhiteboardPayload> { |