~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/jabber_whiteboard/defines.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Whiteboard session manager
 
3
 * Definitions
 
4
 * 
 
5
 * Authors:
 
6
 * David Yip <yipdw@rose-hulman.edu>
 
7
 *
 
8
 * Copyright (c) 2005 Authors
 
9
 *
 
10
 * Released under GNU GPL, read the file 'COPYING' for more information
 
11
 */
 
12
 
 
13
#ifndef __INKSCAPE_WHITEBOARD_DEFINES_H__
 
14
#define __INKSCAPE_WHITEBOARD_DEFINES_H__
 
15
 
 
16
#include "xml/node.h"
 
17
#include "jabber_whiteboard/message-tags.h"
 
18
 
 
19
#include <algorithm>
 
20
#include <cstring>
 
21
#include <string>
 
22
#include <map>
 
23
#include <set>
 
24
#include <bitset>
 
25
#include <vector>
 
26
 
 
27
#include <glibmm.h>
 
28
#include <sigc++/sigc++.h>
 
29
 
 
30
#include "gc-alloc.h"
 
31
 
 
32
// Various specializations of std::less for XMLNodeTracker maps.
 
33
namespace std {
 
34
using Inkscape::XML::Node;
 
35
 
 
36
/**
 
37
 * Specialization of std::less<> for pointers to XML::Nodes.a
 
38
 *
 
39
 * \see Inkscape::XML::Node
 
40
 */
 
41
template<>
 
42
struct less< Node* > : public binary_function < Node*, Node*, bool >
 
43
{
 
44
    bool operator()(Node* _x, Node* _y) const
 
45
    {
 
46
        return _x < _y;
 
47
    }
 
48
 
 
49
};
 
50
 
 
51
}
 
