Changeset 7869e48 for libfaim/im.c
- Timestamp:
- Jan 12, 2013, 1:43:13 PM (12 years ago)
- Children:
- e3a0d71, 4485285
- Parents:
- 4626016
- git-author:
- Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/im.c
rcf02dd6 r7869e48 9 9 * is used for negotiating "rendezvous". These transactions end in 10 10 * something more complex happening, such as a chat invitation, or 11 * a file transfer. Channel 3 is used for chat messages (not in 12 * the same family as these channels). Channel 4 is used for 13 * various ICQ messages. Examples are normal messages, URLs, and 11 * a file transfer. Channel 3 is used for chat messages (not in 12 * the same family as these channels). Channel 4 is used for 13 * various ICQ messages. Examples are normal messages, URLs, and 14 14 * old-style authorization. 15 15 * … … 19 19 * use of this field. 20 20 * 21 * TODO: Split this up into an im.c file an an icbm.c file. It 21 * TODO: Split this up into an im.c file an an icbm.c file. It 22 22 * will be beautiful, you'll see. 23 23 * … … 35 35 36 36 /** 37 * Add a standard ICBM header to the given bstream with the given 37 * Add a standard ICBM header to the given bstream with the given 38 38 * information. 39 39 * … … 64 64 * Heres the current collection: 65 65 * 0501 0003 0101 0101 01 AOL Mobile Communicator, WinAIM 1.0.414 66 * 0501 0003 0101 0201 01 WinAIM 2.0.847, 2.1.1187, 3.0.1464, 66 * 0501 0003 0101 0201 01 WinAIM 2.0.847, 2.1.1187, 3.0.1464, 67 67 * 4.3.2229, 4.4.2286 68 68 * 0501 0004 0101 0102 0101 WinAIM 4.1.2010, libfaim (right here) … … 84 84 } fingerprints[] = { 85 85 /* AOL Mobile Communicator, WinAIM 1.0.414 */ 86 { AIM_CLIENTTYPE_MC, 86 { AIM_CLIENTTYPE_MC, 87 87 3, {0x01, 0x01, 0x01}}, 88 88 89 89 /* WinAIM 2.0.847, 2.1.1187, 3.0.1464, 4.3.2229, 4.4.2286 */ 90 { AIM_CLIENTTYPE_WINAIM, 90 { AIM_CLIENTTYPE_WINAIM, 91 91 3, {0x01, 0x01, 0x02}}, 92 92 … … 116 116 } 117 117 118 /** 118 /** 119 119 * Subtype 0x0002 - Set ICBM parameters. 120 120 * 121 121 * I definitly recommend sending this. If you don't, you'll be stuck 122 122 * with the rather unreasonable defaults. 123 * 123 * 124 124 */ 125 125 faim_export int aim_im_setparams(aim_session_t *sess, struct aim_icbmparameters *params) … … 145 145 146 146 /* These are all read-write */ 147 aimbs_put32(&fr->data, params->flags); 147 aimbs_put32(&fr->data, params->flags); 148 148 aimbs_put16(&fr->data, params->maxmsglen); 149 aimbs_put16(&fr->data, params->maxsenderwarn); 150 aimbs_put16(&fr->data, params->maxrecverwarn); 149 aimbs_put16(&fr->data, params->maxsenderwarn); 150 aimbs_put16(&fr->data, params->maxrecverwarn); 151 151 aimbs_put32(&fr->data, params->minmsginterval); 152 152 … … 185 185 params.maxrecverwarn = aimbs_get16(bs); 186 186 params.minmsginterval = aimbs_get32(bs); 187 187 188 188 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 189 189 return userfunc(sess, rx, ¶ms); … … 193 193 194 194 /** 195 * Subtype 0x0006 - Send an ICBM (instant message). 195 * Subtype 0x0006 - Send an ICBM (instant message). 196 196 * 197 197 * … … 207 207 * what you're doing. 208 208 * AIM_IMFLAGS_ISO_8859_1 -- The message contains the ASCII8 subset 209 * known as ISO-8859-1. 209 * known as ISO-8859-1. 210 210 * 211 211 * Generally, you should use the lowest encoding possible to send 212 212 * your message. If you only use basic punctuation and the generic 213 213 * Latin alphabet, use ASCII7 (no flags). If you happen to use non-ASCII7 214 * characters, but they are all clearly defined in ISO-8859-1, then 214 * characters, but they are all clearly defined in ISO-8859-1, then 215 215 * use that. Keep in mind that not all characters in the PC ASCII8 216 216 * character set are defined in the ISO standard. For those cases (most … … 224 224 * of the clients I use can parse those messages (and besides that, 225 225 * wchars are difficult and non-portable to handle in most UNIX environments). 226 * If you really need to include special characters, use the HTML UNICODE 227 * entities. These are of the form ߪ where 2026 is the hex 228 * representation of the UNICODE index (in this case, UNICODE 226 * If you really need to include special characters, use the HTML UNICODE 227 * entities. These are of the form ߪ where 2026 is the hex 228 * representation of the UNICODE index (in this case, UNICODE 229 229 * "Horizontal Ellipsis", or 133 in in ASCII8). 230 230 * … … 232 232 * in all of libfaim, it is written with performance in mind. As such, 233 233 * it is not as clear as it could be in respect to how this message is 234 * supposed to be layed out. Most obviously, tlvlists should be used 235 * instead of writing out the bytes manually. 234 * supposed to be layed out. Most obviously, tlvlists should be used 235 * instead of writing out the bytes manually. 236 236 * 237 237 * XXX - more precise verification that we never send SNACs larger than 8192 … … 289 289 return -ENOMEM; 290 290 291 /* XXX - should be optional */ 291 /* XXX - should be optional */ 292 292 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1); 293 293 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); 294 294 295 /* 295 /* 296 296 * Generate a random message cookie 297 297 * 298 * We could cache these like we do SNAC IDs. (In fact, it 299 * might be a good idea.) In the message error functions, 300 * the 8byte message cookie is returned as well as the 298 * We could cache these like we do SNAC IDs. (In fact, it 299 * might be a good idea.) In the message error functions, 300 * the 8byte message cookie is returned as well as the 301 301 * SNAC ID. 302 302 * … … 367 367 /* 368 368 * Set the I HAVE A REALLY PURTY ICON flag. 369 * XXX - This should really only be sent on initial 369 * XXX - This should really only be sent on initial 370 370 * IMs and when you change your icon. 371 371 */ … … 397 397 398 398 /* 399 * Simple wrapper for aim_im_sendch1_ext() 399 * Simple wrapper for aim_im_sendch1_ext() 400 400 * 401 401 * You cannot use aim_send_im if you need the HASICON flag. You must … … 505 505 * You'd think this would be in icq.c, but, well, I'm trying to stick with 506 506 * the one-group-per-file scheme as much as possible. This could easily 507 * be an exception, since Rendezvous IMs are external of the Oscar core, 507 * be an exception, since Rendezvous IMs are external of the Oscar core, 508 508 * and therefore are undefined. Really I just need to think of a good way to 509 509 * make an interface similar to what AOL actually uses. But I'm not using COM. … … 613 613 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); 614 614 615 /* 616 * Generate a random message cookie 617 * 618 * This cookie needs to be alphanumeric and NULL-terminated to be 615 /* 616 * Generate a random message cookie 617 * 618 * This cookie needs to be alphanumeric and NULL-terminated to be 619 619 * TOC-compatible. 620 620 * … … 646 646 aim_tlvlist_add_16(&itl, 0x0005, port); 647 647 aim_tlvlist_add_noval(&itl, 0x000f); 648 648 649 649 aim_tlvlist_write(&hdrbs, &itl); 650 650 … … 833 833 * @param sess The oscar session. 834 834 * @param sn The UIN of the user of whom you wish to request info. 835 * @param type The type of info you wish to request. This should be the current 835 * @param type The type of info you wish to request. This should be the current 836 836 * state of the user, as one of the AIM_ICQ_STATE_* defines. 837 837 * @return Return 0 if no errors, otherwise return the error number. … … 931 931 * Subtype 0x0006 - Send an ICQ-esque ICBM. 932 932 * 933 * This can be used to send an ICQ authorization reply (deny or grant). It is the "old way." 934 * The new way is to use SSI. I like the new way a lot better. This seems like such a hack, 935 * mostly because it's in network byte order. Figuring this stuff out sometimes takes a while, 936 * but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people 933 * This can be used to send an ICQ authorization reply (deny or grant). It is the "old way." 934 * The new way is to use SSI. I like the new way a lot better. This seems like such a hack, 935 * mostly because it's in network byte order. Figuring this stuff out sometimes takes a while, 936 * but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people 937 937 * were taking when they merged the two protocols. 938 938 * … … 1073 1073 * 1074 1074 * Not only do AIM ICBM's support multiple channels. Not only do they 1075 * support multiple character sets. But they support multiple character 1075 * support multiple character sets. But they support multiple character 1076 1076 * sets / encodings within the same ICBM. 1077 1077 * … … 1079 1079 * seem utterly unnecessary by today's standards. In fact, there is only 1080 1080 * one client still in popular use that still uses this method: AOL for the 1081 * Macintosh, Version 5.0. Obscure, yes, I know. 1081 * Macintosh, Version 5.0. Obscure, yes, I know. 1082 1082 * 1083 1083 * In modern (non-"legacy") clients, if the user tries to send a character … … 1087 1087 * Multipart messages prevent this wasted space by allowing the client to 1088 1088 * only send the characters in UNICODE that need to be sent that way, and 1089 * the rest of the message can be sent in whatever the native character 1089 * the rest of the message can be sent in whatever the native character 1090 1090 * set is (probably ASCII). 1091 1091 * … … 1116 1116 static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) 1117 1117 { 1118 aim_mpmsg_section_t *sec; 1119 1118 aim_mpmsg_section_t *sec; 1119 1120 1120 if (!(sec = malloc(sizeof(aim_mpmsg_section_t)))) 1121 1121 return -1; … … 1163 1163 fu8_t *dup; 1164 1164 1165 if (!(dup = strdup(ascii))) 1165 if (!(dup = strdup(ascii))) 1166 1166 return -1; 1167 1167 … … 1193 1193 return -1; 1194 1194 } 1195 1195 1196 1196 return 0; 1197 1197 } … … 1203 1203 for (cur = mpm->parts; cur; ) { 1204 1204 aim_mpmsg_section_t *tmp; 1205 1205 1206 1206 tmp = cur->next; 1207 1207 free(cur->data); … … 1209 1209 cur = tmp; 1210 1210 } 1211 1211 1212 1212 mpm->numparts = 0; 1213 1213 mpm->parts = NULL; … … 1217 1217 1218 1218 /* 1219 * Start by building the multipart structures, then pick the first 1219 * Start by building the multipart structures, then pick the first 1220 1220 * human-readable section and stuff it into args->msg so no one gets 1221 1221 * suspicious. … … 1405 1405 * You really shouldn't advertise a zero-length icon 1406 1406 * anyway. 1407 * 1407 * 1408 1408 */ 1409 1409 if (args.iconlen) … … 1552 1552 1553 1553 /* 1554 * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is 1554 * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is 1555 1555 * kind of odd. This sends the client ICQRTF since that is all that I've seen 1556 1556 * SERVERRELAY used for. … … 1571 1571 1572 1572 msgtype = aimbs_getle16(servdata); 1573 1573 1574 1574 anslen = aimbs_getle32(servdata); 1575 1575 aim_bstream_advance(servdata, anslen); … … 1602 1602 args->destructor = (void *)incomingim_ch2_sendfile_free; 1603 1603 1604 /* Maybe there is a better way to tell what kind of sendfile 1604 /* Maybe there is a better way to tell what kind of sendfile 1605 1605 * this is? Maybe TLV t(000a)? */ 1606 1606 if (servdata) { /* Someone is sending us a file */ … … 1613 1613 1614 1614 /* 1615 * I hope to God I'm right when I guess that there is a 1616 * 32 char max filename length for single files. I think 1617 * OFT tends to do that. Gotta love inconsistency. I saw 1615 * I hope to God I'm right when I guess that there is a 1616 * 32 char max filename length for single files. I think 1617 * OFT tends to do that. Gotta love inconsistency. I saw 1618 1618 * a 26 byte filename? 1619 1619 */ 1620 1620 /* AAA - create an aimbs_getnullstr function (don't anymore)(maybe) */ 1621 /* Use an inelegant way of getting the null-terminated filename, 1621 /* Use an inelegant way of getting the null-terminated filename, 1622 1622 * since there's no easy bstream routine. */ 1623 1623 for (flen = 0; aimbs_get8(servdata); flen++); … … 1625 1625 args->info.sendfile.filename = aimbs_getstr(servdata, flen); 1626 1626 1627 /* There is sometimes more after the null-terminated filename, 1627 /* There is sometimes more after the null-terminated filename, 1628 1628 * but I'm unsure of its format. */ 1629 1629 /* I don't believe him. */ … … 1652 1652 1653 1653 /* 1654 * There's another block of TLVs embedded in the type 5 here. 1654 * There's another block of TLVs embedded in the type 5 here. 1655 1655 */ 1656 1656 block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1); … … 1661 1661 * 1662 1662 * 0 is a request, 1 is a cancel, 2 is an accept 1663 */ 1663 */ 1664 1664 args.status = aimbs_get16(&bbs); 1665 1665 … … 1668 1668 */ 1669 1669 cookie2 = aimbs_getraw(&bbs, 8); 1670 if (memcmp(cookie, cookie2, 8) != 0) 1670 if (memcmp(cookie, cookie2, 8) != 0) 1671 1671 faimdprintf(sess, 0, "rend: warning cookies don't match!\n"); 1672 1672 memcpy(args.cookie, cookie2, 8); … … 1679 1679 args.reqclass = aim_locate_getcaps(sess, &bbs, 0x10); 1680 1680 1681 /* 1681 /* 1682 1682 * What follows may be TLVs or nothing, depending on the 1683 1683 * purpose of the message. … … 1761 1761 if (aim_tlv_gettlv(list2, 0x000d, 1)) 1762 1762 args.encoding = aim_tlv_getstr(list2, 0x000d, 1); 1763 1763 1764 1764 /* 1765 1765 * Language. … … 1896 1896 * Channel ID. 1897 1897 * 1898 * Channel 0x0001 is the message channel. It is 1898 * Channel 0x0001 is the message channel. It is 1899 1899 * used to send basic ICBMs. 1900 1900 * … … 1905 1905 * Channel 0x0003 is used for chat messages. 1906 1906 * 1907 * Channel 0x0004 is used for ICQ authorization, or 1907 * Channel 0x0004 is used for ICQ authorization, or 1908 1908 * possibly any system notice. 1909 1909 * … … 1918 1918 * userinfo block contains the number of TLVs that contain user 1919 1919 * information, the rest are not even though there is no seperation. 1920 * You can start reading the message TLVs after aim_info_extract() 1920 * You can start reading the message TLVs after aim_info_extract() 1921 1921 * parses out the standard userinfo block. 1922 1922 * … … 1924 1924 * userinfo block and the rest of the message, however there should 1925 1925 * never be two TLVs of the same type in one block. 1926 * 1926 * 1927 1927 */ 1928 1928 aim_info_extract(sess, bs, &userinfo); … … 1943 1943 1944 1944 /* 1945 * Read block of TLVs (not including the userinfo data). All 1945 * Read block of TLVs (not including the userinfo data). All 1946 1946 * further data is derived from what is parsed here. 1947 1947 */ … … 1970 1970 /* 1971 1971 * Subtype 0x0008 - Send a warning to sn. 1972 * 1972 * 1973 1973 * Flags: 1974 1974 * AIM_WARN_ANON Send as an anonymous (doesn't count as much) 1975 1975 * 1976 * returns -1 on error (couldn't alloc packet), 0 on success. 1976 * returns -1 on error (couldn't alloc packet), 0 on success. 1977 1977 * 1978 1978 */ … … 1991 1991 aim_putsnac(&fr->data, 0x0004, 0x0008, 0x0000, snacid); 1992 1992 1993 aimbs_put16(&fr->data, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000); 1993 aimbs_put16(&fr->data, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000); 1994 1994 aimbs_put8(&fr->data, strlen(sn)); 1995 1995 aimbs_putraw(&fr->data, sn, strlen(sn)); … … 2008 2008 aim_userinfo_t userinfo; 2009 2009 2010 while (aim_bstream_empty(bs)) { 2010 while (aim_bstream_empty(bs)) { 2011 2011 2012 2012 channel = aimbs_get16(bs); … … 2031 2031 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer" 2032 2032 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers" 2033 * 2033 * 2034 2034 */ 2035 2035 faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code) … … 2039 2039 aim_snacid_t snacid; 2040 2040 aim_tlvlist_t *tl = NULL; 2041 2041 2042 2042 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) 2043 2043 return -EINVAL; … … 2048 2048 snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0); 2049 2049 aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid); 2050 2050 2051 2051 aimbs_putraw(&fr->data, cookie, 8); 2052 2052 … … 2153 2153 * Subtype 0x000c - Receive an ack after sending an ICBM. 2154 2154 * 2155 * You have to have send the message with the AIM_IMFLAGS_ACK flag set 2156 * (TLV t(0003)). The ack contains the ICBM header of the message you 2155 * You have to have send the message with the AIM_IMFLAGS_ACK flag set 2156 * (TLV t(0003)). The ack contains the ICBM header of the message you 2157 2157 * sent. 2158 2158 * … … 2182 2182 * Subtype 0x0014 - Send a mini typing notification (mtn) packet. 2183 2183 * 2184 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, 2184 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, 2185 2185 * and Gaim 0.60 and newer. 2186 2186 * … … 2237 2237 * Subtype 0x0014 - Receive a mini typing notification (mtn) packet. 2238 2238 * 2239 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, 2239 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, 2240 2240 * and Gaim 0.60 and newer. 2241 2241 *
Note: See TracChangeset
for help on using the changeset viewer.