comparison src/protocols/oscar/info.c @ 5836:09f7f23dc83a

[gaim-migrate @ 6267] I think I've fixed the negative online time for real, now. Or, at least reduced the frequency of it happening. Also added the ability to see iChat's "available" messages. Sean, I ended up changing more than I thought I would have to, but that's partially because I like to change things a lot. If it conflicts or whatever feel free to back it out and I can re-patch it back in when you're done with your stuff. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 12 Jun 2003 03:27:58 +0000
parents bd37db7531e4
children a747e9e0e2cf
comparison
equal deleted inserted replaced
5835:9a08899192ee 5836:09f7f23dc83a
441 faimdprintf(sess, 0, "\n"); 441 faimdprintf(sess, 0, "\n");
442 442
443 return; 443 return;
444 } 444 }
445 445
446 faim_internal void aim_info_free(aim_userinfo_t *info)
447 {
448 free(info->iconcsum);
449 free(info->availablemsg);
450 }
451
446 /* 452 /*
447 * AIM is fairly regular about providing user info. This is a generic 453 * AIM is fairly regular about providing user info. This is a generic
448 * routine to extract it in its standard form. 454 * routine to extract it in its standard form.
449 */ 455 */
450 faim_internal int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo) 456 faim_internal int aim_info_extract(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo)
451 { 457 {
452 int curtlv, tlvcnt; 458 int curtlv, tlvcnt;
453 fu8_t snlen; 459 fu8_t snlen;
454 460
455 if (!bs || !outinfo) 461 if (!bs || !outinfo)
634 640
635 } else if (type == 0x001d) { 641 } else if (type == 0x001d) {
636 /* 642 /*
637 * Type = 0x001d 643 * Type = 0x001d
638 * 644 *
639 * Buddy icon information. This contains the info 645 * Buddy icon information and available messages.
640 * about the buddy icon that the user has stored on 646 *
641 * the server. 647 * This almost seems like the AIM protocol guys gave
642 */ 648 * the iChat guys a Type, and the iChat guys tried to
643 int flags, number, len; 649 * cram as much cool shit into it as possible. Then
644 fu8_t *csum; 650 * the Windows AIM guys were like, "hey, that's
651 * pretty neat, let's copy those prawns."
652 *
653 * In that spirit, this can contain a custom message,
654 * kind of like an away message, but you're not away
655 * (it's called an "available" message). Or it can
656 * contain information about the buddy icon the user
657 * has stored on the server.
658 */
659 int type2, number, length2;
645 660
646 while (aim_bstream_curpos(bs) < endpos) { 661 while (aim_bstream_curpos(bs) < endpos) {
647 flags = aimbs_get16(bs); 662 type2 = aimbs_get16(bs);
648 number = aimbs_get8(bs); 663 number = aimbs_get8(bs);
649 len = aimbs_get8(bs); 664 length2 = aimbs_get8(bs);
650 if ((flags & 0x0001) && (number == 0x01) && (len < 30)) { 665
651 csum = aimbs_getraw(bs, len); 666 switch (type2) {
652 memcpy(outinfo->iconcsum, csum, len); 667 case 0x0000: { /* This is an official buddy icon? */
653 outinfo->iconcsumlen = len; 668 /* This is always 5 bytes? */
654 free(csum); 669 aim_bstream_advance(bs, length2);
655 } else 670 } break;
656 aim_bstream_advance(bs, len); 671
672 case 0x0001: { /* A buddy icon checksum */
673 if ((length2 > 0) && (number == 0x01)) {
674 free(outinfo->iconcsum);
675 outinfo->iconcsum = aimbs_getraw(bs, length2);
676 outinfo->iconcsumlen = length2;
677 } else
678 aim_bstream_advance(bs, length2);
679 } break;
680
681 case 0x0002: { /* An available message */
682 if (length2 > 4) {
683 free(outinfo->availablemsg);
684 outinfo->availablemsg = aimbs_getstr(bs, aimbs_get16(bs));
685 } else
686 aim_bstream_advance(bs, length2);
687 } break;
688
689 default: {
690 aim_bstream_advance(bs, length2);
691 } break;
692 }
657 } 693 }
658 694
659 } else if (type == 0x001e) { 695 } else if (type == 0x001e) {
660 /* 696 /*
661 * Type 30: Unknown. 697 * Type 30: Unknown.
684 720
685 return 0; 721 return 0;
686 } 722 }
687 723
688 /* 724 /*
689 * Inverse of aim_extractuserinfo() 725 * Inverse of aim_info_extract()
690 */ 726 */
691 faim_internal int aim_putuserinfo(aim_bstream_t *bs, aim_userinfo_t *info) 727 faim_internal int aim_putuserinfo(aim_bstream_t *bs, aim_userinfo_t *info)
692 { 728 {
693 aim_tlvlist_t *tlvlist = NULL; 729 aim_tlvlist_t *tlvlist = NULL;
694 730
814 (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) { 850 (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) {
815 faimdprintf(sess, 0, "parse_userinfo_middle: unknown infotype in request! (0x%04x)\n", inforeq->infotype); 851 faimdprintf(sess, 0, "parse_userinfo_middle: unknown infotype in request! (0x%04x)\n", inforeq->infotype);
816 return 0; 852 return 0;
817 } 853 }
818 854
819 aim_extractuserinfo(sess, bs, &userinfo); 855 aim_info_extract(sess, bs, &userinfo);
820 856
821 tlvlist = aim_readtlvchain(bs); 857 tlvlist = aim_readtlvchain(bs);
822 858
823 /* 859 /*
824 * Depending on what informational text was requested, different 860 * Depending on what informational text was requested, different
852 } 888 }
853 889
854 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 890 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
855 ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text, textlen); 891 ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text, textlen);
856 892
893 aim_info_free(&userinfo);
857 free(text_encoding); 894 free(text_encoding);
858
859 aim_freetlvchain(&tlvlist); 895 aim_freetlvchain(&tlvlist);
860
861 if (origsnac) 896 if (origsnac)
862 free(origsnac->data); 897 free(origsnac->data);
863 free(origsnac); 898 free(origsnac);
864 899
865 return ret; 900 return ret;