52
 
 
53
namespace Inkscape {
 
54
 
 
55
namespace XML {
 
56
    class Node;
 
57
}
 
58
 
 
59
namespace Util {
 
60
    template< typename T > class ListContainer;
 
61
}
 
62
 
 
63
namespace Whiteboard {
 
64
 
 
65
#define NUM_FLAGS       9
 
66
 
 
67
namespace Message {
 
68
 
 
69
    typedef const std::string Wrapper;
 
70
    typedef std::string Message;
 
71
 
 
72
    extern Wrapper PROTOCOL;
 
73
    extern Wrapper NEW;
 
74
    extern Wrapper REMOVE;
 
75
    extern Wrapper CONFIGURE;
 
76
    extern Wrapper MOVE;
 
77
 
 
78
    extern Message CONNECT_REQUEST;
 
79
    extern Message CONNECTED;
 
80
    extern Message ACCEPT_INVITATION;
 
81
    extern Message DECLINE_INVITATION;
 
82
    extern Message DOCUMENT_BEGIN;
 
83
    extern Message DOCUMENT_END;
 
84
 
 
85
}
 
86
 
 
87
namespace Vars {
 
88
 
 
89
    extern const std::string DOCUMENT_ROOT_NODE;
 
90
 
 
91
    extern const std::string INKBOARD_XMLNS; 
 
92
 
 
93
    extern const std::string WHITEBOARD_MESSAGE; 
 
94
    extern const std::string PROTOCOL_MESSAGE; 
 
95
    extern const std::string NEW_MESSAGE; 
 
96
    extern const std::string CONFIGURE_MESSAGE; 
 
97
    extern const std::string CONFIGURE_TEXT_MESSAGE; 
 
98
    extern const std::string MOVE_MESSAGE; 
 
99
    extern const std::string REMOVE_MESSAGE; 
 
100
 
 
101
}
 
102
 
 
103
namespace State {
 
104
 
 
105
    typedef const std::string SessionType;
 
106
 
 
107
    extern SessionType WHITEBOARD_MUC; 
 
108
    extern SessionType WHITEBOARD_PEER;
 
109
 
 
110
    enum SessionState {
 
111
 
 
112
        INITIAL =                   0,
 
113
        AWAITING_INVITATION_REPLY = 1,
 
114
        CONNECTING =                2,
 
115
        INVITATION_RECIEVED =       3,
 
116
        AWAITING_CONNECTED =        4,
 
117
        CONNECTED =                 5,
 
118
        AWAITING_DOCUMENT_BEGIN =   6,
 
119
        SYNCHRONISING =             7,
 
120
        IN_WHITEBOARD =             8
 
121
 
 
122
    };
 
123
}
 
124
 
 
125
namespace Dialog {
 
126
 
 
127
    enum DialogReply {
 
128
 
 
129
        ACCEPT_INVITATION =     0,
 
130
        DECLINE_INVITATION =    1
 
131
    };
 
132
 
 
133
}
 
134
 
 
135
class KeyNodePair;
 
136
class KeyNodeTable;
 
137
 
 
138
typedef std::pair<Glib::ustring, Glib::ustring> Configure;
 
139
 
 
140
// Message handler modes
 
141
enum HandlerMode {
 
142
        DEFAULT,
 
143
        PRESENCE,
 
144
        ERROR
 
145
};
 
146
 
 
147
// Actions to pass to the node tracker when we modify a node in 
 
148
// the document tree upon event serialization
 
149
enum NodeTrackerAction {
 
150
        NODE_ADD,
 
151
        NODE_REMOVE,
 
152
        NODE_UNKNOWN
 
153
};
 
154
 
 
155
// I am assuming that std::string (which will not properly represent Unicode data) will
 
156
// suffice for associating (integer, Jabber ID) identifiers with nodes. 
 
157
// We do not need to preserve all semantics handled by Unicode; we just need to have 
 
158
// the byte representation.  std::string is good enough for that.
 
159
//
 
160
// The reason for this is that comparisons with std::string are much faster than 
 
161
// comparisons with Glib::ustring (simply because the latter is using significantly
 
162
// more complex text-handling algorithms), and we need speed here.  We _could_ use
 
163
// Glib::ustring::collate_key() here and therefore get the best of both worlds,
 
164
// but collation keys are rather big.
 
165
//
 
166
// XML node tracker maps
 
167
 
 
168
/// Associates node keys to pointers to XML::Nodes.
 
169
/// \see Inkscape::Whiteboard::XMLNodeTracker
 
170
typedef std::map< std::string, XML::Node*, std::less< std::string >, GC::Alloc< std::pair< std::string, XML::Node* >, GC::MANUAL > > KeyToTrackerNodeMap;
 
171
 
 
172
/// Associates pointers to XML::Nodes with node keys.
 
173
/// \see Inkscape::Whiteboard::XMLNodeTracker
 
174
typedef std::map< XML::Node*, std::string, std::less< XML::Node* >, GC::Alloc< std::pair< XML::Node*, std::string >, GC::MANUAL > > TrackerNodeToKeyMap;
 
175
 
 
176
 
 
177
// TODO: Clean up these typedefs.  I'm sure quite a few of these aren't used anymore; additionally,
 
178
// it's probably possible to consolidate a few of these types into one.
 
179
 
 
180
// Temporary storage of new object messages and new nodes in said messages
 
181
typedef std::list< Glib::ustring > NewChildObjectMessageList;
 
182
 
 
183
typedef std::pair< KeyNodePair, NodeTrackerAction > SerializedEventNodeAction;
 
184
 
 
185
typedef std::list< SerializedEventNodeAction > KeyToNodeActionList;
 
186
 
 
187
//typedef std::map< std::string, SerializedEventNodeAction > KeyToNodeActionMap;
 
188
 
 
189
typedef std::set< std::string > AttributesScannedSet;
 
190
typedef std::set< XML::Node* > AttributesUpdatedSet;
 
191
 
 
192
typedef std::map< std::string, XML::Node const* > KeyToNodeMap;
 
193
typedef std::map< XML::Node const*, std::string > NodeToKeyMap;
 
194
 
 
195
 
 
196
// Message context verification and processing
 
197
struct MessageProcessor;
 
198
class ReceiveMessageQueue;
 
199
 
 
200
typedef std::map< std::string, ReceiveMessageQueue*, std::less< std::string >, GC::Alloc< std::pair< std::string, ReceiveMessageQueue* >, GC::MANUAL > > RecipientToReceiveQueueMap;
 
201
typedef std::map< std::string, unsigned int > ReceipientToLatestTransactionMap;
 
202
 
 
203
typedef std::string ReceivedCommitEvent;
 
204
typedef std::list< ReceivedCommitEvent > CommitsQueue;
 
205
 
 
206
// Message serialization
 
207
typedef std::list< Glib::ustring > SerializedEventList;
 
208
 
 
209
 
 
210
    //typedef std::pair< Glib::ustring, InvitationResponses > Invitation_response_type;
 
211
    //typedef std::list< Invitation_response_type > Invitation_responses_type;
 
212
// Error handling -- someday
 
213
// TODO: finish and integrate this
 
214
//typedef boost::function< LmHandlerResult (unsigned int code) > ErrorHandlerFunctor;
 
215
//typedef std::map< unsigned int, ErrorHandlerFunctor > ErrorHandlerFunctorMap;
 
216
 
 
217
// TODO: breaking these up into namespaces would be nice, but it's too much typing
 
218
// for now
 
219
 
 
220
// Protocol versions
 
221
extern char const* MESSAGE_PROTOCOL_V1;
 
222
extern int const HIGHEST_SUPPORTED;
 
223
 
 
224
// Node types (as strings)
 
225
extern char const* NODETYPE_DOCUMENT_STR;
 
226
extern char const* NODETYPE_ELEMENT_STR;
 
227
extern char const* NODETYPE_TEXT_STR;
 
228
extern char const* NODETYPE_COMMENT_STR;
 
229
 
 
230
// Number of chars to allocate for type field (in SessionManager::sendMessage)
 
231
extern int const TYPE_FIELD_SIZE;
 
232
 
 
233
// Number of chars to allocate for sequence number field (in SessionManager::sendMessage)
 
234
extern int const SEQNUM_FIELD_SIZE;
 
235
 
 
236
// Designators for certain "special" nodes in the document
 
237
// These nodes are "special" because they are generally present in all documents
 
238
extern char const* DOCUMENT_ROOT_NODE;
 
239
extern char const* DOCUMENT_NAMEDVIEW_NODE;
 
240
 
 
241
// Names of these special nodes
 
242
extern char const* DOCUMENT_ROOT_NAME;
 
243
extern char const* DOCUMENT_NAMEDVIEW_NAME;
 
244
 
 
245
}
 
246
 
 
247
}
 
248
 
 
249
 
 
250
 
 
251
#endif
 
252
 
 
253
/*
 
254
  Local Variables:
 
255
  mode:c++
 
256
  c-file-style:"stroustrup"
 
257
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
258
  indent-tabs-mode:nil
 
259
  fill-column:99
 
260
  End:
 
261
*/
 
262
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :