FreeRDP
xf_client.c File Reference
#include <freerdp/config.h>
#include <math.h>
#include <winpr/assert.h>
#include <winpr/sspicli.h>
#include <float.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/XKBlib.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <pthread.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/select.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/codec/nsc.h>
#include <freerdp/codec/rfx.h>
#include <freerdp/codec/color.h>
#include <freerdp/codec/bitmap.h>
#include <freerdp/utils/signal.h>
#include <freerdp/utils/passphrase.h>
#include <freerdp/client/cliprdr.h>
#include <freerdp/client/channels.h>
#include <freerdp/client/file.h>
#include <freerdp/client/cmdline.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/file.h>
#include <winpr/print.h>
#include <winpr/sysinfo.h>
#include "xf_rail.h"
#include "xf_event.h"
#include "xf_input.h"
#include "xf_cliprdr.h"
#include "xf_disp.h"
#include "xf_video.h"
#include "xf_monitor.h"
#include "xf_graphics.h"
#include "xf_keyboard.h"
#include "xf_channels.h"
#include "xfreerdp.h"
#include "xf_utils.h"
#include <freerdp/log.h>

Macros

#define TAG   CLIENT_TAG("x11")
 
#define MIN_PIXEL_DIFF   0.001
 

Functions

static BOOL xf_setup_x11 (xfContext *xfc)
 
static void xf_teardown_x11 (xfContext *xfc)
 
static int xf_map_error_to_exit_code (DWORD error)
 
static int xf_error_handler_ex (Display *d, XErrorEvent *ev)
 
static void xf_check_extensions (xfContext *context)
 
static void xf_window_free (xfContext *xfc)
 
static BOOL xf_get_pixmap_info (xfContext *xfc)
 
void xf_draw_screen_ (xfContext *xfc, int x, int y, int w, int h, const char *fkt, const char *file, int line)
 
static BOOL xf_desktop_resize (rdpContext *context)
 
static BOOL xf_paint (xfContext *xfc, const GDI_RGN *region)
 
static BOOL xf_end_paint (rdpContext *context)
 
static BOOL xf_sw_desktop_resize (rdpContext *context)
 
static BOOL xf_process_x_events (freerdp *instance)
 
static char * xf_window_get_title (rdpSettings *settings)
 
BOOL xf_create_window (xfContext *xfc)
 
BOOL xf_create_image (xfContext *xfc)
 
void xf_toggle_fullscreen (xfContext *xfc)
 
void xf_lock_x11_ (xfContext *xfc, const char *fkt)
 
void xf_unlock_x11_ (xfContext *xfc, const char *fkt)
 
static int xf_error_handler (Display *d, XErrorEvent *ev)
 
static BOOL xf_play_sound (rdpContext *context, const PLAY_SOUND_UPDATE *play_sound)
 
static void xf_get_x11_button_map (xfContext *xfc, unsigned char *x11_map)
 
static UINT16 get_flags_for_button (int button)
 
static void xf_button_map_init (xfContext *xfc)
 
static BOOL xf_pre_connect (freerdp *instance)
 
static BOOL xf_inject_keypress (rdpContext *context, const char *buffer, size_t size)
 
static BOOL xf_process_pipe (rdpContext *context, const char *pipe)
 
static void cleanup_pipe (int signum, const char *signame, void *context)
 
static DWORD WINAPI xf_handle_pipe (void *arg)
 
static BOOL xf_post_connect (freerdp *instance)
 
static void xf_post_disconnect (freerdp *instance)
 
static void xf_post_final_disconnect (freerdp *instance)
 
static int xf_logon_error_info (freerdp *instance, UINT32 data, UINT32 type)
 
static BOOL handle_window_events (freerdp *instance)
 
static DWORD WINAPI xf_client_thread (LPVOID param)
 
DWORD xf_exit_code_from_disconnect_reason (DWORD reason)
 
static void xf_TerminateEventHandler (void *context, const TerminateEventArgs *e)
 
static BOOL xfreerdp_client_global_init (void)
 
static void xfreerdp_client_global_uninit (void)
 
static int xfreerdp_client_start (rdpContext *context)
 
static Atom get_supported_atom (xfContext *xfc, const char *atomName)
 
static BOOL xfreerdp_client_new (freerdp *instance, rdpContext *context)
 
static void xfreerdp_client_free (freerdp *instance, rdpContext *context)
 
int RdpClientEntry (RDP_CLIENT_ENTRY_POINTS *pEntryPoints)
 

Variables

static const struct xf_exit_code_map_t xf_exit_code_map []
 
static int(* def_error_handler )(Display *, XErrorEvent *)
 
static const button_map xf_button_flags [NUM_BUTTONS_MAPPED]
 

Macro Definition Documentation

◆ MIN_PIXEL_DIFF

