diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-07-16 12:14:05 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-07-16 12:14:05 (GMT) |
commit | b2e11d7f32db65a6be001dfdf74b74f16f4c9ec3 (patch) | |
tree | e99331d9c20e8199fda582e5f1b603d01b368f2a /Swiften/Parser | |
parent | 0ba890e7e8c7e09c1257a7c3b1018f396e6896d1 (diff) | |
download | swift-contrib-b2e11d7f32db65a6be001dfdf74b74f16f4c9ec3.zip swift-contrib-b2e11d7f32db65a6be001dfdf74b74f16f4c9ec3.tar.bz2 |
Extended classes handling synchronization with update operation
Diffstat (limited to 'Swiften/Parser')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index 037eae2..5d4aef1 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -13,6 +13,7 @@ #include <Swiften/Whiteboard/Elements/WhiteboardFreehandPathElement.h> #include <Swiften/Whiteboard/Elements/Color.h> #include <Swiften/Whiteboard/Operations/WhiteboardInsertOperation.h> +#include <Swiften/Whiteboard/Operations/WhiteboardUpdateOperation.h> #include <boost/optional.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <boost/lexical_cast.hpp> @@ -35,6 +36,15 @@ namespace Swift { } catch (boost::bad_lexical_cast&) { } operation = insertOp; + } else if (type == "update") { + WhiteboardUpdateOperation::ref updateOp = boost::make_shared<WhiteboardUpdateOperation>(); + try { + updateOp->setID(attributes.getAttributeValue("id").get_value_or("")); + updateOp->setParentID(attributes.getAttributeValue("parentid").get_value_or("")); + updateOp->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0"))); + } catch (boost::bad_lexical_cast&) { + } + operation = updateOp; } } else if (level_ == 2) { if (element == "line") { @@ -42,15 +52,21 @@ namespace Swift { int y1 = 0; int x2 = 0; int y2 = 0; + int xShift = 0; + int yShift = 0; try { x1 = boost::lexical_cast<int>(attributes.getAttributeValue("x1").get_value_or("0")); y1 = boost::lexical_cast<int>(attributes.getAttributeValue("y1").get_value_or("0")); x2 = boost::lexical_cast<int>(attributes.getAttributeValue("x2").get_value_or("0")); y2 = boost::lexical_cast<int>(attributes.getAttributeValue("y2").get_value_or("0")); + xShift = boost::lexical_cast<int>(attributes.getAttributeValue("xshift").get_value_or("0")); + yShift = boost::lexical_cast<int>(attributes.getAttributeValue("yshift").get_value_or("0")); } catch (boost::bad_lexical_cast&) { } WhiteboardLineElement::ref whiteboardElement = boost::make_shared<WhiteboardLineElement>(x1, y1, x2, y2); + whiteboardElement->setShift(xShift, yShift); + Color color(attributes.getAttributeValue("stroke").get_value_or("#000000")); color.setAlpha(opacityToAlpha(attributes.getAttributeValue("opacity").get_value_or("1"))); whiteboardElement->setColor(color); @@ -253,6 +269,11 @@ namespace Swift { if (insertOp) { insertOp->setElement(wbElement); } + + WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(operation); + if (updateOp) { + updateOp->setElement(wbElement); + } getPayloadInternal()->setOperation(operation); } else if (level_ == 2) { if (element == "text") { |