Code

Swedish translation update by Elias.
[inkscape.git] / src / jabber_whiteboard / inkboard-document.h
1 /**
2  * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation
3  *
4  * Authors:
5  * David Yip <yipdw@rose-hulman.edu>
6  *
7  * Copyright (c) 2005 Authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #ifndef __INKSCAPE_WHITEBOARD_INKBOARDDOCUMENT_H__
13 #define __INKSCAPE_WHITEBOARD_INKBOARDDOCUMENT_H__
15 #include <glibmm.h>
17 #include "document.h"
18 #include "xml/document.h"
19 #include "xml/node.h"
20 #include "xml/simple-node.h"
21 #include "xml/node-observer.h"
22 #include "jabber_whiteboard/defines.h"
23 #include "jabber_whiteboard/keynode.h"
24 #include "jabber_whiteboard/session-manager.h"
26 namespace Inkscape {
28 namespace Whiteboard {
30 class InkboardDocument : public XML::SimpleNode,
31                          public XML::Document,
32                          public XML::NodeObserver
33 {
34 public:
35         
36     explicit InkboardDocument(int code, State::SessionType sessionType, Glib::ustring const& to);
38     XML::NodeType type() const
39     {
40         return Inkscape::XML::DOCUMENT_NODE;
41     }
43     State::SessionState state;
44     KeyNodeTable *tracker;
46     void setRecipient(Glib::ustring const& val);
47     Glib::ustring getRecipient() const;
49     void setSessionId(Glib::ustring const& val);
50     Glib::ustring getSessionId() const;
52     void startSessionNegotiation();
53     void terminateSession();
55     void recieve(Message::Wrapper &wrapper, Pedro::Element* data);
56     bool send(const Glib::ustring &destJid, Message::Wrapper &mwrapper, 
57             Message::Message &message);
59     void sendDocument(Inkscape::XML::Node* root);
61     bool handleOutgoingState(Message::Wrapper &wrapper,Glib::ustring const& message);
62     bool handleIncomingState(Message::Wrapper &wrapper,Pedro::Element* data);
64     bool handleState(State::SessionState expectedState, 
65             State::SessionState newstate);
67     void handleChange(Message::Wrapper &wrapper, Pedro::Element* data);
69     // 
70     // XML::Session methods
71     // 
72     bool inTransaction() 
73     {
74         return _in_transaction;
75     }
77     void beginTransaction();
78     void rollback();
79     void commit();
81     XML::Event* commitUndoable();
83     XML::Node* createElement(char const* name);
84     XML::Node* createTextNode(char const* content);
85     XML::Node* createComment(char const* content);
86     XML::Node* createPI(char const *target, char const* content);
88     //
89     // XML::NodeObserver methods
90     //
91     void notifyChildAdded(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, Inkscape::XML::Node *prev);
93     void notifyChildRemoved(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, Inkscape::XML::Node *prev);
95     void notifyChildOrderChanged(Inkscape::XML::Node &parent, Inkscape::XML::Node &child,
96                                  Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev);
98     void notifyContentChanged(Inkscape::XML::Node &node,
99                               Util::ptr_shared<char> old_content,
100                               Util::ptr_shared<char> new_content);
102     void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name,
103                                 Util::ptr_shared<char> old_value,
104                                 Util::ptr_shared<char> new_value);
106     /* Functions below are defined in inkboard-node.cpp */
107     Glib::ustring addNodeToTracker(Inkscape::XML::Node* node);
108     Message::Message composeNewMessage(Inkscape::XML::Node *node);
110     void changeConfigure(Glib::ustring target, unsigned int version,
111             Glib::ustring attribute, Glib::ustring value);
113     void changeNew(Glib::ustring target, Glib::ustring, 
114             signed int index, Pedro::Element* data);
116     void changeConfigureText(Glib::ustring target, unsigned int version,
117             Glib::ustring text);
119 protected:
120         /**
121          * Copy constructor.
122          * 
123          * \param orig Instance to copy.
124          */
125         InkboardDocument(InkboardDocument const& orig) :
126                 XML::Node(), XML::SimpleNode(orig),
127                 XML::Document(), XML::NodeObserver(),
128                 recipient(orig.recipient), _in_transaction(false)
129         {
130                 _initBindings();
131         }
133         XML::SimpleNode* _duplicate(XML::Document* /*xml_doc*/) const
134         {
135                 return new InkboardDocument(*this);
136         }
137         NodeObserver *logger() { return this; }
139 private:
140     void _initBindings();
142     SessionManager      *sm;
144     State::SessionType  sessionType;
146     Glib::ustring sessionId;
147     Glib::ustring recipient;
149     bool _in_transaction;
150 };
156 #endif
158 /*
159   Local Variables:
160   mode:c++
161   c-file-style:"stroustrup"
162   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
163   indent-tabs-mode:nil
164   fill-column:99
165   End:
166 */
167 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :