[gtk-vnc] Replace 'server_cut_text' operation with a signal
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] Replace 'server_cut_text' operation with a signal
- Date: Sat, 20 Mar 2010 21:30:18 +0000 (UTC)
commit 4a130e727c2737046256903d8bcd9a40ee33e59b
Author: Daniel P. Berrange <berrange redhat com>
Date: Fri Nov 20 17:04:36 2009 +0000
Replace 'server_cut_text' operation with a signal
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 d7bcbf5..417adee 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);
@@ -2205,18 +2214,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)
@@ -3705,6 +3719,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 1d155c2..9dfebfc 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)
@@ -914,12 +913,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:
@@ -1214,21 +1207,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,
@@ -1342,7 +1328,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
};
@@ -2030,6 +2015,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 char *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]