diff options
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 12 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.h | 1 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSession.cpp | 2 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSession.h | 2 |
4 files changed, 14 insertions, 3 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> { diff --git a/Swiften/Whiteboard/WhiteboardSession.cpp b/Swiften/Whiteboard/WhiteboardSession.cpp index 9e4fd9f..18dea52 100644 --- a/Swiften/Whiteboard/WhiteboardSession.cpp +++ b/Swiften/Whiteboard/WhiteboardSession.cpp @@ -27,7 +27,7 @@ namespace Swift { switch (payload->getType()) { case WhiteboardPayload::Data: - onDataReceived(payload->getData()); + onElementReceived(payload->getElement()); break; case WhiteboardPayload::SessionAccept: onRequestAccepted(toJID_); diff --git a/Swiften/Whiteboard/WhiteboardSession.h b/Swiften/Whiteboard/WhiteboardSession.h index fb4305c..e7deb85 100644 --- a/Swiften/Whiteboard/WhiteboardSession.h +++ b/Swiften/Whiteboard/WhiteboardSession.h @@ -32,7 +32,7 @@ namespace Swift { const JID& getTo() const; public: - boost::signal< void(const std::string& data)> onDataReceived; + boost::signal< void(const WhiteboardElement::ref element)> onElementReceived; boost::signal< void(const JID& contact)> onSessionTerminateReceived; boost::signal< void(const JID& contact)> onRequestAccepted; boost::signal< void(const JID& contact)> onSessionCancelled; |