[PATCH 16/25] Replace 'server_cut_text' operation with a signal
- From: "Daniel P. Berrange" <berrange redhat com>
- To: gtk-vnc-list gnome org
- Cc: "Daniel P. Berrange" <berrange redhat com>
- Subject: [PATCH 16/25] Replace 'server_cut_text' operation with a signal
- Date: Sat, 21 Nov 2009 13:28:05 +0000
Remove the 'server_cut_text' operation from VncConnection.
Introduce a signal 'vnc-server-cut-text' for VncConnection and
pass in the text
---
src/vncconnection.c | 39 ++++++++++++++++++++++++++++++++-------
src/vncconnection.h | 2 +-
src/vncdisplay.c | 23 +++++------------------
3 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/src/vncconnection.c b/src/vncconnection.c
index db1bd83..86bb78b 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -190,11 +190,12 @@ enum {
VNC_CURSOR_CHANGED,
VNC_POINTER_MODE_CHANGED,
VNC_BELL,
+ VNC_SERVER_CUT_TEXT,
VNC_LAST_SIGNAL,
};
-static guint signals[VNC_LAST_SIGNAL] = { 0, 0, 0, };
+static guint signals[VNC_LAST_SIGNAL] = { 0, 0, 0, 0, };
#define nibhi(a) (((a) >> 4) & 0x0F)
#define niblo(a) ((a) & 0x0F)
@@ -366,6 +367,7 @@ struct signal_data
union {
VncCursor *cursor;
gboolean absPointer;
+ GString *text;
} params;
};
@@ -393,6 +395,13 @@ static gboolean do_vnc_connection_emit_main_context(gpointer opaque)
signals[data->signum],
0);
break;
+
+ case VNC_SERVER_CUT_TEXT:
+ g_signal_emit(G_OBJECT(data->conn),
+ signals[data->signum],
+ 0,
+ data->params.text);
+ break;
}
coroutine_yieldto(data->caller, NULL);
@@ -2160,18 +2169,23 @@ static void vnc_connection_bell(VncConnection *conn)
vnc_connection_emit_main_context(conn, VNC_BELL, &sigdata);
}
-static void vnc_connection_server_cut_text(VncConnection *conn, const void *data,
+static void vnc_connection_server_cut_text(VncConnection *conn,
+ const void *data,
size_t len)
{
VncConnectionPrivate *priv = conn->priv;
+ struct signal_data sigdata;
+ GString *text;
- if (priv->has_error || !priv->ops.server_cut_text)
+ if (priv->has_error)
return;
- if (!priv->ops.server_cut_text(priv->ops_data, data, len)) {
- GVNC_DEBUG("Closing the connection: vnc_connection_server_cut_text");
- priv->has_error = TRUE;
- }
+ text = g_string_new_len ((const gchar *)data, len);
+ sigdata.params.text = text;
+
+ vnc_connection_emit_main_context(conn, VNC_SERVER_CUT_TEXT, &sigdata);
+
+ g_free(text);
}
static void vnc_connection_resize(VncConnection *conn, int width, int height)
@@ -3660,6 +3674,17 @@ static void vnc_connection_class_init(VncConnectionClass *klass)
G_TYPE_NONE,
0);
+ signals[VNC_SERVER_CUT_TEXT] =
+ g_signal_new ("vnc-server-cut-text",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (VncConnectionClass, vnc_server_cut_text),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+
g_type_class_add_private(klass, sizeof(VncConnectionPrivate));
}
diff --git a/src/vncconnection.h b/src/vncconnection.h
index 897620c..1522f69 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -55,6 +55,7 @@ struct _VncConnectionClass
void (*vnc_cursor_changed)(VncConnection *conn, VncCursor *cursor);
void (*vnc_pointer_mode_changed)(VncConnection *conn, gboolean absPointer);
void (*vnc_bell)(VncConnection *conn);
+ void (*vnc_server_cut_text)(VncConnection *conn, const GString *text);
};
typedef void (rgb24_render_func)(void *, int, int, int, int, guint8 *, int);
@@ -67,7 +68,6 @@ struct vnc_connection_ops
gboolean (*auth_failure)(void *, const char *);
gboolean (*update)(void *, int, int, int, int);
gboolean (*set_color_map_entry)(void *, int, int, int, int);
- gboolean (*server_cut_text)(void *, const void *, size_t);
gboolean (*resize)(void *, int, int);
gboolean (*pixel_format)(void *, VncPixelFormat *);
gboolean (*auth_unsupported)(void *, unsigned int);
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index c6f4d2a..c1a9de1 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -114,7 +114,6 @@ struct signal_data
int height;
const char *msg;
unsigned int auth_type;
- GString *str;
};
G_DEFINE_TYPE(VncDisplay, vnc_display, GTK_TYPE_DRAWING_AREA)
@@ -911,12 +910,6 @@ static gboolean emit_signal_auth_cred(gpointer opaque)
0,
s->auth_type);
break;
- case VNC_SERVER_CUT_TEXT:
- g_signal_emit(G_OBJECT(s->obj),
- signals[VNC_SERVER_CUT_TEXT],
- 0,
- s->str->str);
- break;
case VNC_CONNECTED:
case VNC_INITIALIZED:
case VNC_DISCONNECTED:
@@ -1211,21 +1204,14 @@ static gboolean on_auth_unsupported(void *opaque, unsigned int auth_type)
return TRUE;
}
-static gboolean on_server_cut_text(void *opaque, const void* text, size_t len)
+static void on_server_cut_text(void *opaque, const gchar *text)
{
VncDisplay *obj = VNC_DISPLAY(opaque);
- GString *str;
- struct signal_data s;
if (obj->priv->read_only)
- return TRUE;
-
- str = g_string_new_len ((const gchar *)text, len);
- s.str = str;
- emit_signal_delayed(obj, VNC_SERVER_CUT_TEXT, &s);
+ return;
- g_string_free (str, TRUE);
- return TRUE;
+ g_signal_emit(G_OBJECT(obj), signals[VNC_SERVER_CUT_TEXT], 0, text);
}
static void on_bell(VncConnection *conn G_GNUC_UNUSED,
@@ -1339,7 +1325,6 @@ static const struct vnc_connection_ops vnc_display_ops = {
.resize = on_resize,
.pixel_format = on_pixel_format,
.auth_unsupported = on_auth_unsupported,
- .server_cut_text = on_server_cut_text,
.render_jpeg = on_render_jpeg,
.get_preferred_pixel_format = on_get_preferred_pixel_format
};
@@ -2027,6 +2012,8 @@ static void vnc_display_init(VncDisplay *display)
G_CALLBACK(on_pointer_mode_changed), display);
g_signal_connect(G_OBJECT(priv->conn), "vnc-bell",
G_CALLBACK(on_bell), display);
+ g_signal_connect(G_OBJECT(priv->conn), "vnc-server-cut-text",
+ G_CALLBACK(on_server_cut_text), 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]