mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
wfreerdp-server: generalized managed api callbacks, peer tracking bug fixes, code cleanup
This commit is contained in:
parent
5d0a53a3b3
commit
36394b3c23
@ -1,21 +1,21 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -41,19 +41,19 @@ int wf_info_lock(wfInfo* wfi)
|
||||
|
||||
switch (dRes)
|
||||
{
|
||||
case WAIT_ABANDONED:
|
||||
case WAIT_OBJECT_0:
|
||||
return TRUE;
|
||||
break;
|
||||
case WAIT_ABANDONED:
|
||||
case WAIT_OBJECT_0:
|
||||
return TRUE;
|
||||
break;
|
||||
|
||||
case WAIT_TIMEOUT:
|
||||
return FALSE;
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case WAIT_FAILED:
|
||||
printf("wf_info_lock failed with 0x%08X\n", GetLastError());
|
||||
return -1;
|
||||
break;
|
||||
case WAIT_FAILED:
|
||||
printf("wf_info_lock failed with 0x%08X\n", GetLastError());
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -67,19 +67,19 @@ int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds)
|
||||
|
||||
switch (dRes)
|
||||
{
|
||||
case WAIT_ABANDONED:
|
||||
case WAIT_OBJECT_0:
|
||||
return TRUE;
|
||||
break;
|
||||
case WAIT_ABANDONED:
|
||||
case WAIT_OBJECT_0:
|
||||
return TRUE;
|
||||
break;
|
||||
|
||||
case WAIT_TIMEOUT:
|
||||
return FALSE;
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case WAIT_FAILED:
|
||||
printf("wf_info_try_lock failed with 0x%08X\n", GetLastError());
|
||||
return -1;
|
||||
break;
|
||||
case WAIT_FAILED:
|
||||
printf("wf_info_try_lock failed with 0x%08X\n", GetLastError());
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -100,7 +100,7 @@ wfInfo* wf_info_init()
|
||||
{
|
||||
wfInfo* wfi;
|
||||
|
||||
/*
|
||||
/*
|
||||
OSVERSIONINFOEX osvi;
|
||||
SYSTEM_INFO si;
|
||||
BOOL bOsVersionInfoEx;
|
||||
@ -175,15 +175,15 @@ wfInfo* wf_info_init()
|
||||
wfi->win8 = FALSE;
|
||||
if(bOsVersionInfoEx != 0 )
|
||||
{
|
||||
if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
|
||||
osvi.dwMajorVersion > 4 )
|
||||
{
|
||||
if ( osvi.dwMajorVersion == 6 &&
|
||||
osvi.dwMinorVersion == 2)
|
||||
{
|
||||
wfi->win8 = TRUE;
|
||||
}
|
||||
}
|
||||
if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
|
||||
osvi.dwMajorVersion > 4 )
|
||||
{
|
||||
if ( osvi.dwMajorVersion == 6 &&
|
||||
osvi.dwMinorVersion == 2)
|
||||
{
|
||||
wfi->win8 = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -205,7 +205,6 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
|
||||
{
|
||||
int i;
|
||||
int peerId;
|
||||
//todo: reject peer if we have WF_INFO_MAXPEERS connected
|
||||
if (wfi->peerCount == WF_INFO_MAXPEERS)
|
||||
{
|
||||
context->socketClose = TRUE;
|
||||
@ -240,7 +239,7 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
|
||||
|
||||
wf_info_unlock(wfi);
|
||||
|
||||
wfreerdp_server_peer_connect_event(peerId);
|
||||
wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,7 +263,7 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context)
|
||||
|
||||
wf_info_unlock(wfi);
|
||||
|
||||
wfreerdp_server_peer_disconnect_event(peerId);
|
||||
wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_DISCONNECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "wf_interface.h"
|
||||
|
||||
#define WF_INFO_DEFAULT_FPS 24
|
||||
#define WF_INFO_MAXPEERS 2
|
||||
#define WF_INFO_MAXPEERS 32
|
||||
|
||||
int wf_info_lock(wfInfo* wfi);
|
||||
int wf_info_try_lock(wfInfo* wfi, DWORD dwMilliseconds);
|
||||
|
@ -3,6 +3,7 @@
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -25,6 +26,8 @@
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/windows.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
#include <freerdp\listener.h>
|
||||
//#include <libfreerdp\core\listener.h>
|
||||
|
||||
#include "wf_peer.h"
|
||||
#include "wf_settings.h"
|
||||
@ -32,18 +35,7 @@
|
||||
|
||||
#include "wf_interface.h"
|
||||
|
||||
//todo: remove this
|
||||
struct rdp_listener
|
||||
{
|
||||
freerdp_listener* instance;
|
||||
|
||||
int sockfds[5];
|
||||
int num_sockfds;
|
||||
};
|
||||
//
|
||||
|
||||
cbConEvent cbConnect;
|
||||
cbConEvent cbDisconnect;
|
||||
cbCallback cbEvent;
|
||||
|
||||
DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
||||
{
|
||||
@ -53,7 +45,6 @@ DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
||||
void* rfds[32];
|
||||
fd_set rfds_set;
|
||||
freerdp_listener* instance;
|
||||
struct rdp_listener* listener;
|
||||
wfInfo* wfi;
|
||||
|
||||
wfi = wf_info_get_instance();
|
||||
@ -61,9 +52,8 @@ DWORD WINAPI wf_server_main_loop(LPVOID lpParam)
|
||||
|
||||
ZeroMemory(rfds, sizeof(rfds));
|
||||
instance = (freerdp_listener*) lpParam;
|
||||
listener = (struct rdp_listener*) instance->listener;
|
||||
|
||||
while (listener->num_sockfds > 0)
|
||||
while(wfi->force_all_disconnect == FALSE)
|
||||
{
|
||||
rcount = 0;
|
||||
|
||||
@ -151,8 +141,7 @@ wfServer* wfreerdp_server_new()
|
||||
server->port = 3389;
|
||||
}
|
||||
|
||||
cbConnect = NULL;
|
||||
cbDisconnect = NULL;
|
||||
cbEvent = NULL;
|
||||
|
||||
return server;
|
||||
}
|
||||
@ -212,7 +201,7 @@ FREERDP_API UINT32 wfreerdp_server_get_peer_hostname(int pId, wchar_t * dstStr)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("nonexistent peer\n");
|
||||
printf("nonexistent peer id=%d\n", pId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -293,25 +282,14 @@ FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId)
|
||||
}
|
||||
}
|
||||
|
||||
FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb)
|
||||
FREERDP_API void wfreerdp_server_register_callback_event(cbCallback cb)
|
||||
{
|
||||
cbConnect = cb;
|
||||
cbEvent = cb;
|
||||
}
|
||||
|
||||
FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb)
|
||||
void wfreerdp_server_peer_callback_event(int pId, UINT32 eType)
|
||||
{
|
||||
cbDisconnect = cb;
|
||||
}
|
||||
|
||||
|
||||
void wfreerdp_server_peer_connect_event(int pId)
|
||||
{
|
||||
if (cbConnect)
|
||||
cbConnect(pId);
|
||||
}
|
||||
void wfreerdp_server_peer_disconnect_event(int pId)
|
||||
{
|
||||
if (cbDisconnect)
|
||||
cbDisconnect(pId);
|
||||
if (cbEvent)
|
||||
cbEvent(pId, eType);
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,22 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef WF_INTERFACE_H
|
||||
#define WF_INTERFACE_H
|
||||
@ -29,6 +30,11 @@
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/codec/rfx.h>
|
||||
|
||||
#define WF_SRV_CALLBACK_EVENT_CONNECT 1
|
||||
#define WF_SRV_CALLBACK_EVENT_DISCONNECT 2
|
||||
#define WF_SRV_CALLBACK_EVENT_ACTIVATE 4
|
||||
#define WF_SRV_CALLBACK_EVENT_AUTH 8
|
||||
|
||||
typedef struct wf_info wfInfo;
|
||||
typedef struct wf_peer_context wfPeerContext;
|
||||
|
||||
@ -86,7 +92,7 @@ struct wf_server
|
||||
};
|
||||
typedef struct wf_server wfServer;
|
||||
|
||||
typedef void (__stdcall* cbConEvent) (int);
|
||||
typedef void (__stdcall* cbCallback) (int, UINT32);
|
||||
|
||||
FREERDP_API BOOL wfreerdp_server_start(wfServer* server);
|
||||
FREERDP_API BOOL wfreerdp_server_stop(wfServer* server);
|
||||
@ -103,10 +109,13 @@ FREERDP_API BOOL wfreerdp_server_peer_is_connected(int pId);
|
||||
FREERDP_API BOOL wfreerdp_server_peer_is_activated(int pId);
|
||||
FREERDP_API BOOL wfreerdp_server_peer_is_authenticated(int pId);
|
||||
|
||||
FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb);
|
||||
FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb);
|
||||
//FREERDP_API void wfreerdp_server_register_connect_event(cbConEvent cb);
|
||||
//FREERDP_API void wfreerdp_server_register_disconnect_event(cbConEvent cb);
|
||||
FREERDP_API void wfreerdp_server_register_callback_event(cbCallback cb);
|
||||
|
||||
void wfreerdp_server_peer_connect_event(int pId);
|
||||
void wfreerdp_server_peer_disconnect_event(int pId);
|
||||
//void wfreerdp_server_peer_connect_event(int pId);
|
||||
//void wfreerdp_server_peer_disconnect_event(int pId);
|
||||
|
||||
void wfreerdp_server_peer_callback_event(int pId, UINT32 eType);
|
||||
|
||||
#endif /* WF_INTERFACE_H */
|
||||
|
@ -1,21 +1,22 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -99,6 +100,8 @@ boolean wf_peer_activate(freerdp_peer* client)
|
||||
client->activated = true;
|
||||
wf_update_peer_activate(wfi, context);
|
||||
|
||||
wfreerdp_server_peer_callback_event(((rdpContext*) context)->peer->pId, WF_SRV_CALLBACK_EVENT_ACTIVATE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,6 +115,8 @@ boolean wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, b
|
||||
identity->User, identity->Domain, identity->Password);
|
||||
}
|
||||
|
||||
|
||||
wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,22 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2012 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -133,7 +134,7 @@ void wf_update_encode(wfInfo* wfi)
|
||||
//printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height);
|
||||
|
||||
rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1,
|
||||
pDataBits, width, height, stride);
|
||||
pDataBits, width, height, stride);
|
||||
|
||||
wfi->frame_idx = wfi->rfx_context->frame_idx;
|
||||
|
||||
@ -160,10 +161,10 @@ void wf_update_peer_send(wfInfo* wfi, wfPeerContext* context)
|
||||
context->frame_idx = 0;
|
||||
|
||||
/*
|
||||
* When a new client connects, it is possible that old frames from
|
||||
* from a previous encoding state remain. Those frames should be discarded
|
||||
* as they will cause an error condition in mstsc.
|
||||
*/
|
||||
* When a new client connects, it is possible that old frames from
|
||||
* from a previous encoding state remain. Those frames should be discarded
|
||||
* as they will cause an error condition in mstsc.
|
||||
*/
|
||||
|
||||
if ((context->frame_idx + 1) != wfi->frame_idx)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user