FreeRDP
client_cliprdr_file.c File Reference
#include <freerdp/config.h>
#include <stdlib.h>
#include <errno.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/image.h>
#include <winpr/stream.h>
#include <winpr/clipboard.h>
#include <winpr/path.h>
#include <freerdp/utils/signal.h>
#include <freerdp/log.h>
#include <freerdp/client/cliprdr.h>
#include <freerdp/channels/channels.h>
#include <freerdp/channels/cliprdr.h>
#include <freerdp/client/client_cliprdr_file.h>

Macros

#define MAX_CLIP_DATA_DIR_LEN   10
 
#define MAX_CLIPBOARD_FORMATS   255
 
#define NO_CLIP_DATA_ID   (UINT64_C(1) << 32)
 
#define WIN32_FILETIME_TO_UNIX_EPOCH   UINT64_C(11644473600)
 
#define DEBUG_CLIPRDR(log, ...)
 

Functions

UINT cliprdr_file_context_notify_new_server_format_list (CliprdrFileContext *file_context)
 
UINT cliprdr_file_context_notify_new_client_format_list (CliprdrFileContext *file_context)
 
static CliprdrLocalStream * cliprdr_local_stream_new (CliprdrFileContext *context, UINT32 streamID, const char *data, size_t size)
 
static void cliprdr_file_session_terminate (CliprdrFileContext *file, BOOL stop_thread)
 
static BOOL local_stream_discard (const void *key, void *value, void *arg)
 
static void writelog (wLog *log, DWORD level, const char *fname, const char *fkt, size_t line,...)
 
