libfreerdp-core: improvements to the server-side activation/reactivation code

This commit is contained in:
Marc-André Moreau 2013-07-19 21:52:28 -04:00
parent 91103b76b3
commit 69128d8018
7 changed files with 53 additions and 44 deletions

View File

@ -281,13 +281,10 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
UINT16 lengthSourceDescriptor;
if (rdp->state == CONNECTION_STATE_ACTIVE)
{
rdp->deactivation_reactivation = TRUE;
}
else
{
rdp->deactivation_reactivation = FALSE;
}
/*
* Windows XP can send short DEACTIVATE_ALL PDU that doesn't contain
* the following fields.

View File

@ -30,6 +30,7 @@
#include <winpr/crt.h>
#include <freerdp/error.h>
#include <freerdp/listener.h>
/**
* Connection Sequence\n
@ -966,6 +967,16 @@ BOOL rdp_server_reactivate(rdpRdp* rdp)
int rdp_server_transition_to_state(rdpRdp* rdp, int state)
{
int status = 0;
freerdp_peer* client = NULL;
if (rdp->state >= CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT)
client = rdp->context->peer;
if (rdp->state < CONNECTION_STATE_ACTIVE)
{
if (client)
client->activated = FALSE;
}
switch (state)
{
@ -1026,6 +1037,28 @@ int rdp_server_transition_to_state(rdpRdp* rdp, int state)
case CONNECTION_STATE_ACTIVE:
rdp->state = CONNECTION_STATE_ACTIVE;
update_reset_state(rdp->update);
if (client)
{
if (!client->connected)
{
/**
* PostConnect should only be called once and should not
* be called after a reactivation sequence.
*/
IFCALLRET(client->PostConnect, client->connected, client);
if (!client->connected)
return -1;
}
IFCALLRET(client->Activate, client->activated, client);
if (!client->activated)
return -1;
}
break;
default:

View File

@ -357,18 +357,19 @@ int freerdp_context_new(freerdp* instance)
instance->context = (rdpContext*) malloc(instance->ContextSize);
ZeroMemory(instance->context, instance->ContextSize);
context = instance->context;
context->instance = instance;
context->pubSub = PubSub_New(TRUE);
PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType));
rdp = rdp_new(instance);
rdp = rdp_new(context);
instance->input = rdp->input;
instance->update = rdp->update;
instance->settings = rdp->settings;
context->graphics = graphics_new(context);
context->instance = instance;
context->rdp = rdp;
context->input = instance->input;

View File

@ -106,29 +106,6 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s)
if (!rdp_server_accept_client_font_list_pdu(client->context->rdp, s))
return FALSE;
if (!client->connected)
{
/**
* PostConnect should only be called once and should not be called
* after a reactivation sequence.
*/
IFCALLRET(client->PostConnect, client->connected, client);
if (!client->connected)
return FALSE;
}
if (!client->activated)
{
/* Activate will be called everytime after the client is activated/reactivated. */
IFCALLRET(client->Activate, client->activated, client);
if (!client->activated)
return FALSE;
}
break;
case DATA_PDU_TYPE_SHUTDOWN_REQUEST:
@ -412,14 +389,15 @@ void freerdp_peer_context_new(freerdp_peer* client)
{
rdpRdp* rdp;
rdp = rdp_new(NULL);
client->context = (rdpContext*) malloc(client->ContextSize);
ZeroMemory(client->context, client->ContextSize);
rdp = rdp_new(client->context);
client->input = rdp->input;
client->update = rdp->update;
client->settings = rdp->settings;
client->context = (rdpContext*) malloc(client->ContextSize);
ZeroMemory(client->context, client->ContextSize);
client->context->rdp = rdp;
client->context->peer = client;
client->context->input = client->input;

View File

@ -984,23 +984,25 @@ int rdp_check_fds(rdpRdp* rdp)
* @return new RDP module
*/
rdpRdp* rdp_new(freerdp* instance)
rdpRdp* rdp_new(rdpContext* context)
{
rdpRdp* rdp;
rdp = (rdpRdp*) malloc(sizeof(rdpRdp));
if (rdp != NULL)
if (rdp)
{
ZeroMemory(rdp, sizeof(rdpRdp));
rdp->instance = instance;
rdp->settings = freerdp_settings_new((void*) instance);
rdp->context = context;
if (instance != NULL)
instance->settings = rdp->settings;
rdp->instance = context->instance;
rdp->settings = freerdp_settings_new((void*) context->instance);
rdp->extension = extension_new(instance);
if (context->instance)
context->instance->settings = rdp->settings;
rdp->extension = extension_new(context->instance);
rdp->transport = transport_new(rdp->settings);
rdp->license = license_new(rdp);
rdp->input = input_new(rdp);

View File

@ -120,6 +120,7 @@ struct rdp_rdp
{
int state;
freerdp* instance;
rdpContext* context;
struct rdp_mcs* mcs;
struct rdp_nego* nego;
struct rdp_input* input;
@ -194,7 +195,7 @@ BOOL rdp_recv_out_of_sequence_pdu(rdpRdp* rdp, wStream* s);
void rdp_set_blocking_mode(rdpRdp* rdp, BOOL blocking);
int rdp_check_fds(rdpRdp* rdp);
rdpRdp* rdp_new(freerdp* instance);
rdpRdp* rdp_new(rdpContext* context);
void rdp_free(rdpRdp* rdp);
#ifdef WITH_DEBUG_RDP

View File

@ -783,9 +783,6 @@ static void update_send_synchronize(rdpContext* context)
static void update_send_desktop_resize(rdpContext* context)
{
if (context->peer)
context->peer->activated = FALSE;
rdp_server_reactivate(context->rdp);
}