updated context error messages. utility macros for getting error code CLASS/TYPE

This commit is contained in:
Benoît LeBlanc 2014-03-21 13:45:43 -04:00
parent d1b9565f51
commit 3e1dfc6311
7 changed files with 59 additions and 23 deletions

View File

@ -177,28 +177,58 @@ FREERDP_API extern int connectErrorCode;
#define CANCELEDBYUSER ERRORSTART + 11
/**
* These error codes are used with rdp_context.LastError
* FreeRDP Context Error Codes
*/
#define FREERDP_ERROR_SUCCESS 0x00000000
#define FREERDP_ERROR_ERRORSTART 0x00010000
#define MAKE_FREERDP_ERROR(_class, _type) \
(((FREERDP_ERROR_ ## _class ## _CLASS) << 16) | (_type))
#define FREERDP_ERROR_CANCELLED FREERDP_ERROR_ERRORSTART + 0x00000001
#define GET_FREERDP_ERROR_CLASS(_errorCode) \
((_errorCode >> 16) & 0xFFFF)
/* connect error codes */
#define FREERDP_ERROR_PRE_CONNECT_FAILED FREERDP_ERROR_ERRORSTART + 0x00001001
#define FREERDP_ERROR_UNDEFINED_CONNECT_ERROR FREERDP_ERROR_ERRORSTART + 0x00001002
#define FREERDP_ERROR_POST_CONNECT_FAILED FREERDP_ERROR_ERRORSTART + 0x00001003
#define FREERDP_ERROR_DNS_ERROR FREERDP_ERROR_ERRORSTART + 0x00001004
#define FREERDP_ERROR_DNS_NAME_NOT_FOUND FREERDP_ERROR_ERRORSTART + 0x00001005
#define FREERDP_ERROR_CONNECT_FAILED FREERDP_ERROR_ERRORSTART + 0x00001006
#define FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR FREERDP_ERROR_ERRORSTART + 0x00001007
#define FREERDP_ERROR_TLS_CONNECT_FAILED FREERDP_ERROR_ERRORSTART + 0x00001008
#define FREERDP_ERROR_AUTHENTICATION_FAILED FREERDP_ERROR_ERRORSTART + 0x00001009
#define FREERDP_ERROR_INSUFFICIENT_PRIVILEGES FREERDP_ERROR_ERRORSTART + 0x0000100A
#define GET_FREERDP_ERROR_TYPE(_errorCode) \
(_errorCode & 0xFFFF)
#define GET_FREERDP_ERROR_SUBCODE
#define FREERDP_ERROR_BASE 0
#define FREERDP_ERROR_SUCCESS ERRINFO_SUCCESS
#define FREERDP_ERROR_NONE ERRINFO_NONE
/* Error Info Codes */
#define FREERDP_ERROR_ERRINFO_CLASS (FREERDP_ERROR_BASE + 1)
#define FREERDP_ERROR_RPC_INITIATED_DISCONNECT MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_RPC_INITIATED_DISCONNECT)
#define FREERDP_ERROR_RPC_INITIATED_LOGOFF MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_RPC_INITIATED_LOGOFF)
#define FREERDP_ERROR_IDLE_TIMEOUT MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_IDLE_TIMEOUT)
#define FREERDP_ERROR_LOGON_TIMEOUT MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_LOGON_TIMEOUT)
#define FREERDP_ERROR_DISCONNECTED_BY_OTHER_CONNECTION MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION)
#define FREERDP_ERROR_OUT_OF_MEMORY MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_OUT_OF_MEMORY)
#define FREERDP_ERROR_SERVER_DENIED_CONNECTION MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_SERVER_DENIED_CONNECTION)
#define FREERDP_ERROR_SERVER_INSUFFICIENT_PRIVILEGES MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES)
#define FREERDP_ERROR_SERVER_FRESH_CREDENTIALS_REQUIRED MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED)
#define FREERDP_ERROR_RPC_INITIATED_DISCONNECT_BY_USER MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_RPC_INITIATED_DISCONNECT_BY_USER)
#define FREERDP_ERROR_LOGOFF_BY_USER MAKE_FREERDP_ERROR(ERRINFO, ERRINFO_LOGOFF_BY_USER)
/* Connection Error Codes */
#define FREERDP_ERROR_CONNECT_CLASS (FREERDP_ERROR_BASE + 2)
#define FREERDP_ERROR_PRE_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 1)
#define FREERDP_ERROR_CONNECT_UNDEFINED MAKE_FREERDP_ERROR(CONNECT, 2)
#define FREERDP_ERROR_POST_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 3)
#define FREERDP_ERROR_DNS_ERROR MAKE_FREERDP_ERROR(CONNECT, 4)
#define FREERDP_ERROR_DNS_NAME_NOT_FOUND MAKE_FREERDP_ERROR(CONNECT, 5)
#define FREERDP_ERROR_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 6)
#define FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR MAKE_FREERDP_ERROR(CONNECT, 7)
#define FREERDP_ERROR_TLS_CONNECT_FAILED MAKE_FREERDP_ERROR(CONNECT, 8)
#define FREERDP_ERROR_AUTHENTICATION_FAILED MAKE_FREERDP_ERROR(CONNECT, 9)
#define FREERDP_ERROR_INSUFFICIENT_PRIVILEGES MAKE_FREERDP_ERROR(CONNECT, 10)
#define FREERDP_ERROR_CONNECT_CANCELLED MAKE_FREERDP_ERROR(CONNECT, 11)
#ifdef __cplusplus
}
#endif

View File

@ -200,12 +200,12 @@ BOOL freerdp_connect(freerdp* instance)
if (!freerdp_get_last_error(rdp->context))
{
freerdp_set_last_error(instance->context, FREERDP_ERROR_UNDEFINED_CONNECT_ERROR);
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_UNDEFINED);
}
if (!freerdp_get_last_error(rdp->context))
{
freerdp_set_last_error(instance->context, FREERDP_ERROR_UNDEFINED_CONNECT_ERROR);
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_UNDEFINED);
}
SetEvent(rdp->transport->connectedEvent);

