Commit Graph

224 Commits

Author SHA1 Message Date
akallabeth 239440e28d
[warnings] remove or comment unused macros 2024-09-20 18:49:38 +02:00
akallabeth ae95b66922
[warnings] fix portability [cm]alloc size 0 2024-09-11 20:50:33 +02:00
akallabeth fcdd03a020
[client,x11] fix clipboard cache
Use new function format_to_cache_slot to convert a clipboard format to a
valid key value for wHashTable. This avoids issues with our synthesized
CF_RAW format (value 0) which is an invalid key for wHashTable
2024-09-10 13:35:21 +02:00
akallabeth 9c9d74e920
[warnings] fix redundant casts 2024-08-29 12:03:09 +02:00
Armin Novak 14c85bafd3
[client,x11] fix RAW clipboard copy 2024-08-12 15:55:26 +02:00
akallabeth 56b50966a3
[client,x11] log all XInternAtom calls 2024-07-25 07:47:40 +02:00
Armin Novak 51204c1433
[client,X11] fix X11 event mask
When reading incremental data for clipboard restore previous event mask
when finished. Fixes #10377
2024-07-17 14:19:58 +02:00
Armin Novak 71760d6d9a
[client,X11] log XConvertSelection calls 2024-07-17 11:05:57 +02:00
Armin Novak 3f0f1a3bbb
[client,X11] fix duplicate file clipboard clear 2024-07-17 10:41:14 +02:00
Armin Novak 5ebbd39187
[client,X11] prevend duplicate formatID in formatList
When announcing client clipboard formats skip any format already in the
list.
2024-07-17 10:31:14 +02:00
Armin Novak d9d81d347c
[client,X11] fix clipboard locking 2024-07-17 09:49:54 +02:00
akallabeth 357a92ce55
[client,X11] log atom numbers passed to XGetAtomName 2024-06-28 09:21:17 +02:00
Armin Novak 41841997cc
[client,cliprdr] send format list msgFlags = 0
only a response message might have msgFlags != 0 set
2024-05-22 16:31:34 +02:00
akallabeth 4b1bdc622a [x11,client] always use current clipboard owner 2024-04-07 08:59:51 +02:00
akallabeth acedd305d3 fixed unused-but-set-variable warnings 2024-02-22 12:31:50 +01:00
akallabeth d7ebec5a65 [tidy] move loop variable declaration to loop 2024-02-22 12:31:50 +01:00
Armin Novak ab3f44921c [client,x11] add alternate bitmap mime types
announce alternate mime types to clipboard
2024-02-22 09:33:59 +01:00
akallabeth 0e44b2c674 [clang-tidy] clang-analyzer-unix.Malloc 2024-02-15 11:49:16 +01:00
akallabeth 0ba995655d [clang-tidy] cppcoreguidelines-init-variables 2024-02-15 11:49:16 +01:00
akallabeth 207def5c56 [clang-tidy] readability-isolate-declaration 2024-02-15 11:49:16 +01:00
akallabeth ba8cf8cf21 [build] fix Wmismatched-deallocator warnings
With custom malloc function attributes the fail path in the _New
functions produces warnings due to allocator mismatches. Silence them.
2024-02-05 08:16:55 +01:00
akallabeth 229916d02e [settings] replace XSelectionAtom
the common command line parser should not touch unstable API settings,
so use newly introduced FreeRDP_ClipboardUseSelection
2023-10-19 14:22:19 +02:00
akallabeth 5a7a1c159d [casts] remove fnObject* function pointer casts
use proper types that match the function pointer definition to avoid
surprises if the code should be refactored
2023-09-20 21:11:30 +02:00
akallabeth 7fb2f062f0 [client,x11] fix #9410 leak in xf_cliprdr 2023-09-20 21:11:30 +02:00
Pascal Nowack d7d3055b5f X11/cliprdr: Rework server to client clipboard handling
The purpose of clipboard data locking is to make the other peer
retaining the current file list until a pending paste operation is done,
even though the clipboard selection changed.
As it may be difficult to determine, when a lock is needed, imitate the
same behaviour as mstsc:
When the server side supports clipboard data locking, always attempt to
lock the file list on the server regardless of what is advertised in a
FormatList PDU.
The Lock Clipboard Data PDU can even be already sent, before the
Format List Response PDU is sent.
This is also what mstsc, does: First, lock the new (potential) file
list, then unlock the file list, when the pending paste operation is
done.
So, rework the current clipboard implementation in that direction.

Since the implementation for timeouts for old file lists is a bit hard,
for now always force unlock pending locks, when the selection changes.
However, timeouts for old file lists can still be added in the future.

The reworked clipboard handling is done with the help of three hash
tables:

1. The inode table: This hash table manages all inodes for each file.
   The keys in this table are the inodes themselves, while the values
   the files and directories and their attributes (file size, last write
   time, etc.).
2. The clipdata table: This table manages the locks for each file list.
   The keys in this table represent the clip data id and the values the
   clip data entries, which have a reference to the clip data dir, a
   directory containing the whole selection, and some helper attributes,
   like the clip data id itself.
3. The request table: Every file size or file range request is managed
   here. When a FileContentsRequest is made, its stream id with the
   respective details are added to this table. When a response is
   received, these details can then be easily looked up here.
