diff options
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | 10 | ||||
-rw-r--r-- | Swiften/Whiteboard/IncomingWhiteboardSession.cpp | 5 | ||||
-rw-r--r-- | Swiften/Whiteboard/OutgoingWhiteboardSession.cpp | 5 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSession.h | 3 |
4 files changed, 13 insertions, 10 deletions
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp index 5654c06..fcb8ef1 100644 --- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp @@ -158,7 +158,6 @@ namespace Swift { graphicsView->deleteItem(P2QSTRING(deleteOp->getElementID())); } } - lastOpID = operation->getID(); } void QtWhiteboardWindow::changeLineWidth(int i) @@ -346,15 +345,11 @@ namespace Swift { if (type == GView::New) { WhiteboardInsertOperation::ref insertOp = boost::make_shared<WhiteboardInsertOperation>(); - insertOp->setID(Q2PSTRING(graphicsView->getNewID())); insertOp->setPos(pos); insertOp->setElement(el); - insertOp->setParentID(lastOpID); - lastOpID = insertOp->getID(); whiteboardSession_->sendOperation(insertOp); } else { WhiteboardUpdateOperation::ref updateOp = boost::make_shared<WhiteboardUpdateOperation>(); - updateOp->setID(Q2PSTRING(graphicsView->getNewID())); updateOp->setPos(pos); if (type == GView::Update) { updateOp->setNewPos(pos); @@ -364,19 +359,14 @@ namespace Swift { updateOp->setNewPos(pos-1); } updateOp->setElement(el); - updateOp->setParentID(lastOpID); - lastOpID = updateOp->getID(); whiteboardSession_->sendOperation(updateOp); } } void QtWhiteboardWindow::handleItemDeleted(QString id, int pos) { WhiteboardDeleteOperation::ref deleteOp = boost::make_shared<WhiteboardDeleteOperation>(); - deleteOp->setID(Q2PSTRING(graphicsView->getNewID())); deleteOp->setElementID(Q2PSTRING(id)); deleteOp->setPos(pos); - deleteOp->setParentID(lastOpID); - lastOpID = deleteOp->getID(); whiteboardSession_->sendOperation(deleteOp); } diff --git a/Swiften/Whiteboard/IncomingWhiteboardSession.cpp b/Swiften/Whiteboard/IncomingWhiteboardSession.cpp index 1904457..d3580e1 100644 --- a/Swiften/Whiteboard/IncomingWhiteboardSession.cpp +++ b/Swiften/Whiteboard/IncomingWhiteboardSession.cpp @@ -32,6 +32,7 @@ namespace Swift { WhiteboardClient::Result pairResult = client.handleServerOperationReceived(operation); if (pairResult.client) { onOperationReceived(pairResult.client); + lastOpID = pairResult.client->getID(); } if (pairResult.server) { @@ -42,6 +43,10 @@ namespace Swift { } void IncomingWhiteboardSession::sendOperation(WhiteboardOperation::ref operation) { + operation->setID(getClientID()+idGenerator.generateID()); + operation->setParentID(lastOpID); + lastOpID = operation->getID(); + WhiteboardOperation::ref result = client.handleLocalOperationReceived(operation); if (result) { diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp index c527942..63e4476 100644 --- a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp +++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp @@ -42,6 +42,7 @@ namespace Swift { WhiteboardOperation::ref op = server.handleClientOperationReceived(operation); onOperationReceived(op); + lastOpID = op->getID(); WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>(); payload->setOperation(op); @@ -49,6 +50,10 @@ namespace Swift { } void OutgoingWhiteboardSession::sendOperation(WhiteboardOperation::ref operation) { + operation->setID(getClientID()+idGenerator.generateID()); + operation->setParentID(lastOpID); + lastOpID = operation->getID(); + server.handleLocalOperationReceived(operation); WhiteboardPayload::ref payload = boost::make_shared<WhiteboardPayload>(); payload->setOperation(operation); diff --git a/Swiften/Whiteboard/WhiteboardSession.h b/Swiften/Whiteboard/WhiteboardSession.h index 1eb76a4..abfdd32 100644 --- a/Swiften/Whiteboard/WhiteboardSession.h +++ b/Swiften/Whiteboard/WhiteboardSession.h @@ -10,6 +10,7 @@ #include <Swiften/JID/JID.h> #include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Base/SimpleIDGenerator.h> #include <Swiften/Queries/GenericRequest.h> #include <Swiften/Whiteboard/Elements/WhiteboardElement.h> #include <Swiften/Whiteboard/Operations/WhiteboardOperation.h> @@ -50,5 +51,7 @@ namespace Swift { JID toJID_; IQRouter* router_; + std::string lastOpID; + SimpleIDGenerator idGenerator; }; } |