Refactored reconnect and redirect API
Reconnect and redirect share the same code on disconnect. Move that to a single function and export it as it may be required to terminate the session properly before reconnect is called.
This commit is contained in:
parent
6c7bfe892f
commit
7af9ba9171
@ -305,6 +305,8 @@ FREERDP_API BOOL freerdp_connect(freerdp* instance);
|
||||
FREERDP_API BOOL freerdp_abort_connect(freerdp* instance);
|
||||
FREERDP_API BOOL freerdp_shall_disconnect(freerdp* instance);
|
||||
FREERDP_API BOOL freerdp_disconnect(freerdp* instance);
|
||||
|
||||
FREERDP_API BOOL freerdp_disconnect_before_reconnect(freerdp* instance);
|
||||
FREERDP_API BOOL freerdp_reconnect(freerdp* instance);
|
||||
|
||||
FREERDP_API UINT freerdp_channel_add_init_handle_data(rdpChannelHandles* handles, void* pInitHandle,
|
||||
|
@ -314,16 +314,6 @@ BOOL rdp_client_connect(rdpRdp* rdp)
|
||||
|
||||
BOOL rdp_client_disconnect(rdpRdp* rdp)
|
||||
{
|
||||
BOOL status;
|
||||
status = nego_disconnect(rdp->nego);
|
||||
rdp_reset(rdp);
|
||||
rdp_client_transition_to_state(rdp, CONNECTION_STATE_INITIAL);
|
||||
return status;
|
||||
}
|
||||
|
||||
BOOL rdp_client_redirect(rdpRdp* rdp)
|
||||
{
|
||||
BOOL status;
|
||||
rdpSettings* settings;
|
||||
rdpContext* context;
|
||||
|
||||
@ -333,8 +323,10 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
|
||||
settings = rdp->settings;
|
||||
context = rdp->context;
|
||||
|
||||
if (!rdp_client_disconnect(rdp))
|
||||
if (!nego_disconnect(rdp->nego))
|
||||
return FALSE;
|
||||
rdp_reset(rdp);
|
||||
rdp_client_transition_to_state(rdp, CONNECTION_STATE_INITIAL);
|
||||
|
||||
if (freerdp_channels_disconnect(context->channels, context->instance) != CHANNEL_RC_OK)
|
||||
return FALSE;
|
||||
@ -342,6 +334,20 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
|
||||
freerdp_set_last_error(context, FREERDP_ERROR_SUCCESS);
|
||||
clearChannelError(context);
|
||||
ResetEvent(context->abortEvent);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL rdp_client_redirect(rdpRdp* rdp)
|
||||
{
|
||||
BOOL status;
|
||||
rdpSettings* settings;
|
||||
rdpContext* context;
|
||||
|
||||
if (!rdp_client_disconnect(rdp))
|
||||
return FALSE;
|
||||
|
||||
settings = rdp->settings;
|
||||
context = rdp->context;
|
||||
|
||||
if (rdp_redirection_apply_settings(rdp) != 0)
|
||||
return FALSE;
|
||||
@ -414,12 +420,6 @@ BOOL rdp_client_reconnect(rdpRdp* rdp)
|
||||
if (!rdp_client_disconnect(rdp))
|
||||
return FALSE;
|
||||
|
||||
if (freerdp_channels_disconnect(channels, context->instance) != CHANNEL_RC_OK)
|
||||
return FALSE;
|
||||
|
||||
freerdp_set_last_error(context, FREERDP_ERROR_SUCCESS);
|
||||
clearChannelError(context);
|
||||
ResetEvent(context->abortEvent);
|
||||
status = rdp_client_connect(rdp);
|
||||
|
||||
if (status)
|
||||
|
@ -500,10 +500,6 @@ BOOL freerdp_disconnect(freerdp* instance)
|
||||
MessageQueue_PostQuit(inputQueue, 0);
|
||||
}
|
||||
|
||||
if (freerdp_channels_disconnect(instance->context->channels,
|
||||
instance) != CHANNEL_RC_OK)
|
||||
rc = FALSE;
|
||||
|
||||
IFCALL(instance->PostDisconnect, instance);
|
||||
|
||||
if (instance->update->pcap_rfx)
|
||||
@ -518,6 +514,12 @@ BOOL freerdp_disconnect(freerdp* instance)
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL freerdp_disconnect_before_reconnect(freerdp* instance)
|
||||
{
|
||||
rdpRdp* rdp = instance->context->rdp;
|
||||
return rdp_client_disconnect(rdp);
|
||||
}
|
||||
|
||||
BOOL freerdp_reconnect(freerdp* instance)
|
||||
{
|
||||
BOOL status;
|
||||
|
Loading…
Reference in New Issue
Block a user