Because of some technological reason, e.g. a progress bar that allows user to cancels file transfer has not been done. We have to specify a maximum allowed file size so file content will not consume too much memory. Signed-off-by: Dunrong Huang <riegamaths@xxxxxxxxx> --- gtk/spice-dnd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gtk/spice-dnd.c b/gtk/spice-dnd.c index 3593c9d..6374b2b 100644 --- a/gtk/spice-dnd.c +++ b/gtk/spice-dnd.c @@ -30,6 +30,23 @@ #include "spice-widget-priv.h" #include "glib-compat.h" +#define DND_MAX_FILE_SIZE 100 * 1024 * 1024 /* maximum allowed file size */ + +static void spice_dnd_file_too_large(GtkWidget *parent) +{ + GtkWidget *dialog = gtk_message_dialog_new( + GTK_WINDOW(parent), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, NULL); + gtk_window_set_title(GTK_WINDOW(dialog), "GtkMessageDialog"); + gtk_message_dialog_format_secondary_text( + GTK_MESSAGE_DIALOG(dialog), + "File size exceeds maximum allowed value(%dM)", + DND_MAX_FILE_SIZE / 1024 / 1024); + + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); +} + void spice_dnd_process(SpiceDisplay *display, const char *file_path) { #define DND_CHUNK_SIZE 1600 @@ -60,6 +77,11 @@ void spice_dnd_process(SpiceDisplay *display, const char *file_path) return ; } + if (st.st_size > DND_MAX_FILE_SIZE) { + spice_dnd_file_too_large(gtk_widget_get_toplevel(GTK_WIDGET(display))); + return ; + } + /* Get file basename */ file_name = strrchr(file_path, '/'); if (file_name) { -- 1.7.12.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel