[PATCH 18/25] Replace 'auth_failure' and 'auth_unsupported' operations with signals
- From: "Daniel P. Berrange" <berrange redhat com>
- To: gtk-vnc-list gnome org
- Cc: "Daniel P. Berrange" <berrange redhat com>
- Subject: [PATCH 18/25] Replace 'auth_failure' and 'auth_unsupported' operations with signals
- Date: Sat, 21 Nov 2009 13:28:07 +0000
Remove the 'auth_failure' and 'auth_unsupported' operation callbacks
from VncConnection. Introduce new 'vnc-auth-failure' and
'vnc-auth-unsupported' signals.
---
src/vncconnection.c | 77 +++++++++++++++++++++++++++++++++++++++++++--------
src/vncconnection.h | 4 +-
src/vncdisplay.c | 40 ++++++++------------------
3 files changed, 79 insertions(+), 42 deletions(-)
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 582827e..cd246b9 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -196,11 +196,15 @@ enum {
VNC_DESKTOP_RESIZE,
VNC_PIXEL_FORMAT_CHANGED,
+ VNC_AUTH_FAILURE,
+ VNC_AUTH_UNSUPPORTED,
+
VNC_LAST_SIGNAL,
};
static guint signals[VNC_LAST_SIGNAL] = { 0, 0, 0, 0,
- 0, 0, 0, };
+ 0, 0, 0, 0,
+ 0, };
#define nibhi(a) (((a) >> 4) & 0x0F)
#define niblo(a) ((a) & 0x0F)
@@ -384,6 +388,8 @@ struct signal_data
int height;
} size;
VncPixelFormat *pixelFormat;
+ const char *authReason;
+ unsigned int authUnsupported;
} params;
};
@@ -443,6 +449,21 @@ static gboolean do_vnc_connection_emit_main_context(gpointer opaque)
0,
data->params.pixelFormat);
break;
+
+ case VNC_AUTH_FAILURE:
+ g_signal_emit(G_OBJECT(data->conn),
+ signals[data->signum],
+ 0,
+ data->params.authReason);
+ break;
+
+ case VNC_AUTH_UNSUPPORTED:
+ g_signal_emit(G_OBJECT(data->conn),
+ signals[data->signum],
+ 0,
+ data->params.authUnsupported);
+ break;
+
}
coroutine_yieldto(data->caller, NULL);
@@ -2644,12 +2665,18 @@ static gboolean vnc_connection_check_auth_result(VncConnection *conn)
vnc_connection_read(conn, reason, len);
reason[len] = '\0';
GVNC_DEBUG("Fail %s", reason);
- if (!priv->has_error && priv->ops.auth_failure)
- priv->ops.auth_failure(priv->ops_data, reason);
+ if (!priv->has_error) {
+ struct signal_data sigdata;
+ sigdata.params.authReason = reason;
+ vnc_connection_emit_main_context(conn, VNC_AUTH_FAILURE, &sigdata);
+ }
} else {
GVNC_DEBUG("Fail auth no result");
- if (!priv->has_error && priv->ops.auth_failure)
- priv->ops.auth_failure(priv->ops_data, NULL);
+ if (!priv->has_error) {
+ struct signal_data sigdata;
+ sigdata.params.authReason = "Unknown authentication failure";
+ vnc_connection_emit_main_context(conn, VNC_AUTH_FAILURE, &sigdata);
+ }
}
return FALSE;
}
@@ -3639,10 +3666,12 @@ static gboolean vnc_connection_perform_auth(VncConnection *conn)
return vnc_connection_perform_auth_mslogon(conn);
default:
- if (priv->ops.auth_unsupported)
- priv->ops.auth_unsupported (priv->ops_data, priv->auth_type);
- priv->has_error = TRUE;
-
+ {
+ struct signal_data sigdata;
+ sigdata.params.authUnsupported = priv->auth_type;
+ vnc_connection_emit_main_context(conn, VNC_AUTH_UNSUPPORTED, &sigdata);
+ priv->has_error = TRUE;
+ }
return FALSE;
}
@@ -3766,6 +3795,30 @@ static void vnc_connection_class_init(VncConnectionClass *klass)
1,
G_TYPE_POINTER);
+ signals[VNC_AUTH_FAILURE] =
+ g_signal_new ("vnc-auth-failure",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_failure),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+
+
+ signals[VNC_AUTH_UNSUPPORTED] =
+ g_signal_new ("vnc-auth-unsupported",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (VncConnectionClass, vnc_auth_unsupported),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_UINT);
+
+
g_type_class_add_private(klass, sizeof(VncConnectionPrivate));
}
@@ -4164,10 +4217,10 @@ gboolean vnc_connection_set_auth_type(VncConnection *conn, unsigned int type)
type != GVNC_AUTH_TLS &&
type != GVNC_AUTH_VENCRYPT &&
type != GVNC_AUTH_SASL) {
+ struct signal_data sigdata;
GVNC_DEBUG("Unsupported auth type %u", type);
- if (priv->ops.auth_unsupported)
- priv->ops.auth_unsupported (priv->ops_data, type);
-
+ sigdata.params.authUnsupported = type;
+ vnc_connection_emit_main_context(conn, VNC_AUTH_UNSUPPORTED, &sigdata);
priv->has_error = TRUE;
return !vnc_connection_has_error(conn);
}
diff --git a/src/vncconnection.h b/src/vncconnection.h
index b1505bb..c1f7711 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -59,6 +59,8 @@ struct _VncConnectionClass
void (*vnc_framebuffer_update)(VncConnection *conn, guint16 x, guint16 y, guint16 width, guint16 height);
void (*vnc_desktop_resize)(VncConnection *conn, guint16 width, guint16 height);
void (*vnc_pixel_format_changed)(VncConnection *conn, VncPixelFormat *format);
+ void (*vnc_auth_failure)(VncConnection *conn, const char *reason);
+ void (*vnc_auth_unsupported)(VncConnection *conn, unsigned int authType);
};
typedef void (rgb24_render_func)(void *, int, int, int, int, guint8 *, int);
@@ -68,9 +70,7 @@ struct vnc_connection_ops
gboolean (*auth_cred)(void *);
gboolean (*auth_type)(void *, unsigned int, unsigned int *);
gboolean (*auth_subtype)(void *, unsigned int, unsigned int *);
- gboolean (*auth_failure)(void *, const char *);
gboolean (*set_color_map_entry)(void *, int, int, int, int);
- gboolean (*auth_unsupported)(void *, unsigned int);
gboolean (*render_jpeg)(void *, rgb24_render_func *render, void *,
int, int, int, int, guint8 *, int);
gboolean (*get_preferred_pixel_format)(void *, VncPixelFormat *);
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index 40070b0..05d458c 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -110,8 +110,6 @@ struct signal_data
int signum;
GValueArray *cred_list;
- const char *msg;
- unsigned int auth_type;
};
G_DEFINE_TYPE(VncDisplay, vnc_display, GTK_TYPE_DRAWING_AREA)
@@ -890,18 +888,6 @@ static gboolean emit_signal_auth_cred(gpointer opaque)
0,
s->cred_list);
break;
- case VNC_AUTH_FAILURE:
- g_signal_emit(G_OBJECT(s->obj),
- signals[VNC_AUTH_FAILURE],
- 0,
- s->msg);
- break;
- case VNC_AUTH_UNSUPPORTED:
- g_signal_emit(G_OBJECT(s->obj),
- signals[VNC_AUTH_UNSUPPORTED],
- 0,
- s->auth_type);
- break;
case VNC_CONNECTED:
case VNC_INITIALIZED:
case VNC_DISCONNECTED:
@@ -1175,26 +1161,22 @@ static gboolean on_auth_subtype(void *opaque, unsigned int ntype, unsigned int *
return TRUE;
}
-static gboolean on_auth_failure(void *opaque, const char *msg)
+static void on_auth_failure(VncConnection *conn G_GNUC_UNUSED,
+ const char *reason,
+ gpointer opaque)
{
VncDisplay *obj = VNC_DISPLAY(opaque);
- struct signal_data s;
-
- s.msg = msg;
- emit_signal_delayed(obj, VNC_AUTH_FAILURE, &s);
- return TRUE;
+ g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_FAILURE], 0, reason);
}
-static gboolean on_auth_unsupported(void *opaque, unsigned int auth_type)
+static void on_auth_unsupported(VncConnection *conn G_GNUC_UNUSED,
+ unsigned int authType,
+ gpointer opaque)
{
VncDisplay *obj = VNC_DISPLAY(opaque);
- struct signal_data s;
-
- s.auth_type = auth_type;
- emit_signal_delayed(obj, VNC_AUTH_UNSUPPORTED, &s);
- return TRUE;
+ g_signal_emit(G_OBJECT(obj), signals[VNC_AUTH_UNSUPPORTED], 0, authType);
}
static void on_server_cut_text(void *opaque, const gchar *text)
@@ -1313,8 +1295,6 @@ static const struct vnc_connection_ops vnc_display_ops = {
.auth_cred = on_auth_cred,
.auth_type = on_auth_type,
.auth_subtype = on_auth_subtype,
- .auth_failure = on_auth_failure,
- .auth_unsupported = on_auth_unsupported,
.render_jpeg = on_render_jpeg,
.get_preferred_pixel_format = on_get_preferred_pixel_format
};
@@ -2010,6 +1990,10 @@ static void vnc_display_init(VncDisplay *display)
G_CALLBACK(on_desktop_resize), display);
g_signal_connect(G_OBJECT(priv->conn), "vnc-pixel-format-changed",
G_CALLBACK(on_pixel_format_changed), display);
+ g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-failure",
+ G_CALLBACK(on_auth_failure), display);
+ g_signal_connect(G_OBJECT(priv->conn), "vnc-auth-unsupported",
+ G_CALLBACK(on_auth_unsupported), display);
}
static int vnc_display_best_path(char *buf,
--
1.6.5.2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]