Code

Swedish translation update by Elias.
[inkscape.git] / src / jabber_whiteboard / inkboard-document.h
index 5eaeffca8e65ee8434f5707f77fe8003acc63d2a..a4a82c6fbf828d1aeaaf7ee8bfb1a05a1ba71083 100644 (file)
@@ -16,7 +16,9 @@
 
 #include "document.h"
 #include "xml/document.h"
+#include "xml/node.h"
 #include "xml/simple-node.h"
+#include "xml/node-observer.h"
 #include "jabber_whiteboard/defines.h"
 #include "jabber_whiteboard/keynode.h"
 #include "jabber_whiteboard/session-manager.h"
@@ -25,7 +27,10 @@ namespace Inkscape {
 
 namespace Whiteboard {
 
-class InkboardDocument : public XML::SimpleNode, public XML::Document {
+class InkboardDocument : public XML::SimpleNode,
+                         public XML::Document,
+                         public XML::NodeObserver
+{
 public:
        
     explicit InkboardDocument(int code, State::SessionType sessionType, Glib::ustring const& to);
@@ -61,6 +66,42 @@ public:
 
     void handleChange(Message::Wrapper &wrapper, Pedro::Element* data);
 
+    // 
+    // XML::Session methods
+    // 
+    bool inTransaction() 
+    {
+       return _in_transaction;
+    }
+
+    void beginTransaction();
+    void rollback();
+    void commit();
+
+    XML::Event* commitUndoable();
+
+    XML::Node* createElement(char const* name);
+    XML::Node* createTextNode(char const* content);
+    XML::Node* createComment(char const* content);
+    XML::Node* createPI(char const *target, char const* content);
+
+    //
+    // XML::NodeObserver methods
+    //
+    void notifyChildAdded(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, Inkscape::XML::Node *prev);
+
+    void notifyChildRemoved(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, Inkscape::XML::Node *prev);
+
+    void notifyChildOrderChanged(Inkscape::XML::Node &parent, Inkscape::XML::Node &child,
+                                 Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev);
+
+    void notifyContentChanged(Inkscape::XML::Node &node,
+                              Util::ptr_shared<char> old_content,
+                              Util::ptr_shared<char> new_content);
+
+    void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name,
+                                Util::ptr_shared<char> old_value,
+                                Util::ptr_shared<char> new_value);
 
     /* Functions below are defined in inkboard-node.cpp */
     Glib::ustring addNodeToTracker(Inkscape::XML::Node* node);
@@ -75,7 +116,6 @@ public:
     void changeConfigureText(Glib::ustring target, unsigned int version,
             Glib::ustring text);
 
-
 protected:
        /**
         * Copy constructor.
@@ -83,18 +123,20 @@ protected:
         * \param orig Instance to copy.
         */
        InkboardDocument(InkboardDocument const& orig) :
-               XML::Node(), XML::SimpleNode(orig), XML::Document(), recipient(orig.recipient)
+               XML::Node(), XML::SimpleNode(orig),
+                XML::Document(), XML::NodeObserver(),
+                recipient(orig.recipient), _in_transaction(false)
        {
                _initBindings();
        }
 
-       XML::SimpleNode* _duplicate() const
+       XML::SimpleNode* _duplicate(XML::Document* /*xml_doc*/) const
        {
                return new InkboardDocument(*this);
        }
+       NodeObserver *logger() { return this; }
 
 private:
-
     void _initBindings();
 
     SessionManager      *sm;
@@ -103,6 +145,8 @@ private:
 
     Glib::ustring sessionId;
     Glib::ustring recipient;
+
+    bool _in_transaction;
 };
 
 }