diff options
author | Benjamin Otte <otte@gnome.org> | 2009-06-02 13:19:51 +0200 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2009-06-11 10:05:40 +0200 |
commit | e62142b001e218d268a85f2f90993cdf42148fae (patch) | |
tree | 4948320f6778cb04118a1c6541291eac338fed73 /daemon/gvfsftpconnection.c | |
parent | 2f5c4dcfd579f9b9cceb8eb08b71d4318e9c03b6 (diff) | |
download | gvfs-e62142b001e218d268a85f2f90993cdf42148fae.tar.gz |
[FTP] introduce GVfsFtpTask
split out the old FtpConnection struct into a separate GVfsFtpTask
structure that acts as a one-stop solution to vfuncs. It keeps track of
all important structures:
- the backend
- the current job
- the potential connection to the server
- the error state
during the lifetime of a backend vfunc and supplies convenience
functions to ease implementing these vfuncs. The API of gvfsftptask.h is
documented.
Diffstat (limited to 'daemon/gvfsftpconnection.c')
-rw-r--r-- | daemon/gvfsftpconnection.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/daemon/gvfsftpconnection.c b/daemon/gvfsftpconnection.c index 7a28fb89..485ad68d 100644 --- a/daemon/gvfsftpconnection.c +++ b/daemon/gvfsftpconnection.c @@ -275,3 +275,30 @@ g_vfs_ftp_connection_read_contents (GVfsFtpConnection *conn, g_assert_not_reached (); } +/** + * g_vfs_ftp_connection_is_usable: + * @conn: a connection + * + * Checks if this connection can still be used to send new commands. For + * example, if the connection was closed, this is not possible and this + * function will return %FALSE. + * + * Returns: %TRUE if the connection is still usable + **/ +gboolean +g_vfs_ftp_connection_is_usable (GVfsFtpConnection *conn) +{ + GIOCondition cond; + + g_return_val_if_fail (conn != NULL, FALSE); + + /* FIXME: return FALSE here if a send or receive failed irrecoverably */ + + cond = G_IO_ERR | G_IO_HUP; + cond = g_socket_condition_check (g_socket_connection_get_socket (G_SOCKET_CONNECTION (conn->commands)), cond); + if (cond) + return FALSE; + + return TRUE; +} + |