Removed obsolete connectErrorCode
authorArmin Novak <armin.novak@thincast.com>
Fri, 11 Sep 2020 08:14:14 +0000 (10:14 +0200)
committerakallabeth <akallabeth@posteo.net>
Wed, 2 Dec 2020 13:17:54 +0000 (14:17 +0100)
(cherry picked from commit 3b63903d3fbca0c1b1614aa93ea9ede955da692d)

client/Mac/cli/AppDelegate.m
include/freerdp/error.h
libfreerdp/core/errinfo.c
libfreerdp/core/freerdp.c

index 6986956..b7abcde 100644 (file)
@@ -199,6 +199,7 @@ void mac_set_view_size(rdpContext *context, MRDPView *view);
 
 void AppDelegate_ConnectionResultEventHandler(void *ctx, ConnectionResultEventArgs *e)
 {
+       rdpContext *context = (rdpContext *)ctx;
        NSLog(@"ConnectionResult event result:%d\n", e->result);
 
        if (_singleDelegate)
@@ -206,11 +207,15 @@ void AppDelegate_ConnectionResultEventHandler(void *ctx, ConnectionResultEventAr
                if (e->result != 0)
                {
                        NSString *message = nil;
-
-                       if (connectErrorCode == AUTHENTICATIONERROR)
+                       DWORD code = freerdp_get_last_error(context);
+                       switch (code)
                        {
-                               message = [NSString
-                                   stringWithFormat:@"%@", @"Authentication failure, check credentials."];
+                               case FREERDP_ERROR_AUTHENTICATION_FAILED:
+                                       message = [NSString
+                                           stringWithFormat:@"%@", @"Authentication failure, check credentials."];
+                                       break;
+                               default:
+                                       break;
                        }
 
                        // Making sure this should be invoked on the main UI thread.
index f9d4b6a..0fb5160 100644 (file)
@@ -178,30 +178,6 @@ extern "C"
        FREERDP_API const char* freerdp_get_error_info_category(UINT32 code);
 
        /**
-        * This static variable holds an error code if the return value from connect is FALSE.
-        * This variable is always set to 0 in the beginning of the connect sequence.
-        * The returned code can be used to inform the user of the detailed connect error.
-        * The value can hold one of the defined error codes below OR an error according to errno
-        */
-
-       FREERDP_API extern int connectErrorCode;
-
-#define ERRORSTART 10000
-#define PREECONNECTERROR ERRORSTART + 1
-#define UNDEFINEDCONNECTERROR ERRORSTART + 2
-#define POSTCONNECTERROR ERRORSTART + 3
-#define DNSERROR ERRORSTART + 4        /* general DNS ERROR */
-#define DNSNAMENOTFOUND ERRORSTART + 5 /* EAI_NONAME */
-#define CONNECTERROR                                                            \
-       ERRORSTART + 6 /* a connect error if errno is not define during tcp connect \
-                       */
-#define MCSCONNECTINITIALERROR ERRORSTART + 7
-#define TLSCONNECTERROR ERRORSTART + 8
-#define AUTHENTICATIONERROR ERRORSTART + 9
-#define INSUFFICIENTPRIVILEGESERROR ERRORSTART + 10
-#define CANCELEDBYUSER ERRORSTART + 11
-
-       /**
         * FreeRDP Context Error Codes
         */
 
index e635847..abfe96e 100644 (file)
@@ -34,8 +34,6 @@
                ERRINFO_##_code, "ERRINFO_" #_code, ERRINFO_##_code##_STRING, category \
        }
 
-int connectErrorCode;
-
 /* Protocol-independent codes */
 
 #define ERRINFO_RPC_INITIATED_DISCONNECT_STRING \
index 9094bc3..81183e7 100644 (file)
@@ -55,8 +55,6 @@
 
 #define TAG FREERDP_TAG("core")
 
-/* connectErrorCode is 'extern' in error.h. See comment there.*/
-
 UINT freerdp_channel_add_init_handle_data(rdpChannelHandles* handles, void* pInitHandle,
                                           void* pUserData)
 {
@@ -163,7 +161,6 @@ BOOL freerdp_connect(freerdp* instance)
 
        /* We always set the return code to 0 before we start the connect sequence*/
        instance->ConnectionCallbackState = CLIENT_STATE_INITIAL;
-       connectErrorCode = 0;
        freerdp_set_last_error_log(instance->context, FREERDP_ERROR_SUCCESS);
        clearChannelError(instance->context);
        ResetEvent(instance->context->abortEvent);
@@ -893,61 +890,6 @@ void freerdp_set_last_error_ex(rdpContext* context, UINT32 lastError, const char
        }
 
        context->LastError = lastError;
-
-       switch (lastError)
-       {
-               case FREERDP_ERROR_PRE_CONNECT_FAILED:
-                       connectErrorCode = PREECONNECTERROR;
-                       break;
-
-               case FREERDP_ERROR_CONNECT_UNDEFINED:
-                       connectErrorCode = UNDEFINEDCONNECTERROR;
-                       break;
-
-               case FREERDP_ERROR_POST_CONNECT_FAILED:
-                       connectErrorCode = POSTCONNECTERROR;
-                       break;
-
-               case FREERDP_ERROR_DNS_ERROR:
-                       connectErrorCode = DNSERROR;
-                       break;
-
-               case FREERDP_ERROR_DNS_NAME_NOT_FOUND:
-                       connectErrorCode = DNSNAMENOTFOUND;
-                       break;
-
-               case FREERDP_ERROR_CONNECT_FAILED:
-                       connectErrorCode = CONNECTERROR;
-                       break;
-
-               case FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR:
-                       connectErrorCode = MCSCONNECTINITIALERROR;
-                       break;
-
-               case FREERDP_ERROR_TLS_CONNECT_FAILED:
-                       connectErrorCode = TLSCONNECTERROR;
-                       break;
-
-               case FREERDP_ERROR_AUTHENTICATION_FAILED:
-                       connectErrorCode = AUTHENTICATIONERROR;
-                       break;
-
-               case FREERDP_ERROR_INSUFFICIENT_PRIVILEGES:
-                       connectErrorCode = INSUFFICIENTPRIVILEGESERROR;
-                       break;
-
-               case FREERDP_ERROR_CONNECT_CANCELLED:
-                       connectErrorCode = CANCELEDBYUSER;
-                       break;
-
-               case FREERDP_ERROR_SECURITY_NEGO_CONNECT_FAILED:
-                       connectErrorCode = CONNECTERROR;
-                       break;
-
-               case FREERDP_ERROR_CONNECT_TRANSPORT_FAILED:
-                       connectErrorCode = CONNECTERROR;
-                       break;
-       }
 }
 
 const char* freerdp_get_logon_error_info_type(UINT32 type)