1 /**
2 * Whiteboard session manager
3 * Inkboard message context 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 #include "jabber_whiteboard/defines.h"
14 #include "jabber_whiteboard/message-contexts.h"
16 #include <bitset>
18 namespace Inkscape {
20 namespace Whiteboard {
22 void
23 initialize_received_message_contexts(MessageContextMap& mcm)
24 {
26 // Each Inkboard message has a context of validity according to an Inkboard
27 // client's state. That is, certain messages should be acknowledged and processed
28 // in some states, whereas other messages should not.
29 // For instance, a whiteboard invitation should be acknowledged if an Inkboard
30 // client is not in a whiteboard session, but should be refused if said client
31 // _is_ in a whiteboard session.
33 // Only the flags that are required to be set must be set; all flags, by default,
34 // are zero. Explicit definition doesn't hurt, though.
36 // The general format of message context creation and registration is
37 // std::bitset< NUM_FLAGS > m_
38 // m_.set( );
39 // m_.set( );
40 // mcm[ ] = m_;
43 // Begin
45 // Special bitsets
46 std::bitset< NUM_FLAGS > all_contexts;
47 all_contexts.flip();
49 // Messages: CHANGE_NOT_REPEATABLE, CHANGE_REPEATABLE, DUMMY_CHANGE, CHANGE_COMMIT
50 std::bitset< NUM_FLAGS > m1;
51 m1.set(LOGGED_IN);
52 m1.set(IN_WHITEBOARD);
53 m1.set(IN_CHATROOM);
54 m1.set(SYNCHRONIZING_WITH_CHAT);
55 mcm[CHANGE_NOT_REPEATABLE] = m1;
56 mcm[CHANGE_REPEATABLE] = m1;
57 mcm[DUMMY_CHANGE] = m1;
58 mcm[CHANGE_COMMIT] = m1;
60 // Messages: DOCUMENT_BEGIN, DOCUMENT_END
61 std::bitset< NUM_FLAGS > m4;
62 m4.set(LOGGED_IN);
63 m4.set(IN_WHITEBOARD);
64 m4.set(SYNCHRONIZING_WITH_CHAT);
65 mcm[DOCUMENT_BEGIN] = m4;
66 mcm[DOCUMENT_END] = m4;
68 // Message: CONNECT_REQUEST_USER
69 std::bitset< NUM_FLAGS > m5;
70 m5.set(LOGGED_IN);
72 // We should still _accept_ CONNECT_REQUEST_USER messages even if we're already
73 // waiting for a response. It is up to the higher-level handler (i.e. the connection
74 // request handler) to properly handle it.
75 m5.set(WAITING_FOR_INVITE_RESPONSE);
76 mcm[CONNECT_REQUEST_USER] = m5;
78 // Message: CONNECT_REQUEST_RESPONSE_USER
79 std::bitset< NUM_FLAGS > m6;
80 m6.set(LOGGED_IN);
81 m6.set(WAITING_FOR_INVITE_RESPONSE);
82 mcm[CONNECT_REQUEST_RESPONSE_USER] = m6;
84 // Message: CHATROOM_SYNCHRONIZE_REQUEST
85 std::bitset< NUM_FLAGS > m7;
86 m7.set(LOGGED_IN);
87 m7.set(IN_CHATROOM);
88 m7.set(IN_WHITEBOARD);
89 mcm[CHATROOM_SYNCHRONIZE_REQUEST] = m7;
91 // Message: CHATROOM_SYNCHRONIZE_RESPONSE
92 std::bitset< NUM_FLAGS > m8;
93 m8.set(LOGGED_IN);
94 m8.set(WAITING_TO_SYNC_TO_CHAT);
95 mcm[CHATROOM_SYNCHRONIZE_RESPONSE] = m8;
97 // Message: CONNECT_REQUEST_RESPONSE_CHAT
98 std::bitset< NUM_FLAGS > m9;
99 m9.set(LOGGED_IN);
100 m9.set(IN_CHATROOM);
101 m9.set(IN_WHITEBOARD);
102 mcm[CONNECT_REQUEST_RESPONSE_CHAT] = m9;
104 // Message: CONNECTED_SIGNAL
105 mcm[CONNECTED_SIGNAL] = all_contexts;
107 // Message: DISCONNECTED_FROM_USER_SIGNAL
108 std::bitset< NUM_FLAGS > m11;
109 m11.set(LOGGED_IN);
110 m11.set(IN_WHITEBOARD);
111 mcm[DISCONNECTED_FROM_USER_SIGNAL] = m11;
113 // Messages: CONNECT_REQUEST_REFUSED_BY_PEER, ALREADY_IN_SESSION
114 std::bitset< NUM_FLAGS > m12;
115 m12.set(LOGGED_IN);
116 m12.set(WAITING_FOR_INVITE_RESPONSE);
117 mcm[CONNECT_REQUEST_REFUSED_BY_PEER] = m12;
118 mcm[ALREADY_IN_SESSION] = m12;
120 // Message: UNSUPPORTED_PROTOCOL_VERSION
121 std::bitset< NUM_FLAGS > m14;
122 m14.set(LOGGED_IN);
123 mcm[UNSUPPORTED_PROTOCOL_VERSION] = m14;
124 }
126 }
128 }
130 /*
131 Local Variables:
132 mode:c++
133 c-file-style:"stroustrup"
134 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
135 indent-tabs-mode:nil
136 fill-column:99
137 End:
138 */
139 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :