diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2020-06-04 00:43:53 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2020-06-04 00:43:53 +0300 |
commit | d27609bf2ff34e723ba6ccd278f602a1bb918950 (patch) | |
tree | 2ca6a1bac0c0d08037ed28f59c0639a7f5d45cf4 /src | |
parent | 735437f8e41d0badab06a5fc0426bd9e555b9e17 (diff) |
Implementin resume all for FTP file transfer, should fix #2210
Signed-off-by: Antenore Gatta <antenore@simbiosi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/remmina_ftp_client.c | 18 | ||||
-rw-r--r-- | src/remmina_ftp_client.h | 3 | ||||
-rw-r--r-- | src/remmina_sftp_client.c | 72 | ||||
-rw-r--r-- | src/remmina_sftp_client.h | 3 | ||||
-rw-r--r-- | src/remmina_sftp_plugin.c | 43 |
5 files changed, 87 insertions, 52 deletions
diff --git a/src/remmina_ftp_client.c b/src/remmina_ftp_client.c index 935afa8a0..bf07e087e 100644 --- a/src/remmina_ftp_client.c +++ b/src/remmina_ftp_client.c @@ -151,6 +151,7 @@ struct _RemminaFTPClientPriv { GtkWidget *file_action_widgets[10]; gboolean sensitive; gboolean overwrite_all; + gboolean resume_all; }; static gint remmina_ftp_client_taskid = 1; @@ -837,6 +838,21 @@ gboolean remmina_ftp_client_get_overwrite_status(RemminaFTPClient *client) return client->priv->overwrite_all; } +/* Set the resume status */ +void remmina_ftp_client_set_resume_status(RemminaFTPClient *client, gboolean status) +{ + TRACE_CALL(__func__); + client->priv->resume_all = status; +} + +/* Get the resume status */ +gboolean remmina_ftp_client_get_resume_status(RemminaFTPClient *client) +{ + TRACE_CALL(__func__); + return client->priv->resume_all; +} + + static void remmina_ftp_client_init(RemminaFTPClient *client) { TRACE_CALL(__func__); @@ -854,6 +870,8 @@ static void remmina_ftp_client_init(RemminaFTPClient *client) /* Initialize overwrite status to FALSE */ client->priv->overwrite_all = FALSE; + /* Initialize resume status to FALSE */ + client->priv->resume_all = FALSE; /* Main container */ gtk_widget_set_vexpand(GTK_WIDGET(client), TRUE); diff --git a/src/remmina_ftp_client.h b/src/remmina_ftp_client.h index bc4d72e53..333791bad 100644 --- a/src/remmina_ftp_client.h +++ b/src/remmina_ftp_client.h @@ -144,5 +144,8 @@ void remmina_ftp_task_free(RemminaFTPTask *task); /* Get/Set Set overwrite_all status */ void remmina_ftp_client_set_overwrite_status(RemminaFTPClient *client, gboolean status); gboolean remmina_ftp_client_get_overwrite_status(RemminaFTPClient *client); +/* Get/Set Set resume_all status */ +void remmina_ftp_client_set_resume_status(RemminaFTPClient *client, gboolean status); +gboolean remmina_ftp_client_get_resume_status(RemminaFTPClient *client); G_END_DECLS diff --git a/src/remmina_sftp_client.c b/src/remmina_sftp_client.c index 9aa99a4d2..4911f836a 100644 --- a/src/remmina_sftp_client.c +++ b/src/remmina_sftp_client.c @@ -177,7 +177,7 @@ remmina_sftp_client_thread_download_file(RemminaSFTPClient *client, RemminaSFTP local_file = g_fopen(local_path, "ab"); if (!local_file) { - // TRANSLATORS: The placeholder %s is a file path + // TRANSLATORS: The placeholder %s is a file path remmina_sftp_client_thread_set_error(client, task, _("Could not create the file \"%s\"."), local_path); return FALSE; } @@ -918,6 +918,10 @@ remmina_sftp_client_confirm_resume(RemminaSFTPClient *client, const gchar *path) if (remmina_ftp_client_get_overwrite_status(REMMINA_FTP_CLIENT(client))) return GTK_RESPONSE_ACCEPT; + /* Always reply APPLY if resume was already set */ + if (remmina_ftp_client_get_resume_status(REMMINA_FTP_CLIENT(client))) + return GTK_RESPONSE_APPLY; + if (!remmina_masterthread_exec_is_main_thread()) { /* Allow the execution of this function from a non main thread */ RemminaMTExecData *d; @@ -991,38 +995,38 @@ remmina_sftp_client_open(RemminaSFTPClient *client, RemminaSFTP *sftp) } /* -GtkWidget * -remmina_sftp_client_new_init(RemminaSFTP *sftp) -{ - TRACE_CALL(__func__); - GdkDisplay *display; - GtkWidget *client; - GtkWidget *dialog; - - display = gdk_display_get_default(); - client = remmina_sftp_client_new(); - - - SET_CURSOR(gdk_cursor_new_for_display(display, GDK_WATCH)); - gdk_display_flush(display); - - if (!remmina_ssh_init_session(REMMINA_SSH(sftp)) || - remmina_ssh_auth(REMMINA_SSH(sftp), NULL, NULL, NULL) != REMMINA_SSH_AUTH_SUCCESS || - !remmina_sftp_open(sftp)) { - dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(client)), - GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - (REMMINA_SSH(sftp))->error, NULL); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - gtk_widget_destroy(client); - return NULL; - } - - SET_CURSOR(NULL); - - g_idle_add((GSourceFunc)remmina_sftp_client_refresh, client); - return client; -} -*/ + * GtkWidget * + * remmina_sftp_client_new_init(RemminaSFTP *sftp) + * { + * TRACE_CALL(__func__); + * GdkDisplay *display; + * GtkWidget *client; + * GtkWidget *dialog; + * + * display = gdk_display_get_default(); + * client = remmina_sftp_client_new(); + * + * + * SET_CURSOR(gdk_cursor_new_for_display(display, GDK_WATCH)); + * gdk_display_flush(display); + * + * if (!remmina_ssh_init_session(REMMINA_SSH(sftp)) || + * remmina_ssh_auth(REMMINA_SSH(sftp), NULL, NULL, NULL) != REMMINA_SSH_AUTH_SUCCESS || + * !remmina_sftp_open(sftp)) { + * dialog = gtk_message_dialog_new(GTK_WINDOW(gtk_widget_get_toplevel(client)), + * GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + * (REMMINA_SSH(sftp))->error, NULL); + * gtk_dialog_run(GTK_DIALOG(dialog)); + * gtk_widget_destroy(dialog); + * gtk_widget_destroy(client); + * return NULL; + * } + * + * SET_CURSOR(NULL); + * + * g_idle_add((GSourceFunc)remmina_sftp_client_refresh, client); + * return client; + * } + */ #endif diff --git a/src/remmina_sftp_client.h b/src/remmina_sftp_client.h index 4805311e9..ef183397e 100644 --- a/src/remmina_sftp_client.h +++ b/src/remmina_sftp_client.h @@ -61,8 +61,7 @@ typedef struct _RemminaSFTPClient { pthread_t thread; gint taskid; gboolean thread_abort; - RemminaProtocolWidget *gp; - + RemminaProtocolWidget * gp; } RemminaSFTPClient; typedef struct _RemminaSFTPClientClass { diff --git a/src/remmina_sftp_plugin.c b/src/remmina_sftp_plugin.c index b247acbeb..13dc48f6d 100644 --- a/src/remmina_sftp_plugin.c +++ b/src/remmina_sftp_plugin.c @@ -48,17 +48,19 @@ #include "remmina_protocol_widget.h" #include "remmina_sftp_plugin.h" -#define REMMINA_PLUGIN_SFTP_FEATURE_PREF_SHOW_HIDDEN 1 -#define REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL 2 +#define REMMINA_PLUGIN_SFTP_FEATURE_PREF_SHOW_HIDDEN 1 +#define REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL 2 +#define REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL 3 #define REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL_KEY "overwrite_all" +#define REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL_KEY "resume_all" #define GET_PLUGIN_DATA(gp) (RemminaPluginSftpData *)g_object_get_data(G_OBJECT(gp), "plugin-data"); typedef struct _RemminaPluginSftpData { RemminaSFTPClient * client; - pthread_t thread; - RemminaSFTP * sftp; + pthread_t thread; + RemminaSFTP * sftp; } RemminaPluginSftpData; static RemminaPluginService *remmina_plugin_service = NULL; @@ -96,7 +98,7 @@ remmina_plugin_sftp_main_thread(gpointer data) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); CANCEL_ASYNC - gpdata = GET_PLUGIN_DATA(gp); + gpdata = GET_PLUGIN_DATA(gp); remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); /* we may need to open a new tunnel too */ @@ -197,6 +199,9 @@ remmina_plugin_sftp_init(RemminaProtocolWidget *gp) remmina_ftp_client_set_overwrite_status(REMMINA_FTP_CLIENT(gpdata->client), remmina_plugin_service->file_get_int(remminafile, REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL_KEY, FALSE)); + remmina_ftp_client_set_resume_status(REMMINA_FTP_CLIENT(gpdata->client), + remmina_plugin_service->file_get_int(remminafile, + REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL_KEY, FALSE)); remmina_plugin_service->protocol_plugin_register_hostkey(gp, GTK_WIDGET(gpdata->client)); @@ -282,6 +287,10 @@ remmina_plugin_sftp_call_feature(RemminaProtocolWidget *gp, const RemminaProtoco remmina_ftp_client_set_overwrite_status(REMMINA_FTP_CLIENT(gpdata->client), remmina_plugin_service->file_get_int(remminafile, REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL_KEY, FALSE)); + case REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL: + remmina_ftp_client_set_resume_status(REMMINA_FTP_CLIENT(gpdata->client), + remmina_plugin_service->file_get_int(remminafile, + REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL_KEY, FALSE)); return; } } @@ -301,11 +310,13 @@ static gpointer ssh_auth[] = static const RemminaProtocolFeature remmina_plugin_sftp_features[] = { { REMMINA_PROTOCOL_FEATURE_TYPE_PREF, REMMINA_PLUGIN_SFTP_FEATURE_PREF_SHOW_HIDDEN, GINT_TO_POINTER(REMMINA_PROTOCOL_FEATURE_PREF_CHECK), "showhidden", - N_("Show Hidden Files") }, + N_("Show Hidden Files") }, { REMMINA_PROTOCOL_FEATURE_TYPE_PREF, REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL, GINT_TO_POINTER(REMMINA_PROTOCOL_FEATURE_PREF_CHECK), - REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL_KEY, N_("Overwrite all") }, + REMMINA_PLUGIN_SFTP_FEATURE_PREF_OVERWRITE_ALL_KEY, N_("Overwrite all files") }, + { REMMINA_PROTOCOL_FEATURE_TYPE_PREF, REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL, GINT_TO_POINTER(REMMINA_PROTOCOL_FEATURE_PREF_CHECK), + REMMINA_PLUGIN_SFTP_FEATURE_PREF_RESUME_ALL_KEY, N_("Resume all files transfer") }, { REMMINA_PROTOCOL_FEATURE_TYPE_END, 0, NULL, NULL, - NULL } + NULL } }; /* Array of RemminaProtocolSetting for basic settings. @@ -319,14 +330,14 @@ static const RemminaProtocolFeature remmina_plugin_sftp_features[] = */ static const RemminaProtocolSetting remmina_sftp_basic_settings[] = { - { REMMINA_PROTOCOL_SETTING_TYPE_SERVER, "server", NULL, FALSE, "_sftp-ssh._tcp", NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "username", N_("Username"), FALSE, NULL, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "password", N_("Password"), FALSE, NULL, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "ssh_auth", N_("Authentication type"), FALSE, ssh_auth, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_FILE, "ssh_privatekey", N_("Identity file"), FALSE, NULL, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "ssh_passphrase", N_("Password to unlock private key"), FALSE, NULL, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "ssh_proxycommand", N_("SSH Proxy Command"), FALSE, NULL, NULL }, - { REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL } + { REMMINA_PROTOCOL_SETTING_TYPE_SERVER, "server", NULL, FALSE, "_sftp-ssh._tcp", NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "username", N_("Username"), FALSE, NULL, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "password", N_("Password"), FALSE, NULL, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "ssh_auth", N_("Authentication type"), FALSE, ssh_auth, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_FILE, "ssh_privatekey", N_("Identity file"), FALSE, NULL, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_PASSWORD, "ssh_passphrase", N_("Password to unlock private key"), FALSE, NULL, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_TEXT, "ssh_proxycommand", N_("SSH Proxy Command"), FALSE, NULL, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL } }; /* Protocol plugin definition and features */ |