diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index 445cd486a..8cd513e88 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -72,6 +72,25 @@ extern "C" #define VERIFY_CERT_FLAG_MATCH_LEGACY_SHA1 0x100 #define VERIFY_CERT_FLAG_FP_IS_PEM 0x200 + typedef enum + { + CONNECTION_STATE_INITIAL, + CONNECTION_STATE_NEGO, + CONNECTION_STATE_NLA, + CONNECTION_STATE_MCS_CONNECT, + CONNECTION_STATE_MCS_ERECT_DOMAIN, + CONNECTION_STATE_MCS_ATTACH_USER, + CONNECTION_STATE_MCS_CHANNEL_JOIN, + CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT, + CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE, + CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT, + CONNECTION_STATE_LICENSING, + CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING, + CONNECTION_STATE_CAPABILITIES_EXCHANGE, + CONNECTION_STATE_FINALIZATION, + CONNECTION_STATE_ACTIVE + } CONNECTION_STATE; + /* Message types used by gateway messaging callback */ #define GATEWAY_MESSAGE_CONSENT 1 #define GATEWAY_MESSAGE_SERVICE 2 @@ -545,6 +564,9 @@ fingerprint. DEPRECATED: Use VerifyChangedCertificateEx */ FREERDP_API const char* freerdp_nego_get_routing_token(rdpContext* context, DWORD* length); + FREERDP_API CONNECTION_STATE freerdp_get_state(rdpContext* context); + FREERDP_API const char* freerdp_state_string(CONNECTION_STATE state); + #ifdef __cplusplus } #endif diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 216d0acef..b9122ef5b 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -185,7 +185,7 @@ */ static int rdp_client_connect_finalize(rdpRdp* rdp); -static BOOL rdp_set_state(rdpRdp* rdp, int state); +static BOOL rdp_set_state(rdpRdp* rdp, CONNECTION_STATE state); static BOOL rdp_client_reset_codecs(rdpContext* context) { @@ -1577,7 +1577,7 @@ const char* rdp_client_connection_state_string(int state) } } -const char* rdp_state_string(int state) +const char* rdp_state_string(CONNECTION_STATE state) { switch (state) { @@ -1616,13 +1616,13 @@ const char* rdp_state_string(int state) } } -int rdp_get_state(rdpRdp* rdp) +CONNECTION_STATE rdp_get_state(rdpRdp* rdp) { WINPR_ASSERT(rdp); return rdp->state; } -BOOL rdp_set_state(rdpRdp* rdp, int state) +BOOL rdp_set_state(rdpRdp* rdp, CONNECTION_STATE state) { WINPR_ASSERT(rdp); rdp->state = state; diff --git a/libfreerdp/core/connection.h b/libfreerdp/core/connection.h index cbb24bfec..946f745bd 100644 --- a/libfreerdp/core/connection.h +++ b/libfreerdp/core/connection.h @@ -30,25 +30,6 @@ #include #include -enum CONNECTION_STATE -{ - CONNECTION_STATE_INITIAL, - CONNECTION_STATE_NEGO, - CONNECTION_STATE_NLA, - CONNECTION_STATE_MCS_CONNECT, - CONNECTION_STATE_MCS_ERECT_DOMAIN, - CONNECTION_STATE_MCS_ATTACH_USER, - CONNECTION_STATE_MCS_CHANNEL_JOIN, - CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT, - CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE, - CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT, - CONNECTION_STATE_LICENSING, - CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING, - CONNECTION_STATE_CAPABILITIES_EXCHANGE, - CONNECTION_STATE_FINALIZATION, - CONNECTION_STATE_ACTIVE -}; - enum CLIENT_CONNECTION_STATE { CLIENT_STATE_INITIAL, @@ -67,7 +48,8 @@ FREERDP_LOCAL int rdp_client_connect_license(rdpRdp* rdp, wStream* s); FREERDP_LOCAL int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s); FREERDP_LOCAL int rdp_client_transition_to_state(rdpRdp* rdp, int state); -FREERDP_LOCAL int rdp_get_state(rdpRdp* rdp); +FREERDP_LOCAL CONNECTION_STATE rdp_get_state(rdpRdp* rdp); +FREERDP_LOCAL const char* rdp_state_string(CONNECTION_STATE state); FREERDP_LOCAL BOOL rdp_server_accept_nego(rdpRdp* rdp, wStream* s); FREERDP_LOCAL BOOL rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, wStream* s); @@ -79,7 +61,6 @@ FREERDP_LOCAL BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s); FREERDP_LOCAL BOOL rdp_server_reactivate(rdpRdp* rdp); FREERDP_LOCAL int rdp_server_transition_to_state(rdpRdp* rdp, int state); FREERDP_LOCAL const char* rdp_get_state_string(rdpRdp* rdp); -FREERDP_LOCAL const char* rdp_state_string(int state); FREERDP_LOCAL const char* rdp_client_connection_state_string(int state); diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 491aa4853..a9b179e84 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -1010,3 +1010,14 @@ BOOL freerdp_set_io_callbacks(freerdp* instance, const rdpTransportIo* io_callba return FALSE; return rdp_set_io_callbacks(instance->context->rdp, io_callbacks); } + +CONNECTION_STATE freerdp_get_state(rdpContext* context) +{ + WINPR_ASSERT(context); + return rdp_get_state(context->rdp); +} + +const char* freerdp_state_string(CONNECTION_STATE state) +{ + return rdp_state_string(state); +} diff --git a/libfreerdp/core/rdp.h b/libfreerdp/core/rdp.h index cbd0553f3..9430e16b4 100644 --- a/libfreerdp/core/rdp.h +++ b/libfreerdp/core/rdp.h @@ -132,7 +132,7 @@ struct rdp_rdp { - int state; + CONNECTION_STATE state; freerdp* instance; rdpContext* context; rdpNla* nla;