24 #include <freerdp/display.h>
25 #include <freerdp/session.h>
26 #include <winpr/assert.h>
27 #include <winpr/image.h>
28 #include <winpr/sysinfo.h>
30 #include <freerdp/server/proxy/proxy_log.h>
32 #include "pf_update.h"
33 #include <freerdp/server/proxy/proxy_context.h>
34 #include "proxy_modules.h"
36 #define TAG PROXY_TAG("update")
38 static BOOL pf_server_refresh_rect(rdpContext* context, BYTE count,
const RECTANGLE_16* areas)
40 pServerContext* ps = (pServerContext*)context;
41 rdpContext* pc = NULL;
43 WINPR_ASSERT(ps->pdata);
44 pc = (rdpContext*)ps->pdata->pc;
46 WINPR_ASSERT(pc->update);
47 WINPR_ASSERT(pc->update->RefreshRect);
48 return pc->update->RefreshRect(pc, count, areas);
51 static BOOL pf_server_suppress_output(rdpContext* context, BYTE allow,
const RECTANGLE_16* area)
53 pServerContext* ps = (pServerContext*)context;
54 rdpContext* pc = NULL;
56 WINPR_ASSERT(ps->pdata);
57 pc = (rdpContext*)ps->pdata->pc;
59 WINPR_ASSERT(pc->update);
60 WINPR_ASSERT(pc->update->SuppressOutput);
61 return pc->update->SuppressOutput(pc, allow, area);
70 static BOOL pf_client_begin_paint(rdpContext* context)
72 pClientContext* pc = (pClientContext*)context;
73 proxyData* pdata = NULL;
74 rdpContext* ps = NULL;
78 ps = (rdpContext*)pdata->ps;
80 WINPR_ASSERT(ps->update);
81 WINPR_ASSERT(ps->update->BeginPaint);
82 WLog_DBG(TAG,
"called");
83 return ps->update->BeginPaint(ps);
91 static BOOL pf_client_end_paint(rdpContext* context)
93 pClientContext* pc = (pClientContext*)context;
94 proxyData* pdata = NULL;
95 rdpContext* ps = NULL;
99 ps = (rdpContext*)pdata->ps;
101 WINPR_ASSERT(ps->update);
102 WINPR_ASSERT(ps->update->EndPaint);
104 WLog_DBG(TAG,
"called");
107 if (!ps->update->EndPaint(ps))
110 if (!pf_modules_run_hook(pdata->module, HOOK_TYPE_CLIENT_END_PAINT, pdata, context))
116 static BOOL pf_client_bitmap_update(rdpContext* context,
const BITMAP_UPDATE* bitmap)
118 pClientContext* pc = (pClientContext*)context;
119 proxyData* pdata = NULL;
120 rdpContext* ps = NULL;
124 ps = (rdpContext*)pdata->ps;
126 WINPR_ASSERT(ps->update);
127 WINPR_ASSERT(ps->update->BitmapUpdate);
128 WLog_DBG(TAG,
"called");
129 return ps->update->BitmapUpdate(ps, bitmap);
132 static BOOL pf_client_desktop_resize(rdpContext* context)
134 pClientContext* pc = (pClientContext*)context;
135 proxyData* pdata = NULL;
136 rdpContext* ps = NULL;
140 ps = (rdpContext*)pdata->ps;
142 WINPR_ASSERT(ps->update);
143 WINPR_ASSERT(ps->update->DesktopResize);
144 WINPR_ASSERT(context->settings);
145 WINPR_ASSERT(ps->settings);
146 WLog_DBG(TAG,
"called");
151 return ps->update->DesktopResize(ps);
154 static BOOL pf_client_remote_monitors(rdpContext* context, UINT32 count,
157 pClientContext* pc = (pClientContext*)context;
158 proxyData* pdata = NULL;
159 rdpContext* ps = NULL;
163 ps = (rdpContext*)pdata->ps;
165 WLog_DBG(TAG,
"called");
166 return freerdp_display_send_monitor_layout(ps, count, monitors);
169 static BOOL pf_client_send_pointer_system(rdpContext* context,
172 pClientContext* pc = (pClientContext*)context;
173 proxyData* pdata = NULL;
174 rdpContext* ps = NULL;
178 ps = (rdpContext*)pdata->ps;
180 WINPR_ASSERT(ps->update);
181 WINPR_ASSERT(ps->update->pointer);
182 WINPR_ASSERT(ps->update->pointer->PointerSystem);
183 WLog_DBG(TAG,
"called");
184 return ps->update->pointer->PointerSystem(ps, pointer_system);
187 static BOOL pf_client_send_pointer_position(rdpContext* context,
190 pClientContext* pc = (pClientContext*)context;
191 proxyData* pdata = NULL;
192 rdpContext* ps = NULL;
196 ps = (rdpContext*)pdata->ps;
198 WINPR_ASSERT(ps->update);
199 WINPR_ASSERT(ps->update->pointer);
200 WINPR_ASSERT(ps->update->pointer->PointerPosition);
201 WLog_DBG(TAG,
"called");
202 return ps->update->pointer->PointerPosition(ps, pointerPosition);
205 static BOOL pf_client_send_pointer_color(rdpContext* context,
208 pClientContext* pc = (pClientContext*)context;
209 proxyData* pdata = NULL;
210 rdpContext* ps = NULL;
214 ps = (rdpContext*)pdata->ps;
216 WINPR_ASSERT(ps->update);
217 WINPR_ASSERT(ps->update->pointer);
218 WINPR_ASSERT(ps->update->pointer->PointerColor);
219 WLog_DBG(TAG,
"called");
220 return ps->update->pointer->PointerColor(ps, pointer_color);
223 static BOOL pf_client_send_pointer_large(rdpContext* context,
226 pClientContext* pc = (pClientContext*)context;
227 proxyData* pdata = NULL;
228 rdpContext* ps = NULL;
232 ps = (rdpContext*)pdata->ps;
234 WINPR_ASSERT(ps->update);
235 WINPR_ASSERT(ps->update->pointer);
236 WINPR_ASSERT(ps->update->pointer->PointerLarge);
237 WLog_DBG(TAG,
"called");
238 return ps->update->pointer->PointerLarge(ps, pointer_large);
241 static BOOL pf_client_send_pointer_new(rdpContext* context,
const POINTER_NEW_UPDATE* pointer_new)
243 pClientContext* pc = (pClientContext*)context;
244 proxyData* pdata = NULL;
245 rdpContext* ps = NULL;
249 ps = (rdpContext*)pdata->ps;
251 WINPR_ASSERT(ps->update);
252 WINPR_ASSERT(ps->update->pointer);
253 WINPR_ASSERT(ps->update->pointer->PointerNew);
254 WLog_DBG(TAG,
"called");
255 return ps->update->pointer->PointerNew(ps, pointer_new);
258 static BOOL pf_client_send_pointer_cached(rdpContext* context,
261 pClientContext* pc = (pClientContext*)context;
262 proxyData* pdata = NULL;
263 rdpContext* ps = NULL;
267 ps = (rdpContext*)pdata->ps;
269 WINPR_ASSERT(ps->update);
270 WINPR_ASSERT(ps->update->pointer);
271 WINPR_ASSERT(ps->update->pointer->PointerCached);
272 WLog_DBG(TAG,
"called");
273 return ps->update->pointer->PointerCached(ps, pointer_cached);
276 static BOOL pf_client_save_session_info(rdpContext* context, UINT32 type,
void* data)
278 logon_info* logonInfo = NULL;
279 pClientContext* pc = (pClientContext*)context;
280 proxyData* pdata = NULL;
281 rdpContext* ps = NULL;
285 ps = (rdpContext*)pdata->ps;
287 WINPR_ASSERT(ps->update);
288 WINPR_ASSERT(ps->update->SaveSessionInfo);
290 WLog_DBG(TAG,
"called");
294 case INFO_TYPE_LOGON:
295 case INFO_TYPE_LOGON_LONG:
297 logonInfo = (logon_info*)data;
298 PROXY_LOG_INFO(TAG, pc,
"client logon info: Username: %s, Domain: %s",
299 logonInfo->username, logonInfo->domain);
307 return ps->update->SaveSessionInfo(ps, type, data);
310 static BOOL pf_client_server_status_info(rdpContext* context, UINT32 status)
312 pClientContext* pc = (pClientContext*)context;
313 proxyData* pdata = NULL;
314 rdpContext* ps = NULL;
318 ps = (rdpContext*)pdata->ps;
320 WINPR_ASSERT(ps->update);
321 WINPR_ASSERT(ps->update->ServerStatusInfo);
323 WLog_DBG(TAG,
"called");
324 return ps->update->ServerStatusInfo(ps, status);
327 static BOOL pf_client_set_keyboard_indicators(rdpContext* context, UINT16 led_flags)
329 pClientContext* pc = (pClientContext*)context;
330 proxyData* pdata = NULL;
331 rdpContext* ps = NULL;
335 ps = (rdpContext*)pdata->ps;
337 WINPR_ASSERT(ps->update);
338 WINPR_ASSERT(ps->update->SetKeyboardIndicators);
340 WLog_DBG(TAG,
"called");
341 return ps->update->SetKeyboardIndicators(ps, led_flags);
344 static BOOL pf_client_set_keyboard_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState,
347 pClientContext* pc = (pClientContext*)context;
348 proxyData* pdata = NULL;
349 rdpContext* ps = NULL;
353 ps = (rdpContext*)pdata->ps;
355 WINPR_ASSERT(ps->update);
356 WINPR_ASSERT(ps->update->SetKeyboardImeStatus);
358 WLog_DBG(TAG,
"called");
359 return ps->update->SetKeyboardImeStatus(ps, imeId, imeState, imeConvMode);
362 static BOOL pf_client_window_create(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
366 pClientContext* pc = (pClientContext*)context;
367 proxyData* pdata = NULL;
368 rdpContext* ps = NULL;
372 ps = (rdpContext*)pdata->ps;
374 WINPR_ASSERT(ps->update);
375 WINPR_ASSERT(ps->update->window);
376 WINPR_ASSERT(ps->update->window->WindowCreate);
378 WLog_DBG(TAG,
"called");
379 rdp_update_lock(ps->update);
380 rc = ps->update->window->WindowCreate(ps, orderInfo, windowState);
381 rdp_update_unlock(ps->update);
385 static BOOL pf_client_window_update(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
389 pClientContext* pc = (pClientContext*)context;
390 proxyData* pdata = NULL;
391 rdpContext* ps = NULL;
395 ps = (rdpContext*)pdata->ps;
397 WINPR_ASSERT(ps->update);
398 WINPR_ASSERT(ps->update->window);
399 WINPR_ASSERT(ps->update->window->WindowUpdate);
401 WLog_DBG(TAG,
"called");
402 rdp_update_lock(ps->update);
403 rc = ps->update->window->WindowUpdate(ps, orderInfo, windowState);
404 rdp_update_unlock(ps->update);
408 static BOOL pf_client_window_icon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
412 pClientContext* pc = (pClientContext*)context;
413 proxyData* pdata = NULL;
414 rdpContext* ps = NULL;
418 ps = (rdpContext*)pdata->ps;
420 WINPR_ASSERT(ps->update);
421 WINPR_ASSERT(ps->update->window);
422 WINPR_ASSERT(ps->update->window->WindowIcon);
424 WLog_DBG(TAG,
"called");
425 rdp_update_lock(ps->update);
426 rc = ps->update->window->WindowIcon(ps, orderInfo, windowIcon);
427 rdp_update_unlock(ps->update);
431 static BOOL pf_client_window_cached_icon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
435 pClientContext* pc = (pClientContext*)context;
436 proxyData* pdata = NULL;
437 rdpContext* ps = NULL;
441 ps = (rdpContext*)pdata->ps;
443 WINPR_ASSERT(ps->update);
444 WINPR_ASSERT(ps->update->window);
445 WINPR_ASSERT(ps->update->window->WindowCachedIcon);
447 WLog_DBG(TAG,
"called");
448 rdp_update_lock(ps->update);
449 rc = ps->update->window->WindowCachedIcon(ps, orderInfo, windowCachedIcon);
450 rdp_update_unlock(ps->update);
454 static BOOL pf_client_window_delete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
457 pClientContext* pc = (pClientContext*)context;
458 proxyData* pdata = NULL;
459 rdpContext* ps = NULL;
463 ps = (rdpContext*)pdata->ps;
465 WINPR_ASSERT(ps->update);
466 WINPR_ASSERT(ps->update->window);
467 WINPR_ASSERT(ps->update->window->WindowDelete);
469 WLog_DBG(TAG,
"called");
470 rdp_update_lock(ps->update);
471 rc = ps->update->window->WindowDelete(ps, orderInfo);
472 rdp_update_unlock(ps->update);
476 static BOOL pf_client_notify_icon_create(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
480 pClientContext* pc = (pClientContext*)context;
481 proxyData* pdata = NULL;
482 rdpContext* ps = NULL;
486 ps = (rdpContext*)pdata->ps;
488 WINPR_ASSERT(ps->update);
489 WINPR_ASSERT(ps->update->window);
490 WINPR_ASSERT(ps->update->window->NotifyIconCreate);
492 WLog_DBG(TAG,
"called");
493 rdp_update_lock(ps->update);
494 rc = ps->update->window->NotifyIconCreate(ps, orderInfo, notifyIconState);
495 rdp_update_unlock(ps->update);
499 static BOOL pf_client_notify_icon_update(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
503 pClientContext* pc = (pClientContext*)context;
504 proxyData* pdata = NULL;
505 rdpContext* ps = NULL;
509 ps = (rdpContext*)pdata->ps;
511 WINPR_ASSERT(ps->update);
512 WINPR_ASSERT(ps->update->window);
513 WINPR_ASSERT(ps->update->window->NotifyIconUpdate);
515 WLog_DBG(TAG,
"called");
516 rdp_update_lock(ps->update);
517 rc = ps->update->window->NotifyIconUpdate(ps, orderInfo, notifyIconState);
518 rdp_update_unlock(ps->update);
522 static BOOL pf_client_notify_icon_delete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
526 pClientContext* pc = (pClientContext*)context;
527 proxyData* pdata = NULL;
528 rdpContext* ps = NULL;
532 ps = (rdpContext*)pdata->ps;
534 WINPR_ASSERT(ps->update);
535 WINPR_ASSERT(ps->update->window);
536 WINPR_ASSERT(ps->update->window->NotifyIconDelete);
538 WLog_DBG(TAG,
"called");
539 rdp_update_lock(ps->update);
540 rc = ps->update->window->NotifyIconDelete(ps, orderInfo);
541 rdp_update_unlock(ps->update);
545 static BOOL pf_client_monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
549 pClientContext* pc = (pClientContext*)context;
550 proxyData* pdata = NULL;
551 rdpContext* ps = NULL;
555 ps = (rdpContext*)pdata->ps;
557 WINPR_ASSERT(ps->update);
558 WINPR_ASSERT(ps->update->window);
559 WINPR_ASSERT(ps->update->window->MonitoredDesktop);
561 WLog_DBG(TAG,
"called");
562 rdp_update_lock(ps->update);
563 rc = ps->update->window->MonitoredDesktop(ps, orderInfo, monitoredDesktop);
564 rdp_update_unlock(ps->update);
568 static BOOL pf_client_non_monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
571 pClientContext* pc = (pClientContext*)context;
572 proxyData* pdata = NULL;
573 rdpContext* ps = NULL;
577 ps = (rdpContext*)pdata->ps;
579 WINPR_ASSERT(ps->update);
580 WINPR_ASSERT(ps->update->window);
581 WINPR_ASSERT(ps->update->window->NonMonitoredDesktop);
583 WLog_DBG(TAG,
"called");
584 rdp_update_lock(ps->update);
585 rc = ps->update->window->NonMonitoredDesktop(ps, orderInfo);
586 rdp_update_unlock(ps->update);
590 void pf_server_register_update_callbacks(rdpUpdate* update)
592 WINPR_ASSERT(update);
593 update->RefreshRect = pf_server_refresh_rect;
594 update->SuppressOutput = pf_server_suppress_output;
597 void pf_client_register_update_callbacks(rdpUpdate* update)
599 WINPR_ASSERT(update);
600 update->BeginPaint = pf_client_begin_paint;
601 update->EndPaint = pf_client_end_paint;
602 update->BitmapUpdate = pf_client_bitmap_update;
603 update->DesktopResize = pf_client_desktop_resize;
604 update->RemoteMonitors = pf_client_remote_monitors;
605 update->SaveSessionInfo = pf_client_save_session_info;
606 update->ServerStatusInfo = pf_client_server_status_info;
607 update->SetKeyboardIndicators = pf_client_set_keyboard_indicators;
608 update->SetKeyboardImeStatus = pf_client_set_keyboard_ime_status;
611 update->window->WindowCreate = pf_client_window_create;
612 update->window->WindowUpdate = pf_client_window_update;
613 update->window->WindowIcon = pf_client_window_icon;
614 update->window->WindowCachedIcon = pf_client_window_cached_icon;
615 update->window->WindowDelete = pf_client_window_delete;
616 update->window->NotifyIconCreate = pf_client_notify_icon_create;
617 update->window->NotifyIconUpdate = pf_client_notify_icon_update;
618 update->window->NotifyIconDelete = pf_client_notify_icon_delete;
619 update->window->MonitoredDesktop = pf_client_monitored_desktop;
620 update->window->NonMonitoredDesktop = pf_client_non_monitored_desktop;
623 update->pointer->PointerSystem = pf_client_send_pointer_system;
624 update->pointer->PointerPosition = pf_client_send_pointer_position;
625 update->pointer->PointerColor = pf_client_send_pointer_color;
626 update->pointer->PointerLarge = pf_client_send_pointer_large;
627 update->pointer->PointerNew = pf_client_send_pointer_new;
628 update->pointer->PointerCached = pf_client_send_pointer_cached;
FREERDP_API BOOL freerdp_settings_copy_item(rdpSettings *dst, const rdpSettings *src, SSIZE_T id)
copies one setting identified by id from src to dst