From: daleharvey Date: Thu, 31 Aug 2006 19:32:09 +0000 (+0000) Subject: Update to inkboard X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2279ca882bb0caa7941995b56812c3ffcfee3414;p=inkscape.git Update to inkboard --- diff --git a/src/jabber_whiteboard/defines.cpp b/src/jabber_whiteboard/defines.cpp index a8843b9e7..b1dac9913 100644 --- a/src/jabber_whiteboard/defines.cpp +++ b/src/jabber_whiteboard/defines.cpp @@ -49,7 +49,7 @@ namespace Vars { "<%1><%2 />"); const std::string NEW_MESSAGE( - "%4"); + "%4"); const std::string CONFIGURE_MESSAGE( ""); diff --git a/src/jabber_whiteboard/defines.h b/src/jabber_whiteboard/defines.h index 675e13136..8b3c56354 100644 --- a/src/jabber_whiteboard/defines.h +++ b/src/jabber_whiteboard/defines.h @@ -99,9 +99,6 @@ namespace Vars { extern const std::string MOVE_MESSAGE; extern const std::string REMOVE_MESSAGE; - - - } namespace State { diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp index 60d4cdd27..3c063a382 100644 --- a/src/jabber_whiteboard/inkboard-document.cpp +++ b/src/jabber_whiteboard/inkboard-document.cpp @@ -115,6 +115,10 @@ InkboardDocument::recieve(Message::Wrapper &wrapper, Pedro::Element* data) { this->sm->terminateSession(this->getSessionId()); } + }else if(wrapper == Message::NEW || wrapper == Message::CONFIGURE + || wrapper == Message::MOVE || wrapper == Message::REMOVE ) + { + handleChange(wrapper,data->getFirstChild()->getFirstChild()); } }else{ g_warning("Recieved Message in invalid state = %d", this->state); @@ -133,9 +137,9 @@ InkboardDocument::send(const Glib::ustring &destJid, Message::Wrapper &wrapper, else mes = message; - char *finalmessage = const_cast(String::ucompose(Vars::WHITEBOARD_MESSAGE, - this->sessionType,this->sm->getClient().getJid(),destJid, - Vars::INKBOARD_XMLNS,this->getSessionId(),mes).c_str()); + char *finalmessage = const_cast(String::ucompose( + Vars::WHITEBOARD_MESSAGE, this->sessionType, this->sm->getClient().getJid(), + destJid, Vars::INKBOARD_XMLNS, this->getSessionId(), mes).c_str()); if (!this->sm->getClient().write(finalmessage)) { return false; } @@ -154,16 +158,21 @@ InkboardDocument::sendDocument(Inkscape::XML::Node* root) { for(Inkscape::XML::Node *child = root->firstChild();child!=NULL;child=child->next()) { - Glib::ustring parentKey,tempParentKey,key; + Glib::ustring name(child->name()); - this->addNodeToTracker(child); - Message::Message message = this->composeNewMessage(child); + if(name != "svg:metadata" && name != "svg:defs" && name != "sodipodi:namedview") + { + Glib::ustring parentKey,tempParentKey,key; - this->send(this->getRecipient(),Message::NEW,message); + this->addNodeToTracker(child); + Message::Message message = this->composeNewMessage(child); - if(child->childCount() != 0) - { - sendDocument(child); + this->send(this->getRecipient(),Message::NEW,message); + + if(child->childCount() != 0) + { + sendDocument(child); + } } } } @@ -242,6 +251,42 @@ InkboardDocument::handleState(State::SessionState expectedState, State::SessionS return false; } + +void +InkboardDocument::handleChange(Message::Wrapper &wrapper, Pedro::Element* data) +{ + if(wrapper == Message::NEW) + { + Glib::ustring parent = data->getTagAttribute("new","parent"); + Glib::ustring id = data->getTagAttribute("new","id"); + + signed int index = atoi + (data->getTagAttribute("new","index").c_str()); + + Pedro::Element* element = data->getFirstChild(); + + if(parent.size() > 0 && id.size() > 0) + this->changeNew(parent,id,index,element); + + }else if(wrapper == Message::CONFIGURE) + { + Glib::ustring target = data->getTagAttribute("configure","target"); + Glib::ustring attribute = data->getTagAttribute("configure","attribute"); + Glib::ustring value = data->getTagAttribute("configure","value"); + + signed int version = atoi + (data->getTagAttribute("configure","version").c_str()); + + if(target.size() > 0 && attribute.size() > 0 && value.size() > 0) + this->changeConfigure(target,version,attribute,value); + + }else if(wrapper == Message::MOVE) + { + }else if(wrapper == Message::REMOVE) + { + } +} + } // namespace Whiteboard } // namespace Inkscape diff --git a/src/jabber_whiteboard/inkboard-document.h b/src/jabber_whiteboard/inkboard-document.h index 45a4178d4..510f47c6e 100644 --- a/src/jabber_whiteboard/inkboard-document.h +++ b/src/jabber_whiteboard/inkboard-document.h @@ -48,18 +48,31 @@ public: void terminateSession(); void recieve(Message::Wrapper &wrapper, Pedro::Element* data); - bool send(const Glib::ustring &destJid, Message::Wrapper &mwrapper, Message::Message &message); + bool send(const Glib::ustring &destJid, Message::Wrapper &mwrapper, + Message::Message &message); void sendDocument(Inkscape::XML::Node* root); bool handleOutgoingState(Message::Wrapper &wrapper,Glib::ustring const& message); bool handleIncomingState(Message::Wrapper &wrapper,Pedro::Element* data); - bool handleState(State::SessionState expectedState, State::SessionState newstate); + bool handleState(State::SessionState expectedState, + State::SessionState newstate); + void handleChange(Message::Wrapper &wrapper, Pedro::Element* data); + + + /* Functions below are defined in inkboard-node.cpp */ Glib::ustring addNodeToTracker(Inkscape::XML::Node* node); Message::Message composeNewMessage(Inkscape::XML::Node *node); + void changeConfigure(Glib::ustring target, signed int target, + Glib::ustring attribute, Glib::ustring value); + + void changeNew(Glib::ustring target, Glib::ustring, + signed int index, Pedro::Element* data); + + protected: /** * Copy constructor. diff --git a/src/jabber_whiteboard/inkboard-node.cpp b/src/jabber_whiteboard/inkboard-node.cpp index c463e461a..bcb6cd981 100644 --- a/src/jabber_whiteboard/inkboard-node.cpp +++ b/src/jabber_whiteboard/inkboard-node.cpp @@ -52,6 +52,26 @@ InkboardDocument::composeNewMessage(Inkscape::XML::Node *node) return message; } +void +InkboardDocument::changeConfigure(Glib::ustring target, signed int version, + Glib::ustring attribute, Glib::ustring value) +{ +} + +void +InkboardDocument::changeNew(Glib::ustring target, Glib::ustring, + signed int index, Pedro::Element* data) +{ + Glib::ustring name = data->getName(); + + if(name == "text") + { + //XML::Node* parent = this->tracker->get(target); + //parent->setContent(date->getValue()); + } + +} + } // namespace Whiteboard } // namespace Inkscape