summaryrefslogtreecommitdiff
path: root/client/gdaemonfileoutputstream.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 14:33:46 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 14:33:46 +0000
commit83b5d35fda9f011042fabbcf410ce67284475eb2 (patch)
treed51d0acd67bad88cc5798ef237e008538abb2a5a /client/gdaemonfileoutputstream.c
parent31553c7a759a472b382afdba77e531536f64c6e9 (diff)
downloadgvfs-83b5d35fda9f011042fabbcf410ce67284475eb2.tar.gz
Implement etag sending on close in daemon stream
Original git commit by Alexander Larsson <alexl@redhat.com> at 1185358218 +0200 svn path=/trunk/; revision=709
Diffstat (limited to 'client/gdaemonfileoutputstream.c')
-rw-r--r--client/gdaemonfileoutputstream.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/client/gdaemonfileoutputstream.c b/client/gdaemonfileoutputstream.c
index 51e21ac1..8ba48777 100644
--- a/client/gdaemonfileoutputstream.c
+++ b/client/gdaemonfileoutputstream.c
@@ -125,6 +125,9 @@ struct _GDaemonFileOutputStream {
GString *input_buffer;
GString *output_buffer;
+
+ char *etag;
+
};
static gssize g_daemon_file_output_stream_write (GOutputStream *stream,
@@ -139,6 +142,9 @@ static GFileInfo *g_daemon_file_output_stream_get_file_info (GFileOutputStream
char *attributes,
GCancellable *cancellable,
GError **error);
+static char *g_daemon_file_output_stream_get_etag (GFileOutputStream *stream,
+ GCancellable *cancellable,
+ GError **error);
static goffset g_daemon_file_output_stream_tell (GFileOutputStream *stream);
static gboolean g_daemon_file_output_stream_can_seek (GFileOutputStream *stream);
static gboolean g_daemon_file_output_stream_seek (GFileOutputStream *stream,
@@ -182,6 +188,8 @@ g_daemon_file_output_stream_finalize (GObject *object)
g_string_free (file->input_buffer, TRUE);
g_string_free (file->output_buffer, TRUE);
+
+ g_free (file->etag);
if (G_OBJECT_CLASS (g_daemon_file_output_stream_parent_class)->finalize)
(*G_OBJECT_CLASS (g_daemon_file_output_stream_parent_class)->finalize) (object);
@@ -208,7 +216,7 @@ g_daemon_file_output_stream_class_init (GDaemonFileOutputStreamClass *klass)
file_stream_class->can_seek = g_daemon_file_output_stream_can_seek;
file_stream_class->seek = g_daemon_file_output_stream_seek;
file_stream_class->get_file_info = g_daemon_file_output_stream_get_file_info;
-
+ file_stream_class->get_etag = g_daemon_file_output_stream_get_etag;
}
static void
@@ -278,8 +286,10 @@ get_reply_header_missing_bytes (GString *buffer)
type = g_ntohl (reply->type);
arg2 = g_ntohl (reply->arg2);
-
- if (type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_ERROR)
+
+ /* ERROR and CLOSED has extra data w/ len in arg2 */
+ if (type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_ERROR ||
+ type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED)
return G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE + arg2 - buffer->len;
return 0;
}
@@ -679,6 +689,8 @@ iterate_close_state_machine (GDaemonFileOutputStream *file, IOOperationData *io_
else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED)
{
op->ret_val = TRUE;
+ if (reply.arg2 > 0)
+ file->etag = g_strndup (data, reply.arg2);
g_string_truncate (file->input_buffer, 0);
return STATE_OP_DONE;
}
@@ -941,6 +953,23 @@ g_daemon_file_output_stream_seek (GFileOutputStream *stream,
return op.ret_val;
}
+static char *
+g_daemon_file_output_stream_get_etag (GFileOutputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GDaemonFileOutputStream *file;
+
+ file = G_DAEMON_FILE_OUTPUT_STREAM (stream);
+
+ if (file->etag)
+ return file->etag;
+
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("etag not supported on stream"));
+ return NULL;
+}
+
static GFileInfo *
g_daemon_file_output_stream_get_file_info (GFileOutputStream *stream,
char *attributes,