View File

@ -142,7 +142,7 @@ int rpc_ncacn_http_ntlm_init(rdpRpc* rpc, TSG_CHANNEL channel)
if (!proceed)
{
connectErrorCode = CANCELEDBYUSER;
freerdp_set_last_error(instance->context, FREERDP_ERROR_CANCELLED);
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
return 0;
}

View File

@ -120,7 +120,7 @@ int rpc_send_bind_pdu(rdpRpc* rpc)
if (!proceed)
{
connectErrorCode = CANCELEDBYUSER;
freerdp_set_last_error(instance->context, FREERDP_ERROR_CANCELLED);
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
return 0;
}

View File

@ -153,7 +153,7 @@ int credssp_ntlm_client_init(rdpCredssp* credssp)
if (!proceed)
{
connectErrorCode = CANCELEDBYUSER;
freerdp_set_last_error(instance->context, FREERDP_ERROR_CANCELLED);
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
return 0;
}

View File

@ -235,6 +235,8 @@ BOOL rdp_set_error_info(rdpRdp* rdp, UINT32 errorInfo)
if (rdp->errorInfo != ERRINFO_SUCCESS)
{
rdp->context->LastError = MAKE_FREERDP_ERROR(ERRINFO, errorInfo);
ErrorInfoEventArgs e;
rdpContext* context = rdp->instance->context;
@ -244,6 +246,10 @@ BOOL rdp_set_error_info(rdpRdp* rdp, UINT32 errorInfo)
e.code = rdp->errorInfo;
PubSub_OnErrorInfo(context->pubSub, context, &e);
}
else
{
rdp->context->LastError = FREERDP_ERROR_SUCCESS;
}
return TRUE;
}

View File

@ -699,7 +699,7 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int po
if (status < 0)
{
freerdp_set_last_error(instance->context, FREERDP_ERROR_CANCELLED);
freerdp_set_last_error(instance->context, FREERDP_ERROR_CONNECT_CANCELLED);
}
}
@ -797,7 +797,7 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int po
if (!accept_certificate)
{
freerdp_set_last_error(((freerdp*) tls->settings->instance)->context, FREERDP_ERROR_CANCELLED);
freerdp_set_last_error(((freerdp*) tls->settings->instance)->context, FREERDP_ERROR_CONNECT_CANCELLED);
}
}
@ -824,7 +824,7 @@ BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int po
if (!accept_certificate)
{
freerdp_set_last_error(((freerdp*) tls->settings->instance)->context, FREERDP_ERROR_CANCELLED);
freerdp_set_last_error(((freerdp*) tls->settings->instance)->context, FREERDP_ERROR_CONNECT_CANCELLED);
}
}