wClipboard/posix: basic file list handling
authorilammy <a.lozovsky@gmail.com>
Sat, 8 Apr 2017 23:29:50 +0000 (02:29 +0300)
committerilammy <a.lozovsky@gmail.com>
Sun, 9 Apr 2017 00:15:48 +0000 (03:15 +0300)
commit907f21e720bc221557965dec642a8b4399e4875a
tree2f9bbb52397cbb88338fbc1965c72122e42d2a6d
parentb0bc59595d832033be740d604005e27ef7bd549e
wClipboard/posix: basic file list handling

Here you can see an outline of our approach to handling file lists put
on the clipboard. Typical usage of wClipboard by the clients sums up to
doing a ClipboardSetData() call followed by a ClipboardGetData() call
with appropriate format ID passed to them. Thus for files we would
expect the clients to first set the local format (like "text/uri-list")
and then to get the remote format (the "FileGroupDescriptorW").

MS-RDPECLIP has a concept of locally-stored list of files on the
clipboard. This is modeled by clipboard->localFiles ArrayList.  We need
to populate this list before we serialize it into CLIPRDR_FILELIST and
send it to the server. The easiest way to achieve this is a bit hacky,
but it works: we populate the file list from inside the synthesizer
callback registered for text/uri-list -> FileGroupDescriptorW
conversion.

So the client would first set the data it received from local clipboard
as "text/uri-list" format, then it gets a "FileGroupDescriptorW" format,
during that conversion we will prepare to serve file content requests,
and in the end we provide a FILEDESCRIPTOR array to the client as the
conversion result. The client will then serialize the array into
CLIPRDR_FILELIST and sent it to the server. (We cannot do serialization
in WinPR as WinPR should not know about cliprdr and its data formats.)

The subsystems are expected to store their private structures in the
clipboard->localFiles array. POSIX subsystem uses struct posix_file
which currently has bare minimum of fields: the local file name (for
open() and the like) and the remote file name (the one to put into
FILEDESCRIPTOR).
winpr/libwinpr/clipboard/clipboard.c
winpr/libwinpr/clipboard/clipboard.h
winpr/libwinpr/clipboard/posix.c