Code

Added skeleton files for other filter primitives' SP-objects. Added blur slider on...
[inkscape.git] / src / jabber_whiteboard / defines.h
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  */
13 #ifndef __INKSCAPE_WHITEBOARD_DEFINES_H__
14 #define __INKSCAPE_WHITEBOARD_DEFINES_H__
16 #include "jabber_whiteboard/message-tags.h"
18 #include <algorithm>
19 #include <cstring>
20 #include <string>
21 #include <map>
22 #include <set>
23 #include <bitset>
24 #include <vector>
26 #include <glibmm.h>
27 #include <sigc++/sigc++.h>
29 #include "jabber_whiteboard/keynode.h"
31 #include "gc-alloc.h"
33 // Various specializations of std::less for XMLNodeTracker maps.
34 namespace std {
35 using Inkscape::XML::Node;
37 /**
38  * Specialization of std::less<> for pointers to XML::Nodes.a
39  *
40  * \see Inkscape::XML::Node
41  */
42 template<>
43 struct less< Node* > : public binary_function < Node*, Node*, bool >
44 {
45         bool operator()(Node* _x, Node* _y) const
46         {
47                 return _x < _y;
48         }
50 };
52 }
54 namespace Inkscape {
56 namespace XML {
57     class Node;
58 }
60 namespace Util {
61     template< typename T > class ListContainer;
62 }
64 namespace Whiteboard {
66 #define NUM_FLAGS       9
68 namespace Message {
70     typedef char const* Wrapper;
71     typedef char const* Message;
73     extern Wrapper PROTOCOL;
74     extern Wrapper NEW;
75     extern Wrapper REMOVE;
76     extern Wrapper CONFIGURE;
77     extern Wrapper MOVE;
79     extern Message CONNECT_REQUEST;
80     extern Message CONNECTED;
81     extern Message ACCEPT_INVITATION;
82     extern Message DECLINE_INVITATION;
83     extern Message DOCUMENT_BEGIN;
84     extern Message DOCUMENT_END;
86 }
88 namespace Vars {
90     extern char const* INKBOARD_XMLNS; 
92 }
94 namespace State {
96     typedef char const* SessionType;
98     extern SessionType WHITEBOARD_MUC; 
99     extern SessionType WHITEBOARD_PEER;
101     typedef char const* SessionState;
104 namespace Dialog {
106 enum DialogReply {
108     ACCEPT_INVITATION =     0,
109     DECLINE_INVITATION =    1
110 };
114 // message types
115 // explicitly numbered to aid protocol description later on
119 // Message handler modes
120 enum HandlerMode {
121         DEFAULT,
122         PRESENCE,
123         ERROR
124 };
126 // Actions to pass to the node tracker when we modify a node in 
127 // the document tree upon event serialization
128 enum NodeTrackerAction {
129         NODE_ADD,
130         NODE_REMOVE,
131         NODE_UNKNOWN
132 };
134 // I am assuming that std::string (which will not properly represent Unicode data) will
135 // suffice for associating (integer, Jabber ID) identifiers with nodes. 
136 // We do not need to preserve all semantics handled by Unicode; we just need to have 
137 // the byte representation.  std::string is good enough for that.
138 //
139 // The reason for this is that comparisons with std::string are much faster than 
140 // comparisons with Glib::ustring (simply because the latter is using significantly
141 // more complex text-handling algorithms), and we need speed here.  We _could_ use
142 // Glib::ustring::collate_key() here and therefore get the best of both worlds,
143 // but collation keys are rather big.
144 //
145 // XML node tracker maps
147 /// Associates node keys to pointers to XML::Nodes.
148 /// \see Inkscape::Whiteboard::XMLNodeTracker
149 typedef std::map< std::string, XML::Node*, std::less< std::string >, GC::Alloc< std::pair< std::string, XML::Node* >, GC::MANUAL > > KeyToTrackerNodeMap;
151 /// Associates pointers to XML::Nodes with node keys.
152 /// \see Inkscape::Whiteboard::XMLNodeTracker
153 typedef std::map< XML::Node*, std::string, std::less< XML::Node* >, GC::Alloc< std::pair< XML::Node*, std::string >, GC::MANUAL > > TrackerNodeToKeyMap;
156 // TODO: Clean up these typedefs.  I'm sure quite a few of these aren't used anymore; additionally,
157 // it's probably possible to consolidate a few of these types into one.
159 // Temporary storage of new object messages and new nodes in said messages
160 typedef std::list< Glib::ustring > NewChildObjectMessageList;
162 typedef std::pair< KeyNodePair, NodeTrackerAction > SerializedEventNodeAction;
164 typedef std::list< SerializedEventNodeAction > KeyToNodeActionList;
166 //typedef std::map< std::string, SerializedEventNodeAction > KeyToNodeActionMap;
168 typedef std::set< std::string > AttributesScannedSet;
169 typedef std::set< XML::Node* > AttributesUpdatedSet;
171 typedef std::map< std::string, XML::Node const* > KeyToNodeMap;
172 typedef std::map< XML::Node const*, std::string > NodeToKeyMap;
175 // Message context verification and processing
176 struct MessageProcessor;
177 class ReceiveMessageQueue;
179 typedef std::map< std::string, ReceiveMessageQueue*, std::less< std::string >, GC::Alloc< std::pair< std::string, ReceiveMessageQueue* >, GC::MANUAL > > RecipientToReceiveQueueMap;
180 typedef std::map< std::string, unsigned int > ReceipientToLatestTransactionMap;
182 typedef std::string ReceivedCommitEvent;
183 typedef std::list< ReceivedCommitEvent > CommitsQueue;
185 // Message serialization
186 typedef std::list< Glib::ustring > SerializedEventList;
189     //typedef std::pair< Glib::ustring, InvitationResponses > Invitation_response_type;
190     //typedef std::list< Invitation_response_type > Invitation_responses_type;
191 // Error handling -- someday
192 // TODO: finish and integrate this
193 //typedef boost::function< LmHandlerResult (unsigned int code) > ErrorHandlerFunctor;
194 //typedef std::map< unsigned int, ErrorHandlerFunctor > ErrorHandlerFunctorMap;
196 // TODO: breaking these up into namespaces would be nice, but it's too much typing
197 // for now
199 // Protocol versions
200 extern char const* MESSAGE_PROTOCOL_V1;
201 extern int const HIGHEST_SUPPORTED;
203 // Node types (as strings)
204 extern char const* NODETYPE_DOCUMENT_STR;
205 extern char const* NODETYPE_ELEMENT_STR;
206 extern char const* NODETYPE_TEXT_STR;
207 extern char const* NODETYPE_COMMENT_STR;
209 // Number of chars to allocate for type field (in SessionManager::sendMessage)
210 extern int const TYPE_FIELD_SIZE;
212 // Number of chars to allocate for sequence number field (in SessionManager::sendMessage)
213 extern int const SEQNUM_FIELD_SIZE;
215 // Designators for certain "special" nodes in the document
216 // These nodes are "special" because they are generally present in all documents
217 extern char const* DOCUMENT_ROOT_NODE;
218 extern char const* DOCUMENT_NAMEDVIEW_NODE;
220 // Names of these special nodes
221 extern char const* DOCUMENT_ROOT_NAME;
222 extern char const* DOCUMENT_NAMEDVIEW_NAME;
224 // Inkboard client states
225 extern int const IN_WHITEBOARD;
226 extern int const LOGGED_IN;
227 extern int const IN_CHATROOM;
228 extern int const WAITING_FOR_INVITE_RESPONSE;
229 extern int const CONNECTING_TO_CHAT;
230 extern int const WAITING_TO_SYNC_TO_CHAT;
231 extern int const SYNCHRONIZING_WITH_CHAT;
232 extern int const OPEN_FOR_DOC;
233 extern int const PLAYING_SESSION_FILE;
235 // update this if any other status flags are added
237 // TODO: make this user-configurable, within sane limits
238 // ("sane" limits being roughly in the range (10, 100], from personal testing)
239 // Based on discussions with Ted, it seems that we're going to make the Jabber guys
240 // accomodate Inkscape, not the other way around...
241 // Dispatch interval (in milliseconds)
242 extern int const SEND_TIMEOUT;
250 #endif
252 /*
253   Local Variables:
254   mode:c++
255   c-file-style:"stroustrup"
256   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
257   indent-tabs-mode:nil
258   fill-column:99
259   End:
260 */
261 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :