changeset 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 c226809c03c8
children 77c77098795a
files lib/config_file.c lib/gftp.h lib/options.h lib/protocols.c src/gtk/dnd.c src/gtk/transfer.c
diffstat 6 files changed, 39 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lib/config_file.c	Tue Dec 03 02:36:37 2002 +0000
+++ b/lib/config_file.c	Wed Dec 04 02:35:45 2002 +0000
@@ -143,8 +143,6 @@
 
   {"list_dblclk_action", "", &listbox_dblclick_action, CONFIG_HIDEINT, 
 	N_("This defines what will happen when you double click a file in the file listboxes. 0=View file 1=Edit file 2=Transfer file"), NULL, 0},
-  {"use_default_dl_types", "", &use_default_dl_types, CONFIG_HIDEINT, 
-	N_("(*) If this is set, and there is a ext= line below for the file extension, it will download the file as specified below"), NULL, 0},
   {"listbox_local_width", "", &listbox_local_width, CONFIG_HIDEINT, 
 	N_("The default width of the local files listbox"), NULL, 0},
   {"listbox_remote_width", "", &listbox_remote_width, CONFIG_HIDEINT,
--- a/lib/gftp.h	Tue Dec 03 02:36:37 2002 +0000
+++ b/lib/gftp.h	Wed Dec 04 02:35:45 2002 +0000
@@ -478,15 +478,14 @@
 extern gftp_bookmarks * bookmarks;
 extern int do_one_transfer_at_a_time, start_file_transfers, 
            transfer_in_progress, passive_transfer, sort_dirs_first, 
-           use_default_dl_types, show_hidden_files, refresh_files, 
-           listbox_local_width, listbox_remote_width, listbox_file_height, 
-           transfer_height, log_height, retries, sleep_time, network_timeout, 
-           use_http11, listbox_dblclick_action, file_trans_column, 
-           local_columns[6], remote_columns[6], resolve_symlinks, 
-           firewall_port, http_proxy_port, overwrite_by_default, 
-           append_file_transfers, enable_old_ssh, ssh_need_userpass, 
-           ssh_use_askpass, sshv2_use_sftp_subsys, local_sortcol, 
-           local_sortasds, remote_sortcol, remote_sortasds;
+           show_hidden_files, refresh_files, listbox_local_width, 
+           listbox_remote_width, listbox_file_height, transfer_height, 
+           log_height, retries, sleep_time, network_timeout, use_http11, 
+           listbox_dblclick_action, file_trans_column, local_columns[6], 
+           remote_columns[6], resolve_symlinks, firewall_port, http_proxy_port,
+           overwrite_by_default, append_file_transfers, enable_old_ssh, 
+           ssh_need_userpass, ssh_use_askpass, sshv2_use_sftp_subsys, 
+           local_sortcol, local_sortasds, remote_sortcol, remote_sortasds;
 extern guint max_log_window_size;
 extern GHashTable * bookmarks_htable, * config_htable;
 extern GList * localhistory, * remotehistory, * host_history, * port_history, 
--- a/lib/options.h	Tue Dec 03 02:36:37 2002 +0000
+++ b/lib/options.h	Wed Dec 04 02:35:45 2002 +0000
@@ -90,14 +90,6 @@
     passive_transfer = 1, 		/* Are we sending PASV or PORT to the 
 					   server */
     sort_dirs_first = 1, 		/* Put the dirs first when sorting */
-    use_default_dl_types = 1, 		/* If this is set, then files will use 
-                                           their default dl type. For example, 
-                                           if you set in the config file .txt 
-                                           files to have a default option of 
-                                           ASCII, and if this setting is set, 
-                                           it will use ASCII. Otherwise, it 
-                                           would use the setting in the FTP 
-                                           menu */
     show_hidden_files = 1, 		/* Show hidden files */
     refresh_files = 0, 			/* Refresh the listbox after each file 
                                            is done */
--- a/lib/protocols.c	Tue Dec 03 02:36:37 2002 +0000
+++ b/lib/protocols.c	Wed Dec 04 02:35:45 2002 +0000
@@ -1588,9 +1588,6 @@
   GList * templist;
   int stlen, ret;
 
-  if (!use_default_dl_types)
-    return (def);
-
   ret = def;
   stlen = strlen (filename);
   for (templist = registered_exts; templist != NULL; templist = templist->next)
--- a/src/gtk/dnd.c	Tue Dec 03 02:36:37 2002 +0000
+++ b/src/gtk/dnd.c	Wed Dec 04 02:35:45 2002 +0000
@@ -84,9 +84,6 @@
   
   newfle->destfile = g_strconcat (GFTP_GET_DIRECTORY (wdata->request),
                                      "/", pos, NULL);
-  newfle->ascii = gftp_get_file_transfer_mode (newfle->file, 
-                                wdata->request->data_type) == GFTP_TYPE_ASCII;
-
   templist = g_malloc0 (sizeof (*templist));
   templist->data = newfle;
   templist->next = NULL;
--- a/src/gtk/transfer.c	Tue Dec 03 02:36:37 2002 +0000
+++ b/src/gtk/transfer.c	Wed Dec 04 02:35:45 2002 +0000
@@ -727,13 +727,13 @@
 void * 
 gftp_gtk_transfer_files (void *data)
 {
+  int i, mode, from_data_type, to_data_type;
   gftp_transfer * transfer;
   char *tempstr, buf[8192];
   int tofd, fromfd;
   off_t fromsize, total;
   gftp_file * curfle; 
   ssize_t num_read;
-  int i, mode;
 
   pthread_detach (pthread_self ());
   transfer = data;
@@ -743,6 +743,8 @@
           sizeof (transfer->lasttime));
   while (transfer->curfle != NULL)
     {
+      from_data_type = to_data_type = -1;
+
       pthread_mutex_lock (transfer->structmutex);
       curfle = transfer->curfle->data;
       transfer->current_file_number++;
@@ -813,6 +815,21 @@
           if (GFTP_IS_CONNECTED (transfer->fromreq) &&
               GFTP_IS_CONNECTED (transfer->toreq))
             {
+              if (curfle->ascii)
+                {
+                  if (transfer->fromreq->data_type != GFTP_TYPE_ASCII)
+                    {
+                      from_data_type = transfer->fromreq->data_type;
+                      gftp_set_data_type (transfer->fromreq, GFTP_TYPE_ASCII);
+                    }
+
+                  if (transfer->toreq->data_type != GFTP_TYPE_ASCII)
+                    {
+                      to_data_type = transfer->toreq->data_type;
+                      gftp_set_data_type (transfer->toreq, GFTP_TYPE_ASCII);
+                    }
+                }
+
               fromsize = gftp_transfer_file (transfer->fromreq, curfle->file, 
                           fromfd,
                           curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
@@ -820,6 +837,15 @@
                           transfer->toreq, curfle->destfile, tofd,
                           curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
                                                     curfle->startsize : 0);
+
+              if (curfle->ascii)
+                {
+                  if (from_data_type != -1)
+                    gftp_set_data_type (transfer->fromreq, from_data_type);
+
+                  if (to_data_type != -1)
+                    gftp_set_data_type (transfer->toreq, to_data_type);
+                }
             }
         }
 
@@ -865,7 +891,8 @@
               total += num_read;
               gftp_gtk_calc_kbs (transfer, num_read);
 
-              if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII)
+              if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII ||
+                  curfle->ascii)
                 tempstr = gftp_convert_ascii (buf, &num_read, 1);
               else
                 tempstr = buf;
@@ -879,7 +906,8 @@
 
               /* We don't have to free tempstr for a download because new 
                  memory is not allocated for it in that case */
-              if (GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII && 
+              if ((GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII ||
+                   curfle->ascii) && 
                   transfer->transfer_direction == GFTP_DIRECTION_UPLOAD)
                 g_free (tempstr);
             }