comparison src/protocols/oscar/info.c @ 3952:07283934dedd

[gaim-migrate @ 4133] Ok, big commit with little functionality change. Most of it is me shuffling crap around because I'm one of them neat freaks. Lots of general code cleanup too. I'm trying to move to that whole "one-family-per-file" thing. The details... I added libfaim support for aim's new search family, 0x000f. I only tested this briefly, so if anyone uses it for anything, be aware that it could be buggy. I'll add oscar support sometime. Advantages of this family are... when you search for someone, you get the directory info for that person. So like, first name, middle name, last name, maiden name, city, state, country, zip, address, interests, nickname, and maybe some other stuff. Basically all the info that they've set in their directory info thing. Info. Oh, and I'm calling it "new search" because seach was already taken, and cookie monster ate my right brain. The reason I didn't add support to oscar.c... the new search family requires making a connection to another server. While moving stuff around I realized that I didn't really like how new connections are made. It's kind of sloppy. I'm thinking it would be nice to have an outgoing queue for each type of connection, and then let the client queue messages as much as they want. Then, if libfaim sees that there is a message for a certain type of connection, and there is no open connection of that type, it will connect, and then flush the queue when the connection is made. This seems a lot cleaner, but it also seems like a pain in the ass. I should do ssi for icq first, anyway :-) Also, I think it would be neat if there was an ICBM file that handled channels 1 through 4. Then im.c and chat.c could pass the ICBM part to the icbm stuff and it could get parsed there. im.c is really huge right now. I applied a patch from Graham Booker that paves the way for unicode in direct IMs. Thanks Graham. Now we just need Paco-Paco to git a little free time and write a patch for this. http://sourceforge.net/tracker/index.php?func=detail&aid=633589&group_id=235&atid=300235 I applied 2 patches from Will Mahan dealing with file transfer/oft/rendezous/whatever. Here's some info on them, from The Man himself: Patch 1 "Currently the Rendezvous code is rather messy; this patch attempts to bring it up to speed with the rest of the Oscar prpl. Its changes include: * Rewrite several ft.c functions to use bstreams. Apparently the code in question was written before bstreams were implemented. * Handle incoming Rendezvous packets through the rxqueue like FLAP packets, rather than handling them as a special case as soon as they are received. This takes advantage of the bstream cleanup to unify some code and simplify the aim_frame_t struct. * Change some names used to try to clarify the distinction between OFT, which refers specifically to file transfer, and Rendezvous, which encompasses OFT as well as other types of client-to-client connections." Patch 2 "* Add some comments I inadvertently left out of my last patch. * Fix a double-free that occurs when connections time out. * Correct a bug causing filenames to be truncated by 4 characters on some clients. * Preserve directory structure when sending multiple files. * Handle (throw away) resource forks sent by Mac clients." I also changed all indents to tabs in ft.c. And split all the bstream stuff from rxqueue.c and put it in bstream.c. It really is a separate thing. Especially since it can be used for outgoing connections. Also, I was going to look over the whole patch tonight to make sure it's all good, but it's like 6000 lines, so, uh, I'll do it later. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 13 Nov 2002 07:01:37 +0000
parents d82f53194f09
children 2532f1192da3
comparison
equal deleted inserted replaced
3951:32942c49dced 3952:07283934dedd
1 /* 1 /*
2 * aim_info.c 2 * Family 0x0002 - Information.
3 * 3 *
4 * The functions here are responsible for requesting and parsing information- 4 * The functions here are responsible for requesting and parsing information-
5 * gathering SNACs. Or something like that. 5 * gathering SNACs. Or something like that.
6 * 6 *
7 */ 7 */
12 struct aim_priv_inforeq { 12 struct aim_priv_inforeq {
13 char sn[MAXSNLEN+1]; 13 char sn[MAXSNLEN+1];
14 fu16_t infotype; 14 fu16_t infotype;
15 }; 15 };
16 16
17 /*
18 * Subtype 0x0002
19 *
20 * Request Location services rights.
21 *
22 */
23 faim_export int aim_bos_reqlocaterights(aim_session_t *sess, aim_conn_t *conn)
24 {
25 return aim_genericreq_n(sess, conn, 0x0002, 0x0002);
26 }
27
28 /*
29 * Subtype 0x0004
30 *
31 * Gives BOS your profile.
32 *
33 */
34 faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, fu32_t caps)
35 {
36 static const char defencoding[] = {"text/aolrtf; charset=\"us-ascii\""};
37 aim_frame_t *fr;
38 aim_tlvlist_t *tl = NULL;
39 aim_snacid_t snacid;
40
41 /* Build to packet first to get real length */
42 if (profile) {
43 aim_addtlvtochain_raw(&tl, 0x0001, strlen(defencoding), defencoding);
44 aim_addtlvtochain_raw(&tl, 0x0002, strlen(profile), profile);
45 }
46
47 /*
48 * So here's how this works:
49 * - You are away when you have a non-zero-length type 4 TLV stored.
50 * - You become unaway when you clear the TLV with a zero-length
51 * type 4 TLV.
52 * - If you do not send the type 4 TLV, your status does not change
53 * (that is, if you were away, you'll remain away).
54 */
55 if (awaymsg) {
56 if (strlen(awaymsg)) {
57 aim_addtlvtochain_raw(&tl, 0x0003, strlen(defencoding), defencoding);
58 aim_addtlvtochain_raw(&tl, 0x0004, strlen(awaymsg), awaymsg);
59 } else
60 aim_addtlvtochain_noval(&tl, 0x0004);
61 }
62
63 aim_addtlvtochain_caps(&tl, 0x0005, caps);
64
65 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl))))
66 return -ENOMEM;
67
68 snacid = aim_cachesnac(sess, 0x0002, 0x0004, 0x0000, NULL, 0);
69
70 aim_putsnac(&fr->data, 0x0002, 0x004, 0x0000, snacid);
71 aim_writetlvchain(&fr->data, &tl);
72 aim_freetlvchain(&tl);
73
74 aim_tx_enqueue(sess, fr);
75
76 return 0;
77 }
78
79 /*
80 * Subtype 0x0005 - Request info of another AIM user.
81 *
82 */
17 faim_export int aim_getinfo(aim_session_t *sess, aim_conn_t *conn, const char *sn, fu16_t infotype) 83 faim_export int aim_getinfo(aim_session_t *sess, aim_conn_t *conn, const char *sn, fu16_t infotype)
18 { 84 {
19 struct aim_priv_inforeq privdata; 85 struct aim_priv_inforeq privdata;
20 aim_frame_t *fr; 86 aim_frame_t *fr;
21 aim_snacid_t snacid; 87 aim_snacid_t snacid;
197 263
198 {AIM_CAPS_SENDBUDDYLIST, 264 {AIM_CAPS_SENDBUDDYLIST,
199 {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1, 265 {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
200 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, 266 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
201 267
268 /* from ICQ2002a
269 {AIM_CAPS_ICQUNKNOWN2,
270 {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1,
271 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, */
272
202 {AIM_CAPS_ICQRTF, 273 {AIM_CAPS_ICQRTF,
203 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 274 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
204 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}}, 275 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}},
205 276
277 /* supposed to be ICQRTF?
278 {AIM_CAPS_TRILLUNKNOWN,
279 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
280 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x09}}, */
281
206 {AIM_CAPS_ICQUNKNOWN, 282 {AIM_CAPS_ICQUNKNOWN,
207 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, 283 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
208 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}}, 284 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}},
209 285
210 {AIM_CAPS_EMPTY, 286 {AIM_CAPS_EMPTY,
214 {AIM_CAPS_TRILLIANCRYPT, 290 {AIM_CAPS_TRILLIANCRYPT,
215 {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb, 291 {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
216 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}}, 292 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}},
217 293
218 {AIM_CAPS_APINFO, 294 {AIM_CAPS_APINFO,
219 {0xAA, 0x4A, 0x32, 0xB5, 295 {0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6,
220 0xF8, 0x84, 296 0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}},
221 0x48, 0xc6,
222 0xA3, 0xD7,
223 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}},
224 297
225 {AIM_CAPS_LAST} 298 {AIM_CAPS_LAST}
226 }; 299 };
227 300
228 /* 301 /*
411 * counting idle times, so this may or may not be 484 * counting idle times, so this may or may not be
412 * related to reality. 485 * related to reality.
413 */ 486 */
414 outinfo->idletime = aimbs_get16(bs); 487 outinfo->idletime = aimbs_get16(bs);
415 outinfo->present |= AIM_USERINFO_PRESENT_IDLE; 488 outinfo->present |= AIM_USERINFO_PRESENT_IDLE;
489
416 } else if (type == 0x0005) { 490 } else if (type == 0x0005) {
417 /* 491 /*
418 * Type = 0x0005: Member since date. 492 * Type = 0x0005: Member since date.
419 * 493 *
420 * The time/date that the user originally registered for 494 * The time/date that the user originally registered for
421 * the service, stored in time_t format. 495 * the service, stored in time_t format.
422 * 496 *
423 * This is sometimes sent instead of type 2 ("account 497 * This is sometimes sent instead of type 2 ("account
424 * creation time"), particularly in the self-info. 498 * creation time"), particularly in the self-info.
499 * And particularly for ICQ?
425 */ 500 */
426 outinfo->membersince = aimbs_get32(bs); 501 outinfo->membersince = aimbs_get32(bs);
427 outinfo->present |= AIM_USERINFO_PRESENT_MEMBERSINCE; 502 outinfo->present |= AIM_USERINFO_PRESENT_MEMBERSINCE;
428 503
429 } else if (type == 0x0006) { 504 } else if (type == 0x0006) {
553 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) 628 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE)
554 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); 629 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince);
555 if (info->present & AIM_USERINFO_PRESENT_IDLE) 630 if (info->present & AIM_USERINFO_PRESENT_IDLE)
556 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); 631 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime);
557 632
633 /* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */
558 #if ICQ_OSCAR_SUPPORT 634 #if ICQ_OSCAR_SUPPORT
559 if (atoi(info->sn) != 0) { 635 if (atoi(info->sn) != 0) {
560 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) 636 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS)
561 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); 637 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status);
562 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) 638 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR)
575 aim_freetlvchain(&tlvlist); 651 aim_freetlvchain(&tlvlist);
576 652
577 return 0; 653 return 0;
578 } 654 }
579 655
580 faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info) 656 /*
581 { 657 * Subtype 0x000b - Huh? What is this?
582 aim_frame_t *fr;
583 aim_snacid_t snacid;
584
585 if (!sess || !conn || !info)
586 return -EINVAL;
587
588 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
589 return -ENOMEM;
590
591 snacid = aim_cachesnac(sess, 0x0003, 0x000b, 0x0000, NULL, 0);
592
593 aim_putsnac(&fr->data, 0x0003, 0x000b, 0x0000, snacid);
594 aim_putuserinfo(&fr->data, info);
595
596 aim_tx_enqueue(sess, fr);
597
598 return 0;
599 }
600
601 faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn)
602 {
603 aim_frame_t *fr;
604 aim_snacid_t snacid;
605
606 if (!sess || !conn || !sn)
607 return -EINVAL;
608
609 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn))))
610 return -ENOMEM;
611
612 snacid = aim_cachesnac(sess, 0x0003, 0x000c, 0x0000, NULL, 0);
613
614 aim_putsnac(&fr->data, 0x0003, 0x000c, 0x0000, snacid);
615 aimbs_put8(&fr->data, strlen(sn));
616 aimbs_putraw(&fr->data, sn, strlen(sn));
617
618 aim_tx_enqueue(sess, fr);
619
620 return 0;
621 }
622
623 /*
624 * Huh? What is this?
625 */ 658 */
626 faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn) 659 faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn)
627 { 660 {
628 aim_frame_t *fr; 661 aim_frame_t *fr;
629 aim_snacid_t snacid; 662 aim_snacid_t snacid;
644 677
645 return 0; 678 return 0;
646 } 679 }
647 680
648 /* 681 /*
682 * Subtype 0x0003
683 *
649 * Normally contains: 684 * Normally contains:
650 * t(0001) - short containing max profile length (value = 1024) 685 * t(0001) - short containing max profile length (value = 1024)
651 * t(0002) - short - unknown (value = 16) [max MIME type length?] 686 * t(0002) - short - unknown (value = 16) [max MIME type length?]
652 * t(0003) - short - unknown (value = 10) 687 * t(0003) - short - unknown (value = 10)
653 * t(0004) - short - unknown (value = 2048) [ICQ only?] 688 * t(0004) - short - unknown (value = 2048) [ICQ only?]
670 aim_freetlvchain(&tlvlist); 705 aim_freetlvchain(&tlvlist);
671 706
672 return ret; 707 return ret;
673 } 708 }
674 709
710 /* Subtype 0x0006 */
675 static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 711 static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
676 { 712 {
677 aim_userinfo_t userinfo; 713 aim_userinfo_t userinfo;
678 char *text_encoding = NULL, *text = NULL; 714 char *text_encoding = NULL, *text = NULL;
679 aim_rxcallback_t userfunc; 715 aim_rxcallback_t userfunc;
741 free(origsnac); 777 free(origsnac);
742 778
743 return ret; 779 return ret;
744 } 780 }
745 781
782 /*
783 * Subtype 0x0009 - Set directory profile data.
784 *
785 * This is not the same as aim_bos_setprofile!
786 * privacy: 1 to allow searching, 0 to disallow.
787 *
788 */
789 faim_export int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, fu16_t privacy)
790 {
791 aim_frame_t *fr;
792 aim_snacid_t snacid;
793 aim_tlvlist_t *tl = NULL;
794
795 aim_addtlvtochain16(&tl, 0x000a, privacy);
796
797 if (first)
798 aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), first);
799 if (last)
800 aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), last);
801 if (middle)
802 aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), middle);
803 if (maiden)
804 aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), maiden);
805
806 if (state)
807 aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), state);
808 if (city)
809 aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), city);
810
811 if (nickname)
812 aim_addtlvtochain_raw(&tl, 0x000c, strlen(nickname), nickname);
813 if (zip)
814 aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), zip);
815
816 if (street)
817 aim_addtlvtochain_raw(&tl, 0x0021, strlen(street), street);
818
819 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
820 return -ENOMEM;
821
822 snacid = aim_cachesnac(sess, 0x0002, 0x0009, 0x0000, NULL, 0);
823
824 aim_putsnac(&fr->data, 0x0002, 0x0009, 0x0000, snacid);
825 aim_writetlvchain(&fr->data, &tl);
826 aim_freetlvchain(&tl);
827
828 aim_tx_enqueue(sess, fr);
829
830 return 0;
831 }
832
833 /*
834 * Subtype 0x000f
835 *
836 * XXX pass these in better
837 *
838 */
839 faim_export int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, fu16_t privacy)
840 {
841 aim_frame_t *fr;
842 aim_snacid_t snacid;
843 aim_tlvlist_t *tl = NULL;
844
845 /* ?? privacy ?? */
846 aim_addtlvtochain16(&tl, 0x000a, privacy);
847
848 if (interest1)
849 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest1), interest1);
850 if (interest2)
851 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest2), interest2);
852 if (interest3)
853 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest3), interest3);
854 if (interest4)
855 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest4), interest4);
856 if (interest5)
857 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest5), interest5);
858
859 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
860 return -ENOMEM;
861
862 snacid = aim_cachesnac(sess, 0x0002, 0x000f, 0x0000, NULL, 0);
863
864 aim_putsnac(&fr->data, 0x0002, 0x000f, 0x0000, 0);
865 aim_writetlvchain(&fr->data, &tl);
866 aim_freetlvchain(&tl);
867
868 aim_tx_enqueue(sess, fr);
869
870 return 0;
871 }
872
746 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 873 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
747 { 874 {
748 875
749 if (snac->subtype == 0x0003) 876 if (snac->subtype == 0x0003)
750 return rights(sess, mod, rx, snac, bs); 877 return rights(sess, mod, rx, snac, bs);