[gtk-frdp] frdp-session: Handle FreeRDP fatal connection error codes
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-frdp] frdp-session: Handle FreeRDP fatal connection error codes
- Date: Mon, 14 Jun 2021 10:23:56 +0000 (UTC)
commit a837c36e19260e9b8e9c7b5845ba1aca499c455b
Author: wmindewicz <wmindewicz contentnetworks pl>
Date: Fri Jun 28 17:13:51 2019 +0200
frdp-session: Handle FreeRDP fatal connection error codes
Fixes #21
src/frdp-session.c | 33 ++++++++++++++++++++++++++-------
src/frdp-session.h | 7 +++++++
2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/src/frdp-session.c b/src/frdp-session.c
index a6985c7..643862d 100644
--- a/src/frdp-session.c
+++ b/src/frdp-session.c
@@ -27,6 +27,7 @@
#include "frdp-session.h"
#define SELECT_TIMEOUT 50
+#define FRDP_CONNECTION_THREAD_MAX_ERRORS 10
struct frdp_pointer
{
@@ -575,22 +576,39 @@ frdp_session_connect_thread (GTask *task,
{
FrdpSession *self = (FrdpSession*) source_object;
guint authentication_errors = 0;
+ guint overflow_protection = 0;
frdp_session_init_freerdp (self);
-
+ gboolean await_connection = TRUE;
do {
self->priv->is_connected = freerdp_connect (self->priv->freerdp_session);
if (!self->priv->is_connected) {
- authentication_errors +=
- freerdp_get_last_error (self->priv->freerdp_session->context) == 0x20009 ||
- freerdp_get_last_error (self->priv->freerdp_session->context) == 0x2000c ||
- freerdp_get_last_error (self->priv->freerdp_session->context) == 0x20005;
-
+ UINT32 error_code = freerdp_get_last_error (self->priv->freerdp_session->context);
+ g_debug ("Failed to connect RPD host with error '%s'", freerdp_get_last_error_string( error_code ) );
+ switch(error_code){
+ case FRDP_ERRCONNECT_CONNECT_CANCELLED:
+ case FRDP_ERRCONNECT_AUTHENTICATION_FAILED:
+ case FRDP_ERRCONNECT_SECURITY_NEGO_CONNECT_FAILED:
+ //@TODO signal UI thread with custom error message
+ g_warning ("Failed to connect RPD host with error '%s'", freerdp_get_last_error_string(
error_code ) );
+ authentication_errors++;
+ break;
+
+ default:
+ g_warning ("Unhandled FreeRDP error occured '%s'", freerdp_get_last_error_string( error_code )
);
+ overflow_protection++;
+ break;
+ }
freerdp_free (self->priv->freerdp_session);
frdp_session_init_freerdp (self);
+
+ if( authentication_errors >= 3 || overflow_protection >= FRDP_CONNECTION_THREAD_MAX_ERRORS ){
+ await_connection = FALSE;
+ }
+
}
- } while (!self->priv->is_connected && authentication_errors < 3);
+ } while (!self->priv->is_connected && await_connection);
if (self->priv->is_connected) {
g_signal_connect (self->priv->display, "draw",
@@ -762,6 +780,7 @@ frdp_session_class_init (FrdpSessionClass *klass)
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
+
}
static void
diff --git a/src/frdp-session.h b/src/frdp-session.h
index b88b217..829bf43 100644
--- a/src/frdp-session.h
+++ b/src/frdp-session.h
@@ -88,5 +88,12 @@ void frdp_session_send_key (FrdpSession *self,
guint16 keycode);
GdkPixbuf *frdp_session_get_pixbuf (FrdpSession *self);
+/*FreeRDP fatal error codes*/
+typedef enum {
+ FRDP_ERRCONNECT_CONNECT_CANCELLED = 0x2000B,
+ FRDP_ERRCONNECT_AUTHENTICATION_FAILED = 0x20009,
+ FRDP_ERRCONNECT_SECURITY_NEGO_CONNECT_FAILED = 0x2000c,
+
+} FrdpErrConnect;
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]