comparison src/protocols/sametime/meanwhile/mw_message.h @ 10969:3ef77720e577

[gaim-migrate @ 12790] importing meanwhile library for use in the sametime plugin committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Sun, 05 Jun 2005 02:50:13 +0000
parents
children 0110fc7c6a8a
comparison
equal deleted inserted replaced
10968:e0d5038fbb7e 10969:3ef77720e577
1
2 /*
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
4 Copyright (C) 2004 Christopher (siege) O'Brien
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the Free
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef _MW_MESSAGE_H
22 #define _MW_MESSAGE_H
23
24
25 #include <glib/glist.h>
26 #include "mw_common.h"
27
28
29 /** Cast a pointer to a message subtype (eg, mwMsgHandshake,
30 mwMsgAdmin) into a pointer to a mwMessage */
31 #define MW_MESSAGE(msg) (&msg->head)
32
33
34 /** Indicates the type of a message. */
35 enum mwMessageType {
36 mwMessage_HANDSHAKE = 0x0000, /**< mwMsgHandshake */
37 mwMessage_HANDSHAKE_ACK = 0x8000, /**< mwMsgHandshakeAck */
38 mwMessage_LOGIN = 0x0001, /**< mwMsgLogin */
39 mwMessage_LOGIN_ACK = 0x8001, /**< mwMsgLoginAck */
40 mwMessage_LOGIN_REDIRECT = 0x0018, /**< mwMsgLoginRedirect */
41 mwMessage_LOGIN_CONTINUE = 0x0016, /**< mwMsgLoginContinue */
42
43 mwMessage_CHANNEL_CREATE = 0x0002, /**< mwMsgChannelCreate */
44 mwMessage_CHANNEL_DESTROY = 0x0003, /**< mwMsgChannelDestroy */
45 mwMessage_CHANNEL_SEND = 0x0004, /**< mwMsgChannelSend */
46 mwMessage_CHANNEL_ACCEPT = 0x0006, /**< mwMsgChannelAccept */
47
48 mwMessage_SET_USER_STATUS = 0x0009, /**< mwMsgSetUserStatus */
49 mwMessage_SET_PRIVACY_LIST = 0x000b, /**< mwMsgSetPrivacyList */
50 mwMessage_SENSE_SERVICE = 0x0011, /**< mwMsgSenseService */
51 mwMessage_ADMIN = 0x0019, /**< mwMsgAdmin */
52 };
53
54
55 enum mwMessageOption {
56 mwMessageOption_ENCRYPT = 0x4000, /**< message data is encrypted */
57 mwMessageOption_HAS_ATTRIBS = 0x8000, /**< message has attributes */
58 };
59
60
61 /** @see mwMessageOption */
62 #define MW_MESSAGE_HAS_OPTION(msg, opt) \
63 ((msg)->options & (opt))
64
65
66 struct mwMessage {
67 guint16 type; /**< @see mwMessageType */
68 guint16 options; /**< @see mwMessageOption */
69 guint32 channel; /**< ID of channel message is intended for */
70 struct mwOpaque attribs; /**< optional message attributes */
71 };
72
73
74
75 /** Allocate and initialize a new message of the specified type */
76 struct mwMessage *mwMessage_new(enum mwMessageType type);
77
78
79 /** build a message from its representation */
80 struct mwMessage *mwMessage_get(struct mwGetBuffer *b);
81
82
83 void mwMessage_put(struct mwPutBuffer *b, struct mwMessage *msg);
84
85
86 void mwMessage_free(struct mwMessage *msg);
87
88
89 /* 8.4 Messages */
90 /* 8.4.1 Basic Community Messages */
91 /* 8.4.1.1 Handshake */
92
93 struct mwMsgHandshake {
94 struct mwMessage head;
95 guint16 major; /**< client's major version number */
96 guint16 minor; /**< client's minor version number */
97 guint32 srvrcalc_addr; /**< */
98 guint16 login_type; /**< @see mwLoginType */
99 guint32 loclcalc_addr; /**< */
100 };
101
102
103 /* 8.4.1.2 HandshakeAck */
104
105 struct mwMsgHandshakeAck {
106 struct mwMessage head;
107 guint16 major; /**< server's major version number */
108 guint16 minor; /**< server's minor version number */
109 guint32 srvrcalc_addr; /**< server-calculated address */
110 guint32 unknown; /**< four bytes of something */
111 struct mwOpaque data; /**< some stuff */
112 };
113
114
115 /* 8.3.7 Authentication Types */
116
117 enum mwAuthType {
118 mwAuthType_PLAIN = 0x0000,
119 mwAuthType_TOKEN = 0x0001,
120 mwAuthType_ENCRYPT = 0x0002,
121 };
122
123
124 /* 8.4.1.3 Login */
125
126 struct mwMsgLogin {
127 struct mwMessage head;
128 guint16 login_type; /**< @see mwLoginType */
129 char *name; /**< user identification */
130 guint16 auth_type; /**< @see mwAuthType */
131 struct mwOpaque auth_data; /**< authentication data */
132 };
133
134
135 /* 8.4.1.4 LoginAck */
136
137 struct mwMsgLoginAck {
138 struct mwMessage head;
139 struct mwLoginInfo login;
140 struct mwPrivacyInfo privacy;
141 struct mwUserStatus status;
142 };
143
144
145 /* 8.4.1.5 LoginCont */
146
147 struct mwMsgLoginContinue {
148 struct mwMessage head;
149 };
150
151
152 /* 8.4.1.6 AuthPassed */
153
154 struct mwMsgLoginRedirect {
155 struct mwMessage head;
156 char *host;
157 char *server_id;
158 };
159
160
161 /* 8.4.1.7 CreateCnl */
162
163 /** an offer of encryption items */
164 struct mwEncryptOffer {
165 guint16 mode; /**< encryption mode */
166 GList *items; /**< list of mwEncryptItem offered */
167 guint16 extra; /**< encryption mode again? */
168 gboolean flag; /**< unknown flag */
169 };
170
171
172 struct mwMsgChannelCreate {
173 struct mwMessage head;
174 guint32 reserved; /**< unknown reserved data */
175 guint32 channel; /**< intended ID for new channel */
176 struct mwIdBlock target; /**< User ID. for service use */
177 guint32 service; /**< ID for the target service */
178 guint32 proto_type; /**< protocol type for the service */
179 guint32 proto_ver; /**< protocol version for the service */
180 guint32 options; /**< options */
181 struct mwOpaque addtl; /**< service-specific additional data */
182 gboolean creator_flag; /**< indicate presence of creator information */
183 struct mwLoginInfo creator;
184 struct mwEncryptOffer encrypt;
185 };
186
187
188 /* 8.4.1.8 AcceptCnl */
189
190 /** a selected encryption item from those offered */
191 struct mwEncryptAccept {
192 guint16 mode; /**< encryption mode */
193 struct mwEncryptItem *item; /**< chosen mwEncryptItem (optional) */
194 guint16 extra; /**< encryption mode again? */
195 gboolean flag; /**< unknown flag */
196 };
197
198
199 struct mwMsgChannelAccept {
200 struct mwMessage head;
201 guint32 service; /**< ID for the channel's service */
202 guint32 proto_type; /**< protocol type for the service */
203 guint32 proto_ver; /**< protocol version for the service */
204 struct mwOpaque addtl; /**< service-specific additional data */
205 gboolean acceptor_flag; /**< indicate presence of acceptor information */
206 struct mwLoginInfo acceptor;
207 struct mwEncryptAccept encrypt;
208 };
209
210
211 /* 8.4.1.9 SendOnCnl */
212
213 struct mwMsgChannelSend {
214 struct mwMessage head;
215
216 /** message type. each service defines its own send types. Type IDs
217 are only necessarily unique within a given service. */
218 guint16 type;
219
220 /** protocol data to be interpreted by the handling service */
221 struct mwOpaque data;
222 };
223
224
225 /* 8.4.1.10 DestroyCnl */
226
227 struct mwMsgChannelDestroy {
228 struct mwMessage head;
229 guint32 reason; /**< reason for closing the channel. */
230 struct mwOpaque data; /**< additional information */
231 };
232
233
234 /* 8.4.1.11 SetUserStatus */
235
236 struct mwMsgSetUserStatus {
237 struct mwMessage head;
238 struct mwUserStatus status;
239 };
240
241
242 /* 8.4.1.12 SetPrivacyList */
243
244 struct mwMsgSetPrivacyList {
245 struct mwMessage head;
246 struct mwPrivacyInfo privacy;
247 };
248
249
250 /* Sense Service */
251
252 /** Sent to the server to request the presense of a service by its
253 ID. Sent to the client to indicate the presense of such a
254 service */
255 struct mwMsgSenseService {
256 struct mwMessage head;
257 guint32 service;
258 };
259
260
261 /* Admin */
262
263 /** An administrative broadcast message */
264 struct mwMsgAdmin {
265 struct mwMessage head;
266 char *text;
267 };
268
269
270 #endif
271