Mercurial > pidgin
annotate src/protocols/sametime/meanwhile/mw_message.h @ 12179:92ba143044e6
[gaim-migrate @ 14481]
I didn't know I could do this, that's neat. Thanks to the random patch I just
saw which did this.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Mon, 21 Nov 2005 06:56:35 +0000 |
parents | 0110fc7c6a8a |
children |
rev | line source |
---|---|
10969 | 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 */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
52 mwMessage_ANNOUNCE = 0x0022, /**< mwMsgAnnounce */ |
10969 | 53 }; |
54 | |
55 | |
56 enum mwMessageOption { | |
57 mwMessageOption_ENCRYPT = 0x4000, /**< message data is encrypted */ | |
58 mwMessageOption_HAS_ATTRIBS = 0x8000, /**< message has attributes */ | |
59 }; | |
60 | |
61 | |
62 /** @see mwMessageOption */ | |
63 #define MW_MESSAGE_HAS_OPTION(msg, opt) \ | |
64 ((msg)->options & (opt)) | |
65 | |
66 | |
67 struct mwMessage { | |
68 guint16 type; /**< @see mwMessageType */ | |
69 guint16 options; /**< @see mwMessageOption */ | |
70 guint32 channel; /**< ID of channel message is intended for */ | |
71 struct mwOpaque attribs; /**< optional message attributes */ | |
72 }; | |
73 | |
74 | |
75 | |
76 /** Allocate and initialize a new message of the specified type */ | |
77 struct mwMessage *mwMessage_new(enum mwMessageType type); | |
78 | |
79 | |
80 /** build a message from its representation */ | |
81 struct mwMessage *mwMessage_get(struct mwGetBuffer *b); | |
82 | |
83 | |
84 void mwMessage_put(struct mwPutBuffer *b, struct mwMessage *msg); | |
85 | |
86 | |
87 void mwMessage_free(struct mwMessage *msg); | |
88 | |
89 | |
90 /* 8.4 Messages */ | |
91 /* 8.4.1 Basic Community Messages */ | |
92 /* 8.4.1.1 Handshake */ | |
93 | |
94 struct mwMsgHandshake { | |
95 struct mwMessage head; | |
96 guint16 major; /**< client's major version number */ | |
97 guint16 minor; /**< client's minor version number */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
98 guint32 srvrcalc_addr; /**< 0.0.0.0 */ |
10969 | 99 guint16 login_type; /**< @see mwLoginType */ |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
100 guint32 loclcalc_addr; /**< local public IP */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
101 guint16 unknown_a; /**< normally 0x0100 */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
102 guint32 unknown_b; /**< normally 0x00000000 */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
103 char *local_host; /**< name of client host */ |
10969 | 104 }; |
105 | |
106 | |
107 /* 8.4.1.2 HandshakeAck */ | |
108 | |
109 struct mwMsgHandshakeAck { | |
110 struct mwMessage head; | |
111 guint16 major; /**< server's major version number */ | |
112 guint16 minor; /**< server's minor version number */ | |
113 guint32 srvrcalc_addr; /**< server-calculated address */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
114 guint32 magic; /**< four bytes of something */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
115 struct mwOpaque data; /**< server's DH public key for auth */ |
10969 | 116 }; |
117 | |
118 | |
119 /* 8.3.7 Authentication Types */ | |
120 | |
121 enum mwAuthType { | |
122 mwAuthType_PLAIN = 0x0000, | |
123 mwAuthType_TOKEN = 0x0001, | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
124 mwAuthType_ENCRYPT = 0x0002, /**< @todo remove for 1.0 */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
125 mwAuthType_RC2_40 = 0x0002, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
126 mwAuthType_RC2_128 = 0x0004, |
10969 | 127 }; |
128 | |
129 | |
130 /* 8.4.1.3 Login */ | |
131 | |
132 struct mwMsgLogin { | |
133 struct mwMessage head; | |
134 guint16 login_type; /**< @see mwLoginType */ | |
135 char *name; /**< user identification */ | |
136 guint16 auth_type; /**< @see mwAuthType */ | |
137 struct mwOpaque auth_data; /**< authentication data */ | |
138 }; | |
139 | |
140 | |
141 /* 8.4.1.4 LoginAck */ | |
142 | |
143 struct mwMsgLoginAck { | |
144 struct mwMessage head; | |
145 struct mwLoginInfo login; | |
146 struct mwPrivacyInfo privacy; | |
147 struct mwUserStatus status; | |
148 }; | |
149 | |
150 | |
151 /* 8.4.1.5 LoginCont */ | |
152 | |
153 struct mwMsgLoginContinue { | |
154 struct mwMessage head; | |
155 }; | |
156 | |
157 | |
158 /* 8.4.1.6 AuthPassed */ | |
159 | |
160 struct mwMsgLoginRedirect { | |
161 struct mwMessage head; | |
162 char *host; | |
163 char *server_id; | |
164 }; | |
165 | |
166 | |
167 /* 8.4.1.7 CreateCnl */ | |
168 | |
169 /** an offer of encryption items */ | |
170 struct mwEncryptOffer { | |
171 guint16 mode; /**< encryption mode */ | |
172 GList *items; /**< list of mwEncryptItem offered */ | |
173 guint16 extra; /**< encryption mode again? */ | |
174 gboolean flag; /**< unknown flag */ | |
175 }; | |
176 | |
177 | |
178 struct mwMsgChannelCreate { | |
179 struct mwMessage head; | |
180 guint32 reserved; /**< unknown reserved data */ | |
181 guint32 channel; /**< intended ID for new channel */ | |
182 struct mwIdBlock target; /**< User ID. for service use */ | |
183 guint32 service; /**< ID for the target service */ | |
184 guint32 proto_type; /**< protocol type for the service */ | |
185 guint32 proto_ver; /**< protocol version for the service */ | |
186 guint32 options; /**< options */ | |
187 struct mwOpaque addtl; /**< service-specific additional data */ | |
188 gboolean creator_flag; /**< indicate presence of creator information */ | |
189 struct mwLoginInfo creator; | |
190 struct mwEncryptOffer encrypt; | |
191 }; | |
192 | |
193 | |
194 /* 8.4.1.8 AcceptCnl */ | |
195 | |
196 /** a selected encryption item from those offered */ | |
197 struct mwEncryptAccept { | |
198 guint16 mode; /**< encryption mode */ | |
199 struct mwEncryptItem *item; /**< chosen mwEncryptItem (optional) */ | |
200 guint16 extra; /**< encryption mode again? */ | |
201 gboolean flag; /**< unknown flag */ | |
202 }; | |
203 | |
204 | |
205 struct mwMsgChannelAccept { | |
206 struct mwMessage head; | |
207 guint32 service; /**< ID for the channel's service */ | |
208 guint32 proto_type; /**< protocol type for the service */ | |
209 guint32 proto_ver; /**< protocol version for the service */ | |
210 struct mwOpaque addtl; /**< service-specific additional data */ | |
211 gboolean acceptor_flag; /**< indicate presence of acceptor information */ | |
212 struct mwLoginInfo acceptor; | |
213 struct mwEncryptAccept encrypt; | |
214 }; | |
215 | |
216 | |
217 /* 8.4.1.9 SendOnCnl */ | |
218 | |
219 struct mwMsgChannelSend { | |
220 struct mwMessage head; | |
221 | |
222 /** message type. each service defines its own send types. Type IDs | |
223 are only necessarily unique within a given service. */ | |
224 guint16 type; | |
225 | |
226 /** protocol data to be interpreted by the handling service */ | |
227 struct mwOpaque data; | |
228 }; | |
229 | |
230 | |
231 /* 8.4.1.10 DestroyCnl */ | |
232 | |
233 struct mwMsgChannelDestroy { | |
234 struct mwMessage head; | |
235 guint32 reason; /**< reason for closing the channel. */ | |
236 struct mwOpaque data; /**< additional information */ | |
237 }; | |
238 | |
239 | |
240 /* 8.4.1.11 SetUserStatus */ | |
241 | |
242 struct mwMsgSetUserStatus { | |
243 struct mwMessage head; | |
244 struct mwUserStatus status; | |
245 }; | |
246 | |
247 | |
248 /* 8.4.1.12 SetPrivacyList */ | |
249 | |
250 struct mwMsgSetPrivacyList { | |
251 struct mwMessage head; | |
252 struct mwPrivacyInfo privacy; | |
253 }; | |
254 | |
255 | |
256 /* Sense Service */ | |
257 | |
258 /** Sent to the server to request the presense of a service by its | |
259 ID. Sent to the client to indicate the presense of such a | |
260 service */ | |
261 struct mwMsgSenseService { | |
262 struct mwMessage head; | |
263 guint32 service; | |
264 }; | |
265 | |
266 | |
267 /* Admin */ | |
268 | |
269 /** An administrative broadcast message */ | |
270 struct mwMsgAdmin { | |
271 struct mwMessage head; | |
272 char *text; | |
273 }; | |
274 | |
275 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
276 /* Announce */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
277 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
278 /** An announcement between users */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
279 struct mwMsgAnnounce { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
280 struct mwMessage head; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
281 gboolean sender_present; /**< indicates presence of sender data */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
282 struct mwLoginInfo sender; /**< who sent the announcement */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
283 guint16 unknown_a; /**< unknown A. Usually 0x00 */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
284 gboolean may_reply; /**< replies allowed */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
285 char *text; /**< text of message */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
286 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
287 /** list of (char *) indicating recipients. Recipient users are in |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
288 the format "@U username" and recipient NAB groups are in the |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
289 format "@G groupname" */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
290 GList *recipients; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
291 }; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
292 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
10969
diff
changeset
|
293 |
10969 | 294 #endif |
295 |