2014-10-13 13:43:16 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2014-11-17 18:36:28 +03:00
|
|
|
* Wayland Client
|
2014-10-13 13:43:16 +04:00
|
|
|
*
|
|
|
|
* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net>
|
2016-04-05 18:07:45 +03:00
|
|
|
* Copyright 2016 Thincast Technologies GmbH
|
|
|
|
* Copyright 2016 Armin Novak <armin.novak@thincast.com>
|
2014-10-13 13:43:16 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2016-08-03 19:44:26 +03:00
|
|
|
#include <locale.h>
|
2014-10-13 13:43:16 +04:00
|
|
|
|
|
|
|
#include <freerdp/client/cmdline.h>
|
|
|
|
#include <freerdp/channels/channels.h>
|
|
|
|
#include <freerdp/gdi/gdi.h>
|
2016-08-03 19:44:26 +03:00
|
|
|
#include <freerdp/client.h>
|
|
|
|
#include <freerdp/utils/signal.h>
|
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
#include <linux/input.h>
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
#include <uwac/uwac.h>
|
|
|
|
|
2014-11-17 18:36:28 +03:00
|
|
|
#include "wlfreerdp.h"
|
2016-01-07 01:56:05 +03:00
|
|
|
#include "wlf_input.h"
|
2016-08-03 19:44:26 +03:00
|
|
|
#include "wlf_channels.h"
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static BOOL wl_update_content(wlfContext* context_w)
|
2016-01-07 01:56:05 +03:00
|
|
|
{
|
|
|
|
if (!context_w->waitingFrameDone && context_w->haveDamage)
|
|
|
|
{
|
|
|
|
UwacWindowSubmitBuffer(context_w->window, true);
|
|
|
|
context_w->waitingFrameDone = TRUE;
|
|
|
|
context_w->haveDamage = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
static BOOL wl_begin_paint(rdpContext* context)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
|
|
|
rdpGdi* gdi;
|
|
|
|
gdi = context->gdi;
|
2016-10-06 14:41:52 +03:00
|
|
|
gdi->primary->hdc->hwnd->invalid->null = TRUE;
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-10-13 13:43:16 +04:00
|
|
|
}
|
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
static BOOL wl_end_paint(rdpContext* context)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
|
|
|
rdpGdi* gdi;
|
2016-08-03 19:44:26 +03:00
|
|
|
char* data;
|
|
|
|
wlfContext* context_w;
|
2014-11-26 12:38:12 +03:00
|
|
|
INT32 x, y;
|
|
|
|
UINT32 w, h;
|
|
|
|
int i;
|
2014-10-13 13:43:16 +04:00
|
|
|
gdi = context->gdi;
|
2016-08-03 19:44:26 +03:00
|
|
|
|
2014-10-13 13:43:16 +04:00
|
|
|
if (gdi->primary->hdc->hwnd->invalid->null)
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2014-11-26 12:38:12 +03:00
|
|
|
x = gdi->primary->hdc->hwnd->invalid->x;
|
|
|
|
y = gdi->primary->hdc->hwnd->invalid->y;
|
|
|
|
w = gdi->primary->hdc->hwnd->invalid->w;
|
|
|
|
h = gdi->primary->hdc->hwnd->invalid->h;
|
2014-11-17 18:36:28 +03:00
|
|
|
context_w = (wlfContext*) context;
|
2016-01-07 01:56:05 +03:00
|
|
|
data = UwacWindowGetDrawingBuffer(context_w->window);
|
2016-08-03 19:44:26 +03:00
|
|
|
|
2016-02-25 02:41:19 +03:00
|
|
|
if (!data)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-11-26 12:38:12 +03:00
|
|
|
for (i = 0; i < h; i++)
|
2016-01-07 01:56:05 +03:00
|
|
|
{
|
2016-08-03 19:44:26 +03:00
|
|
|
memcpy(data + ((i + y) * (gdi->width * GetBytesPerPixel(
|
|
|
|
gdi->dstFormat))) + x * GetBytesPerPixel(gdi->dstFormat),
|
|
|
|
gdi->primary_buffer + ((i + y) * (gdi->width * GetBytesPerPixel(
|
|
|
|
gdi->dstFormat))) + x * GetBytesPerPixel(gdi->dstFormat),
|
|
|
|
w * GetBytesPerPixel(gdi->dstFormat));
|
2016-01-07 01:56:05 +03:00
|
|
|
}
|
2014-11-17 18:36:28 +03:00
|
|
|
|
2016-02-25 02:41:19 +03:00
|
|
|
if (UwacWindowAddDamage(context_w->window, x, y, w, h) != UWAC_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
context_w->haveDamage = TRUE;
|
|
|
|
return wl_update_content(context_w);
|
2014-10-13 13:43:16 +04:00
|
|
|
}
|
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
static BOOL wl_pre_connect(freerdp* instance)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
2016-08-03 19:44:26 +03:00
|
|
|
rdpSettings* settings;
|
2014-11-17 18:36:28 +03:00
|
|
|
wlfContext* context;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (!instance)
|
2015-04-20 17:20:16 +03:00
|
|
|
return FALSE;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2014-11-17 18:36:28 +03:00
|
|
|
context = (wlfContext*) instance->context;
|
2016-08-03 19:44:26 +03:00
|
|
|
settings = instance->settings;
|
|
|
|
|
|
|
|
if (!context || !settings)
|
2015-04-20 17:20:16 +03:00
|
|
|
return FALSE;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
settings->OsMajorType = OSMAJORTYPE_UNIX;
|
|
|
|
settings->OsMinorType = OSMINORTYPE_NATIVE_WAYLAND;
|
|
|
|
settings->SoftwareGdi = TRUE;
|
|
|
|
ZeroMemory(settings->OrderSupport, 32);
|
|
|
|
settings->OrderSupport[NEG_DSTBLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_PATBLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_OPAQUE_RECT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_DRAWNINEGRID_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_MULTI_DRAWNINEGRID_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_LINETO_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_POLYLINE_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_MEMBLT_INDEX] = settings->BitmapCacheEnabled;
|
|
|
|
settings->OrderSupport[NEG_MEM3BLT_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = settings->BitmapCacheEnabled;
|
|
|
|
settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_FAST_INDEX_INDEX] = TRUE;
|
|
|
|
settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = TRUE;
|
2016-10-16 16:08:47 +03:00
|
|
|
settings->OrderSupport[NEG_POLYGON_SC_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_POLYGON_CB_INDEX] = FALSE;
|
2016-08-03 19:44:26 +03:00
|
|
|
settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
|
|
|
|
settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
|
|
|
|
PubSub_SubscribeChannelConnected(instance->context->pubSub,
|
|
|
|
(pChannelConnectedEventHandler) wlf_OnChannelConnectedEventHandler);
|
|
|
|
PubSub_SubscribeChannelDisconnected(instance->context->pubSub,
|
|
|
|
(pChannelDisconnectedEventHandler) wlf_OnChannelDisconnectedEventHandler);
|
|
|
|
|
|
|
|
if (!freerdp_client_load_addins(instance->context->channels,
|
|
|
|
instance->settings))
|
|
|
|
return FALSE;
|
|
|
|
|
2014-10-13 13:43:16 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
static BOOL wl_post_connect(freerdp* instance)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
|
|
|
rdpGdi* gdi;
|
2016-01-07 01:56:05 +03:00
|
|
|
UwacWindow* window;
|
2014-11-17 18:36:28 +03:00
|
|
|
wlfContext* context;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
|
2015-05-08 22:39:23 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2014-10-13 13:43:16 +04:00
|
|
|
gdi = instance->context->gdi;
|
2016-08-03 19:44:26 +03:00
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
if (!gdi)
|
|
|
|
return FALSE;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2014-11-17 18:36:28 +03:00
|
|
|
context = (wlfContext*) instance->context;
|
2016-08-03 19:44:26 +03:00
|
|
|
context->window = window = UwacCreateWindowShm(context->display, gdi->width,
|
|
|
|
gdi->height, WL_SHM_FORMAT_XRGB8888);
|
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
if (!window)
|
|
|
|
return FALSE;
|
2014-11-17 18:36:28 +03:00
|
|
|
|
2017-07-03 20:09:01 +03:00
|
|
|
UwacWindowSetFullscreenState(window, NULL, instance->context->settings->Fullscreen);
|
2016-01-07 01:56:05 +03:00
|
|
|
UwacWindowSetTitle(window, "FreeRDP");
|
2014-10-13 13:43:16 +04:00
|
|
|
instance->update->BeginPaint = wl_begin_paint;
|
|
|
|
instance->update->EndPaint = wl_end_paint;
|
2016-08-03 19:44:26 +03:00
|
|
|
memcpy(UwacWindowGetDrawingBuffer(context->window), gdi->primary_buffer,
|
|
|
|
gdi->width * gdi->height * 4);
|
2016-01-07 01:56:05 +03:00
|
|
|
UwacWindowAddDamage(context->window, 0, 0, gdi->width, gdi->height);
|
|
|
|
context->haveDamage = TRUE;
|
2017-07-03 20:09:01 +03:00
|
|
|
|
|
|
|
freerdp_keyboard_init(instance->context->settings->KeyboardLayout);
|
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
return wl_update_content(context);
|
2014-10-13 13:43:16 +04:00
|
|
|
}
|
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
static void wl_post_disconnect(freerdp* instance)
|
|
|
|
{
|
2016-08-03 19:44:26 +03:00
|
|
|
wlfContext* context;
|
|
|
|
|
2015-04-20 17:20:16 +03:00
|
|
|
if (!instance)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!instance->context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
context = (wlfContext*) instance->context;
|
2016-01-07 01:56:05 +03:00
|
|
|
gdi_free(instance);
|
2016-08-03 19:44:26 +03:00
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
if (context->window)
|
|
|
|
UwacDestroyWindow(&context->window);
|
|
|
|
}
|
2015-04-20 17:20:16 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
|
|
|
|
{
|
2016-01-07 01:56:05 +03:00
|
|
|
UwacEvent event;
|
2016-08-03 19:44:26 +03:00
|
|
|
wlfContext* context;
|
2016-01-07 01:56:05 +03:00
|
|
|
|
|
|
|
if (UwacDisplayDispatch(display, 1) < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while (UwacHasEvent(display))
|
|
|
|
{
|
|
|
|
if (UwacNextEvent(display, &event) != UWAC_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*printf("UWAC event type %d\n", event.type);*/
|
2016-08-03 19:44:26 +03:00
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case UWAC_EVENT_FRAME_DONE:
|
|
|
|
if (!instance)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
context = (wlfContext*)instance->context;
|
|
|
|
context->waitingFrameDone = FALSE;
|
|
|
|
|
|
|
|
if (context->haveDamage && !wl_end_paint(instance->context))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UWAC_EVENT_POINTER_ENTER:
|
|
|
|
if (!wlf_handle_pointer_enter(instance, &event.mouse_enter_leave))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UWAC_EVENT_POINTER_MOTION:
|
|
|
|
if (!wlf_handle_pointer_motion(instance, &event.mouse_motion))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UWAC_EVENT_POINTER_BUTTONS:
|
|
|
|
if (!wlf_handle_pointer_buttons(instance, &event.mouse_button))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UWAC_EVENT_POINTER_AXIS:
|
|
|
|
if (!wlf_handle_pointer_axis(instance, &event.mouse_axis))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UWAC_EVENT_KEY:
|
|
|
|
if (!wlf_handle_key(instance, &event.key))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UWAC_EVENT_KEYBOARD_ENTER:
|
|
|
|
if (!wlf_keyboard_enter(instance, &event.keyboard_enter_leave))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2016-01-07 01:56:05 +03:00
|
|
|
}
|
|
|
|
}
|
2016-08-03 19:44:26 +03:00
|
|
|
|
2016-01-07 01:56:05 +03:00
|
|
|
return TRUE;
|
2015-04-20 17:20:16 +03:00
|
|
|
}
|
|
|
|
|
2015-04-22 12:05:29 +03:00
|
|
|
static int wlfreerdp_run(freerdp* instance)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
2016-08-03 19:44:26 +03:00
|
|
|
wlfContext* context;
|
2015-04-22 12:05:29 +03:00
|
|
|
DWORD count;
|
|
|
|
HANDLE handles[64];
|
|
|
|
DWORD status;
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (!instance)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
context = (wlfContext*)instance->context;
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return -1;
|
|
|
|
|
2015-04-22 12:05:29 +03:00
|
|
|
if (!freerdp_connect(instance))
|
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
printf("Failed to connect\n");
|
|
|
|
return -1;
|
2015-04-22 12:05:29 +03:00
|
|
|
}
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
handle_uwac_events(instance, context->display);
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2015-04-22 12:05:29 +03:00
|
|
|
while (!freerdp_shall_disconnect(instance))
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
2016-08-03 19:44:26 +03:00
|
|
|
handles[0] = context->displayHandle;
|
2016-01-07 01:56:05 +03:00
|
|
|
count = freerdp_get_event_handles(instance->context, &handles[1], 63);
|
2016-08-03 19:44:26 +03:00
|
|
|
|
2015-04-22 12:05:29 +03:00
|
|
|
if (!count)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
2015-04-22 12:05:29 +03:00
|
|
|
printf("Failed to get FreeRDP file descriptor\n");
|
2014-10-13 13:43:16 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
status = WaitForMultipleObjects(count + 1, handles, FALSE, INFINITE);
|
|
|
|
|
2015-04-22 12:05:29 +03:00
|
|
|
if (WAIT_FAILED == status)
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
2015-04-22 12:05:29 +03:00
|
|
|
printf("%s: WaitForMultipleObjects failed\n", __FUNCTION__);
|
2014-10-13 13:43:16 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (!handle_uwac_events(instance, context->display))
|
|
|
|
{
|
2016-01-07 01:56:05 +03:00
|
|
|
printf("error handling UWAC events\n");
|
2014-10-13 13:43:16 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-01-07 01:56:05 +03:00
|
|
|
|
|
|
|
//if (WaitForMultipleObjects(count, &handles[1], FALSE, INFINITE)) {
|
2016-04-05 18:07:45 +03:00
|
|
|
if (freerdp_check_event_handles(instance->context) != TRUE)
|
|
|
|
{
|
|
|
|
printf("Failed to check FreeRDP file descriptor\n");
|
|
|
|
break;
|
|
|
|
}
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
//}
|
2014-10-13 13:43:16 +04:00
|
|
|
}
|
|
|
|
|
2015-01-20 13:24:36 +03:00
|
|
|
freerdp_disconnect(instance);
|
2014-10-13 13:43:16 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static BOOL wlf_client_global_init()
|
2014-10-13 13:43:16 +04:00
|
|
|
{
|
2016-08-03 19:44:26 +03:00
|
|
|
setlocale(LC_ALL, "");
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (freerdp_handle_signals() != 0)
|
|
|
|
return FALSE;
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
2016-01-07 01:56:05 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static void wlf_client_global_uninit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL wlf_client_new(freerdp* instance, rdpContext* context)
|
|
|
|
{
|
|
|
|
UwacReturnCode status;
|
|
|
|
wlfContext* wfl = (wlfContext*) context;
|
|
|
|
|
|
|
|
if (!instance || !context)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-10-13 13:43:16 +04:00
|
|
|
instance->PreConnect = wl_pre_connect;
|
|
|
|
instance->PostConnect = wl_post_connect;
|
2015-04-20 17:20:16 +03:00
|
|
|
instance->PostDisconnect = wl_post_disconnect;
|
2015-12-17 18:43:55 +03:00
|
|
|
instance->Authenticate = client_cli_authenticate;
|
|
|
|
instance->GatewayAuthenticate = client_cli_gw_authenticate;
|
|
|
|
instance->VerifyCertificate = client_cli_verify_certificate;
|
|
|
|
instance->VerifyChangedCertificate = client_cli_verify_changed_certificate;
|
2016-08-03 19:44:26 +03:00
|
|
|
instance->LogonErrorInfo = NULL;
|
|
|
|
wfl->display = UwacOpenDisplay(NULL, &status);
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (!wfl->display || (status != UWAC_SUCCESS))
|
|
|
|
return FALSE;
|
2015-04-20 17:20:16 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
wfl->displayHandle = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
|
|
|
|
UwacDisplayGetFd(wfl->display), WINPR_FD_READ);
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (!wfl->displayHandle)
|
|
|
|
return FALSE;
|
2014-10-16 17:44:48 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
2014-10-13 13:43:16 +04:00
|
|
|
|
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static void wlf_client_free(freerdp* instance, rdpContext* context)
|
|
|
|
{
|
|
|
|
wlfContext* wlf = (wlfContext*) instance->context;
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (wlf->display)
|
|
|
|
UwacCloseDisplay(&wlf->display);
|
2014-10-13 13:43:16 +04:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
if (wlf->displayHandle)
|
|
|
|
CloseHandle(wlf->displayHandle);
|
|
|
|
}
|
2015-04-20 17:20:16 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static int wfl_client_start(rdpContext* context)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-04-20 17:20:16 +03:00
|
|
|
|
2016-08-03 19:44:26 +03:00
|
|
|
static int wfl_client_stop(rdpContext* context)
|
|
|
|
{
|
2014-10-13 13:43:16 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2016-08-03 19:44:26 +03:00
|
|
|
|
|
|
|
static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
|
|
|
{
|
|
|
|
ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
|
|
|
|
pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION;
|
|
|
|
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
|
|
|
|
pEntryPoints->GlobalInit = wlf_client_global_init;
|
|
|
|
pEntryPoints->GlobalUninit = wlf_client_global_uninit;
|
|
|
|
pEntryPoints->ContextSize = sizeof(wlfContext);
|
|
|
|
pEntryPoints->ClientNew = wlf_client_new;
|
|
|
|
pEntryPoints->ClientFree = wlf_client_free;
|
|
|
|
pEntryPoints->ClientStart = wfl_client_start;
|
|
|
|
pEntryPoints->ClientStop = wfl_client_stop;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
int rc = -1;
|
|
|
|
DWORD status;
|
|
|
|
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
|
|
|
|
rdpContext* context;
|
|
|
|
//if (!handle_uwac_events(NULL, g_display))
|
|
|
|
// exit(1);
|
|
|
|
RdpClientEntry(&clientEntryPoints);
|
|
|
|
context = freerdp_client_context_new(&clientEntryPoints);
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
status = freerdp_client_settings_parse_command_line(context->settings, argc,
|
|
|
|
argv, FALSE);
|
|
|
|
status = freerdp_client_settings_command_line_status_print(context->settings,
|
|
|
|
status, argc, argv);
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (freerdp_client_start(context) != 0)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
rc = wlfreerdp_run(context->instance);
|
|
|
|
|
|
|
|
if (freerdp_client_stop(context) != 0)
|
|
|
|
rc = -1;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
freerdp_client_context_free(context);
|
|
|
|
return rc;
|
|
|
|
}
|