summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-06-11 17:36:06 +0200
committerBenjamin Otte <otte@gnome.org>2009-06-11 17:38:03 +0200
commit883ebd74c283d873cb383709d50e1b4faf60e0f1 (patch)
tree22486495661600b8fd62f29edbd4b3a6759afb39
parentb07c3a9b238f03b203c09adbb764e88b585cfdc6 (diff)
downloadgvfs-883ebd74c283d873cb383709d50e1b4faf60e0f1.tar.gz
[FTP] get rid of connection read/write functions
use get_data_stream() instead and call read/write on that manually. Reduces the number of API.
-rw-r--r--daemon/gvfsbackendftp.c25
-rw-r--r--daemon/gvfsftpconnection.c48
-rw-r--r--daemon/gvfsftpconnection.h15
3 files changed, 15 insertions, 73 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index d137d6ad..18c8a7e4 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -672,13 +672,15 @@ do_read (GVfsBackend * backend,
GVfsBackendFtp *ftp = G_VFS_BACKEND_FTP (backend);
GVfsFtpTask task = G_VFS_FTP_TASK_INIT (ftp, G_VFS_JOB (job));
GVfsFtpConnection *conn = handle;
+ GInputStream *input;
gssize n_bytes;
- n_bytes = g_vfs_ftp_connection_read_data (conn,
- buffer,
- bytes_requested,
- task.cancellable,
- &task.error);
+ input = g_io_stream_get_input_stream (g_vfs_ftp_connection_get_data_stream (conn));
+ n_bytes = g_input_stream_read (input,
+ buffer,
+ bytes_requested,
+ task.cancellable,
+ &task.error);
if (n_bytes >= 0)
g_vfs_job_read_set_size (job, n_bytes);
@@ -826,14 +828,17 @@ do_write (GVfsBackend *backend,
GVfsBackendFtp *ftp = G_VFS_BACKEND_FTP (backend);
GVfsFtpTask task = G_VFS_FTP_TASK_INIT (ftp, G_VFS_JOB (job));
GVfsFtpConnection *conn = handle;
+ GOutputStream *output;
gssize n_bytes;
+ output = g_io_stream_get_output_stream (g_vfs_ftp_connection_get_data_stream (conn));
+
/* FIXME: use write_all here? */
- n_bytes = g_vfs_ftp_connection_write_data (conn,
- buffer,
- buffer_size,
- task.cancellable,
- &task.error);
+ n_bytes = g_output_stream_write (output,
+ buffer,
+ buffer_size,
+ task.cancellable,
+ &task.error);
if (n_bytes >= 0)
g_vfs_job_write_set_written_size (job, n_bytes);
diff --git a/daemon/gvfsftpconnection.c b/daemon/gvfsftpconnection.c
index 4c398748..ac5418f0 100644
--- a/daemon/gvfsftpconnection.c
+++ b/daemon/gvfsftpconnection.c
@@ -274,54 +274,6 @@ g_vfs_ftp_connection_get_data_stream (GVfsFtpConnection *conn)
return conn->data;
}
-gssize
-g_vfs_ftp_connection_write_data (GVfsFtpConnection *conn,
- const char * data,
- gsize len,
- GCancellable * cancellable,
- GError ** error)
-{
- g_return_val_if_fail (conn != NULL, -1);
- g_return_val_if_fail (conn->data != NULL, -1);
-
- /* FIXME: use write_all here? */
- return g_output_stream_write (g_io_stream_get_output_stream (conn->data),
- data,
- len,
- cancellable,
- error);
-}
-
-gssize
-g_vfs_ftp_connection_read_data (GVfsFtpConnection *conn,
- char * data,
- gsize len,
- GCancellable * cancellable,
- GError ** error)
-{
- g_return_val_if_fail (conn != NULL, -1);
- g_return_val_if_fail (conn->data != NULL, -1);
-
- return g_input_stream_read (g_io_stream_get_input_stream (conn->data),
- data,
- len,
- cancellable,
- error);
-}
-
-gboolean
-g_vfs_ftp_connection_read_contents (GVfsFtpConnection *conn,
- char ** data,
- gsize * len,
- GCancellable * cancellable,
- GError ** error)
-{
- g_return_val_if_fail (conn != NULL, -1);
- g_return_val_if_fail (conn->data != NULL, -1);
-
- g_assert_not_reached ();
-}
-
/**
* g_vfs_ftp_connection_is_usable:
* @conn: a connection
diff --git a/daemon/gvfsftpconnection.h b/daemon/gvfsftpconnection.h
index 12e90259..3605f267 100644
--- a/daemon/gvfsftpconnection.h
+++ b/daemon/gvfsftpconnection.h
@@ -58,21 +58,6 @@ gboolean g_vfs_ftp_connection_open_data_connection
void g_vfs_ftp_connection_close_data_connection
(GVfsFtpConnection * conn);
GIOStream * g_vfs_ftp_connection_get_data_stream (GVfsFtpConnection * conn);
-gssize g_vfs_ftp_connection_write_data (GVfsFtpConnection * conn,
- const char * data,
- gsize len,
- GCancellable * cancellable,
- GError ** error);
-gssize g_vfs_ftp_connection_read_data (GVfsFtpConnection * conn,
- char * data,
- gsize len,
- GCancellable * cancellable,
- GError ** error);
-gboolean g_vfs_ftp_connection_read_contents (GVfsFtpConnection * conn,
- char ** data,
- gsize * len,
- GCancellable * cancellable,
- GError ** error);