diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-29 07:32:51 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-29 07:33:48 (GMT) |
commit | a8f57139d663a176af87d7bc71dd85c62f6274cf (patch) | |
tree | e1c4def39b63d64e6f4ad7baefceae0f154789ce /Swiften | |
parent | dc04410eb678b8db257dc04b04662f974f6b3b83 (diff) | |
download | swift-contrib-a8f57139d663a176af87d7bc71dd85c62f6274cf.zip swift-contrib-a8f57139d663a176af87d7bc71dd85c62f6274cf.tar.bz2 |
Improved handling of IDs
Added ID parsing to every element and added function to get prefixes from
session to be able to distinguish elements between clients
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 10 | ||||
-rw-r--r-- | Swiften/Whiteboard/IncomingWhiteboardSession.cpp | 4 | ||||
-rw-r--r-- | Swiften/Whiteboard/IncomingWhiteboardSession.h | 1 | ||||
-rw-r--r-- | Swiften/Whiteboard/OutgoingWhiteboardSession.cpp | 4 | ||||
-rw-r--r-- | Swiften/Whiteboard/OutgoingWhiteboardSession.h | 1 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSession.cpp | 7 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSession.h | 2 |
7 files changed, 16 insertions, 13 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index 0477988..0f2734c 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -48,7 +48,7 @@ namespace Swift { } catch (boost::bad_lexical_cast&) { } whiteboardElement->setPenWidth(penWidth); - + whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); } else if (element == "path") { WhiteboardFreehandPathElement::ref whiteboardElement = boost::make_shared<WhiteboardFreehandPathElement>(); @@ -96,7 +96,7 @@ namespace Swift { Color color(attributes.getAttributeValue("stroke").get_value_or("#000000")); color.setAlpha(opacityToAlpha(attributes.getAttributeValue("opacity").get_value_or("1"))); whiteboardElement->setColor(color); - + whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); } else if (element == "rect") { int x = 0; @@ -126,7 +126,7 @@ namespace Swift { brushColor.setAlpha(opacityToAlpha(attributes.getAttributeValue("fill-opacity").get_value_or("1"))); whiteboardElement->setPenColor(penColor); whiteboardElement->setBrushColor(brushColor); - + whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); } else if (element == "polygon") { WhiteboardPolygonElement::ref whiteboardElement = boost::make_shared<WhiteboardPolygonElement>(); @@ -188,7 +188,7 @@ namespace Swift { } catch (boost::bad_lexical_cast&) { } whiteboardElement->setSize(fontSize); - + whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); } else if (element == "ellipse") { int cx = 0; @@ -218,7 +218,7 @@ namespace Swift { brushColor.setAlpha(opacityToAlpha(attributes.getAttributeValue("fill-opacity").get_value_or("1"))); whiteboardElement->setPenColor(penColor); whiteboardElement->setBrushColor(brushColor); - + whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); } } diff --git a/Swiften/Whiteboard/IncomingWhiteboardSession.cpp b/Swiften/Whiteboard/IncomingWhiteboardSession.cpp index 92a86a1..5cdba1a 100644 --- a/Swiften/Whiteboard/IncomingWhiteboardSession.cpp +++ b/Swiften/Whiteboard/IncomingWhiteboardSession.cpp @@ -19,4 +19,8 @@ namespace Swift { boost::shared_ptr<GenericRequest<WhiteboardPayload> > request = boost::make_shared<GenericRequest<WhiteboardPayload> >(IQ::Set, toJID_, payload, router_); request->send(); } + + std::string IncomingWhiteboardSession::getClientID() const { + return "b"; + } } diff --git a/Swiften/Whiteboard/IncomingWhiteboardSession.h b/Swiften/Whiteboard/IncomingWhiteboardSession.h index a0d0b49..9971d75 100644 --- a/Swiften/Whiteboard/IncomingWhiteboardSession.h +++ b/Swiften/Whiteboard/IncomingWhiteboardSession.h @@ -20,5 +20,6 @@ namespace Swift { ~IncomingWhiteboardSession(); void accept(); + std::string getClientID() const; }; } diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp index 2693fcd..585a689 100644 --- a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp +++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp @@ -21,4 +21,8 @@ namespace Swift { boost::shared_ptr<GenericRequest<WhiteboardPayload> > request = boost::make_shared<GenericRequest<WhiteboardPayload> >(IQ::Set, toJID_, payload, router_); request->send(); } + + std::string OutgoingWhiteboardSession::getClientID() const { + return "a"; + } } diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.h b/Swiften/Whiteboard/OutgoingWhiteboardSession.h index dfbd200..3d0dd1a 100644 --- a/Swiften/Whiteboard/OutgoingWhiteboardSession.h +++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.h @@ -20,5 +20,6 @@ namespace Swift { OutgoingWhiteboardSession(const JID& jid, IQRouter* router); virtual ~OutgoingWhiteboardSession(); void startSession(); + std::string getClientID() const; }; } diff --git a/Swiften/Whiteboard/WhiteboardSession.cpp b/Swiften/Whiteboard/WhiteboardSession.cpp index 18dea52..d9dc592 100644 --- a/Swiften/Whiteboard/WhiteboardSession.cpp +++ b/Swiften/Whiteboard/WhiteboardSession.cpp @@ -35,13 +35,6 @@ namespace Swift { } } - void WhiteboardSession::sendData(const std::string& data) { - boost::shared_ptr<WhiteboardPayload> payload = boost::make_shared<WhiteboardPayload>(); - payload->setData(data); - boost::shared_ptr<GenericRequest<WhiteboardPayload> > request = boost::make_shared<GenericRequest<WhiteboardPayload> >(IQ::Set, toJID_, payload, router_); - request->send(); - } - void WhiteboardSession::sendElement(const WhiteboardElement::ref element) { boost::shared_ptr<WhiteboardPayload> payload = boost::make_shared<WhiteboardPayload>(); payload->setElement(element); diff --git a/Swiften/Whiteboard/WhiteboardSession.h b/Swiften/Whiteboard/WhiteboardSession.h index e7deb85..d3e435a 100644 --- a/Swiften/Whiteboard/WhiteboardSession.h +++ b/Swiften/Whiteboard/WhiteboardSession.h @@ -26,10 +26,10 @@ namespace Swift { WhiteboardSession(const JID& jid, IQRouter* router); virtual ~WhiteboardSession(); void handleIncomingAction(boost::shared_ptr<WhiteboardPayload> payload); - void sendData(const std::string& data); void sendElement(const WhiteboardElement::ref element); void cancel(); const JID& getTo() const; + virtual std::string getClientID() const = 0; public: boost::signal< void(const WhiteboardElement::ref element)> onElementReceived; |