Expose CONNECTION_STATE via public API

* Expose type CONNECTION_STATE
* Add getter freerdp_get_state
* Add helper freerdp_state_string
This commit is contained in:
akallabeth 2021-09-03 09:12:23 +02:00 committed by akallabeth
parent ad86192ac6
commit 32b3f54bb3
5 changed files with 40 additions and 26 deletions

View File

@ -72,6 +72,25 @@ extern "C"
#define VERIFY_CERT_FLAG_MATCH_LEGACY_SHA1 0x100 #define VERIFY_CERT_FLAG_MATCH_LEGACY_SHA1 0x100
#define VERIFY_CERT_FLAG_FP_IS_PEM 0x200 #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 */ /* Message types used by gateway messaging callback */
#define GATEWAY_MESSAGE_CONSENT 1 #define GATEWAY_MESSAGE_CONSENT 1
#define GATEWAY_MESSAGE_SERVICE 2 #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 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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -185,7 +185,7 @@
*/ */
static int rdp_client_connect_finalize(rdpRdp* rdp); 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) 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) 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); WINPR_ASSERT(rdp);
return rdp->state; return rdp->state;
} }
BOOL rdp_set_state(rdpRdp* rdp, int state) BOOL rdp_set_state(rdpRdp* rdp, CONNECTION_STATE state)
{ {
WINPR_ASSERT(rdp); WINPR_ASSERT(rdp);
rdp->state = state; rdp->state = state;

View File

@ -30,25 +30,6 @@
#include <freerdp/settings.h> #include <freerdp/settings.h>
#include <freerdp/api.h> #include <freerdp/api.h>
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 enum CLIENT_CONNECTION_STATE
{ {
CLIENT_STATE_INITIAL, 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_connect_demand_active(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_transition_to_state(rdpRdp* rdp, int state); 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_nego(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL BOOL rdp_server_accept_mcs_connect_initial(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 BOOL rdp_server_reactivate(rdpRdp* rdp);
FREERDP_LOCAL int rdp_server_transition_to_state(rdpRdp* rdp, int state); 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_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); FREERDP_LOCAL const char* rdp_client_connection_state_string(int state);

View File

@ -1010,3 +1010,14 @@ BOOL freerdp_set_io_callbacks(freerdp* instance, const rdpTransportIo* io_callba
return FALSE; return FALSE;
return rdp_set_io_callbacks(instance->context->rdp, io_callbacks); 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);
}

View File

@ -132,7 +132,7 @@
struct rdp_rdp struct rdp_rdp
{ {
int state; CONNECTION_STATE state;
freerdp* instance; freerdp* instance;
rdpContext* context; rdpContext* context;
rdpNla* nla; rdpNla* nla;