Mercurial > pidgin.yaz
annotate libfaim/aim_im.c @ 338:9d258a0aa560
[gaim-migrate @ 348]
Whoa, all kinds of things happened here. The applet looks better. The
preferences dialog changes based on your compile-time options (oscar,
gnome). Whispering works again. libfaim got updated; it can almost do
RVOUS stuff, and hopefully soon can make requests too. The applet doesn't
need to have its sounds go through GNOME, although it still can. There
is code to facilitate SOCKS5 support (all that needs to be done is to
actually write the code to communicate with the proxy server).
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 06 Jun 2000 09:55:30 +0000 |
parents | bafaf1b68f9a |
children | e4c34ca88d9b |
rev | line source |
---|---|
2 | 1 /* |
2 * aim_im.c | |
3 * | |
4 * The routines for sending/receiving Instant Messages. | |
5 * | |
6 */ | |
7 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
8 #include <faim/aim.h> |
2 | 9 |
10 /* | |
11 * Send an ICBM (instant message). | |
12 * | |
13 * | |
14 * Possible flags: | |
15 * AIM_IMFLAGS_AWAY -- Marks the message as an autoresponse | |
16 * AIM_IMFLAGS_ACK -- Requests that the server send an ack | |
17 * when the message is received (of type 0x0004/0x000c) | |
18 * | |
19 */ | |
237 | 20 u_long aim_send_im(struct aim_session_t *sess, |
21 struct aim_conn_t *conn, | |
22 char *destsn, u_int flags, char *msg) | |
2 | 23 { |
24 | |
237 | 25 int curbyte,i; |
26 struct command_tx_struct *newpacket; | |
2 | 27 |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
28 if (strlen(msg) >= MAXMSGLEN) |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
29 return -1; |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
30 |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
31 if (!(newpacket = aim_tx_new(0x0002, conn, strlen(msg)+256))) |
237 | 32 return -1; |
2 | 33 |
237 | 34 newpacket->lock = 1; /* lock struct */ |
2 | 35 |
36 curbyte = 0; | |
237 | 37 curbyte += aim_putsnac(newpacket->data+curbyte, |
38 0x0004, 0x0006, 0x0000, sess->snac_nextid); | |
39 | |
40 /* | |
41 * Generate a random message cookie | |
42 * | |
43 * We could cache these like we do SNAC IDs. (In fact, it | |
44 * might be a good idea.) In the message error functions, | |
45 * the 8byte message cookie is returned as well as the | |
46 * SNAC ID. | |
47 * | |
48 */ | |
49 for (i=0;i<8;i++) | |
50 curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random()); | |
2 | 51 |
237 | 52 /* |
53 * Channel ID | |
54 */ | |
55 curbyte += aimutil_put16(newpacket->data+curbyte,0x0001); | |
56 | |
57 /* | |
58 * Destination SN (prepended with byte length) | |
59 */ | |
60 curbyte += aimutil_put8(newpacket->data+curbyte,strlen(destsn)); | |
61 curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
62 | |
63 /* | |
64 * metaTLV start. | |
65 */ | |
66 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); | |
67 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x0d); | |
2 | 68 |
237 | 69 /* |
70 * Flag data? | |
71 */ | |
72 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0501); | |
73 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); | |
74 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0101); | |
75 curbyte += aimutil_put8 (newpacket->data+curbyte, 0x01); | |
76 | |
77 /* | |
78 * Message block length. | |
79 */ | |
80 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04); | |
81 | |
82 /* | |
83 * Character set data? | |
84 */ | |
85 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
86 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
2 | 87 |
237 | 88 /* |
89 * Message. Not terminated. | |
90 */ | |
91 curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg)); | |
2 | 92 |
237 | 93 /* |
94 * Set the Request Acknowledge flag. | |
95 */ | |
96 if (flags & AIM_IMFLAGS_ACK) { | |
97 curbyte += aimutil_put16(newpacket->data+curbyte,0x0003); | |
98 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000); | |
99 } | |
100 | |
101 /* | |
102 * Set the Autoresponse flag. | |
103 */ | |
104 if (flags & AIM_IMFLAGS_AWAY) { | |
105 curbyte += aimutil_put16(newpacket->data+curbyte,0x0004); | |
106 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000); | |
107 } | |
108 | |
109 newpacket->commandlen = curbyte; | |
110 newpacket->lock = 0; | |
111 | |
112 aim_tx_enqueue(sess, newpacket); | |
2 | 113 |
114 #ifdef USE_SNAC_FOR_IMS | |
115 { | |
116 struct aim_snac_t snac; | |
117 | |
237 | 118 snac.id = sess->snac_nextid; |
2 | 119 snac.family = 0x0004; |
120 snac.type = 0x0006; | |
121 snac.flags = 0x0000; | |
122 | |
123 snac.data = malloc(strlen(destsn)+1); | |
124 memcpy(snac.data, destsn, strlen(destsn)+1); | |
125 | |
237 | 126 aim_newsnac(sess, &snac); |
2 | 127 } |
128 | |
237 | 129 aim_cleansnacs(sess, 60); /* clean out all SNACs over 60sec old */ |
2 | 130 #endif |
131 | |
237 | 132 return (sess->snac_nextid++); |
2 | 133 } |
134 | |
237 | 135 /* |
136 * It can easily be said that parsing ICBMs is THE single | |
137 * most difficult thing to do in the in AIM protocol. In | |
138 * fact, I think I just did say that. | |
139 * | |
140 * Below is the best damned solution I've come up with | |
141 * over the past sixteen months of battling with it. This | |
142 * can parse both away and normal messages from every client | |
143 * I have access to. Its not fast, its not clean. But it works. | |
144 * | |
145 * We should also support at least minimal parsing of | |
146 * Channel 2, so that we can at least know the name of the | |
147 * room we're invited to, but obviously can't attend... | |
148 * | |
149 */ | |
150 int aim_parse_incoming_im_middle(struct aim_session_t *sess, | |
151 struct command_rx_struct *command) | |
2 | 152 { |
237 | 153 u_int i = 0,z; |
154 rxcallback_t userfunc = NULL; | |
155 u_char cookie[8]; | |
156 int channel; | |
157 struct aim_tlvlist_t *tlvlist; | |
158 struct aim_userinfo_s userinfo; | |
159 u_short wastebits; | |
160 | |
161 memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s)); | |
162 | |
163 i = 10; /* Skip SNAC header */ | |
2 | 164 |
237 | 165 /* |
166 * Read ICBM Cookie. And throw away. | |
167 */ | |
168 for (z=0; z<8; z++,i++) | |
169 cookie[z] = command->data[i]; | |
2 | 170 |
237 | 171 /* |
172 * Channel ID. | |
173 * | |
174 * Channel 0x0001 is the message channel. There are | |
175 * other channels for things called "rendevous" | |
176 * which represent chat and some of the other new | |
177 * features of AIM2/3/3.5. | |
178 * | |
179 * Channel 0x0002 is the Rendevous channel, which | |
180 * is where Chat Invitiations and various client-client | |
181 * connection negotiations come from. | |
182 * | |
183 */ | |
184 channel = aimutil_get16(command->data+i); | |
185 i += 2; | |
2 | 186 |
237 | 187 /* |
188 * | |
189 */ | |
190 if ((channel != 0x01) && (channel != 0x02)) | |
191 { | |
192 printf("faim: icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel); | |
193 return 1; | |
194 } | |
195 | |
196 /* | |
197 * Source screen name. | |
198 */ | |
199 memcpy(userinfo.sn, command->data+i+1, (int)command->data[i]); | |
200 userinfo.sn[(int)command->data[i]] = '\0'; | |
201 i += 1 + (int)command->data[i]; | |
202 | |
203 /* | |
204 * Warning Level | |
205 */ | |
206 userinfo.warnlevel = aimutil_get16(command->data+i); /* guess */ | |
207 i += 2; | |
208 | |
209 /* | |
210 * Number of TLVs that follow. Not needed. | |
211 */ | |
212 wastebits = aimutil_get16(command->data+i); | |
2 | 213 i += 2; |
214 | |
237 | 215 /* |
216 * Read block of TLVs. All further data is derived | |
217 * from what is parsed here. | |
218 */ | |
219 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i); | |
2 | 220 |
237 | 221 /* |
222 * From here on, its depends on what channel we're on. | |
223 */ | |
224 if (channel == 1) | |
225 { | |
226 u_int j = 0, y = 0, z = 0; | |
227 char *msg = NULL; | |
228 u_int icbmflags = 0; | |
229 struct aim_tlv_t *msgblocktlv, *tmptlv; | |
230 u_char *msgblock; | |
231 u_short flag1,flag2; | |
232 | |
233 /* | |
234 * Check Autoresponse status. If it is an autoresponse, | |
235 * it will contain a second type 0x0004 TLV, with zero length. | |
236 */ | |
237 if (aim_gettlv(tlvlist, 0x0004, 2)) | |
238 icbmflags |= AIM_IMFLAGS_AWAY; | |
239 | |
240 /* | |
241 * Check Ack Request status. | |
242 */ | |
243 if (aim_gettlv(tlvlist, 0x0003, 2)) | |
244 icbmflags |= AIM_IMFLAGS_ACK; | |
245 | |
246 /* | |
247 * Extract the various pieces of the userinfo struct. | |
248 */ | |
249 /* Class. */ | |
250 if ((tmptlv = aim_gettlv(tlvlist, 0x0001, 1))) | |
251 userinfo.class = aimutil_get16(tmptlv->value); | |
252 /* Member-since date. */ | |
253 if ((tmptlv = aim_gettlv(tlvlist, 0x0002, 1))) | |
254 { | |
255 /* If this is larger than 4, its probably the message block, skip */ | |
256 if (tmptlv->length <= 4) | |
257 userinfo.membersince = aimutil_get32(tmptlv->value); | |
258 } | |
259 /* On-since date */ | |
260 if ((tmptlv = aim_gettlv(tlvlist, 0x0003, 1))) | |
261 userinfo.onlinesince = aimutil_get32(tmptlv->value); | |
262 /* Idle-time */ | |
263 if ((tmptlv = aim_gettlv(tlvlist, 0x0004, 1))) | |
264 userinfo.idletime = aimutil_get16(tmptlv->value); | |
265 /* Session Length (AIM) */ | |
266 if ((tmptlv = aim_gettlv(tlvlist, 0x000f, 1))) | |
267 userinfo.sessionlen = aimutil_get16(tmptlv->value); | |
268 /* Session Length (AOL) */ | |
269 if ((tmptlv = aim_gettlv(tlvlist, 0x0010, 1))) | |
270 userinfo.sessionlen = aimutil_get16(tmptlv->value); | |
271 | |
272 /* | |
273 * Message block. | |
274 * | |
275 * XXX: Will the msgblock always be the second 0x0002? | |
276 */ | |
277 msgblocktlv = aim_gettlv(tlvlist, 0x0002, 1); | |
278 if (!msgblocktlv) | |
279 { | |
280 printf("faim: icbm: major error! no message block TLV found!\n"); | |
281 aim_freetlvchain(&tlvlist); | |
282 return 1; | |
283 } | |
284 | |
285 /* | |
286 * Extracting the message from the unknown cruft. | |
287 * | |
288 * This is a bit messy, and I'm not really qualified, | |
289 * even as the author, to comment on it. At least | |
290 * its not as bad as a while loop shooting into infinity. | |
291 * | |
292 * "Do you believe in magic?" | |
293 * | |
294 */ | |
295 msgblock = msgblocktlv->value; | |
296 j = 0; | |
297 | |
298 wastebits = aimutil_get8(msgblock+j++); | |
299 wastebits = aimutil_get8(msgblock+j++); | |
300 | |
301 y = aimutil_get16(msgblock+j); | |
302 j += 2; | |
303 for (z = 0; z < y; z++) | |
304 wastebits = aimutil_get8(msgblock+j++); | |
305 wastebits = aimutil_get8(msgblock+j++); | |
306 wastebits = aimutil_get8(msgblock+j++); | |
307 | |
308 /* | |
309 * Message string length, including flag words. | |
310 */ | |
311 i = aimutil_get16(msgblock+j); | |
312 j += 2; | |
313 | |
314 /* | |
315 * Flag words. | |
316 * | |
317 * Its rumored that these can kick in some funky | |
318 * 16bit-wide char stuff that used to really kill | |
319 * libfaim. Hopefully the latter is no longer true. | |
320 * | |
321 * Though someone should investiagte the former. | |
322 * | |
323 */ | |
324 flag1 = aimutil_get16(msgblock+j); | |
325 j += 2; | |
326 flag2 = aimutil_get16(msgblock+j); | |
327 j += 2; | |
328 | |
329 if (flag1 || flag2) | |
330 printf("faim: icbm: **warning: encoding flags are being used! {%04x, %04x}\n", flag1, flag2); | |
331 | |
332 /* | |
333 * Message string. | |
334 */ | |
335 i -= 4; | |
336 msg = (char *)malloc(i+1); | |
337 memcpy(msg, msgblock+j, i); | |
338 msg[i] = '\0'; | |
339 | |
340 /* | |
341 * Call client. | |
342 */ | |
343 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); | |
344 if (userfunc) | |
345 i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2); | |
346 else | |
347 i = 0; | |
348 | |
349 free(msg); | |
350 } | |
351 else if (channel == 0x0002) | |
352 { | |
353 struct aim_tlv_t *block1; | |
354 struct aim_tlvlist_t *list2; | |
355 struct aim_tlv_t *tmptlv; | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
356 struct aim_tlv_t *miscinfo; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
357 unsigned short reqclass = 0; |
237 | 358 int a; |
359 | |
360 /* Class. */ | |
361 if ((tmptlv = aim_gettlv(tlvlist, 0x0001, 1))) | |
362 userinfo.class = aimutil_get16(tmptlv->value); | |
363 /* On-since date */ | |
364 if ((tmptlv = aim_gettlv(tlvlist, 0x0003, 1))) | |
365 userinfo.onlinesince = aimutil_get32(tmptlv->value); | |
366 /* Idle-time */ | |
367 if ((tmptlv = aim_gettlv(tlvlist, 0x0004, 1))) | |
368 userinfo.idletime = aimutil_get16(tmptlv->value); | |
369 /* Session Length (AIM) */ | |
370 if ((tmptlv = aim_gettlv(tlvlist, 0x000f, 1))) | |
371 userinfo.sessionlen = aimutil_get16(tmptlv->value); | |
372 /* Session Length (AOL) */ | |
373 if ((tmptlv = aim_gettlv(tlvlist, 0x0010, 1))) | |
374 userinfo.sessionlen = aimutil_get16(tmptlv->value); | |
2 | 375 |
237 | 376 /* |
377 * There's another block of TLVs embedded in the type 5 here. | |
378 */ | |
379 block1 = aim_gettlv(tlvlist, 0x0005, 1); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
380 if (!block1) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
381 printf("faim: no tlv 0x0005 in rendezvous transaction!\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
382 aim_freetlvchain(&tlvlist); |
237 | 383 return 1; /* major problem */ |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
384 } |
237 | 385 |
386 a = 0x1a; /* skip -- not sure what this information is! */ | |
387 | |
388 /* | |
389 * XXX: Ignore if there's no data, only cookie information. | |
390 * | |
391 * Its probably just an accepted invitation or something. | |
392 * | |
393 */ | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
394 if (block1->length <= 0x1a) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
395 aim_freetlvchain(&tlvlist); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
396 return 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
397 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
398 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
399 list2 = aim_readtlvchain(block1->value+a, block1->length-a); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
400 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
401 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
402 struct aim_msgcookie_t *cook; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
403 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
404 if ((cook = aim_uncachecookie(sess, cookie)) == NULL) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
405 printf("faim: no 0x2711 info TLV in rendezvous and its not in cache!\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
406 aim_freetlvchain(&list2); |
237 | 407 aim_freetlvchain(&tlvlist); |
408 return 1; | |
409 } | |
410 | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
411 if (cook->type == 1) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
412 struct aim_filetransfer_t *ft; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
413 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
414 if (cook->data) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
415 struct aim_tlv_t *errortlv; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
416 int errorcode = -1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
417 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
418 ft = (struct aim_filetransfer_t *)cook->data; |
237 | 419 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
420 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
421 errorcode = aimutil_get16(errortlv->value); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
422 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
423 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sender, ft->ip, ft->filename, errorcode); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
424 free(cook->data); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
425 } else { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
426 printf("faim: not data attached to file transfer\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
427 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
428 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
429 } else { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
430 printf("faim: unknown cookie cache type %d\n", cook->type); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
431 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
432 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
433 free(cook); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
434 return 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
435 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
436 |
2 | 437 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
438 /* |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
439 * Parse the first two bytes of the 0x2711 TLV. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
440 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
441 * This can be interpretted in a couple ways. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
442 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
443 * It could be said that its a service type or some such and |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
444 * that voice is 0, file transfer is 1, and chat is 4 (and 5). |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
445 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
446 * Or it could be said that its an exchange value. Exchanges |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
447 * four and five are for chat, voice is on exchange zero and |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
448 * file transfer is done on exchange 1. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
449 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
450 * It should work out the same no how its thought of. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
451 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
452 */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
453 reqclass = aimutil_get16(miscinfo->value+0); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
454 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
455 switch (reqclass) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
456 case AIM_RENDEZVOUS_VOICE: { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
457 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
458 /* XXX: implement all this */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
459 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
460 /* |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
461 * Call client. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
462 */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
463 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
464 if (userfunc || (i = 0)) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
465 i = userfunc(sess, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
466 command, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
467 channel, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
468 reqclass, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
469 &userinfo); |
237 | 470 } |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
471 break; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
472 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
473 case AIM_RENDEZVOUS_FILETRANSFER: { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
474 char ip[30]; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
475 char *desc = NULL; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
476 struct aim_msgcookie_t cachedcook; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
477 struct aim_filetransfer_t *ft; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
478 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
479 memset(ip, 0, sizeof(ip)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
480 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
481 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
482 struct aim_tlv_t *iptlv, *porttlv; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
483 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
484 iptlv = aim_gettlv(list2, 0x0003, 1); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
485 porttlv = aim_gettlv(list2, 0x0005, 1); |
237 | 486 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
487 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d", |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
488 aimutil_get8(iptlv->value+0), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
489 aimutil_get8(iptlv->value+1), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
490 aimutil_get8(iptlv->value+2), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
491 aimutil_get8(iptlv->value+3), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
492 aimutil_get16(porttlv->value)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
493 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
494 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
495 if (aim_gettlv(list2, 0x000c, 1)) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
496 desc = aim_gettlv_str(list2, 0x000c, 1); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
497 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
498 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
499 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n", |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
500 userinfo.sn, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
501 miscinfo->value+8, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
502 desc, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
503 ip); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
504 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
505 memcpy(cachedcook.cookie, cookie, 8); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
506 memcpy(cachedcook.extended, block1->value+10, 16); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
507 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
508 ft = malloc(sizeof(struct aim_filetransfer_t)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
509 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
510 strncpy(ft->ip, ip, sizeof(ft->ip)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
511 ft->filename = strdup(miscinfo->value+8); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
512 cachedcook.type = 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
513 cachedcook.data = ft; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
514 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
515 if (aim_cachecookie(sess, &cachedcook) != 0) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
516 printf("faim: ERROR caching message cookie\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
517 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
518 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
519 aim_denytransfer(sess, command->conn, ft->sender, cookie, 0); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
520 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
521 free(desc); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
522 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
523 i = 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
524 break; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
525 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
526 case AIM_RENDEZVOUS_FILETRANSFER_GET: { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
527 printf("faim: file get request (unsupported)\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
528 i = 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
529 break; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
530 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
531 case AIM_RENDEZVOUS_CHAT_EX3: |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
532 case AIM_RENDEZVOUS_CHAT_EX4: |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
533 case AIM_RENDEZVOUS_CHAT_EX5: { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
534 struct aim_chat_roominfo roominfo; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
535 char *msg=NULL,*encoding=NULL,*lang=NULL; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
536 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
537 aim_chat_readroominfo(miscinfo->value, &roominfo); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
538 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
539 if (aim_gettlv(list2, 0x000c, 1)) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
540 msg = aim_gettlv_str(list2, 0x000c, 1); |
237 | 541 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
542 if (aim_gettlv(list2, 0x000d, 1)) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
543 encoding = aim_gettlv_str(list2, 0x000d, 1); |
237 | 544 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
545 if (aim_gettlv(list2, 0x000e, 1)) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
546 lang = aim_gettlv_str(list2, 0x000e, 1); |
237 | 547 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
548 /* |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
549 * Call client. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
550 */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
551 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
552 if (userfunc || (i = 0)) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
553 i = userfunc(sess, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
554 command, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
555 channel, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
556 reqclass, /* == roominfo->exchange */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
557 &userinfo, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
558 &roominfo, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
559 msg, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
560 encoding?encoding+1:NULL, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
561 lang?lang+1:NULL); |
237 | 562 free(roominfo.name); |
563 free(msg); | |
564 free(encoding); | |
565 free(lang); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
566 break; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
567 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
568 default: { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
569 printf("faim: rendezvous: unknown rend class 0x%04x\n", reqclass); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
570 i = 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
571 break; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
572 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
573 } /* switch */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
574 |
237 | 575 aim_freetlvchain(&list2); |
2 | 576 } |
577 | |
237 | 578 /* |
579 * Free up the TLV chain. | |
580 */ | |
581 aim_freetlvchain(&tlvlist); | |
2 | 582 |
583 | |
584 return i; | |
585 } | |
237 | 586 |
587 /* | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
588 * Possible codes: |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
589 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
590 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer" |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
591 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers" |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
592 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
593 */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
594 u_long aim_denytransfer(struct aim_session_t *sess, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
595 struct aim_conn_t *conn, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
596 char *sender, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
597 char *cookie, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
598 unsigned short code) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
599 { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
600 struct command_tx_struct *newpacket; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
601 int curbyte, i; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
602 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
603 if(!(newpacket = aim_tx_new(0x0002, conn, 10+8+2+1+strlen(sender)+6))) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
604 return -1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
605 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
606 newpacket->lock = 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
607 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
608 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x000b, 0x0000, sess->snac_nextid); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
609 for (i = 0; i < 8; i++) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
610 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
611 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
612 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
613 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
614 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0003, code); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
615 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
616 newpacket->lock = 0; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
617 aim_tx_enqueue(sess, newpacket); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
618 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
619 return (sess->snac_nextid++); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
620 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
621 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
622 /* |
237 | 623 * Not real sure what this does, nor does anyone I've talk to. |
624 * | |
625 * Didn't use to send it. But now I think it might be a good | |
626 * idea. | |
627 * | |
628 */ | |
629 u_long aim_seticbmparam(struct aim_session_t *sess, | |
630 struct aim_conn_t *conn) | |
631 { | |
632 struct command_tx_struct *newpacket; | |
633 int curbyte; | |
634 | |
635 if(!(newpacket = aim_tx_new(0x0002, conn, 10+16))) | |
636 return -1; | |
637 | |
638 newpacket->lock = 1; | |
639 | |
640 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid); | |
641 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
642 curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003); | |
643 curbyte += aimutil_put8(newpacket->data+curbyte, 0x1f); | |
644 curbyte += aimutil_put8(newpacket->data+curbyte, 0x40); | |
645 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03); | |
646 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7); | |
647 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03); | |
648 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7); | |
649 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
650 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
651 | |
652 newpacket->lock = 0; | |
653 aim_tx_enqueue(sess, newpacket); | |
654 | |
655 return (sess->snac_nextid++); | |
656 } | |
657 | |
658 int aim_parse_msgerror_middle(struct aim_session_t *sess, | |
659 struct command_rx_struct *command) | |
660 { | |
661 u_long snacid = 0x000000000; | |
662 struct aim_snac_t *snac = NULL; | |
663 int ret = 0; | |
664 rxcallback_t userfunc = NULL; | |
665 | |
666 /* | |
667 * Get SNAC from packet and look it up | |
668 * the list of unrepliedto/outstanding | |
669 * SNACs. | |
670 * | |
671 * After its looked up, the SN that the | |
672 * message should've gone to will be | |
673 * in the ->data element of the snac struct. | |
674 * | |
675 */ | |
676 snacid = aimutil_get32(command->data+6); | |
677 snac = aim_remsnac(sess, snacid); | |
678 | |
284
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
679 if (!snac) { |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
680 printf("faim: msgerr: got an ICBM-failed error on an unknown SNAC ID! (%08lx)\n", snacid); |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
681 } |
237 | 682 |
683 /* | |
684 * Call client. | |
685 */ | |
686 userfunc = aim_callhandler(command->conn, 0x0004, 0x0001); | |
687 if (userfunc) | |
688 ret = userfunc(sess, command, (snac)?snac->data:"(UNKNOWN)"); | |
689 else | |
690 ret = 0; | |
691 | |
284
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
692 if (snac) { |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
693 free(snac->data); |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
694 free(snac); |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
695 } |
237 | 696 |
697 return ret; | |
698 } | |
699 | |
700 |