2023-07-20 11:36:11 +02:00
Armin Novak 7dbf7cec68 [client,x11] fix RAILS image paste, fixes #7276 2023-07-10 10:26:55 +02:00
Armin Novak b05eacb99e [build] fixed compilation warnings 2023-06-08 08:13:16 +02:00
Armin Novak a4c6b36a19 [build] fix memory sanitizer stack frame warnings 2023-06-07 09:14:45 +02:00
Armin Novak 4545783dff [client,x11] always only send available clipboard 2023-05-30 13:42:28 +02:00
akallabeth 4ee6cfe13a [warnings] fix -Wmissing-prototypes 2023-05-24 08:24:32 +02:00
Pascal Nowack 7fce527cff client/X11: Fix IO errors during server to client file transfer
When receiving a file list, xfreerdp3 rebuilds the content of the FUSE
filesystem.
Since fetching uri-lists can happen during a paste action too, xfreerdp3
caches the content of the last fetched mime type.
However, uri-lists exists in different variations, e.g. nautilus uses a
different mime type, than gnome-terminal does.
Furthermore, FormatLists can also contain other formats in addition to
file lists.
Fetching those contents during a paste operation leads to IO errors in
the paste operation.

In order to fix those errors, cache every mimetype in two hash tables:
One for the raw (unconverted) data, and one for the converted data.
When a content request is received, xfreerdp3 can with the already
cached converted data, directly serve the data.
If the content is not available as cached data, but its source data was
already fetched, use that source data to create the converted data.
Then serve the converted data.
Only if no cached converted data or cached raw data is available, issue
a new FormatDataRequest.
2023-04-17 08:33:53 +02:00
Pascal Nowack d9fe2df6b5 client/X11: Only serve cached data when format matches
Format lists can contain multiple clipboard formats. When the data for
one is requested, xfreerdp caches it.
When the data for a different format in the same format lists is
requested, xfreerdp cannot use the already cached data, since that data
refers to a different format.
As a result, xfreerdp needs to ask for the data of the now requested
format.

However, this is currently not the case. xfreerdp will just provide the
data of the first request after receiving the last format list.
In order to fix this situation, also save the format id of the last
requested format.
If the format id of the cached data matches the one of the current
request, serve the data from the cached data.
Otherwise, issue a new FormatDataRequest.
2023-04-04 09:05:39 +02:00
Pascal Nowack 1f79eaa831 client/X11: Reintroduce handling for relieving filename restriction
Commit 6492a00959 introduced a way to
relieve the filename restriction, which ensured that file lists
containing files with names, that have characters, which are not allowed
on MS Windows.
This relief handling kicked in, when xfreerdp did not connect to MS
Windows RDS.
Commit d521c7fa74 got rid of any
wClipboardDelegate occurrence in xf_cliprdr.c, which also got rid of the
filename restriction relieve handling.
However, the relief handling was not added back, so do it now.
2023-04-04 09:05:39 +02:00
Armin Novak 3f5b44ba36 [clients] fix wClipboard locking 2023-03-22 16:28:01 +01:00
akallabeth a360f1ca8c [build] fix a few compiler warnings 2023-03-13 13:04:45 +01:00
Armin Novak 0b048e247e [client,x11] add Safe_XGetAtomName 2023-03-07 07:51:52 +01:00
Armin Novak 26d1fff864 [client,x11] wrap XGetWindowProperty
use a logging version of the function to diagnose issues
2023-03-07 07:51:52 +01:00
Armin Novak 87a91eb0c6 [client,x11] wrap XDeleteProperty
wrap function calls to logging version for debugging.
2023-03-07 07:51:52 +01:00
Armin Novak 684558d6d7 [client,x11] wrap XChangeProperty
to debug bug reports occuring only with certain setups wrap the function
call with a logging edition so we have the arguments available in the
log for debugging.
2023-03-07 07:51:52 +01:00
Armin Novak 2eeb5d718a [warnings] Fixed shadow warnings 2023-03-06 10:04:59 +01:00
Armin Novak d7c55d76df [client,x11] fixed missing NULL check in clipboard 2023-03-05 17:55:28 +01:00
Armin Novak cc65f5db31 [client,x11] fixed clipboard data cache 2023-03-05 17:55:28 +01:00
Armin Novak 7722961fcc [client,common] simplify file clipboard API 2023-03-05 17:55:28 +01:00
Armin Novak 46f1d141c1 [client,common] fixed winpr clipboard locking 2023-03-05 17:55:28 +01:00
Armin Novak bfea14a5b1 [cliprdr] deactivate local file paste if not supported
if the file clipboard was compiled without FUSE do not announce the
availability.
2023-03-05 17:55:28 +01:00
Armin Novak 0fb242da7b [client,x11] properly initialize file clipboard 2023-03-05 17:55:28 +01:00
Armin Novak ba128f4661 [client] move file clipboard to client common 2023-03-05 17:55:28 +01:00
Armin Novak d521c7fa74 remove wClipboardDelegate 2023-03-05 17:55:28 +01:00
Armin Novak b2fa6da8d2 [client,x11] fix fuse2 compatibility 2023-02-28 09:47:54 +01:00
Armin Novak e673405711 [client,x11] split file clipboard to own struct
* split file clipboard to own file
* check for changed file data in cliprdr_file_context_update_data,
  prevents duplidate entries in fuse filesystem
2023-02-28 09:47:54 +01:00