comparison src/gtk/transfer.c @ 74:e2b30d0c97a4

2002-12-333 Brian Masney <masneyb@gftp.org> * lib/config_file.c lib/gftp.h lib/protocols.c - removed use_default_dl_types option. This is always enabled by default now. * src/gtk/dnd.c src/gtk/transfer.c - fix for files that should be transferred as ascii
author masneyb
date Wed, 04 Dec 2002 02:35:45 +0000
parents aa971a4bb16f
children fe308e435ed5
comparison
equal deleted inserted replaced
73:c226809c03c8 74:e2b30d0c97a4
725 725
726 726
727 void * 727 void *
728 gftp_gtk_transfer_files (void *data) 728 gftp_gtk_transfer_files (void *data)
729 { 729 {
730 int i, mode, from_data_type, to_data_type;
730 gftp_transfer * transfer; 731 gftp_transfer * transfer;
731 char *tempstr, buf[8192]; 732 char *tempstr, buf[8192];
732 int tofd, fromfd; 733 int tofd, fromfd;
733 off_t fromsize, total; 734 off_t fromsize, total;
734 gftp_file * curfle; 735 gftp_file * curfle;
735 ssize_t num_read; 736 ssize_t num_read;
736 int i, mode;
737 737
738 pthread_detach (pthread_self ()); 738 pthread_detach (pthread_self ());
739 transfer = data; 739 transfer = data;
740 transfer->curfle = transfer->files; 740 transfer->curfle = transfer->files;
741 gettimeofday (&transfer->starttime, NULL); 741 gettimeofday (&transfer->starttime, NULL);
742 memcpy (&transfer->lasttime, &transfer->starttime, 742 memcpy (&transfer->lasttime, &transfer->starttime,
743 sizeof (transfer->lasttime)); 743 sizeof (transfer->lasttime));
744 while (transfer->curfle != NULL) 744 while (transfer->curfle != NULL)
745 { 745 {
746 from_data_type = to_data_type = -1;
747
746 pthread_mutex_lock (transfer->structmutex); 748 pthread_mutex_lock (transfer->structmutex);
747 curfle = transfer->curfle->data; 749 curfle = transfer->curfle->data;
748 transfer->current_file_number++; 750 transfer->current_file_number++;
749 pthread_mutex_unlock (transfer->structmutex); 751 pthread_mutex_unlock (transfer->structmutex);
750 752
811 } 813 }
812 814
813 if (GFTP_IS_CONNECTED (transfer->fromreq) && 815 if (GFTP_IS_CONNECTED (transfer->fromreq) &&
814 GFTP_IS_CONNECTED (transfer->toreq)) 816 GFTP_IS_CONNECTED (transfer->toreq))
815 { 817 {
818 if (curfle->ascii)
819 {
820 if (transfer->fromreq->data_type != GFTP_TYPE_ASCII)
821 {
822 from_data_type = transfer->fromreq->data_type;
823 gftp_set_data_type (transfer->fromreq, GFTP_TYPE_ASCII);
824 }
825
826 if (transfer->toreq->data_type != GFTP_TYPE_ASCII)
827 {
828 to_data_type = transfer->toreq->data_type;
829 gftp_set_data_type (transfer->toreq, GFTP_TYPE_ASCII);
830 }
831 }
832
816 fromsize = gftp_transfer_file (transfer->fromreq, curfle->file, 833 fromsize = gftp_transfer_file (transfer->fromreq, curfle->file,
817 fromfd, 834 fromfd,
818 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? 835 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
819 curfle->startsize : 0, 836 curfle->startsize : 0,
820 transfer->toreq, curfle->destfile, tofd, 837 transfer->toreq, curfle->destfile, tofd,
821 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? 838 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
822 curfle->startsize : 0); 839 curfle->startsize : 0);
840
841 if (curfle->ascii)
842 {
843 if (from_data_type != -1)
844 gftp_set_data_type (transfer->fromreq, from_data_type);
845
846 if (to_data_type != -1)
847 gftp_set_data_type (transfer->toreq, to_data_type);
848 }
823 } 849 }
824 } 850 }
825 851
826 if (!GFTP_IS_CONNECTED (transfer->fromreq) || 852 if (!GFTP_IS_CONNECTED (transfer->fromreq) ||
827 !GFTP_IS_CONNECTED (transfer->toreq)) 853 !GFTP_IS_CONNECTED (transfer->toreq))
863 buf, sizeof (buf))) > 0) 889 buf, sizeof (buf))) > 0)
864 { 890 {
865 total += num_read; 891 total += num_read;
866 gftp_gtk_calc_kbs (transfer, num_read); 892 gftp_gtk_calc_kbs (transfer, num_read);
867 893
868 if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII) 894 if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII ||
895 curfle->ascii)
869 tempstr = gftp_convert_ascii (buf, &num_read, 1); 896 tempstr = gftp_convert_ascii (buf, &num_read, 1);
870 else 897 else
871 tempstr = buf; 898 tempstr = buf;
872 899
873 if (gftp_put_next_file_chunk (transfer->toreq, tempstr, 900 if (gftp_put_next_file_chunk (transfer->toreq, tempstr,
877 break; 904 break;
878 } 905 }
879 906
880 /* We don't have to free tempstr for a download because new 907 /* We don't have to free tempstr for a download because new
881 memory is not allocated for it in that case */ 908 memory is not allocated for it in that case */
882 if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII && 909 if ((GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII ||
910 curfle->ascii) &&
883 transfer->transfer_direction == GFTP_DIRECTION_UPLOAD) 911 transfer->transfer_direction == GFTP_DIRECTION_UPLOAD)
884 g_free (tempstr); 912 g_free (tempstr);
885 } 913 }
886 } 914 }
887 915