comparison src/protocols/oscar/info.c @ 3459:d82f53194f09

[gaim-migrate @ 3507] DANCE! committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 28 Aug 2002 07:24:12 +0000
parents 7ed9fa994055
children 07283934dedd
comparison
equal deleted inserted replaced
3458:66b1ad9782a9 3459:d82f53194f09
72 72
73 if (!ui) 73 if (!ui)
74 return 0.00; 74 return 0.00;
75 75
76 return (ui->warnlevel / 10); 76 return (ui->warnlevel / 10);
77 }
78
79 faim_export time_t aim_userinfo_createtime(aim_userinfo_t *ui)
80 {
81
82 if (!ui)
83 return 0;
84
85 return (time_t)ui->createtime;
77 } 86 }
78 87
79 faim_export time_t aim_userinfo_membersince(aim_userinfo_t *ui) 88 faim_export time_t aim_userinfo_membersince(aim_userinfo_t *ui)
80 { 89 {
81 90
276 } 285 }
277 286
278 return 0; 287 return 0;
279 } 288 }
280 289
290 static void dumptlv(aim_session_t *sess, fu16_t type, aim_bstream_t *bs, fu8_t len)
291 {
292 int i;
293
294 if (!sess || !bs || !len)
295 return;
296
297 faimdprintf(sess, 0, "userinfo: type =0x%04x\n", type);
298 faimdprintf(sess, 0, "userinfo: length=0x%04x\n", len);
299
300 faimdprintf(sess, 0, "userinfo: value:\n");
301
302 for (i = 0; i < len; i++) {
303 if ((i % 8) == 0)
304 faimdprintf(sess, 0, "\nuserinfo: ");
305
306 faimdprintf(sess, 0, "0x%2x ", aimbs_get8(bs));
307 }
308
309 faimdprintf(sess, 0, "\n");
310
311 return;
312 }
313
281 /* 314 /*
282 * AIM is fairly regular about providing user info. This is a generic 315 * AIM is fairly regular about providing user info. This is a generic
283 * routine to extract it in its standard form. 316 * routine to extract it in its standard form.
284 */ 317 */
285 faim_internal int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo) 318 faim_internal int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo)
340 outinfo->flags = aimbs_get16(bs); 373 outinfo->flags = aimbs_get16(bs);
341 outinfo->present |= AIM_USERINFO_PRESENT_FLAGS; 374 outinfo->present |= AIM_USERINFO_PRESENT_FLAGS;
342 375
343 } else if (type == 0x0002) { 376 } else if (type == 0x0002) {
344 /* 377 /*
345 * Type = 0x0002: Member-Since date. 378 * Type = 0x0002: Account creation time.
346 * 379 *
347 * The time/date that the user originally registered for 380 * The time/date that the user originally registered for
348 * the service, stored in time_t format. 381 * the service, stored in time_t format.
349 */ 382 *
350 outinfo->membersince = aimbs_get32(bs); 383 * I'm not sure how this differs from type 5 ("member
351 outinfo->present |= AIM_USERINFO_PRESENT_MEMBERSINCE; 384 * since").
385 *
386 * Note: This is the field formerly known as "member
387 * since". All these years and I finally found out
388 * that I got the name wrong.
389 */
390 outinfo->createtime = aimbs_get32(bs);
391 outinfo->present |= AIM_USERINFO_PRESENT_CREATETIME;
352 392
353 } else if (type == 0x0003) { 393 } else if (type == 0x0003) {
354 /* 394 /*
355 * Type = 0x0003: On-Since date. 395 * Type = 0x0003: On-Since date.
356 * 396 *
371 * counting idle times, so this may or may not be 411 * counting idle times, so this may or may not be
372 * related to reality. 412 * related to reality.
373 */ 413 */
374 outinfo->idletime = aimbs_get16(bs); 414 outinfo->idletime = aimbs_get16(bs);
375 outinfo->present |= AIM_USERINFO_PRESENT_IDLE; 415 outinfo->present |= AIM_USERINFO_PRESENT_IDLE;
416 } else if (type == 0x0005) {
417 /*
418 * Type = 0x0005: Member since date.
419 *
420 * The time/date that the user originally registered for
421 * the service, stored in time_t format.
422 *
423 * This is sometimes sent instead of type 2 ("account
424 * creation time"), particularly in the self-info.
425 */
426 outinfo->membersince = aimbs_get32(bs);
427 outinfo->present |= AIM_USERINFO_PRESENT_MEMBERSINCE;
376 428
377 } else if (type == 0x0006) { 429 } else if (type == 0x0006) {
378 /* 430 /*
379 * Type = 0x0006: ICQ Online Status 431 * Type = 0x0006: ICQ Online Status
380 * 432 *
440 * 492 *
441 */ 493 */
442 outinfo->sessionlen = aimbs_get32(bs); 494 outinfo->sessionlen = aimbs_get32(bs);
443 outinfo->present |= AIM_USERINFO_PRESENT_SESSIONLEN; 495 outinfo->present |= AIM_USERINFO_PRESENT_SESSIONLEN;
444 496
497 } else if (type == 0x001d) {
498 /*
499 * Type 29: Unknown.
500 *
501 * Currently very rare. Always 18 bytes of mostly zero.
502 */
503
504 } else if (type == 0x001e) {
505 /*
506 * Type 30: Unknown.
507 *
508 * Always four bytes, but it doesn't look like an int.
509 */
445 } else { 510 } else {
446 511
447 /* 512 /*
448 * Reaching here indicates that either AOL has 513 * Reaching here indicates that either AOL has
449 * added yet another TLV for us to deal with, 514 * added yet another TLV for us to deal with,
453 * recovery. 518 * recovery.
454 * 519 *
455 */ 520 */
456 faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV:\n"); 521 faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV:\n");
457 faimdprintf(sess, 0, "userinfo: sn =%s\n", outinfo->sn); 522 faimdprintf(sess, 0, "userinfo: sn =%s\n", outinfo->sn);
458 faimdprintf(sess, 0, "userinfo: type =0x%04x\n",type); 523 dumptlv(sess, type, bs, length);
459 faimdprintf(sess, 0, "userinfo: length=0x%04x\n", length);
460
461 } 524 }
462 525
463 /* Save ourselves. */ 526 /* Save ourselves. */
464 aim_bstream_setpos(bs, endpos); 527 aim_bstream_setpos(bs, endpos);
465 } 528 }
481 aimbs_putraw(bs, info->sn, strlen(info->sn)); 544 aimbs_putraw(bs, info->sn, strlen(info->sn));
482 545
483 aimbs_put16(bs, info->warnlevel); 546 aimbs_put16(bs, info->warnlevel);
484 547
485 548
486 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); 549 if (info->present & AIM_USERINFO_PRESENT_FLAGS)
487 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); 550 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags);
488 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); 551 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE)
489 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); 552 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince);
553 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE)
554 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince);
555 if (info->present & AIM_USERINFO_PRESENT_IDLE)
556 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime);
490 557
491 #if ICQ_OSCAR_SUPPORT 558 #if ICQ_OSCAR_SUPPORT
492 if (atoi(info->sn) != 0) { 559 if (atoi(info->sn) != 0) {
493 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); 560 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS)
494 aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); 561 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status);
562 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR)
563 aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr);
495 } 564 }
496 #endif 565 #endif
497 566
498 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); 567 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES)
499 568 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities);
500 aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); 569
570 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
571 aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen);
501 572
502 aimbs_put16(bs, aim_counttlvchain(&tlvlist)); 573 aimbs_put16(bs, aim_counttlvchain(&tlvlist));
503 aim_writetlvchain(bs, &tlvlist); 574 aim_writetlvchain(bs, &tlvlist);
504 aim_freetlvchain(&tlvlist); 575 aim_freetlvchain(&tlvlist);
505 576