Code

Update to inkboard
authordaleharvey <daleharvey@users.sourceforge.net>
Thu, 31 Aug 2006 19:32:09 +0000 (19:32 +0000)
committerdaleharvey <daleharvey@users.sourceforge.net>
Thu, 31 Aug 2006 19:32:09 +0000 (19:32 +0000)
src/jabber_whiteboard/defines.cpp
src/jabber_whiteboard/defines.h
src/jabber_whiteboard/inkboard-document.cpp
src/jabber_whiteboard/inkboard-document.h
src/jabber_whiteboard/inkboard-node.cpp

index a8843b9e758f40331275480cbb49d45e66652b67..b1dac9913e609e6b09ea2c56715c759c9fb3e01e 100644 (file)
@@ -49,7 +49,7 @@ namespace Vars {
         "<%1><%2 /></%1>");
 
     const std::string NEW_MESSAGE(
-        "<new parent=\"%1\" id=\"%2\" target=\"%3\">%4</new>");
+        "<new parent=\"%1\" id=\"%2\" index=\"%3\">%4</new>");
 
     const std::string CONFIGURE_MESSAGE(
         "<configure target=\"%1\" version=\"%2\" attribute=\"%3\" value=\"%4\" />");
index 675e1313615ad24158dbf5258e79c029560e0694..8b3c563540f325cdfe77781a5047d9239268669b 100644 (file)
@@ -99,9 +99,6 @@ namespace Vars {
     extern const std::string MOVE_MESSAGE; 
     extern const std::string REMOVE_MESSAGE; 
 
-
-
-
 }
 
 namespace State {
index 60d4cdd27e15c532339fe084d7f006b38bfbab0d..3c063a382d6c3b86f597ddeed792bdb63d89caa3 100644 (file)
@@ -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<char* >(String::ucompose(Vars::WHITEBOARD_MESSAGE,
-            this->sessionType,this->sm->getClient().getJid(),destJid,
-            Vars::INKBOARD_XMLNS,this->getSessionId(),mes).c_str());
+        char *finalmessage = const_cast<char* >(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
 
index 45a4178d46cbd6671bda13eb45afb76a01f74b54..510f47c6e5d11c0e69e2c11e98a7a9957cf4cdb1 100644 (file)
@@ -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.
index c463e461a2013b5206aa1596e3c0da66208bf4fd..bcb6cd981af3f522a4f23fb43842cac7b43a5138 100644 (file)
@@ -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