From 2dbec6332772dfd402795acd967306085445f2de Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 14 Sep 2021 15:00:01 +0100 Subject: [PATCH] Add Nautilus 3 compatibility --- docs/man/sesman.ini.5.in | 8 ++++++++ sesman/chansrv/chansrv_config.c | 11 +++++++++-- sesman/chansrv/chansrv_config.h | 3 +++ sesman/chansrv/clipboard.c | 23 ++++++++++++++++++++++- sesman/sesman.ini.in | 4 ++++ 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/docs/man/sesman.ini.5.in b/docs/man/sesman.ini.5.in index 32c93cb4..0f58c0ce 100644 --- a/docs/man/sesman.ini.5.in +++ b/docs/man/sesman.ini.5.in @@ -290,6 +290,14 @@ features:- .P - copying-and-pasting of files .RE +.TP +\fBUseNautilus3FlistFormat\fR=\fI[false|true]\fR +Defaults to \fIfalse\fR. +Set to \fItrue\fR to make file copy-paste compatible with Nautilus from +GNOME 3 versions later than 3.29.92. Do not use this for any other reason. + +This setting will be removed in a later version of xrdp, when GNOME 3 is +no longer supported. .SH "SESSIONS VARIABLES" All entries in the \fB[SessionVariables]\fR section are set as diff --git a/sesman/chansrv/chansrv_config.c b/sesman/chansrv/chansrv_config.c index ad8789ec..adbecb5e 100644 --- a/sesman/chansrv/chansrv_config.c +++ b/sesman/chansrv/chansrv_config.c @@ -39,7 +39,7 @@ #define DEFAULT_ENABLE_FUSE_MOUNT 1 #define DEFAULT_FUSE_MOUNT_NAME "xrdp-client" #define DEFAULT_FILE_UMASK 077 - +#define DEFAULT_USE_NAUTILUS3_FLIST_FORMAT 0 /** * Type used for passing a logging function about */ @@ -161,7 +161,7 @@ read_config_chansrv(log_func_t logmsg, { cfg->enable_fuse_mount = g_text2bool(value); } - if (g_strcasecmp(name, "FuseMountName") == 0) + else if (g_strcasecmp(name, "FuseMountName") == 0) { g_free(cfg->fuse_mount_name); cfg->fuse_mount_name = g_strdup(value); @@ -176,6 +176,10 @@ read_config_chansrv(log_func_t logmsg, { cfg->file_umask = strtol(value, NULL, 0); } + else if (g_strcasecmp(name, "UseNautilus3FlistFormat") == 0) + { + cfg->use_nautilus3_flist_format = g_text2bool(value); + } } return error; @@ -206,6 +210,7 @@ new_config(void) cfg->restrict_outbound_clipboard = DEFAULT_RESTRICT_OUTBOUND_CLIPBOARD; cfg->fuse_mount_name = fuse_mount_name; cfg->file_umask = DEFAULT_FILE_UMASK; + cfg->use_nautilus3_flist_format = DEFAULT_USE_NAUTILUS3_FLIST_FORMAT; } return cfg; @@ -290,6 +295,8 @@ config_dump(struct config_chansrv *config) g_bool2text(config->enable_fuse_mount)); g_writeln(" FuseMountName: %s", config->fuse_mount_name); g_writeln(" FileMask: 0%o", config->file_umask); + g_writeln(" Nautilus 3 Flist Format: %s", + g_bool2text(config->use_nautilus3_flist_format)); } /******************************************************************************/ diff --git a/sesman/chansrv/chansrv_config.h b/sesman/chansrv/chansrv_config.h index 3d0ff379..f4acd592 100644 --- a/sesman/chansrv/chansrv_config.h +++ b/sesman/chansrv/chansrv_config.h @@ -36,6 +36,9 @@ struct config_chansrv char *fuse_mount_name; /** FileUmask from sesman.ini */ mode_t file_umask; + + /** Whether to use nautilus3-compatible file lists for the clipboard */ + int use_nautilus3_flist_format; }; diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index 16b9382e..36ddc39f 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -1244,7 +1244,28 @@ clipboard_process_data_response_for_file(struct stream *s, else if ((g_clip_c2s.type == XA_STRING) || (g_clip_c2s.type == g_utf8_atom)) { - rv = clipboard_c2s_in_files(s, g_clip_c2s.data, flist_size, ""); + if (g_cfg->use_nautilus3_flist_format) + { + /* + * This file list format is only used by GNOME 3 + * versions >= 3.29.92. It is not used by GNOME 4. Remove + * this workaround when GNOME 3 is no longer supported by + * long-term distros */ +#define LIST_PREFIX "x-special/nautilus-clipboard\ncopy\n" +#define LIST_PREFIX_LEN (sizeof(LIST_PREFIX) - 1) + g_strcpy(g_clip_c2s.data, LIST_PREFIX); + rv = clipboard_c2s_in_files(s, + g_clip_c2s.data + LIST_PREFIX_LEN, + flist_size - LIST_PREFIX_LEN - 1, + "file://"); + g_strcat(g_clip_c2s.data, "\n"); +#undef LIST_PREFIX_LEN +#undef LIST_PREFIX + } + else + { + rv = clipboard_c2s_in_files(s, g_clip_c2s.data, flist_size, ""); + } } else { diff --git a/sesman/sesman.ini.in b/sesman/sesman.ini.in index 59f99774..7b8f0880 100644 --- a/sesman/sesman.ini.in +++ b/sesman/sesman.ini.in @@ -125,6 +125,10 @@ FuseMountName=thinclient_drives FileUmask=077 ; Can be used to disable FUSE functionality - see sesman.ini(5) #EnableFuseMount=false +; Uncomment this line only if you are using GNOME 3 versions 3.29.92 +; and up, and you wish to cut-paste files between Nautilus and Windows. Do +; not use this setting for GNOME 4, or other file managers +#UseNautilus3FlistFormat=true [ChansrvLogging] ; Note: one log file is created per display and the LogFile config value