diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-07-13 18:18:37 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-07-13 18:18:37 (GMT) |
commit | 0ba890e7e8c7e09c1257a7c3b1018f396e6896d1 (patch) | |
tree | 13dc4658023e89d48d4e7ae1854f70e827bf9cf6 /Swiften/Parser/PayloadParsers | |
parent | 4dc0788b78da3fe5a9daed5ab4593ba6423600ec (diff) | |
download | swift-contrib-0ba890e7e8c7e09c1257a7c3b1018f396e6896d1.zip swift-contrib-0ba890e7e8c7e09c1257a7c3b1018f396e6896d1.tar.bz2 |
Integrated WhiteboardClient and WhiteboardServer into rest of the code
Diffstat (limited to 'Swiften/Parser/PayloadParsers')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 27 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.h | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index 0f2734c..037eae2 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -12,6 +12,7 @@ #include <Swiften/Whiteboard/Elements/WhiteboardEllipseElement.h> #include <Swiften/Whiteboard/Elements/WhiteboardFreehandPathElement.h> #include <Swiften/Whiteboard/Elements/Color.h> +#include <Swiften/Whiteboard/Operations/WhiteboardInsertOperation.h> #include <boost/optional.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <boost/lexical_cast.hpp> @@ -24,6 +25,18 @@ namespace Swift { if (level_ == 0) { getPayloadInternal()->setType(stringToType(attributes.getAttributeValue("type").get_value_or(""))); } else if (level_ == 1) { + std::string type = attributes.getAttributeValue("type").get_value_or(""); + if (type == "insert") { + WhiteboardInsertOperation::ref insertOp = boost::make_shared<WhiteboardInsertOperation>(); + try { + insertOp->setID(attributes.getAttributeValue("id").get_value_or("")); + insertOp->setParentID(attributes.getAttributeValue("parentid").get_value_or("")); + insertOp->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0"))); + } catch (boost::bad_lexical_cast&) { + } + operation = insertOp; + } + } else if (level_ == 2) { if (element == "line") { int x1 = 0; int y1 = 0; @@ -50,6 +63,7 @@ namespace Swift { whiteboardElement->setPenWidth(penWidth); whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); + wbElement = whiteboardElement; } else if (element == "path") { WhiteboardFreehandPathElement::ref whiteboardElement = boost::make_shared<WhiteboardFreehandPathElement>(); std::string pathData = attributes.getAttributeValue("d").get_value_or(""); @@ -98,6 +112,7 @@ namespace Swift { whiteboardElement->setColor(color); whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); + wbElement = whiteboardElement; } else if (element == "rect") { int x = 0; int y = 0; @@ -128,6 +143,7 @@ namespace Swift { whiteboardElement->setBrushColor(brushColor); whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); + wbElement = whiteboardElement; } else if (element == "polygon") { WhiteboardPolygonElement::ref whiteboardElement = boost::make_shared<WhiteboardPolygonElement>(); @@ -166,6 +182,7 @@ namespace Swift { whiteboardElement->setBrushColor(brushColor); whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); + wbElement = whiteboardElement; } else if (element == "text") { int x = 0; int y = 0; @@ -190,6 +207,7 @@ namespace Swift { whiteboardElement->setSize(fontSize); whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); + wbElement = whiteboardElement; } else if (element == "ellipse") { int cx = 0; int cy = 0; @@ -220,6 +238,7 @@ namespace Swift { whiteboardElement->setBrushColor(brushColor); whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); + wbElement = whiteboardElement; } } ++level_; @@ -230,6 +249,12 @@ namespace Swift { if (level_ == 0) { getPayloadInternal()->setData(data_); } else if (level_ == 1) { + WhiteboardInsertOperation::ref insertOp = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(operation); + if (insertOp) { + insertOp->setElement(wbElement); + } + getPayloadInternal()->setOperation(operation); + } else if (level_ == 2) { if (element == "text") { actualIsText = false; } @@ -237,7 +262,7 @@ namespace Swift { } void WhiteboardParser::handleCharacterData(const std::string& data) { - if (level_ == 2 && actualIsText) { + if (level_ == 3 && actualIsText) { WhiteboardTextElement::ref element = boost::dynamic_pointer_cast<WhiteboardTextElement>(getPayloadInternal()->getElement()); element->setText(data); } diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.h b/Swiften/Parser/PayloadParsers/WhiteboardParser.h index 7c93de3..bc4ed2a 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.h +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.h @@ -9,6 +9,7 @@ #include <Swiften/Elements/WhiteboardPayload.h> #include <Swiften/Parser/GenericPayloadParser.h> #include <Swiften/Whiteboard/Elements/WhiteboardElement.h> +#include <Swiften/Whiteboard/Operations/WhiteboardOperation.h> namespace Swift { class WhiteboardParser : public Swift::GenericPayloadParser<WhiteboardPayload> { @@ -27,5 +28,7 @@ namespace Swift { bool actualIsText; int level_; std::string data_; + WhiteboardElement::ref wbElement; + WhiteboardOperation::ref operation; }; } |