Send clip response for string while file list is available

This commit is contained in:
matt335672 2021-09-14 14:43:33 +01:00
parent d9988c340c
commit 253ea6eb6d
3 changed files with 36 additions and 14 deletions

View File

@ -1231,13 +1231,20 @@ clipboard_process_data_response_for_file(struct stream *s,
/* text/uri-list */
else if (g_clip_c2s.type == g_file_atom1)
{
rv = clipboard_c2s_in_files(s, g_clip_c2s.data, flist_size);
rv = clipboard_c2s_in_files(s, g_clip_c2s.data, flist_size,
"file://");
}
/* x-special/gnome-copied-files */
else if (g_clip_c2s.type == g_file_atom2)
{
g_strcpy(g_clip_c2s.data, "copy\n");
rv = clipboard_c2s_in_files(s, g_clip_c2s.data + 5, flist_size - 5);
rv = clipboard_c2s_in_files(s, g_clip_c2s.data + 5, flist_size - 5,
"file://");
}
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, "");
}
else
{
@ -2211,11 +2218,24 @@ clipboard_event_selection_request(XEvent *xevent)
}
else if ((lxev->target == XA_STRING) || (lxev->target == g_utf8_atom))
{
g_memcpy(&g_saved_selection_req_event, lxev,
sizeof(g_saved_selection_req_event));
g_clip_c2s.type = lxev->target;
g_clip_c2s.xrdp_clip_type = XRDP_CB_TEXT;
clipboard_send_data_request(CB_FORMAT_UNICODETEXT);
if (clipboard_find_format_id(g_file_format_id) >= 0)
{
LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
"text requested when files available");
g_memcpy(&g_saved_selection_req_event, lxev,
sizeof(g_saved_selection_req_event));
g_clip_c2s.type = lxev->target;
g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE;
clipboard_send_data_request(g_file_format_id);
}
else
{
g_memcpy(&g_saved_selection_req_event, lxev,
sizeof(g_saved_selection_req_event));
g_clip_c2s.type = lxev->target;
g_clip_c2s.xrdp_clip_type = XRDP_CB_TEXT;
clipboard_send_data_request(CB_FORMAT_UNICODETEXT);
}
return 0;
}
else if (lxev->target == g_image_bmp_atom)

View File

@ -598,7 +598,8 @@ clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd)
/*****************************************************************************/
int
clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size)
clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size,
const char *fprefix)
{
int citems;
int lindex;
@ -607,7 +608,6 @@ clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size)
char *ptr;
char *last; /* Last writeable char in buffer */
int dropped_files = 0; /* # files we can't add to buffer */
const char *prefix = "file://";
if (file_list_size < 1)
{
@ -655,7 +655,7 @@ clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size)
/* Room for this file? */
str_len = (ptr == file_list) ? 0 : 1; /* Delimiter */
str_len += g_strlen(prefix);
str_len += g_strlen(fprefix); /* e.g. "file://" */
str_len += g_strlen(g_fuse_clipboard_path);
str_len += 1; /* '/' */
str_len += g_strlen(cfd.cFileName);
@ -677,8 +677,8 @@ clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size)
*ptr++ = '\n';
}
str_len = g_strlen(prefix);
g_strcpy(ptr, prefix);
str_len = g_strlen(fprefix);
g_strcpy(ptr, fprefix);
ptr += str_len;
str_len = g_strlen(g_fuse_clipboard_path);

View File

@ -35,7 +35,7 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
*
* Files in the list are added to the xfs filesystem in the clipboard
* directory. The filenames names are added to the 'file_list' for the user.
* Files are prefixed with 'file://<clipboard_dir>/' and separated by '\n'.
* Files are prefixed with '<fprefix><clipboard_dir>/' and separated by '\n'.
*
* If the list is not big enough, whole filenames are omitted, and a warning
* message is logged. This is not an error.
@ -43,11 +43,13 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
* @param s Input stream containing CLIPRDR_FILELIST
* @param file_list Output buffer for filenames
* @param file_list_size Size of buffer, including space for '\0'.
* @param fprefix Prefix for each file in the file list (e.g. "file://")
*
* @return Zero for success.
*/
int
clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size);
clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size,
const char *fprefix);
int
clipboard_request_file_size(int stream_id, int lindex);