Mercurial > pidgin
comparison src/protocols/oscar/im.c @ 3752:b32474e522fa
[gaim-migrate @ 3890]
From: "William T. Mahan" <wtm2@duke.edu>
This patch, against CVS HEAD, fixes three bugs in Oscar File Transfer
support. I can split it up further if desired.
* Send a null checksum when initiating a file transfer, which fixes
"files don't match" warnings produced by some versions of WinAIM; add
a compile-time option to actually compute the checksum, which is
slow but necessary when sending to some Mac clients.
* Don't allow sending files to oneself, because it causes all kinds of
subtle problems and it's not useful.
* Don't crash when there is an error writing to the output file when
receiving.
From: "William T. Mahan" <wtm2@duke.edu>
This patch 2 of 3, which applies on top of the first, adds support for
reverse connections for Oscar File Transfer, the lack of which has
been the biggest complaint so far. Reverse connections are used by
newer AIM clients when there is difficulty verifying the IP of the
sender.
From: "William T. Mahan" <wtm2@duke.edu>
This patch 3 of 3, which applies on top of the first 2, removes the
alarm() and sigaction() calls that were added by my original FT patch
to detect transfer timeouts. Besides apparently not working on
Windows, they involved a lot of ugly code to handle a special case.
My new approach is to add destructors that can called when SNACs are
freed; a timeout is detected when a request SNAC is cleaned up before
the transfer is accepted. Although this touches several files, it is
more generic than the old method. I tried to implement this in an
unintrusive manner, so that there is little preformance penalty for
SNACs that do not use destructors.
My first two patches should work fine without this. If there are any
objections to the third patch, I ask that the first two patches be
applied, in which case I will set up a SourceForge page for this one.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 19 Oct 2002 05:22:30 +0000 |
parents | 9682c0e022c6 |
children | 765769211688 |
comparison
equal
deleted
inserted
replaced
3751:e25577506dec | 3752:b32474e522fa |
---|---|
652 aim_conn_t *conn; | 652 aim_conn_t *conn; |
653 int i; | 653 int i; |
654 fu8_t ck[8]; | 654 fu8_t ck[8]; |
655 aim_frame_t *fr; | 655 aim_frame_t *fr; |
656 aim_snacid_t snacid; | 656 aim_snacid_t snacid; |
657 struct aim_snac_destructor snacdest; | |
657 | 658 |
658 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) | 659 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
659 return -EINVAL; | 660 return -EINVAL; |
660 | 661 |
661 if (!sn || !filename) | 662 if (!sn || !filename) |
662 return -EINVAL; | 663 return -EINVAL; |
663 | 664 |
664 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn)+2+2+2+8+16+6+8+6+4+2+2+2+2+4+strlen(filename)+4))) | 665 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn)+2+2+2+8+16+6+8+6+4+2+2+2+2+4+strlen(filename)+4))) |
665 return -ENOMEM; | 666 return -ENOMEM; |
666 | |
667 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); | |
668 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
669 | 667 |
670 for (i = 0; i < 7; i++) | 668 for (i = 0; i < 7; i++) |
671 aimutil_put8(ck+i, 0x30 + ((fu8_t) rand() % 10)); | 669 aimutil_put8(ck+i, 0x30 + ((fu8_t) rand() % 10)); |
672 ck[7] = '\0'; | 670 ck[7] = '\0'; |
673 | 671 |
674 if (ckret) | 672 if (ckret) |
675 memcpy(ckret, ck, 8); | 673 memcpy(ckret, ck, 8); |
674 | |
675 /* Fill in the snac destructor so we know if the request | |
676 * times out. Use the cookie in the data field, so we | |
677 * know what request to cancel if there is an error. | |
678 */ | |
679 snacdest.data = malloc(8); | |
680 memcpy(snacdest.data, ck, 8); | |
681 snacdest.conn = conn; | |
682 snacid = aim_cachesnac(sess, 0x0004, 0x0006, AIM_SNACFLAGS_DESTRUCTOR, &snacdest, sizeof(snacdest)); | |
683 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
676 | 684 |
677 /* | 685 /* |
678 * Cookie | 686 * Cookie |
679 */ | 687 */ |
680 aimbs_putraw(&fr->data, ck, 8); | 688 aimbs_putraw(&fr->data, ck, 8); |
733 | 741 |
734 /* ? */ | 742 /* ? */ |
735 aimbs_put32(&fr->data, 0x00000000); | 743 aimbs_put32(&fr->data, 0x00000000); |
736 | 744 |
737 #if 0 | 745 #if 0 |
738 /* from brian's patch (?) -- wtm */ | 746 /* Newer clients seem to send this (?) -- wtm */ |
739 aimbs_put32(&fr->data, 0x00030000); | 747 aimbs_put32(&fr->data, 0x00030000); |
740 #endif | 748 #endif |
741 | 749 |
742 aim_tx_enqueue(sess, fr); | 750 aim_tx_enqueue(sess, fr); |
743 | 751 |
2216 return mtn_receive(sess, mod, rx, snac, bs); | 2224 return mtn_receive(sess, mod, rx, snac, bs); |
2217 | 2225 |
2218 return 0; | 2226 return 0; |
2219 } | 2227 } |
2220 | 2228 |
2229 static int snacdestructor(aim_session_t *sess, aim_conn_t *conn, aim_modsnac_t *snac, void *data) | |
2230 { | |
2231 aim_rxcallback_t userfunc; | |
2232 int ret = 0; | |
2233 | |
2234 if (snac->subtype == 0x0006) { | |
2235 if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_MSGTIMEOUT))) | |
2236 ret = userfunc(sess, NULL, conn, data); | |
2237 } | |
2238 /* Note that we return 1 for success, 0 for failure. */ | |
2239 return ret; | |
2240 } | |
2241 | |
2242 | |
2221 faim_internal int msg_modfirst(aim_session_t *sess, aim_module_t *mod) | 2243 faim_internal int msg_modfirst(aim_session_t *sess, aim_module_t *mod) |
2222 { | 2244 { |
2223 | 2245 |
2224 mod->family = 0x0004; | 2246 mod->family = 0x0004; |
2225 mod->version = 0x0001; | 2247 mod->version = 0x0001; |
2226 mod->toolid = 0x0110; | 2248 mod->toolid = 0x0110; |
2227 mod->toolversion = 0x047b; | 2249 mod->toolversion = 0x047b; |
2228 mod->flags = 0; | 2250 mod->flags = 0; |
2229 strncpy(mod->name, "messaging", sizeof(mod->name)); | 2251 strncpy(mod->name, "messaging", sizeof(mod->name)); |
2230 mod->snachandler = snachandler; | 2252 mod->snachandler = snachandler; |
2253 mod->snacdestructor = snacdestructor; | |
2231 | 2254 |
2232 return 0; | 2255 return 0; |
2233 } | 2256 } |