Mercurial > pidgin
comparison src/toc.c @ 1469:d74112de59ed
[gaim-migrate @ 1479]
get file in toc works (send file works better on different-endianness? systems. bah i hate endianness). also i like jabber.org as my primary server :-D
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Sun, 04 Feb 2001 11:05:04 +0000 |
| parents | 1a24237f5865 |
| children | 5a5284be5d66 |
comparison
equal
deleted
inserted
replaced
| 1468:9db35684c68c | 1469:d74112de59ed |
|---|---|
| 46 #include "pixmaps/aol_icon.xpm" | 46 #include "pixmaps/aol_icon.xpm" |
| 47 #include "pixmaps/away_icon.xpm" | 47 #include "pixmaps/away_icon.xpm" |
| 48 #include "pixmaps/dt_icon.xpm" | 48 #include "pixmaps/dt_icon.xpm" |
| 49 #include "pixmaps/free_icon.xpm" | 49 #include "pixmaps/free_icon.xpm" |
| 50 | 50 |
| 51 #define REVISION "gaim:$Revision: 1476 $" | 51 #define REVISION "gaim:$Revision: 1479 $" |
| 52 | 52 |
| 53 #define TYPE_SIGNON 1 | 53 #define TYPE_SIGNON 1 |
| 54 #define TYPE_DATA 2 | 54 #define TYPE_DATA 2 |
| 55 #define TYPE_ERROR 3 | 55 #define TYPE_ERROR 3 |
| 56 #define TYPE_SIGNOFF 4 | 56 #define TYPE_SIGNOFF 4 |
| 1416 ft->recvsize += rt; | 1416 ft->recvsize += rt; |
| 1417 for (i = 0; i < rt; i++) | 1417 for (i = 0; i < rt; i++) |
| 1418 fprintf(ft->file, "%c", buf[i]); | 1418 fprintf(ft->file, "%c", buf[i]); |
| 1419 | 1419 |
| 1420 if (ft->recvsize == ntohl(ft->hdr.size)) { | 1420 if (ft->recvsize == ntohl(ft->hdr.size)) { |
| 1421 ft->hdr.hdrtype = 0x402; | 1421 ft->hdr.hdrtype = htons(0x0204); |
| 1422 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); | 1422 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); |
| 1423 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); | 1423 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); |
| 1424 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ | 1424 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ |
| 1425 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); | 1425 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); |
| 1426 ft->hdr.flags = 0; | 1426 ft->hdr.flags = 0; |
| 1427 write(source, ft, 256); | 1427 write(source, ft, 256); |
| 1428 debug_header(ft); | |
| 1428 ft->recvsize = 0; | 1429 ft->recvsize = 0; |
| 1429 fclose(ft->file); | 1430 fclose(ft->file); |
| 1430 if (ft->hdr.filesleft == 0) { | 1431 if (ft->hdr.filesleft == 0) { |
| 1431 gdk_input_remove(ft->inpa); | 1432 gdk_input_remove(ft->inpa); |
| 1432 close(source); | 1433 close(source); |
| 1490 char buf[BUF_LONG]; | 1491 char buf[BUF_LONG]; |
| 1491 | 1492 |
| 1492 struct file_transfer *ft = data; | 1493 struct file_transfer *ft = data; |
| 1493 | 1494 |
| 1494 if (cond & GDK_INPUT_EXCEPTION) { | 1495 if (cond & GDK_INPUT_EXCEPTION) { |
| 1496 do_error_dialog("The file tranfer has been aborted; the other side most likely" | |
| 1497 " cancelled.", "Error"); | |
| 1495 gdk_input_remove(ft->inpa); | 1498 gdk_input_remove(ft->inpa); |
| 1496 close(source); | 1499 close(source); |
| 1497 g_free(ft->filename); | 1500 g_free(ft->filename); |
| 1498 g_free(ft->user); | 1501 g_free(ft->user); |
| 1499 g_free(ft->ip); | 1502 g_free(ft->ip); |
| 1517 toc_get_file_callback, ft); | 1520 toc_get_file_callback, ft); |
| 1518 } | 1521 } |
| 1519 return; | 1522 return; |
| 1520 } | 1523 } |
| 1521 | 1524 |
| 1522 if (ft->hdr.hdrtype == 0x0811) { | 1525 if (ft->hdr.hdrtype == htons(0x1108)) { |
| 1523 struct tm *fortime; | 1526 struct tm *fortime; |
| 1524 struct stat st; | 1527 struct stat st; |
| 1525 | 1528 |
| 1526 read(source, ft, 8); | 1529 read(source, ft, 8); |
| 1527 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 1530 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1531 fortime = localtime(&st.st_mtime); | 1534 fortime = localtime(&st.st_mtime); |
| 1532 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", | 1535 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
| 1533 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, | 1536 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, |
| 1534 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, | 1537 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, |
| 1535 g_basename(ft->filename)); | 1538 g_basename(ft->filename)); |
| 1536 write(source, ft, 256); | 1539 write(source, buf, ntohl(ft->hdr.size)); |
| 1537 return; | 1540 return; |
| 1538 } | 1541 } |
| 1539 | 1542 |
| 1540 if (ft->hdr.hdrtype == 0x0912) { | 1543 if (ft->hdr.hdrtype == htons(0x1209)) { |
| 1541 read(source, ft, 8); | 1544 read(source, ft, 8); |
| 1542 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 1545 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1543 debug_header(ft); | 1546 debug_header(ft); |
| 1544 return; | 1547 return; |
| 1545 } | 1548 } |
| 1546 | 1549 |
| 1547 if (ft->hdr.hdrtype == 0x0b12) { | 1550 if (ft->hdr.hdrtype == htons(0x120b)) { |
| 1548 read(source, ft, 8); | 1551 read(source, ft, 8); |
| 1549 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 1552 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1550 debug_header(ft); | 1553 debug_header(ft); |
| 1551 | 1554 |
| 1552 if (ft->hdr.hdrtype != 0xc12) { | 1555 if (ft->hdr.hdrtype != htons(0x120c)) { |
| 1553 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); | 1556 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); |
| 1557 do_error_dialog(buf, "Error"); | |
| 1554 gdk_input_remove(ft->inpa); | 1558 gdk_input_remove(ft->inpa); |
| 1555 close(source); | 1559 close(source); |
| 1556 g_free(ft->filename); | 1560 g_free(ft->filename); |
| 1557 g_free(ft->user); | 1561 g_free(ft->user); |
| 1558 g_free(ft->ip); | 1562 g_free(ft->ip); |
| 1659 } | 1663 } |
| 1660 | 1664 |
| 1661 hdr = (struct file_header *)ft; | 1665 hdr = (struct file_header *)ft; |
| 1662 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | 1666 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; |
| 1663 hdr->hdrlen = htons(256); | 1667 hdr->hdrlen = htons(256); |
| 1664 hdr->hdrtype = 0x0811; | 1668 hdr->hdrtype = htons(0x1108); |
| 1665 buf = frombase64(ft->cookie); | 1669 buf = frombase64(ft->cookie); |
| 1666 g_snprintf(hdr->bcookie, 8, "%s", buf); | 1670 g_snprintf(hdr->bcookie, 8, "%s", buf); |
| 1667 g_free (buf); | 1671 g_free(buf); |
| 1668 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | 1672 hdr->totfiles = htons(1); hdr->filesleft = htons(1); |
| 1669 hdr->totparts = htons(1); hdr->partsleft = htons(1); | 1673 hdr->totparts = htons(1); hdr->partsleft = htons(1); |
| 1670 hdr->totsize = htonl((long)st.st_size); /* combined size of all files */ | 1674 hdr->totsize = htonl((long)st.st_size); /* combined size of all files */ |
| 1671 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ | 1675 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ |
| 1672 hdr->size = htonl(28 + strlen(g_basename(ft->filename))); /* size of listing.txt */ | 1676 hdr->size = htonl(28 + strlen(g_basename(ft->filename))); /* size of listing.txt */ |
