comparison libgaim/protocols/oscar/oft.c @ 14538:72ada44b052e

[gaim-migrate @ 17259] Present an error message if the Gaim user tries to send a file that is larger than the maximum size allowed for AIM file transfer (4GB) committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 12 Sep 2006 07:05:27 +0000
parents 648e33275d9d
children 033e1604cf63
comparison
equal deleted inserted replaced
14537:f915d073868f 14538:72ada44b052e
53 * "received" checksum and size) and closes the connection. 53 * "received" checksum and size) and closes the connection.
54 */ 54 */
55 55
56 #include "oscar.h" 56 #include "oscar.h"
57 #include "peer.h" 57 #include "peer.h"
58
59 #include "util.h"
58 60
59 /** 61 /**
60 * Calculate oft checksum of buffer 62 * Calculate oft checksum of buffer
61 * 63 *
62 * Prevcheck should be 0xFFFF0000 when starting a checksum of a file. The 64 * Prevcheck should be 0xFFFF0000 when starting a checksum of a file. The
438 440
439 void 441 void
440 peer_oft_sendcb_init(GaimXfer *xfer) 442 peer_oft_sendcb_init(GaimXfer *xfer)
441 { 443 {
442 PeerConnection *conn; 444 PeerConnection *conn;
445 size_t size;
443 446
444 conn = xfer->data; 447 conn = xfer->data;
445 conn->flags |= PEER_CONNECTION_FLAG_APPROVED; 448 conn->flags |= PEER_CONNECTION_FLAG_APPROVED;
449
450 /* Make sure the file size can be represented in 32 bits */
451 size = gaim_xfer_get_size(xfer);
452 if (size > G_MAXUINT32)
453 {
454 gchar *tmp, *size1, *size2;
455 size1 = gaim_str_size_to_units(size);
456 size2 = gaim_str_size_to_units(G_MAXUINT32);
457 tmp = g_strdup_printf(_("File %s is %s, which is larger than "
458 "the maximum size of %s."),
459 xfer->local_filename, size1, size2);
460 gaim_xfer_error(gaim_xfer_get_type(xfer),
461 gaim_xfer_get_account(xfer), xfer->who, tmp);
462 g_free(size1);
463 g_free(size2);
464 g_free(tmp);
465 peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL);
466 return;
467 }
446 468
447 /* Keep track of file transfer info */ 469 /* Keep track of file transfer info */
448 conn->xferdata.totfiles = 1; 470 conn->xferdata.totfiles = 1;
449 conn->xferdata.filesleft = 1; 471 conn->xferdata.filesleft = 1;
450 conn->xferdata.totparts = 1; 472 conn->xferdata.totparts = 1;
451 conn->xferdata.partsleft = 1; 473 conn->xferdata.partsleft = 1;
452 conn->xferdata.totsize = gaim_xfer_get_size(xfer); 474 conn->xferdata.totsize = size;
453 conn->xferdata.size = gaim_xfer_get_size(xfer); 475 conn->xferdata.size = size;
454 conn->xferdata.checksum = 0xffff0000; 476 conn->xferdata.checksum = 0xffff0000;
455 conn->xferdata.rfrcsum = 0xffff0000; 477 conn->xferdata.rfrcsum = 0xffff0000;
456 conn->xferdata.rfcsum = 0xffff0000; 478 conn->xferdata.rfcsum = 0xffff0000;
457 conn->xferdata.recvcsum = 0xffff0000; 479 conn->xferdata.recvcsum = 0xffff0000;
458 strncpy((gchar *)conn->xferdata.idstring, "OFT_Windows ICBMFT V1.1 32", 31); 480 strncpy((gchar *)conn->xferdata.idstring, "OFT_Windows ICBMFT V1.1 32", 31);