20#include <freerdp/config.h>
22#include <winpr/assert.h>
24#include <freerdp/client/rail.h>
25#include <freerdp/client/cliprdr.h>
26#include <freerdp/client/disp.h>
27#include <freerdp/channels/rdpewa.h>
29#include "sdl_channels.hpp"
30#include "sdl_context.hpp"
31#include "sdl_disp.hpp"
33void sdl_OnChannelConnectedEventHandler(
void* context,
const ChannelConnectedEventArgs* e)
35 auto sdl = get_context(context);
40 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
43 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
45 auto clip =
reinterpret_cast<CliprdrClientContext*
>(e->pInterface);
48 if (!
sdl->getClipboardChannelContext().init(clip))
49 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize clipboard channel");
51 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
53 auto disp =
reinterpret_cast<DispClientContext*
>(e->pInterface);
56 if (!
sdl->getDisplayChannelContext().init(disp))
57 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize display channel");
60 freerdp_client_OnChannelConnectedEventHandler(context, e);
63void sdl_OnChannelDisconnectedEventHandler(
void* context,
const ChannelDisconnectedEventArgs* e)
65 auto sdl = get_context(context);
71 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
74 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
76 auto clip =
reinterpret_cast<CliprdrClientContext*
>(e->pInterface);
79 if (!
sdl->getClipboardChannelContext().uninit(clip))
80 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to uninitialize clipboard channel");
81 clip->custom =
nullptr;
83 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
85 auto disp =
reinterpret_cast<DispClientContext*
>(e->pInterface);
88 if (!
sdl->getDisplayChannelContext().uninit(disp))
89 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to uninitialize display channel");
90 disp->custom =
nullptr;
93 freerdp_client_OnChannelDisconnectedEventHandler(context, e);
96void sdl_OnUserNotificationEventHandler(
void* context,
const UserNotificationEventArgs* e)
98 WINPR_UNUSED(context);
100 WINPR_ASSERT(e->e.Sender);
102 if (strcmp(e->e.Sender, RDPEWA_CHANNEL_NAME) != 0)
105 if (e->cancelPreviousNotification)
108 WINPR_ASSERT(e->message);
109 auto parent = SDL_GetMouseFocus();
111 parent = SDL_GetKeyboardFocus();
112 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, e->e.Sender, e->message, parent);