diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 6c734e522..15682890a 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -24,6 +24,7 @@ #include "info.h" #include "input.h" #include "rdp.h" +#include "peer.h" #include "connection.h" #include "transport.h" @@ -1550,8 +1551,9 @@ BOOL rdp_server_reactivate(rdpRdp* rdp) return FALSE; rdp_finalize_set_flag(rdp, FINALIZE_DEACTIVATE_REACTIVATE); - return rdp_server_transition_to_state(rdp, - CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE); + if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE)) + return FALSE; + return rdp_peer_handle_state_demand_active(client) > 0; } BOOL rdp_server_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state) diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index f1125678a..5ca32d84e 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -697,6 +697,33 @@ static int peer_unexpected_client_message(rdpRdp* rdp, UINT32 flag) return 0; /* we ignore this as per spec input PDU are already allowed */ } +int rdp_peer_handle_state_demand_active(freerdp_peer* client) +{ + int ret = -1; + + WINPR_ASSERT(client); + WINPR_ASSERT(client->context); + + rdpRdp* rdp = client->context->rdp; + WINPR_ASSERT(rdp); + + if (client->Capabilities && !client->Capabilities(client)) + { + WLog_ERR(TAG, "[%s] freerdp_peer::Capabilities() callback failed", + rdp_get_state_string(rdp)); + } + else if (!rdp_send_demand_active(rdp)) + { + WLog_ERR(TAG, "[%s] rdp_send_demand_active() fail", rdp_get_state_string(rdp)); + } + else + { + rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT); + ret = 1; + } + return ret; +} + static int peer_recv_callback_internal(rdpTransport* transport, wStream* s, void* extra) { UINT32 SelectedProtocol; @@ -891,21 +918,7 @@ static int peer_recv_callback_internal(rdpTransport* transport, wStream* s, void break; case CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE: - if (client->Capabilities && !client->Capabilities(client)) - { - WLog_ERR(TAG, "[%s] freerdp_peer::Capabilities() callback failed", - rdp_get_state_string(rdp)); - } - else if (!rdp_send_demand_active(rdp)) - { - WLog_ERR(TAG, "[%s] rdp_send_demand_active() fail", rdp_get_state_string(rdp)); - } - else - { - rdp_server_transition_to_state( - rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT); - ret = 1; - } + ret = rdp_peer_handle_state_demand_active(client); break; case CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT: diff --git a/libfreerdp/core/peer.h b/libfreerdp/core/peer.h index 65c8538b7..57cecce6c 100644 --- a/libfreerdp/core/peer.h +++ b/libfreerdp/core/peer.h @@ -26,4 +26,6 @@ #include +FREERDP_LOCAL int rdp_peer_handle_state_demand_active(freerdp_peer* client); + #endif /* FREERDP_LIB_CORE_PEER_H */