static UINT cliprdr_file_context_send_file_contents_failure (CliprdrFileContext *file, const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
 
static UINT cliprdr_file_context_send_contents_response (CliprdrFileContext *file, const CLIPRDR_FILE_CONTENTS_REQUEST *request, const void *data, size_t size)
 
static BOOL dump_streams (const void *key, void *value, void *arg)
 
static CliprdrLocalFile * file_info_for_request (CliprdrFileContext *file, UINT32 lockId, UINT32 listIndex)
 
static CliprdrLocalFile * file_for_request (CliprdrFileContext *file, UINT32 lockId, UINT32 listIndex)
 
static void cliprdr_local_file_try_close (CliprdrLocalFile *file, UINT res, UINT64 offset, UINT64 size)
 
static UINT cliprdr_file_context_server_file_size_request (CliprdrFileContext *file, const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
 
static UINT cliprdr_file_context_server_file_range_request (CliprdrFileContext *file, const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
 
static void cliprdr_local_stream_free (void *obj)
 
static UINT change_lock (CliprdrFileContext *file, UINT32 lockId, BOOL lock)
 
static UINT cliprdr_file_context_lock (CliprdrClientContext *context, const CLIPRDR_LOCK_CLIPBOARD_DATA *lockClipboardData)
 
static UINT cliprdr_file_context_unlock (CliprdrClientContext *context, const CLIPRDR_UNLOCK_CLIPBOARD_DATA *unlockClipboardData)
 
static UINT cliprdr_file_context_server_file_contents_request (CliprdrClientContext *context, const CLIPRDR_FILE_CONTENTS_REQUEST *fileContentsRequest)
 
BOOL cliprdr_file_context_init (CliprdrFileContext *file, CliprdrClientContext *cliprdr)
 
BOOL cliprdr_file_context_uninit (CliprdrFileContext *file, CliprdrClientContext *cliprdr)
 
static BOOL cliprdr_file_content_changed_and_update (void *ihash, size_t hsize, const void *data, size_t size)
 
static BOOL cliprdr_file_server_content_changed_and_update (CliprdrFileContext *file, const void *data, size_t size)
 
static BOOL cliprdr_file_client_content_changed_and_update (CliprdrFileContext *file, const void *data, size_t size)
 
BOOL cliprdr_file_context_update_server_data (CliprdrFileContext *file_context, wClipboard *clip, const void *data, size_t size)
 updates the files the server announces to the client More...
 
void * cliprdr_file_context_get_context (CliprdrFileContext *file)
 
void cliprdr_file_context_free (CliprdrFileContext *file)
 
static BOOL create_base_path (CliprdrFileContext *file)
 
static void cliprdr_local_file_free (CliprdrLocalFile *file)
 
static BOOL cliprdr_local_file_new (CliprdrFileContext *context, CliprdrLocalFile *f, const char *path)
 
static void cliprdr_local_files_free (CliprdrLocalStream *stream)
 
static BOOL append_entry (CliprdrLocalStream *stream, const char *path)
 
static BOOL is_directory (const char *path)
 
static BOOL add_directory (CliprdrLocalStream *stream, const char *path)
 
static BOOL cliprdr_local_stream_update (CliprdrLocalStream *stream, const char *data, size_t size)
 
static UINT32 UINTPointerHash (const void *id)
 
static BOOL UINTPointerCompare (const void *pointer1, const void *pointer2)
 
static void * UINTPointerClone (const void *other)
 
CliprdrFileContext * cliprdr_file_context_new (void *context)
 
BOOL cliprdr_file_context_clear (CliprdrFileContext *file)
 
BOOL cliprdr_file_context_update_client_data (CliprdrFileContext *file, const char *data, size_t size)
 updates the files the client announces to the server More...
 
UINT32 cliprdr_file_context_current_flags (CliprdrFileContext *file)
 
BOOL cliprdr_file_context_set_locally_available (CliprdrFileContext *file, BOOL available)
 sets state of local file paste support More...
 
BOOL cliprdr_file_context_remote_set_flags (CliprdrFileContext *file, UINT32 flags)
 
UINT32 cliprdr_file_context_remote_get_flags (CliprdrFileContext *file)
 
BOOL cliprdr_file_context_has_local_support (CliprdrFileContext *file)
 returns if the implementation supports pasting files in a client file browser. More...
 

Macro Definition Documentation

◆ DEBUG_CLIPRDR

#define DEBUG_CLIPRDR (   log,
  ... 
)
Value:
do \
{ \
} while (0)

◆ MAX_CLIP_DATA_DIR_LEN

#define MAX_CLIP_DATA_DIR_LEN   10

FreeRDP: A Remote Desktop Protocol Implementation X11 Clipboard Redirection

Copyright 2010-2011 Vic Lee Copyright 2015 Thincast Technologies GmbH Copyright 2015 DI (FH) Martin Haimberger marti.nosp@m.n.ha.nosp@m.imber.nosp@m.ger@.nosp@m.thinc.nosp@m.ast..nosp@m.com Copyright 2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2023 Pascal Nowack Pasca.nosp@m.l.No.nosp@m.wack@.nosp@m.gmx..nosp@m.de

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ MAX_CLIPBOARD_FORMATS

#define MAX_CLIPBOARD_FORMATS   255

◆ NO_CLIP_DATA_ID

#define NO_CLIP_DATA_ID   (UINT64_C(1) << 32)

◆ WIN32_FILETIME_TO_UNIX_EPOCH

#define WIN32_FILETIME_TO_UNIX_EPOCH   UINT64_C(11644473600)

Function Documentation

◆ add_directory()

static BOOL add_directory ( CliprdrLocalStream *  stream,
const char *  path 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_entry()

static BOOL append_entry ( CliprdrLocalStream *  stream,
const char *  path 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ change_lock()

static UINT change_lock ( CliprdrFileContext *  file,
UINT32  lockId,
BOOL  lock 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_client_content_changed_and_update()

static BOOL cliprdr_file_client_content_changed_and_update ( CliprdrFileContext *  file,
const void *  data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_content_changed_and_update()

static BOOL cliprdr_file_content_changed_and_update ( void *  ihash,
size_t  hsize,
const void *  data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_clear()

BOOL cliprdr_file_context_clear ( CliprdrFileContext *  file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_current_flags()

UINT32 cliprdr_file_context_current_flags ( CliprdrFileContext *  file)
Here is the caller graph for this function:

◆ cliprdr_file_context_free()

void cliprdr_file_context_free ( CliprdrFileContext *  file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_get_context()

void* cliprdr_file_context_get_context ( CliprdrFileContext *  file)
Here is the caller graph for this function:

◆ cliprdr_file_context_has_local_support()

BOOL cliprdr_file_context_has_local_support ( CliprdrFileContext *  file)

returns if the implementation supports pasting files in a client file browser.

!

Parameters
filethe file context to query
Returns
TRUE if files can be pasted locally, FALSE if not (e.g. no FUSE, ...)
Here is the caller graph for this function:

◆ cliprdr_file_context_init()

BOOL cliprdr_file_context_init ( CliprdrFileContext *  file,
CliprdrClientContext *  cliprdr 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_lock()

static UINT cliprdr_file_context_lock ( CliprdrClientContext *  context,
const CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_new()

CliprdrFileContext* cliprdr_file_context_new ( void *  context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_notify_new_client_format_list()

UINT cliprdr_file_context_notify_new_client_format_list ( CliprdrFileContext *  file_context)
Here is the caller graph for this function:

◆ cliprdr_file_context_notify_new_server_format_list()

UINT cliprdr_file_context_notify_new_server_format_list ( CliprdrFileContext *  file_context)
Here is the caller graph for this function:

◆ cliprdr_file_context_remote_get_flags()

UINT32 cliprdr_file_context_remote_get_flags ( CliprdrFileContext *  file)
Here is the caller graph for this function:

◆ cliprdr_file_context_remote_set_flags()

BOOL cliprdr_file_context_remote_set_flags ( CliprdrFileContext *  file,
UINT32  flags 
)
Here is the caller graph for this function:

◆ cliprdr_file_context_send_contents_response()

static UINT cliprdr_file_context_send_contents_response ( CliprdrFileContext *  file,
const CLIPRDR_FILE_CONTENTS_REQUEST request,
const void *  data,
size_t  size 
)
static
Here is the caller graph for this function:

◆ cliprdr_file_context_send_file_contents_failure()

static UINT cliprdr_file_context_send_file_contents_failure ( CliprdrFileContext *  file,
const CLIPRDR_FILE_CONTENTS_REQUEST fileContentsRequest 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_server_file_contents_request()

static UINT cliprdr_file_context_server_file_contents_request ( CliprdrClientContext *  context,
const CLIPRDR_FILE_CONTENTS_REQUEST fileContentsRequest 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_server_file_range_request()

static UINT cliprdr_file_context_server_file_range_request ( CliprdrFileContext *  file,
const CLIPRDR_FILE_CONTENTS_REQUEST fileContentsRequest 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_server_file_size_request()

static UINT cliprdr_file_context_server_file_size_request ( CliprdrFileContext *  file,
const CLIPRDR_FILE_CONTENTS_REQUEST fileContentsRequest 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_set_locally_available()

BOOL cliprdr_file_context_set_locally_available ( CliprdrFileContext *  file,
BOOL  available 
)

sets state of local file paste support

!

Parameters
filethe file context to update
availableTRUE if the client supports pasting files to local file browsers, FALSE otherwise
Returns
TRUE for success, FALSE otherwise
Here is the caller graph for this function:

◆ cliprdr_file_context_uninit()

BOOL cliprdr_file_context_uninit ( CliprdrFileContext *  file,
CliprdrClientContext *  cliprdr 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_unlock()

static UINT cliprdr_file_context_unlock ( CliprdrClientContext *  context,
const CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_update_client_data()

BOOL cliprdr_file_context_update_client_data ( CliprdrFileContext *  file,
const char *  data,
size_t  count 
)

updates the files the client announces to the server

Parameters
filethe file context to update
datathe file list
countthe length of the file list
Returns
TRUE for success, FALSE otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_context_update_server_data()

BOOL cliprdr_file_context_update_server_data ( CliprdrFileContext *  file,
wClipboard *  clip,
const void *  data,
size_t  size 
)

updates the files the server announces to the client

Parameters
filethe file context to update
clipthe clipboard instance to use
datathe file list [MS-RDPECLIP] 2.2.5.2.3 Packed File List (CLIPRDR_FILELIST)
sizethe length of the file list
Returns
TRUE for success, FALSE otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_file_server_content_changed_and_update()

static BOOL cliprdr_file_server_content_changed_and_update ( CliprdrFileContext *  file,
const void *  data,
size_t  size 
)
static
Here is the call graph for this function:

◆ cliprdr_file_session_terminate()

void cliprdr_file_session_terminate ( CliprdrFileContext *  file,
BOOL  stop_thread 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_local_file_free()

static void cliprdr_local_file_free ( CliprdrLocalFile *  file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_local_file_new()

static BOOL cliprdr_local_file_new ( CliprdrFileContext *  context,
CliprdrLocalFile *  f,
const char *  path 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_local_file_try_close()

static void cliprdr_local_file_try_close ( CliprdrLocalFile *  file,
UINT  res,
UINT64  offset,
UINT64  size 
)
static
Here is the caller graph for this function:

◆ cliprdr_local_files_free()

static void cliprdr_local_files_free ( CliprdrLocalStream *  stream)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_local_stream_free()

static void cliprdr_local_stream_free ( void *  obj)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_local_stream_new()

CliprdrLocalStream * cliprdr_local_stream_new ( CliprdrFileContext *  context,
UINT32  streamID,
const char *  data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cliprdr_local_stream_update()

static BOOL cliprdr_local_stream_update ( CliprdrLocalStream *  stream,
const char *  data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_base_path()

static BOOL create_base_path ( CliprdrFileContext *  file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_streams()

static BOOL dump_streams ( const void *  key,
void *  value,
void *  arg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_for_request()

static CliprdrLocalFile* file_for_request ( CliprdrFileContext *  file,
UINT32  lockId,
UINT32  listIndex 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_info_for_request()

static CliprdrLocalFile* file_info_for_request ( CliprdrFileContext *  file,
UINT32  lockId,
UINT32  listIndex 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_directory()

static BOOL is_directory ( const char *  path)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_stream_discard()

BOOL local_stream_discard ( const void *  key,
void *  value,
void *  arg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UINTPointerClone()

static void* UINTPointerClone ( const void *  other)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UINTPointerCompare()

static BOOL UINTPointerCompare ( const void *  pointer1,
const void *  pointer2 
)
static
Here is the caller graph for this function:

◆ UINTPointerHash()

static UINT32 UINTPointerHash ( const void *  id)
static
Here is the caller graph for this function:

◆ writelog()

static void writelog ( wLog *  log,
DWORD  level,
const char *  fname,
const char *  fkt,
size_t  line,
  ... 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: