From 35cd438eca30ce4a93295d2c5a7c444f52f0f052 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 19 Jun 2018 17:28:22 +0200 Subject: [PATCH] Added enum for client connection state. --- libfreerdp/core/connection.c | 4 ++-- libfreerdp/core/connection.h | 8 ++++++++ libfreerdp/core/freerdp.c | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 9db1fa4..05a902f 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -424,7 +424,7 @@ BOOL rdp_client_redirect(rdpRdp* rdp) status = rdp_client_connect(rdp); - if (status && (context->instance->ConnectionCallbackState == 2)) + if (status && (context->instance->ConnectionCallbackState == CLIENT_STATE_POSTCONNECT_PASSED)) status = (freerdp_channels_post_connect(context->channels, context->instance) == CHANNEL_RC_OK); return status; @@ -447,7 +447,7 @@ BOOL rdp_client_reconnect(rdpRdp* rdp) status = rdp_client_connect(rdp); - if (status && (context->instance->ConnectionCallbackState == 2)) + if (status && (context->instance->ConnectionCallbackState == CLIENT_STATE_POSTCONNECT_PASSED)) status = (freerdp_channels_post_connect(channels, context->instance) == CHANNEL_RC_OK); return status; diff --git a/libfreerdp/core/connection.h b/libfreerdp/core/connection.h index 62aaea0..78dbba5 100644 --- a/libfreerdp/core/connection.h +++ b/libfreerdp/core/connection.h @@ -49,6 +49,14 @@ enum CONNECTION_STATE CONNECTION_STATE_ACTIVE }; +enum CLIENT_CONNECTION_STATE +{ + CLIENT_STATE_INITIAL, + CLIENT_STATE_PRECONNECT_PASSED, + CLIENT_STATE_POSTCONNECT_PASSED, + CLIENT_STATE_POSTDISCONNECT_PASSED +}; + FREERDP_LOCAL BOOL rdp_client_connect(rdpRdp* rdp); FREERDP_LOCAL BOOL rdp_client_disconnect(rdpRdp* rdp); FREERDP_LOCAL BOOL rdp_client_disconnect_and_clear(rdpRdp* rdp); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index c8c88ba..d6fb99b 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -157,6 +157,7 @@ BOOL freerdp_connect(freerdp* instance) return FALSE; /* We always set the return code to 0 before we start the connect sequence*/ + instance->ConnectionCallbackState = CLIENT_STATE_INITIAL; connectErrorCode = 0; instance->context->LastError = FREERDP_ERROR_SUCCESS; clearChannelError(instance->context); @@ -165,7 +166,7 @@ BOOL freerdp_connect(freerdp* instance) settings = instance->settings; instance->context->codecs = codecs_new(instance->context); IFCALLRET(instance->PreConnect, status, instance); - instance->ConnectionCallbackState++; + instance->ConnectionCallbackState = CLIENT_STATE_PRECONNECT_PASSED; if (status) status2 = freerdp_channels_pre_connect(instance->context->channels, @@ -213,7 +214,7 @@ BOOL freerdp_connect(freerdp* instance) } IFCALLRET(instance->PostConnect, status, instance); - instance->ConnectionCallbackState++; + instance->ConnectionCallbackState = CLIENT_STATE_POSTCONNECT_PASSED; if (status) status2 = freerdp_channels_post_connect(instance->context->channels, instance); @@ -503,7 +504,7 @@ BOOL freerdp_disconnect(freerdp* instance) } IFCALL(instance->PostDisconnect, instance); - instance->ConnectionCallbackState++; + instance->ConnectionCallbackState = CLIENT_STATE_POSTDISCONNECT_PASSED; if (instance->update->pcap_rfx) { -- 2.7.4