FreeRDP
sdl_freerdp.cpp File Reference
#include <memory>
#include <mutex>
#include <iostream>
#include <freerdp/config.h>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/streamdump.h>
#include <freerdp/utils/signal.h>
#include <freerdp/client/file.h>
#include <freerdp/client/cmdline.h>
#include <freerdp/client/cliprdr.h>
#include <freerdp/client/channels.h>
#include <freerdp/channels/channels.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/synch.h>
#include <freerdp/log.h>
#include <SDL.h>
#include <SDL_hints.h>
#include <SDL_video.h>
#include "sdl_channels.hpp"
#include "sdl_freerdp.hpp"
#include "sdl_utils.hpp"
#include "sdl_disp.hpp"
#include "sdl_monitor.hpp"
#include "sdl_kbd.hpp"
#include "sdl_touch.hpp"
#include "sdl_pointer.hpp"
#include "dialogs/sdl_dialogs.hpp"
#include "aad/sdl_webview.hpp"

Macros

#define SDL_TAG   CLIENT_TAG("SDL")
 
#define ENTRY(x, y)
 

Enumerations

enum  SDL_EXIT_CODE {
  SDL_EXIT_SUCCESS = 0 , SDL_EXIT_DISCONNECT = 1 , SDL_EXIT_LOGOFF = 2 , SDL_EXIT_IDLE_TIMEOUT = 3 ,
  SDL_EXIT_LOGON_TIMEOUT = 4 , SDL_EXIT_CONN_REPLACED = 5 , SDL_EXIT_OUT_OF_MEMORY = 6 , SDL_EXIT_CONN_DENIED = 7 ,
  SDL_EXIT_CONN_DENIED_FIPS = 8 , SDL_EXIT_USER_PRIVILEGES = 9 , SDL_EXIT_FRESH_CREDENTIALS_REQUIRED = 10 , SDL_EXIT_DISCONNECT_BY_USER = 11 ,
  SDL_EXIT_LICENSE_INTERNAL = 16 , SDL_EXIT_LICENSE_NO_LICENSE_SERVER = 17 , SDL_EXIT_LICENSE_NO_LICENSE = 18 , SDL_EXIT_LICENSE_BAD_CLIENT_MSG = 19 ,
  SDL_EXIT_LICENSE_HWID_DOESNT_MATCH = 20 , SDL_EXIT_LICENSE_BAD_CLIENT = 21 , SDL_EXIT_LICENSE_CANT_FINISH_PROTOCOL = 22 , SDL_EXIT_LICENSE_CLIENT_ENDED_PROTOCOL = 23 ,
  SDL_EXIT_LICENSE_BAD_CLIENT_ENCRYPTION = 24 , SDL_EXIT_LICENSE_CANT_UPGRADE = 25 , SDL_EXIT_LICENSE_NO_REMOTE_CONNECTIONS = 26 , SDL_EXIT_RDP = 32 ,
  SDL_EXIT_PARSE_ARGUMENTS = 128 , SDL_EXIT_MEMORY = 129 , SDL_EXIT_PROTOCOL = 130 , SDL_EXIT_CONN_FAILED = 131 ,
  SDL_EXIT_AUTH_FAILURE = 132 , SDL_EXIT_NEGO_FAILURE = 133 , SDL_EXIT_LOGON_FAILURE = 134 , SDL_EXIT_ACCOUNT_LOCKED_OUT = 135 ,
  SDL_EXIT_PRE_CONNECT_FAILED = 136 , SDL_EXIT_CONNECT_UNDEFINED = 137 , SDL_EXIT_POST_CONNECT_FAILED = 138 , SDL_EXIT_DNS_ERROR = 139 ,
  SDL_EXIT_DNS_NAME_NOT_FOUND = 140 , SDL_EXIT_CONNECT_FAILED = 141 , SDL_EXIT_MCS_CONNECT_INITIAL_ERROR = 142 , SDL_EXIT_TLS_CONNECT_FAILED = 143 ,
  SDL_EXIT_INSUFFICIENT_PRIVILEGES = 144 , SDL_EXIT_CONNECT_CANCELLED = 145 , SDL_EXIT_CONNECT_TRANSPORT_FAILED = 147 , SDL_EXIT_CONNECT_PASSWORD_EXPIRED = 148 ,
  SDL_EXIT_CONNECT_PASSWORD_MUST_CHANGE = 149 , SDL_EXIT_CONNECT_KDC_UNREACHABLE = 150 , SDL_EXIT_CONNECT_ACCOUNT_DISABLED = 151 , SDL_EXIT_CONNECT_PASSWORD_CERTAINLY_EXPIRED = 152 ,
  SDL_EXIT_CONNECT_CLIENT_REVOKED = 153 , SDL_EXIT_CONNECT_WRONG_PASSWORD = 154 , SDL_EXIT_CONNECT_ACCESS_DENIED = 155 , SDL_EXIT_CONNECT_ACCOUNT_RESTRICTION = 156 ,
  SDL_EXIT_CONNECT_ACCOUNT_EXPIRED = 157 , SDL_EXIT_CONNECT_LOGON_TYPE_NOT_GRANTED = 158 , SDL_EXIT_CONNECT_NO_OR_MISSING_CREDENTIALS = 159 , SDL_EXIT_UNKNOWN = 255
}
 

