diff options
| author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-01-21 14:32:13 +0100 |
|---|---|---|
| committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-01-21 19:04:53 +0100 |
| commit | d657ef13ebc3d99816dd03bafde8fa770c3c6ded (patch) | |
| tree | cee469f5ef240a08c4c1c838a76c4a4c27eca44e /gtk | |
| parent | 5ebe5dfb90e1e9fbf01d2f8c58d40210a0688e15 (diff) | |
gtk: use a callback to handle spice_channel_recv_msg()
Diffstat (limited to 'gtk')
| -rw-r--r-- | gtk/spice-channel-priv.h | 4 | ||||
| -rw-r--r-- | gtk/spice-channel.c | 17 |
2 files changed, 14 insertions, 7 deletions
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h index 16300a2..cd3ac0e 100644 --- a/gtk/spice-channel-priv.h +++ b/gtk/spice-channel-priv.h @@ -130,6 +130,10 @@ void spice_channel_wakeup(SpiceChannel *channel); SpiceSession* spice_channel_get_session(SpiceChannel *channel); +/* coroutine context */ +typedef void (*handler_msg_in)(SpiceChannel *channel, spice_msg_in *msg, gpointer data); +void spice_channel_recv_msg(SpiceChannel *channel, handler_msg_in handler, gpointer data); + /* channel-base.c */ /* coroutine context */ void spice_channel_handle_set_ack(SpiceChannel *channel, spice_msg_in *in); diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c index f18f56f..5b96de8 100644 --- a/gtk/spice-channel.c +++ b/gtk/spice-channel.c @@ -996,7 +996,9 @@ static void spice_channel_send_msg(SpiceChannel *channel, spice_msg_out *out, gb } /* coroutine context */ -static void spice_channel_recv_msg(SpiceChannel *channel) +G_GNUC_INTERNAL +void spice_channel_recv_msg(SpiceChannel *channel, + handler_msg_in msg_handler, gpointer data) { spice_channel *c = channel->priv; spice_msg_in *in; @@ -1050,7 +1052,7 @@ static void spice_channel_recv_msg(SpiceChannel *channel) c->name, sub_in->header.type); return; } - SPICE_CHANNEL_GET_CLASS(channel)->handle_msg(channel, sub_in); + msg_handler(channel, sub_in, data); spice_msg_in_unref(sub_in); } } @@ -1076,11 +1078,11 @@ static void spice_channel_recv_msg(SpiceChannel *channel) } /* process message */ - SPICE_CHANNEL_GET_CLASS(channel)->handle_msg(channel, in); + c->msg_in = NULL; /* the function is reentrant, reset state */ + msg_handler(channel, in, data); /* release message */ - spice_msg_in_unref(c->msg_in); - c->msg_in = NULL; + spice_msg_in_unref(in); } /** @@ -1366,7 +1368,8 @@ static void spice_channel_iterate_read(SpiceChannel *channel) spice_channel_recv_auth(channel); break; case SPICE_CHANNEL_STATE_READY: - spice_channel_recv_msg(channel); + spice_channel_recv_msg(channel, + (handler_msg_in)SPICE_CHANNEL_GET_CLASS(channel)->handle_msg, NULL); break; default: g_critical("unknown state %d", c->state); @@ -1523,7 +1526,7 @@ connected: } cleanup: - SPICE_DEBUG("Doing final channel cleanup"); + SPICE_DEBUG("Coroutine exit"); SPICE_CHANNEL_GET_CLASS(channel)->channel_disconnect(channel); g_idle_add(spice_channel_delayed_unref, data); |
