Mercurial > pidgin
comparison libfaim/aim_chat.c @ 316:8cdc4ab449ec
[gaim-migrate @ 326]
Monkey see monkey do
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 02 Jun 2000 18:16:21 +0000 |
parents | 0f14e6d8a51b |
children | 9d258a0aa560 |
comparison
equal
deleted
inserted
replaced
315:68637b451377 | 316:8cdc4ab449ec |
---|---|
1 /* | 1 /* |
2 * aim_chat.c | 2 * aim_chat.c |
3 * | 3 * |
4 * Routines for the Chat service. Nothing works (yet). | 4 * Routines for the Chat service. |
5 * | 5 * |
6 */ | 6 */ |
7 | 7 |
8 #include <faim/aim.h> | 8 #include <faim/aim.h> |
9 | 9 |
219 * | 219 * |
220 * Values I know are in here but I havent attached | 220 * Values I know are in here but I havent attached |
221 * them to any of the 'Unknown's: | 221 * them to any of the 'Unknown's: |
222 * - Language (English) | 222 * - Language (English) |
223 * | 223 * |
224 * SNAC 000e/0002 | |
224 */ | 225 */ |
225 int aim_chat_parse_infoupdate(struct aim_session_t *sess, | 226 int aim_chat_parse_infoupdate(struct aim_session_t *sess, |
226 struct command_rx_struct *command) | 227 struct command_rx_struct *command) |
227 { | 228 { |
228 struct aim_userinfo_s *userinfo = NULL; | 229 struct aim_userinfo_s *userinfo = NULL; |
233 char *roomname = NULL; | 234 char *roomname = NULL; |
234 struct aim_chat_roominfo roominfo; | 235 struct aim_chat_roominfo roominfo; |
235 u_short tlvcount = 0; | 236 u_short tlvcount = 0; |
236 struct aim_tlvlist_t *tlvlist; | 237 struct aim_tlvlist_t *tlvlist; |
237 char *roomdesc = NULL; | 238 char *roomdesc = NULL; |
239 struct aim_tlv_t *tmptlv; | |
240 unsigned short unknown_c9 = 0; | |
241 unsigned long creationtime = 0; | |
242 unsigned short maxmsglen = 0; | |
243 unsigned short unknown_d2 = 0, unknown_d5 = 0; | |
238 | 244 |
239 i = 10; | 245 i = 10; |
240 i += aim_chat_readroominfo(command->data+i, &roominfo); | 246 i += aim_chat_readroominfo(command->data+i, &roominfo); |
241 | 247 |
242 detaillevel = aimutil_get8(command->data+i); | 248 detaillevel = aimutil_get8(command->data+i); |
243 i++; | 249 i++; |
250 | |
251 if (detaillevel != 0x02) { | |
252 if (detaillevel == 0x01) | |
253 printf("faim: chat_roomupdateinfo: detail level 2 not supported\n"); | |
254 else | |
255 printf("faim: chat_roomupdateinfo: unknown detail level %d\n", detaillevel); | |
256 return 1; | |
257 } | |
244 | 258 |
245 tlvcount = aimutil_get16(command->data+i); | 259 tlvcount = aimutil_get16(command->data+i); |
246 i += 2; | 260 i += 2; |
247 | 261 |
248 /* | 262 /* |
257 roomname = aim_gettlv_str(tlvlist, 0x006a, 1); | 271 roomname = aim_gettlv_str(tlvlist, 0x006a, 1); |
258 | 272 |
259 /* | 273 /* |
260 * Type 0x006f: Number of occupants. | 274 * Type 0x006f: Number of occupants. |
261 */ | 275 */ |
262 if (aim_gettlv(tlvlist, 0x006f, 1)) | 276 if (aim_gettlv(tlvlist, 0x006f, 1)) { |
263 { | 277 struct aim_tlv_t *tmptlv; |
264 struct aim_tlv_t *tmptlv; | 278 tmptlv = aim_gettlv(tlvlist, 0x006f, 1); |
265 tmptlv = aim_gettlv(tlvlist, 0x006f, 1); | 279 |
266 | 280 usercount = aimutil_get16(tmptlv->value); |
267 usercount = aimutil_get16(tmptlv->value); | 281 } |
268 } | |
269 | 282 |
270 /* | 283 /* |
271 * Type 0x0073: Occupant list. | 284 * Type 0x0073: Occupant list. |
272 */ | 285 */ |
273 if (aim_gettlv(tlvlist, 0x0073, 1)) | 286 if (aim_gettlv(tlvlist, 0x0073, 1)) { |
274 { | 287 int curoccupant = 0; |
275 int curoccupant = 0; | 288 struct aim_tlv_t *tmptlv; |
276 struct aim_tlv_t *tmptlv; | 289 |
277 | 290 tmptlv = aim_gettlv(tlvlist, 0x0073, 1); |
278 tmptlv = aim_gettlv(tlvlist, 0x0073, 1); | 291 |
279 | 292 /* Allocate enough userinfo structs for all occupants */ |
280 /* Allocate enough userinfo structs for all occupants */ | 293 userinfo = calloc(usercount, sizeof(struct aim_userinfo_s)); |
281 userinfo = calloc(usercount, sizeof(struct aim_userinfo_s)); | 294 |
282 | 295 i = 0; |
283 i = 0; | 296 while (curoccupant < usercount) |
284 while (curoccupant < usercount) | 297 i += aim_extractuserinfo(tmptlv->value+i, &userinfo[curoccupant++]); |
285 i += aim_extractuserinfo(tmptlv->value+i, &userinfo[curoccupant++]); | 298 } |
286 } | 299 |
287 | 300 /* |
288 /* | 301 * Type 0x00c9: Unknown. (2 bytes) |
289 * Type 0x00c9: Unknown. | 302 */ |
290 */ | 303 if ((tmptlv = aim_gettlv(tlvlist, 0x00c9, 1))) |
291 if (aim_gettlv(tlvlist, 0x00c9, 1)) | 304 unknown_c9 = aimutil_get16(tmptlv->value); |
292 ; | 305 |
293 | 306 /* |
294 /* | 307 * Type 0x00ca: Creation time (4 bytes) |
295 * Type 0x00ca: Creation date | 308 */ |
296 */ | 309 if ((tmptlv = aim_gettlv(tlvlist, 0x00ca, 1))) |
297 if (aim_gettlv(tlvlist, 0x00ca, 1)) | 310 creationtime = aimutil_get32(tmptlv->value); |
298 ; | |
299 | 311 |
300 /* | 312 /* |
301 * Type 0x00d1: Maximum Message Length | 313 * Type 0x00d1: Maximum Message Length |
302 */ | 314 */ |
303 if (aim_gettlv(tlvlist, 0x00d1, 1)) | 315 if ((tmptlv = aim_gettlv(tlvlist, 0x00d1, 1))) |
304 ; | 316 maxmsglen = aimutil_get16(tmptlv->value); |
305 | 317 |
306 /* | 318 /* |
307 * Type 0x00d2: Unknown. | 319 * Type 0x00d2: Unknown. (2 bytes) |
308 */ | 320 */ |
309 if (aim_gettlv(tlvlist, 0x00d2, 1)) | 321 if ((tmptlv = aim_gettlv(tlvlist, 0x00d2, 1))) |
310 ; | 322 unknown_d2 = aimutil_get16(tmptlv->value);; |
311 | 323 |
312 /* | 324 /* |
313 * Type 0x00d3: Room Description | 325 * Type 0x00d3: Room Description |
314 */ | 326 */ |
315 if (aim_gettlv(tlvlist, 0x00d3, 1)) | 327 if (aim_gettlv(tlvlist, 0x00d3, 1)) |
316 roomdesc = aim_gettlv_str(tlvlist, 0x00d3, 1); | 328 roomdesc = aim_gettlv_str(tlvlist, 0x00d3, 1); |
317 | 329 |
318 /* | 330 /* |
319 * Type 0x00d5: Unknown. | 331 * Type 0x00d5: Unknown. (1 byte) |
320 */ | 332 */ |
321 if (aim_gettlv(tlvlist, 0x00d5, 1)) | 333 if ((tmptlv = aim_gettlv(tlvlist, 0x00d5, 1))) |
322 ; | 334 unknown_d5 = aimutil_get8(tmptlv->value);; |
323 | 335 |
324 | 336 |
325 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE); | 337 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE); |
326 if (userfunc) | 338 if (userfunc) { |
327 { | 339 ret = userfunc(sess, |
328 ret = userfunc(sess, | 340 command, |
329 command, | 341 &roominfo, |
330 &roominfo, | 342 roomname, |
331 roomname, | 343 usercount, |
332 usercount, | 344 userinfo, |
333 userinfo, | 345 roomdesc, |
334 roomdesc); | 346 unknown_c9, |
335 } | 347 creationtime, |
348 maxmsglen, | |
349 unknown_d2, | |
350 unknown_d5); | |
351 } | |
336 free(roominfo.name); | 352 free(roominfo.name); |
337 free(userinfo); | 353 free(userinfo); |
338 free(roomname); | 354 free(roomname); |
339 free(roomdesc); | 355 free(roomdesc); |
340 aim_freetlvchain(&tlvlist); | 356 aim_freetlvchain(&tlvlist); |
347 { | 363 { |
348 struct aim_userinfo_s *userinfo = NULL; | 364 struct aim_userinfo_s *userinfo = NULL; |
349 rxcallback_t userfunc=NULL; | 365 rxcallback_t userfunc=NULL; |
350 int i = 10, curcount = 0, ret = 1; | 366 int i = 10, curcount = 0, ret = 1; |
351 | 367 |
352 while (i < command->commandlen) | 368 while (i < command->commandlen) { |
353 { | 369 curcount++; |
354 curcount++; | 370 userinfo = realloc(userinfo, curcount * sizeof(struct aim_userinfo_s)); |
355 userinfo = realloc(userinfo, curcount * sizeof(struct aim_userinfo_s)); | 371 i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]); |
356 i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]); | 372 } |
357 } | |
358 | 373 |
359 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN); | 374 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN); |
360 if (userfunc) | 375 if (userfunc) { |
361 { | 376 ret = userfunc(sess, |
362 ret = userfunc(sess, | 377 command, |
363 command, | 378 curcount, |
364 curcount, | 379 userinfo); |
365 userinfo); | 380 } |
366 } | |
367 | 381 |
368 free(userinfo); | 382 free(userinfo); |
369 | 383 |
370 return ret; | 384 return ret; |
371 } | 385 } |
376 | 390 |
377 struct aim_userinfo_s *userinfo = NULL; | 391 struct aim_userinfo_s *userinfo = NULL; |
378 rxcallback_t userfunc=NULL; | 392 rxcallback_t userfunc=NULL; |
379 int i = 10, curcount = 0, ret = 1; | 393 int i = 10, curcount = 0, ret = 1; |
380 | 394 |
381 while (i < command->commandlen) | 395 while (i < command->commandlen) { |
382 { | 396 curcount++; |
383 curcount++; | 397 userinfo = realloc(userinfo, curcount * sizeof(struct aim_userinfo_s)); |
384 userinfo = realloc(userinfo, curcount * sizeof(struct aim_userinfo_s)); | 398 i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]); |
385 i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]); | 399 } |
386 } | |
387 | 400 |
388 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE); | 401 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE); |
389 if (userfunc) | 402 if (userfunc) { |
390 { | 403 ret = userfunc(sess, |
391 ret = userfunc(sess, | 404 command, |
392 command, | 405 curcount, |
393 curcount, | 406 userinfo); |
394 userinfo); | 407 } |
395 } | |
396 | 408 |
397 free(userinfo); | 409 free(userinfo); |
398 | 410 |
399 return ret; | 411 return ret; |
400 } | 412 } |
435 * | 447 * |
436 */ | 448 */ |
437 channel = aimutil_get16(command->data+i); | 449 channel = aimutil_get16(command->data+i); |
438 i += 2; | 450 i += 2; |
439 | 451 |
440 if (channel != 0x0003) | 452 if (channel != 0x0003) { |
441 { | 453 printf("faim: chat_incoming: unknown channel! (0x%04x)\n", channel); |
442 printf("faim: chat_incoming: unknown channel! (0x%04x)\n", channel); | 454 return 1; |
443 return 1; | 455 } |
444 } | |
445 | 456 |
446 /* | 457 /* |
447 * Start parsing TLVs right away. | 458 * Start parsing TLVs right away. |
448 */ | 459 */ |
449 outerlist = aim_readtlvchain(command->data+i, command->commandlen-i); | 460 outerlist = aim_readtlvchain(command->data+i, command->commandlen-i); |
450 | 461 |
451 /* | 462 /* |
452 * Type 0x0003: Source User Information | 463 * Type 0x0003: Source User Information |
453 */ | 464 */ |
454 if (aim_gettlv(outerlist, 0x0003, 1)) | 465 if (aim_gettlv(outerlist, 0x0003, 1)) { |
455 { | 466 struct aim_tlv_t *userinfotlv; |
456 struct aim_tlv_t *userinfotlv; | 467 |
457 | 468 userinfotlv = aim_gettlv(outerlist, 0x0003, 1); |
458 userinfotlv = aim_gettlv(outerlist, 0x0003, 1); | 469 aim_extractuserinfo(userinfotlv->value, &userinfo); |
459 aim_extractuserinfo(userinfotlv->value, &userinfo); | 470 } |
460 } | |
461 | 471 |
462 /* | 472 /* |
463 * Type 0x0001: Unknown. | 473 * Type 0x0001: Unknown. |
464 */ | 474 */ |
465 if (aim_gettlv(outerlist, 0x0001, 1)) | 475 if (aim_gettlv(outerlist, 0x0001, 1)) |