Functions

static const struct sdl_exit_code_map_t * sdl_map_entry_by_code (int exit_code)
 
static const struct sdl_exit_code_map_t * sdl_map_entry_by_error (DWORD error)
 
static int sdl_map_error_to_exit_code (DWORD error)
 
static const char * sdl_map_error_to_code_tag (DWORD error)
 
static const char * sdl_map_to_code_tag (int code)
 
static int error_info_to_error (freerdp *instance, DWORD *pcode, char **msg, size_t *len)
 
static BOOL sdl_begin_paint (rdpContext *context)
 
static BOOL sdl_redraw (SdlContext *sdl)
 
static bool sdl_draw_to_window_rect (SdlContext *sdl, SdlWindow &window, SDL_Surface *surface, SDL_Point offset, const SDL_Rect &srcRect)
 
static bool sdl_draw_to_window_rect (SdlContext *sdl, SdlWindow &window, SDL_Surface *surface, SDL_Point offset, const std::vector< SDL_Rect > &rects={})
 
static bool sdl_draw_to_window_scaled_rect (SdlContext *sdl, SdlWindow &window, SDL_Surface *surface, const SDL_Rect &srcRect)
 
static BOOL sdl_draw_to_window_scaled_rect (SdlContext *sdl, SdlWindow &window, SDL_Surface *surface, const std::vector< SDL_Rect > &rects={})
 
static BOOL sdl_draw_to_window (SdlContext *sdl, SdlWindow &window, const std::vector< SDL_Rect > &rects={})
 
static BOOL sdl_draw_to_window (SdlContext *sdl, std::map< Uint32, SdlWindow > &windows, const std::vector< SDL_Rect > &rects={})
 
static BOOL sdl_end_paint_process (rdpContext *context)
 
static BOOL sdl_end_paint (rdpContext *context)
 
static void sdl_destroy_primary (SdlContext *sdl)
 
static BOOL sdl_create_primary (SdlContext *sdl)
 
static BOOL sdl_desktop_resize (rdpContext *context)
 
static BOOL sdl_play_sound (rdpContext *context, const PLAY_SOUND_UPDATE *play_sound)
 
static BOOL sdl_wait_for_init (SdlContext *sdl)
 
static BOOL sdl_pre_connect (freerdp *instance)
 
static const char * sdl_window_get_title (rdpSettings *settings)
 
static void sdl_term_handler (int signum, const char *signame, void *context)
 
static void sdl_cleanup_sdl (SdlContext *sdl)
 
static BOOL sdl_create_windows (SdlContext *sdl)
 
static BOOL sdl_wait_create_windows (SdlContext *sdl)
 
static bool shall_abort (SdlContext *sdl)
 
static int sdl_run (SdlContext *sdl)
 
static BOOL sdl_post_connect (freerdp *instance)
 
static void sdl_post_disconnect (freerdp *instance)
 
static void sdl_post_final_disconnect (freerdp *instance)
 
static DWORD WINAPI sdl_client_thread_proc (SdlContext *sdl)
 
static BOOL sdl_client_global_init (void)
 
static void sdl_client_global_uninit (void)
 
static BOOL sdl_client_new (freerdp *instance, rdpContext *context)
 
static void sdl_client_free (freerdp *instance, rdpContext *context)
 
static int sdl_client_start (rdpContext *context)
 
static int sdl_client_stop (rdpContext *context)
 
static int RdpClientEntry (RDP_CLIENT_ENTRY_POINTS *pEntryPoints)
 
static void context_free (sdl_rdp_context *sdl)
 
static const char * category2str (int category)
 
static SDL_LogPriority wloglevel2dl (DWORD level)
 
static DWORD sdlpriority2wlog (SDL_LogPriority priority)
 
