1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/**
* Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation
*
* Authors:
* David Yip <yipdw@rose-hulman.edu>
*
* Copyright (c) 2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifndef __INKSCAPE_WHITEBOARD_INKBOARDDOCUMENT_H__
#define __INKSCAPE_WHITEBOARD_INKBOARDDOCUMENT_H__
#include <glibmm.h>
#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"
namespace Inkscape {
namespace Whiteboard {
class InkboardDocument : public XML::SimpleNode,
public XML::Document,
public XML::NodeObserver
{
public:
explicit InkboardDocument(int code, State::SessionType sessionType, Glib::ustring const& to);
XML::NodeType type() const
{
return Inkscape::XML::DOCUMENT_NODE;
}
State::SessionState state;
KeyNodeTable *tracker;
void setRecipient(Glib::ustring const& val);
Glib::ustring getRecipient() const;
void setSessionId(Glib::ustring const& val);
Glib::ustring getSessionId() const;
void startSessionNegotiation();
void terminateSession();
void recieve(Message::Wrapper &wrapper, Pedro::Element* data);
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);
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);
Message::Message composeNewMessage(Inkscape::XML::Node *node);
void changeConfigure(Glib::ustring target, unsigned int version,
Glib::ustring attribute, Glib::ustring value);
void changeNew(Glib::ustring target, Glib::ustring,
signed int index, Pedro::Element* data);
void changeConfigureText(Glib::ustring target, unsigned int version,
Glib::ustring text);
protected:
/**
* Copy constructor.
*
* \param orig Instance to copy.
*/
InkboardDocument(InkboardDocument const& orig) :
XML::Node(), XML::SimpleNode(orig),
XML::Document(), XML::NodeObserver(),
recipient(orig.recipient), _in_transaction(false)
{
_initBindings();
}
XML::SimpleNode* _duplicate(XML::Document* /*xml_doc*/) const
{
return new InkboardDocument(*this);
}
NodeObserver *logger() { return this; }
private:
void _initBindings();
SessionManager *sm;
State::SessionType sessionType;
Glib::ustring sessionId;
Glib::ustring recipient;
bool _in_transaction;
};
}
}
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
|