Changeset 862371b for libfaim/info.c
- Timestamp:
- Jun 29, 2003, 1:47:04 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e016fc2
- Parents:
- 03ad7b2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/info.c
r5e53c4a r862371b 1 1 /* 2 * aim_info.c2 * Family 0x0002 - Information. 3 3 * 4 4 * The functions here are responsible for requesting and parsing information- … … 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 83 faim_export int aim_getinfo(aim_session_t *sess, aim_conn_t *conn, const char *sn, fu16_t infotype) 18 84 { … … 200 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 273 {AIM_CAPS_ICQRTF, 203 274 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 204 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 282 {AIM_CAPS_ICQUNKNOWN, 207 283 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, … … 217 293 218 294 {AIM_CAPS_APINFO, 219 {0xAA, 0x4A, 0x32, 0xB5, 220 0xF8, 0x84, 221 0x48, 0xc6, 222 0xA3, 0xD7, 223 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}}, 295 {0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6, 296 0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}}, 224 297 225 298 {AIM_CAPS_LAST} … … 376 449 } else if (type == 0x0002) { 377 450 /* 378 * Type = 0x0002: Account creation time. 451 * Type = 0x0002: Account creation time. 379 452 * 380 453 * The time/date that the user originally registered for … … 424 497 * This is sometimes sent instead of type 2 ("account 425 498 * creation time"), particularly in the self-info. 499 * And particularly for ICQ? 426 500 */ 427 501 outinfo->membersince = aimbs_get32(bs); … … 557 631 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); 558 632 633 /* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */ 559 634 #if ICQ_OSCAR_SUPPORT 560 635 if (atoi(info->sn) != 0) { … … 568 643 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) 569 644 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); 570 645 571 646 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) 572 647 aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); … … 579 654 } 580 655 581 faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info) 582 { 583 aim_frame_t *fr; 584 aim_snacid_t snacid; 585 586 if (!sess || !conn || !info) 587 return -EINVAL; 588 589 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) 590 return -ENOMEM; 591 592 snacid = aim_cachesnac(sess, 0x0003, 0x000b, 0x0000, NULL, 0); 593 594 aim_putsnac(&fr->data, 0x0003, 0x000b, 0x0000, snacid); 595 aim_putuserinfo(&fr->data, info); 596 597 aim_tx_enqueue(sess, fr); 598 599 return 0; 600 } 601 602 faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn) 603 { 604 aim_frame_t *fr; 605 aim_snacid_t snacid; 606 607 if (!sess || !conn || !sn) 608 return -EINVAL; 609 610 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)))) 611 return -ENOMEM; 612 613 snacid = aim_cachesnac(sess, 0x0003, 0x000c, 0x0000, NULL, 0); 614 615 aim_putsnac(&fr->data, 0x0003, 0x000c, 0x0000, snacid); 616 aimbs_put8(&fr->data, strlen(sn)); 617 aimbs_putraw(&fr->data, sn, strlen(sn)); 618 619 aim_tx_enqueue(sess, fr); 620 621 return 0; 622 } 623 624 /* 625 * Huh? What is this? 656 /* 657 * Subtype 0x000b - Huh? What is this? 626 658 */ 627 659 faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn) … … 648 680 649 681 /* 682 * Subtype 0x0003 683 * 650 684 * Normally contains: 651 685 * t(0001) - short containing max profile length (value = 1024) 652 686 * t(0002) - short - unknown (value = 16) [max MIME type length?] 653 687 * t(0003) - short - unknown (value = 10) 688 * t(0004) - short - unknown (value = 2048) [ICQ only?] 654 689 */ 655 690 static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) … … 673 708 } 674 709 710 /* Subtype 0x0006 */ 675 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 { … … 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 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 {
Note: See TracChangeset
for help on using the changeset viewer.