#define MIN_PIXEL_DIFF   0.001

◆ TAG

#define TAG   CLIENT_TAG("x11")

FreeRDP: A Remote Desktop Protocol Implementation X11 Client Interface

Copyright 2013 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2013 Corey Clayton can.o.nosp@m.f.tu.nosp@m.na@gm.nosp@m.ail..nosp@m.com Copyright 2014 Thincast Technologies GmbH Copyright 2014 Norbert Federa norbe.nosp@m.rt.f.nosp@m.edera.nosp@m.@thi.nosp@m.ncast.nosp@m..com Copyright 2016 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2016 Thincast Technologies GmbH

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.

Function Documentation

◆ cleanup_pipe()

static void cleanup_pipe ( int  signum,
const char *  signame,
void *  context 
)
static
Here is the caller graph for this function:

◆ get_flags_for_button()

static UINT16 get_flags_for_button ( int  button)
static
Here is the caller graph for this function:

◆ get_supported_atom()

static Atom get_supported_atom ( xfContext *  xfc,
const char *  atomName 
)
static
Here is the caller graph for this function:

◆ handle_window_events()

static BOOL handle_window_events ( freerdp *  instance)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RdpClientEntry()

int RdpClientEntry ( RDP_CLIENT_ENTRY_POINTS pEntryPoints)

Client Interface

Here is the call graph for this function:

◆ xf_button_map_init()

static void xf_button_map_init ( xfContext *  xfc)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_check_extensions()

static void xf_check_extensions ( xfContext *  context)
static
Here is the caller graph for this function:

◆ xf_client_thread()

static DWORD WINAPI xf_client_thread ( LPVOID  param)
static

Main loop for the rdp connection. It will be run from the thread's entry point (thread_func()). It initiates the connection, and will continue to run until the session ends, processing events as they are received.

Parameters
param- pointer to the rdp_freerdp structure that contains the session's settings
Returns
A code from the enum XF_EXIT_CODE (0 if successful)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_create_image()

