comparison src/protocols/oscar/info.c @ 4151:1a5dcfa1823e

[gaim-migrate @ 4377] Why do I make these things so long? I'm defective, that's why. Mr. Walp pointed out a problem with "allow only peeps in my buddy list" for ICQ, so I fixed that. One important problem: If you set your permdeny to "allow only peeps in my buddy list," and then add or remove someone from your buddy list, it will not update the allow/deny list on the server. And that's a bad thing. I changed an error message string or 4 in oscar.c for various reasons. 1) I feel that "he/she" is much better than "it." If you disagree, please let me know, because I'm not sure of the correct phrasing. 2) There is only 1 unknown reason, it just applies to multiple messages. I shuffled some of the clientauto functions around in oscar.c to make it more uniform. I intend to look into why status messages aren't working well soon. I added some semblance of more advanced ICQ info support to libfaim. There's also a bit of support in oscar.c for it, but making it display itself nicely will take a little work, so I'll do it later. A patch from the good Mr. Blanton taking out a non-ascii character from oscar.c (my bad). A patch from the good Mr. Blanton adding support for i18n to away messages and aim profile info. Questions for the good Mr. Blanton: 1) Line 59 of info.c, in the first half of that if statement, should profile_len also be &&'ed in with the other 2? 2) I changed a gaim_parse_user_info so that it works for non-unicode away messages and profiles. Or so I think. 3) I changed little bits of your patch to appease my annoyingness, so it might not cvs update cleanly for you. Sorry. I organized the ChangeLog entries for 0.60. I tried to put stuff that I thought was more important near the top of each category. Please change stuff around, because I'm pretty sure it could be better. Breathe in, breathe out, breathe in, breathe out... Tied to a wheel... committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 29 Dec 2002 17:12:05 +0000
parents 2532f1192da3
children d833bacc054f
comparison
equal deleted inserted replaced
4150:1bd663beada5 4151:1a5dcfa1823e
27 27
28 /* 28 /*
29 * Subtype 0x0004 29 * Subtype 0x0004
30 * 30 *
31 * Gives BOS your profile. 31 * Gives BOS your profile.
32 *
33 * profile_encoding and awaymsg_encoding MUST be set if profile or
34 * away are set, respectively, and their value may or may not be
35 * restricted to a few choices. I am currently aware of:
32 * 36 *
33 */ 37 * us-ascii Just that
34 faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, fu32_t caps) 38 * unicode-2-0 UCS2-BE
35 { 39 *
36 static const char defencoding[] = {"text/aolrtf; charset=\"us-ascii\""}; 40 * profile_len and awaymsg_len MUST be set similarly, and they MUST
41 * be the length of their respective strings in bytes.
42 *
43 * To get the previous behavior of awaymsg == "" un-setting the away
44 * message, set awaymsg non-NULL and awaymsg_len to 0 (this is the
45 * obvious equivalent).
46 *
47 */
48 faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn,
49 const char *profile_encoding, const char *profile, const int profile_len,
50 const char *awaymsg_encoding, const char *awaymsg, const int awaymsg_len,
51 fu32_t caps)
52 {
53 static const char defencoding[] = {"text/aolrtf; charset=\"%s\""};
37 aim_frame_t *fr; 54 aim_frame_t *fr;
38 aim_tlvlist_t *tl = NULL; 55 aim_tlvlist_t *tl = NULL;
39 aim_snacid_t snacid; 56 aim_snacid_t snacid;
57 char *encoding;
58
59 if ((profile && profile_encoding == NULL) || (awaymsg && awaymsg_len && awaymsg_encoding == NULL)) {
60 return -EINVAL;
61 }
40 62
41 /* Build to packet first to get real length */ 63 /* Build to packet first to get real length */
42 if (profile) { 64 if (profile) {
43 aim_addtlvtochain_raw(&tl, 0x0001, strlen(defencoding), defencoding); 65 /* no + 1 here because of %s */
44 aim_addtlvtochain_raw(&tl, 0x0002, strlen(profile), profile); 66 encoding = malloc(strlen(defencoding) + strlen(profile_encoding));
67 if (encoding == NULL) {
68 return -ENOMEM;
69 }
70 snprintf(encoding, strlen(defencoding) + strlen(profile_encoding), defencoding, profile_encoding);
71 aim_addtlvtochain_raw(&tl, 0x0001, strlen(encoding), encoding);
72 aim_addtlvtochain_raw(&tl, 0x0002, profile_len, profile);
73 free(encoding);
45 } 74 }
46 75
47 /* 76 /*
48 * So here's how this works: 77 * So here's how this works:
49 * - You are away when you have a non-zero-length type 4 TLV stored. 78 * - You are away when you have a non-zero-length type 4 TLV stored.
51 * type 4 TLV. 80 * type 4 TLV.
52 * - If you do not send the type 4 TLV, your status does not change 81 * - 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). 82 * (that is, if you were away, you'll remain away).
54 */ 83 */
55 if (awaymsg) { 84 if (awaymsg) {
56 if (strlen(awaymsg)) { 85 if (awaymsg_len) {
57 aim_addtlvtochain_raw(&tl, 0x0003, strlen(defencoding), defencoding); 86 encoding = malloc(strlen(defencoding) + strlen(awaymsg_encoding));
58 aim_addtlvtochain_raw(&tl, 0x0004, strlen(awaymsg), awaymsg); 87 if (encoding == NULL) {
88 return -ENOMEM;
89 }
90 snprintf(encoding, strlen(defencoding) + strlen(awaymsg_encoding), defencoding, awaymsg_encoding);
91 aim_addtlvtochain_raw(&tl, 0x0003, strlen(encoding), encoding);
92 aim_addtlvtochain_raw(&tl, 0x0004, awaymsg_len, awaymsg);
93 free(encoding);
59 } else 94 } else
60 aim_addtlvtochain_noval(&tl, 0x0004); 95 aim_addtlvtochain_noval(&tl, 0x0004);
61 } 96 }
62 97
63 aim_addtlvtochain_caps(&tl, 0x0005, caps); 98 aim_addtlvtochain_caps(&tl, 0x0005, caps);
710 /* Subtype 0x0006 */ 745 /* Subtype 0x0006 */
711 static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 746 static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
712 { 747 {
713 aim_userinfo_t userinfo; 748 aim_userinfo_t userinfo;
714 char *text_encoding = NULL, *text = NULL; 749 char *text_encoding = NULL, *text = NULL;
750 int textlen = 0;
715 aim_rxcallback_t userfunc; 751 aim_rxcallback_t userfunc;
716 aim_tlvlist_t *tlvlist; 752 aim_tlvlist_t *tlvlist;
753 aim_tlv_t *text_tlv = NULL;
717 aim_snac_t *origsnac = NULL; 754 aim_snac_t *origsnac = NULL;
718 struct aim_priv_inforeq *inforeq; 755 struct aim_priv_inforeq *inforeq;
719 int ret = 0; 756 int ret = 0;
720 757
721 origsnac = aim_remsnac(sess, snac->id); 758 origsnac = aim_remsnac(sess, snac->id);
745 * Profile will be 1 and 2, away message will be 3 and 4, caps 782 * Profile will be 1 and 2, away message will be 3 and 4, caps
746 * will be 5. 783 * will be 5.
747 */ 784 */
748 if (inforeq->infotype == AIM_GETINFO_GENERALINFO) { 785 if (inforeq->infotype == AIM_GETINFO_GENERALINFO) {
749 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); 786 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1);
750 text = aim_gettlv_str(tlvlist, 0x0002, 1); 787 text_tlv = aim_gettlv(tlvlist, 0x0002, 1);
751 } else if (inforeq->infotype == AIM_GETINFO_AWAYMESSAGE) { 788 } else if (inforeq->infotype == AIM_GETINFO_AWAYMESSAGE) {
752 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); 789 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1);
753 text = aim_gettlv_str(tlvlist, 0x0004, 1); 790 text_tlv = aim_gettlv(tlvlist, 0x0004, 1);
754 } else if (inforeq->infotype == AIM_GETINFO_CAPABILITIES) { 791 } else if (inforeq->infotype == AIM_GETINFO_CAPABILITIES) {
755 aim_tlv_t *ct; 792 aim_tlv_t *ct;
756 793
757 if ((ct = aim_gettlv(tlvlist, 0x0005, 1))) { 794 if ((ct = aim_gettlv(tlvlist, 0x0005, 1))) {
758 aim_bstream_t cbs; 795 aim_bstream_t cbs;
762 userinfo.capabilities = aim_getcap(sess, &cbs, ct->length); 799 userinfo.capabilities = aim_getcap(sess, &cbs, ct->length);
763 userinfo.present = AIM_USERINFO_PRESENT_CAPABILITIES; 800 userinfo.present = AIM_USERINFO_PRESENT_CAPABILITIES;
764 } 801 }
765 } 802 }
766 803
804 if (text_tlv) {
805 text = text_tlv->value;
806 textlen = text_tlv->length;
807 }
808
767 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 809 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
768 ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text); 810 ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text, textlen);
769 811
770 free(text_encoding); 812 free(text_encoding);
771 free(text);
772 813
773 aim_freetlvchain(&tlvlist); 814 aim_freetlvchain(&tlvlist);
774 815
775 if (origsnac) 816 if (origsnac)
776 free(origsnac->data); 817 free(origsnac->data);