Allow open_fd() to be called with -1

In this case, a valid fd will be requested via the
SpiceChannel::open-fd signal.
This commit is contained in:
Marc-André Lureau 2012-02-29 14:01:45 +01:00
parent 919af70d78
commit 161c0fc6b0
2 changed files with 14 additions and 4 deletions

View File

@ -2302,10 +2302,14 @@ gboolean spice_channel_connect(SpiceChannel *channel)
/**
* spice_channel_open_fd:
* @channel:
* @fd: a file descriptor (socket)
* @fd: a file descriptor (socket) or -1.
* request mechanism
*
* Connect the channel using @fd socket.
*
* If @fd is -1, a valid fd will be requested later via the
* SpiceChannel::open-fd signal.
*
* Returns: %TRUE on success.
**/
gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
@ -2313,7 +2317,7 @@ gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
g_return_val_if_fail(c != NULL, FALSE);
g_return_val_if_fail(fd >= 0, FALSE);
g_return_val_if_fail(fd >= -1, FALSE);
c->fd = fd;

View File

@ -1042,12 +1042,15 @@ gboolean spice_session_connect(SpiceSession *session)
/**
* spice_session_open_fd:
* @session:
* @fd: a file descriptor
* @fd: a file descriptor (socket) or -1
*
* Open the session using the provided @fd socket file
* descriptor. This is useful if you create the fd yourself, for
* example to setup a SSH tunnel.
*
* If @fd is -1, a valid fd will be requested later via the
* SpiceChannel::open-fd signal.
*
* Returns:
**/
gboolean spice_session_open_fd(SpiceSession *session, int fd)
@ -1055,14 +1058,17 @@ gboolean spice_session_open_fd(SpiceSession *session, int fd)
SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
g_return_val_if_fail(s != NULL, FALSE);
g_return_val_if_fail(fd >= 0, FALSE);
g_return_val_if_fail(fd >= -1, FALSE);
spice_session_disconnect(session);
s->disconnecting = FALSE;
s->client_provided_sockets = TRUE;
g_warn_if_fail(s->cmain == NULL);
s->cmain = spice_channel_new(session, SPICE_CHANNEL_MAIN, 0);
glz_decoder_window_clear(s->glz_window);
return spice_channel_open_fd(s->cmain, fd);
}