static void SDLCALL winpr_LogOutputFunction (void *userdata, int category, SDL_LogPriority priority, const char *message)
 
static void print_config_file_help ()
 
int main (int argc, char *argv[])
 

Variables

static const struct sdl_exit_code_map_t sdl_exit_code_map []
 

Macro Definition Documentation

◆ ENTRY

#define ENTRY (   x,
  y 
)
Value:
{ \
x, y, #y \
}
UINT16 y
Definition: include/freerdp/event.h:111

◆ SDL_TAG

#define SDL_TAG   CLIENT_TAG("SDL")

FreeRDP: A Remote Desktop Protocol Implementation FreeRDP SDL UI

Copyright 2022 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m

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.

Enumeration Type Documentation

◆ SDL_EXIT_CODE

Enumerator
SDL_EXIT_SUCCESS 
SDL_EXIT_DISCONNECT 
SDL_EXIT_LOGOFF 
SDL_EXIT_IDLE_TIMEOUT 
SDL_EXIT_LOGON_TIMEOUT 
SDL_EXIT_CONN_REPLACED 
SDL_EXIT_OUT_OF_MEMORY 
SDL_EXIT_CONN_DENIED 
SDL_EXIT_CONN_DENIED_FIPS 
SDL_EXIT_USER_PRIVILEGES 
SDL_EXIT_FRESH_CREDENTIALS_REQUIRED 
SDL_EXIT_DISCONNECT_BY_USER 
SDL_EXIT_LICENSE_INTERNAL 
SDL_EXIT_LICENSE_NO_LICENSE_SERVER 
SDL_EXIT_LICENSE_NO_LICENSE 
SDL_EXIT_LICENSE_BAD_CLIENT_MSG 
SDL_EXIT_LICENSE_HWID_DOESNT_MATCH 
SDL_EXIT_LICENSE_BAD_CLIENT 
SDL_EXIT_LICENSE_CANT_FINISH_PROTOCOL 
SDL_EXIT_LICENSE_CLIENT_ENDED_PROTOCOL 
SDL_EXIT_LICENSE_BAD_CLIENT_ENCRYPTION 
SDL_EXIT_LICENSE_CANT_UPGRADE 
SDL_EXIT_LICENSE_NO_REMOTE_CONNECTIONS 
SDL_EXIT_RDP 
SDL_EXIT_PARSE_ARGUMENTS 
SDL_EXIT_MEMORY 
SDL_EXIT_PROTOCOL 
SDL_EXIT_CONN_FAILED 
SDL_EXIT_AUTH_FAILURE 
SDL_EXIT_NEGO_FAILURE 
SDL_EXIT_LOGON_FAILURE 
SDL_EXIT_ACCOUNT_LOCKED_OUT 
SDL_EXIT_PRE_CONNECT_FAILED 
SDL_EXIT_CONNECT_UNDEFINED 
SDL_EXIT_POST_CONNECT_FAILED 
SDL_EXIT_DNS_ERROR 
SDL_EXIT_DNS_NAME_NOT_FOUND 
SDL_EXIT_CONNECT_FAILED 
SDL_EXIT_MCS_CONNECT_INITIAL_ERROR 
SDL_EXIT_TLS_CONNECT_FAILED 
SDL_EXIT_INSUFFICIENT_PRIVILEGES 
SDL_EXIT_CONNECT_CANCELLED 
SDL_EXIT_CONNECT_TRANSPORT_FAILED 
SDL_EXIT_CONNECT_PASSWORD_EXPIRED 
SDL_EXIT_CONNECT_PASSWORD_MUST_CHANGE 
SDL_EXIT_CONNECT_KDC_UNREACHABLE 
SDL_EXIT_CONNECT_ACCOUNT_DISABLED 
SDL_EXIT_CONNECT_PASSWORD_CERTAINLY_EXPIRED 
SDL_EXIT_CONNECT_CLIENT_REVOKED 
SDL_EXIT_CONNECT_WRONG_PASSWORD 
SDL_EXIT_CONNECT_ACCESS_DENIED 
SDL_EXIT_CONNECT_ACCOUNT_RESTRICTION 
SDL_EXIT_CONNECT_ACCOUNT_EXPIRED 
SDL_EXIT_CONNECT_LOGON_TYPE_NOT_GRANTED 
SDL_EXIT_CONNECT_NO_OR_MISSING_CREDENTIALS 
SDL_EXIT_UNKNOWN 

Function Documentation

◆ category2str()

static const char* category2str ( int  category)
static
Here is the caller graph for this function:

◆ context_free()