BOOL xf_create_image ( xfContext *  xfc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_create_window()

BOOL xf_create_window ( xfContext *  xfc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_desktop_resize()

static BOOL xf_desktop_resize ( rdpContext *  context)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_draw_screen_()

void xf_draw_screen_ ( xfContext *  xfc,
int  x,
int  y,
int  w,
int  h,
const char *  fkt,
const char *  file,
int  line 
)
Here is the call graph for this function:

◆ xf_end_paint()

static BOOL xf_end_paint ( rdpContext *  context)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_error_handler()

static int xf_error_handler ( Display *  d,
XErrorEvent *  ev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_error_handler_ex()

static int xf_error_handler_ex ( Display *  d,
XErrorEvent *  ev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_exit_code_from_disconnect_reason()

DWORD xf_exit_code_from_disconnect_reason ( DWORD  reason)
Here is the caller graph for this function:

◆ xf_get_pixmap_info()

static BOOL xf_get_pixmap_info ( xfContext *  xfc)
static
Here is the caller graph for this function:

◆ xf_get_x11_button_map()

static void xf_get_x11_button_map ( xfContext *  xfc,
unsigned char *  x11_map 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_handle_pipe()

static DWORD WINAPI xf_handle_pipe ( void *  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_inject_keypress()

static BOOL xf_inject_keypress ( rdpContext *  context,
const char *  buffer,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_lock_x11_()

void xf_lock_x11_ ( xfContext *  xfc,
const char *  fkt 
)
Here is the call graph for this function:

◆ xf_logon_error_info()

static int xf_logon_error_info ( freerdp *  instance,
UINT32  data,
UINT32  type 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_map_error_to_exit_code()

static int xf_map_error_to_exit_code ( DWORD  error)
static
Here is the caller graph for this function:

◆ xf_paint()

static BOOL xf_paint ( xfContext *  xfc,
const GDI_RGN region 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_play_sound()

static BOOL xf_play_sound ( rdpContext *  context,
const PLAY_SOUND_UPDATE play_sound 
)
static
Here is the caller graph for this function:

◆ xf_post_connect()

static BOOL xf_post_connect ( freerdp *  instance)
static

Callback given to freerdp_connect() to perform post-connection operations. It will be called only if the connection was initialized properly, and will continue the initialization based on the newly created connection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_post_disconnect()

static void xf_post_disconnect ( freerdp *  instance)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_post_final_disconnect()

static void xf_post_final_disconnect ( freerdp *  instance)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_pre_connect()

static BOOL xf_pre_connect ( freerdp *  instance)
static

Callback given to freerdp_connect() to process the pre-connect operations. It will fill the rdp_freerdp structure (instance) with the appropriate options to use for the connection.

Parameters
instance- pointer to the rdp_freerdp structure that contains the connection's parameters, and will be filled with the appropriate informations.
Returns
TRUE if successful. FALSE otherwise. Can exit with error code XF_EXIT_PARSE_ARGUMENTS if there is an error in the parameters.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_process_pipe()

static BOOL xf_process_pipe ( rdpContext *  context,
const char *  pipe 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_process_x_events()

static BOOL xf_process_x_events ( freerdp *  instance)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_setup_x11()

BOOL xf_setup_x11 ( xfContext *  xfc)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_sw_desktop_resize()

static BOOL xf_sw_desktop_resize ( rdpContext *  context)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_teardown_x11()

void xf_teardown_x11 ( xfContext *  xfc)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_TerminateEventHandler()

static void xf_TerminateEventHandler ( void *  context,
const TerminateEventArgs *  e 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_toggle_fullscreen()

void xf_toggle_fullscreen ( xfContext *  xfc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_unlock_x11_()

void xf_unlock_x11_ ( xfContext *  xfc,
const char *  fkt 
)
Here is the call graph for this function:

◆ xf_window_free()

static void xf_window_free ( xfContext *  xfc)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xf_window_get_title()

static char* xf_window_get_title ( rdpSettings *  settings)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfreerdp_client_free()

static void xfreerdp_client_free ( freerdp *  instance,
rdpContext *  context 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfreerdp_client_global_init()

static BOOL xfreerdp_client_global_init ( void  )
static

Client Interface

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfreerdp_client_global_uninit()

static void xfreerdp_client_global_uninit ( void  )
static
Here is the caller graph for this function:

◆ xfreerdp_client_new()

static BOOL xfreerdp_client_new ( freerdp *  instance,
rdpContext *  context 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xfreerdp_client_start()

static int xfreerdp_client_start ( rdpContext *  context)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ def_error_handler

int(* def_error_handler) (Display *, XErrorEvent *) ( Display *  ,
XErrorEvent *   
)
static

◆ xf_button_flags

const button_map xf_button_flags[NUM_BUTTONS_MAPPED]
static
Initial value:
= {
{ Button1, PTR_FLAGS_BUTTON1 },
{ Button2, PTR_FLAGS_BUTTON3 },
{ Button3, PTR_FLAGS_BUTTON2 },
{ Button4, PTR_FLAGS_WHEEL | 0x78 },
{ Button5, PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | (0x100 - 0x78) },
{ 6, PTR_FLAGS_HWHEEL | PTR_FLAGS_WHEEL_NEGATIVE | (0x100 - 0x78) },
{ 7, PTR_FLAGS_HWHEEL | 0x78 },
}
#define PTR_FLAGS_BUTTON3
Definition: include/freerdp/input.h:46
#define PTR_FLAGS_WHEEL_NEGATIVE
Definition: include/freerdp/input.h:41
#define PTR_FLAGS_WHEEL
Definition: include/freerdp/input.h:40
#define PTR_FLAGS_BUTTON1
Definition: include/freerdp/input.h:44
#define PTR_FLAGS_BUTTON2
Definition: include/freerdp/input.h:45
#define PTR_FLAGS_HWHEEL
Definition: include/freerdp/input.h:39
#define PTR_XFLAGS_BUTTON2
Definition: include/freerdp/input.h:52
#define PTR_XFLAGS_BUTTON1
Definition: include/freerdp/input.h:51

◆ xf_exit_code_map

const struct xf_exit_code_map_t xf_exit_code_map[]
static
Initial value:
= {
}
#define FREERDP_ERROR_CONNECT_PASSWORD_EXPIRED
Definition: include/freerdp/error.h:315
#define FREERDP_ERROR_CONNECT_PASSWORD_MUST_CHANGE
Definition: include/freerdp/error.h:318
#define FREERDP_ERROR_CONNECT_CANCELLED
Definition: include/freerdp/error.h:307
#define FREERDP_ERROR_CONNECT_CLIENT_REVOKED
Definition: include/freerdp/error.h:330
#define FREERDP_ERROR_CONNECT_LOGON_FAILURE
Definition: include/freerdp/error.h:332
#define FREERDP_ERROR_TLS_CONNECT_FAILED
Definition: include/freerdp/error.h:299
#define FREERDP_ERROR_CONNECT_NO_OR_MISSING_CREDENTIALS
Definition: include/freerdp/error.h:350
#define FREERDP_ERROR_CONNECT_ACCOUNT_RESTRICTION
Definition: include/freerdp/error.h:338
#define FREERDP_ERROR_CONNECT_KDC_UNREACHABLE
Definition: include/freerdp/error.h:321
#define FREERDP_ERROR_CONNECT_LOGON_TYPE_NOT_GRANTED
Definition: include/freerdp/error.h:347
#define FREERDP_ERROR_CONNECT_UNDEFINED
Definition: include/freerdp/error.h:285
#define FREERDP_ERROR_CONNECT_FAILED
Definition: include/freerdp/error.h:294
#define FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR
Definition: include/freerdp/error.h:296
#define FREERDP_ERROR_DNS_NAME_NOT_FOUND
Definition: include/freerdp/error.h:292
#define FREERDP_ERROR_CONNECT_ACCOUNT_EXPIRED
Definition: include/freerdp/error.h:344
#define FREERDP_ERROR_SECURITY_NEGO_CONNECT_FAILED
Definition: include/freerdp/error.h:309
#define FREERDP_ERROR_CONNECT_PASSWORD_CERTAINLY_EXPIRED
Definition: include/freerdp/error.h:327
#define FREERDP_ERROR_PRE_CONNECT_FAILED
Definition: include/freerdp/error.h:283
#define FREERDP_ERROR_CONNECT_WRONG_PASSWORD
Definition: include/freerdp/error.h:334
#define FREERDP_ERROR_CONNECT_ACCOUNT_DISABLED
Definition: include/freerdp/error.h:324
#define FREERDP_ERROR_INSUFFICIENT_PRIVILEGES
Definition: include/freerdp/error.h:304
#define FREERDP_ERROR_AUTHENTICATION_FAILED
Definition: include/freerdp/error.h:301
#define FREERDP_ERROR_CONNECT_ACCESS_DENIED
Definition: include/freerdp/error.h:336
#define FREERDP_ERROR_DNS_ERROR
Definition: include/freerdp/error.h:290
#define FREERDP_ERROR_POST_CONNECT_FAILED
Definition: include/freerdp/error.h:287
#define FREERDP_ERROR_CONNECT_TRANSPORT_FAILED
Definition: include/freerdp/error.h:312
#define FREERDP_ERROR_CONNECT_ACCOUNT_LOCKED_OUT
Definition: include/freerdp/error.h:341
@ XF_EXIT_DNS_NAME_NOT_FOUND
Definition: xfreerdp.h:348
@ XF_EXIT_CONNECT_PASSWORD_EXPIRED
Definition: xfreerdp.h:356
@ XF_EXIT_CONNECT_LOGON_TYPE_NOT_GRANTED
Definition: xfreerdp.h:366
@ XF_EXIT_CONNECT_KDC_UNREACHABLE
Definition: xfreerdp.h:358
@ XF_EXIT_INSUFFICIENT_PRIVILEGES
Definition: xfreerdp.h:352
@ XF_EXIT_CONNECT_ACCOUNT_DISABLED
Definition: xfreerdp.h:359
@ XF_EXIT_CONNECT_UNDEFINED
Definition: xfreerdp.h:345
@ XF_EXIT_CONNECT_CLIENT_REVOKED
Definition: xfreerdp.h:361
@ XF_EXIT_POST_CONNECT_FAILED
Definition: xfreerdp.h:346
@ XF_EXIT_DNS_ERROR
Definition: xfreerdp.h:347
@ XF_EXIT_CONNECT_WRONG_PASSWORD
Definition: xfreerdp.h:362
@ XF_EXIT_CONNECT_TRANSPORT_FAILED
Definition: xfreerdp.h:355
@ XF_EXIT_CONNECT_ACCOUNT_EXPIRED
Definition: xfreerdp.h:365
@ XF_EXIT_CONNECT_ACCESS_DENIED
Definition: xfreerdp.h:363
@ XF_EXIT_MCS_CONNECT_INITIAL_ERROR
Definition: xfreerdp.h:350
@ XF_EXIT_LOGON_FAILURE
Definition: xfreerdp.h:342
@ XF_EXIT_ACCOUNT_LOCKED_OUT
Definition: xfreerdp.h:343
@ XF_EXIT_CONNECT_FAILED
Definition: xfreerdp.h:349
@ XF_EXIT_NEGO_FAILURE
Definition: xfreerdp.h:341
@ XF_EXIT_TLS_CONNECT_FAILED
Definition: xfreerdp.h:351
@ XF_EXIT_CONNECT_PASSWORD_CERTAINLY_EXPIRED
Definition: xfreerdp.h:360
@ XF_EXIT_CONNECT_PASSWORD_MUST_CHANGE
Definition: xfreerdp.h:357
@ XF_EXIT_AUTH_FAILURE
Definition: xfreerdp.h:340
@ XF_EXIT_CONNECT_NO_OR_MISSING_CREDENTIALS
Definition: xfreerdp.h:367
@ XF_EXIT_PRE_CONNECT_FAILED
Definition: xfreerdp.h:344
@ XF_EXIT_CONNECT_CANCELLED
Definition: xfreerdp.h:353
@ XF_EXIT_CONNECT_ACCOUNT_RESTRICTION
Definition: xfreerdp.h:364