summaryrefslogtreecommitdiffstats
path: root/src/jabber_whiteboard/inkboard-session.h
blob: 10eeb63223674e24591eaf1fa438b313f403284f (plain)
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
/**
 * Inkscape::Whiteboard::InkboardSession - Whiteboard implementation of XML::Session interface
 *
 * 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_SESSION_H__
#define __INKSCAPE_WHITEBOARD_SESSION_H__

#include <glibmm.h>
#include <bitset>

#include "gc-managed.h"

#include "xml/session.h"
#include "xml/transaction-logger.h"
#include "xml/log-builder.h"
#include "xml/node-observer.h"
#include "xml/simple-session.h"

#include "pedro/pedroxmpp.h"

#include "jabber_whiteboard/inkboard-document.h"
#include "jabber_whiteboard/defines.h"

#include "util/share.h"

namespace Inkscape {

namespace Whiteboard {

class InkboardDocument;

class InkboardSession : public GC::Managed<>, public XML::Session,
                         public XML::TransactionLogger
{
public:

    InkboardSession() : _in_transaction(false) { }
    InkboardSession(InkboardDocument *document) : _in_transaction(false), doc(document) {}
    virtual ~InkboardSession() { }

    //
    // XML::TransactionLogger methods
    //
    Session& session()
    {
    	return *this;
    }

    // 
    // XML::Session methods
    // 
    bool inTransaction() 
    {
    	return _in_transaction;
    }

    void beginTransaction();
    void rollback();
    void commit();

    XML::Event* commitUndoable();

    XML::Node* createElementNode(char const* name);
    XML::Node* createTextNode(char const* content);
    XML::Node* createCommentNode(char const* content);

    //
    // XML::NodeObserver methodscd ../
    // (inherited from XML::TransactionLogger)
    //
    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);

private:

    InkboardSession(InkboardSession const &); // no copy
    void operator=(InkboardSession const &); // no assign

    bool _in_transaction;

    InkboardDocument *doc;
};

}

}

#endif