static void context_free ( sdl_rdp_context sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ error_info_to_error()

static int error_info_to_error ( freerdp *  instance,
DWORD *  pcode,
char **  msg,
size_t *  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)
Here is the call graph for this function:

◆ print_config_file_help()

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

◆ RdpClientEntry()

static int RdpClientEntry ( RDP_CLIENT_ENTRY_POINTS pEntryPoints)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_begin_paint()

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

◆ sdl_cleanup_sdl()

static void sdl_cleanup_sdl ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_client_free()

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

◆ sdl_client_global_init()

static BOOL sdl_client_global_init ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_client_global_uninit()

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

◆ sdl_client_new()

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

◆ sdl_client_start()

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

◆ sdl_client_stop()

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

◆ sdl_client_thread_proc()

static DWORD WINAPI sdl_client_thread_proc ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_create_primary()

static BOOL sdl_create_primary ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_create_windows()

static BOOL sdl_create_windows ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_desktop_resize()

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

◆ sdl_destroy_primary()

static void sdl_destroy_primary ( SdlContext sdl)
static
Here is the caller graph for this function:

◆ sdl_draw_to_window() [1/2]

static BOOL sdl_draw_to_window ( SdlContext sdl,
SdlWindow window,
const std::vector< SDL_Rect > &  rects = {} 
)
static
Here is the caller graph for this function:

◆ sdl_draw_to_window() [2/2]

static BOOL sdl_draw_to_window ( SdlContext sdl,
std::map< Uint32, SdlWindow > &  windows,
const std::vector< SDL_Rect > &  rects = {} 
)
static

◆ sdl_draw_to_window_rect() [1/2]

static bool sdl_draw_to_window_rect ( SdlContext sdl,
SdlWindow window,
SDL_Surface *  surface,
SDL_Point  offset,
const SDL_Rect &  srcRect 
)
static
Here is the call graph for this function:

◆ sdl_draw_to_window_rect() [2/2]

static bool sdl_draw_to_window_rect ( SdlContext sdl,
SdlWindow window,
SDL_Surface *  surface,
SDL_Point  offset,
const std::vector< SDL_Rect > &  rects = {} 
)
static

◆ sdl_draw_to_window_scaled_rect() [1/2]

static bool sdl_draw_to_window_scaled_rect ( SdlContext sdl,
SdlWindow window,
SDL_Surface *  surface,
const SDL_Rect &  srcRect 
)
static
Here is the call graph for this function:

◆ sdl_draw_to_window_scaled_rect() [2/2]

static BOOL sdl_draw_to_window_scaled_rect ( SdlContext sdl,
SdlWindow window,
SDL_Surface *  surface,
const std::vector< SDL_Rect > &  rects = {} 
)
static

◆ sdl_end_paint()

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

◆ sdl_end_paint_process()

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

◆ sdl_map_entry_by_code()

static const struct sdl_exit_code_map_t* sdl_map_entry_by_code ( int  exit_code)
static
Here is the caller graph for this function:

◆ sdl_map_entry_by_error()

static const struct sdl_exit_code_map_t* sdl_map_entry_by_error ( DWORD  error)
static
Here is the caller graph for this function:

◆ sdl_map_error_to_code_tag()

static const char* sdl_map_error_to_code_tag ( DWORD  error)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_map_error_to_exit_code()

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

◆ sdl_map_to_code_tag()

static const char* sdl_map_to_code_tag ( int  code)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_play_sound()

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

◆ sdl_post_connect()

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

◆ sdl_post_disconnect()

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

◆ sdl_post_final_disconnect()

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

◆ sdl_pre_connect()

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

◆ sdl_redraw()

static BOOL sdl_redraw ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_run()

static int sdl_run ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_term_handler()

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

◆ sdl_wait_create_windows()

static BOOL sdl_wait_create_windows ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_wait_for_init()

static BOOL sdl_wait_for_init ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdl_window_get_title()

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

◆ sdlpriority2wlog()

static DWORD sdlpriority2wlog ( SDL_LogPriority  priority)
static
Here is the caller graph for this function:

◆ shall_abort()

static bool shall_abort ( SdlContext sdl)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_LogOutputFunction()

static void SDLCALL winpr_LogOutputFunction ( void *  userdata,
int  category,
SDL_LogPriority  priority,
const char *  message 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wloglevel2dl()

static SDL_LogPriority wloglevel2dl ( DWORD  level)
static
Here is the caller graph for this function:

Variable Documentation

◆ sdl_exit_code_map

const struct sdl_exit_code_map_t sdl_exit_code_map[]
static