summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 11:57:08 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 11:57:08 +0000
commitfd9e5a6cd9eda6908eb48cbd433434f192b90922 (patch)
tree505a6ec4c00957ae12b72be3d1e2984f212ab774
parentbfa91af000af5511c7a14ecd3427e6859653b62f (diff)
downloadgvfs-fd9e5a6cd9eda6908eb48cbd433434f192b90922.tar.gz
Revert "Move GVfsReadChannel into .c file, remove priv"
This reverts commit 8c69e9308a565dfc6774a5c0bf351da363b11a0c. Original git commit by Alexander Larsson <alex@greebo.(none)> at 1171622056 +0100 svn path=/trunk/; revision=353
-rw-r--r--daemon/gvfsreadchannel.c193
-rw-r--r--daemon/gvfsreadchannel.h8
2 files changed, 108 insertions, 93 deletions
diff --git a/daemon/gvfsreadchannel.c b/daemon/gvfsreadchannel.c
index 839bfa0b..4c6362e4 100644
--- a/daemon/gvfsreadchannel.c
+++ b/daemon/gvfsreadchannel.c
@@ -23,6 +23,14 @@
static void g_vfs_read_channel_job_source_iface_init (GVfsJobSourceIface *iface);
+G_DEFINE_TYPE_WITH_CODE (GVfsReadChannel, g_vfs_read_channel, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (G_TYPE_VFS_JOB_SOURCE,
+ g_vfs_read_channel_job_source_iface_init))
+
+enum {
+ PROP_0,
+};
+
typedef struct
{
GVfsReadChannel *read_channel;
@@ -31,10 +39,8 @@ typedef struct
int buffer_size;
} RequestReader;
-struct _GVfsReadChannel
+struct _GVfsReadChannelPrivate
{
- GObject parent_instance;
-
GVfsBackend *backend;
gboolean connection_closed;
GInputStream *command_stream;
@@ -56,10 +62,6 @@ struct _GVfsReadChannel
gsize output_data_pos;
};
-G_DEFINE_TYPE_WITH_CODE (GVfsReadChannel, g_vfs_read_channel, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_VFS_JOB_SOURCE,
- g_vfs_read_channel_job_source_iface_init))
-
static void start_request_reader (GVfsReadChannel *channel);
static void
@@ -69,26 +71,26 @@ g_vfs_read_channel_finalize (GObject *object)
read_channel = G_VFS_READ_CHANNEL (object);
- if (read_channel->current_job)
- g_object_unref (read_channel->current_job);
- read_channel->current_job = NULL;
+ if (read_channel->priv->current_job)
+ g_object_unref (read_channel->priv->current_job);
+ read_channel->priv->current_job = NULL;
- if (read_channel->reply_stream)
- g_object_unref (read_channel->reply_stream);
- read_channel->reply_stream = NULL;
+ if (read_channel->priv->reply_stream)
+ g_object_unref (read_channel->priv->reply_stream);
+ read_channel->priv->reply_stream = NULL;
- if (read_channel->request_reader)
- read_channel->request_reader->read_channel = NULL;
- read_channel->request_reader = NULL;
+ if (read_channel->priv->request_reader)
+ read_channel->priv->request_reader->read_channel = NULL;
+ read_channel->priv->request_reader = NULL;
- if (read_channel->command_stream)
- g_object_unref (read_channel->command_stream);
- read_channel->command_stream = NULL;
+ if (read_channel->priv->command_stream)
+ g_object_unref (read_channel->priv->command_stream);
+ read_channel->priv->command_stream = NULL;
- if (read_channel->remote_fd != -1)
- close (read_channel->remote_fd);
+ if (read_channel->priv->remote_fd != -1)
+ close (read_channel->priv->remote_fd);
- g_assert (read_channel->backend_handle == NULL);
+ g_assert (read_channel->priv->backend_handle == NULL);
if (G_OBJECT_CLASS (g_vfs_read_channel_parent_class)->finalize)
(*G_OBJECT_CLASS (g_vfs_read_channel_parent_class)->finalize) (object);
@@ -104,28 +106,33 @@ g_vfs_read_channel_class_init (GVfsReadChannelClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (klass, sizeof (GVfsReadChannelPrivate));
+
gobject_class->finalize = g_vfs_read_channel_finalize;
}
static void
g_vfs_read_channel_init (GVfsReadChannel *channel)
{
- channel->remote_fd = -1;
+ channel->priv = G_TYPE_INSTANCE_GET_PRIVATE (channel,
+ G_TYPE_VFS_READ_CHANNEL,
+ GVfsReadChannelPrivate);
+ channel->priv->remote_fd = -1;
}
static void
g_vfs_read_channel_connection_closed (GVfsReadChannel *channel)
{
- if (channel->connection_closed)
+ if (channel->priv->connection_closed)
return;
- channel->connection_closed = TRUE;
+ channel->priv->connection_closed = TRUE;
- if (channel->current_job == NULL &&
- channel->backend_handle != NULL)
+ if (channel->priv->current_job == NULL &&
+ channel->priv->backend_handle != NULL)
{
- channel->current_job = g_vfs_job_close_read_new (channel, channel->backend_handle, channel->backend);
- channel->current_job_seq_nr = 0;
- g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->current_job);
+ channel->priv->current_job = g_vfs_job_close_read_new (channel, channel->priv->backend_handle, channel->priv->backend);
+ channel->priv->current_job_seq_nr = 0;
+ g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->priv->current_job);
}
/* Otherwise we'll close when current_job is finished */
}
@@ -143,7 +150,7 @@ got_command (GVfsReadChannel *channel,
g_print ("got_command %d %d %d %d\n", command, seq_nr, arg1, arg2);
- if (channel->current_job != NULL)
+ if (channel->priv->current_job != NULL)
{
if (command != G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_CANCEL)
{
@@ -151,8 +158,8 @@ got_command (GVfsReadChannel *channel,
return;
}
- if (arg1 == channel->current_job_seq_nr)
- g_vfs_job_cancel (channel->current_job);
+ if (arg1 == channel->priv->current_job_seq_nr)
+ g_vfs_job_cancel (channel->priv->current_job);
return;
}
@@ -161,14 +168,14 @@ got_command (GVfsReadChannel *channel,
{
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_READ:
job = g_vfs_job_read_new (channel,
- channel->backend_handle,
+ channel->priv->backend_handle,
arg1,
- channel->backend);
+ channel->priv->backend);
break;
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_CLOSE:
job = g_vfs_job_close_read_new (channel,
- channel->backend_handle,
- channel->backend);
+ channel->priv->backend_handle,
+ channel->priv->backend);
break;
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SEEK_CUR:
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SEEK_END:
@@ -179,12 +186,12 @@ got_command (GVfsReadChannel *channel,
else if (command == G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SEEK_CUR)
seek_type = G_SEEK_CUR;
- channel->seek_generation++;
+ channel->priv->seek_generation++;
job = g_vfs_job_seek_read_new (channel,
- channel->backend_handle,
+ channel->priv->backend_handle,
seek_type,
((goffset)arg1) | (((goffset)arg2) << 32),
- channel->backend);
+ channel->priv->backend);
break;
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_CANCEL:
@@ -203,9 +210,9 @@ got_command (GVfsReadChannel *channel,
if (job)
{
- channel->current_job = job;
- channel->current_job_seq_nr = seq_nr;
- g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->current_job);
+ channel->priv->current_job = job;
+ channel->priv->current_job_seq_nr = seq_nr;
+ g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->priv->current_job);
}
}
@@ -233,7 +240,7 @@ command_read_cb (GInputStream *input_stream,
if (count_read <= 0)
{
- reader->read_channel->request_reader = NULL;
+ reader->read_channel->priv->request_reader = NULL;
g_vfs_read_channel_connection_closed (reader->read_channel);
g_object_unref (reader->command_stream);
g_free (reader);
@@ -282,7 +289,7 @@ start_request_reader (GVfsReadChannel *channel)
reader = g_new0 (RequestReader, 1);
reader->read_channel = channel;
- reader->command_stream = g_object_ref (channel->command_stream);
+ reader->command_stream = g_object_ref (channel->priv->command_stream);
reader->buffer_size = 0;
g_input_stream_read_async (reader->command_stream,
@@ -293,7 +300,7 @@ start_request_reader (GVfsReadChannel *channel)
reader,
NULL);
- channel->request_reader = reader;
+ channel->priv->request_reader = reader;
}
@@ -316,16 +323,16 @@ send_reply_cb (GOutputStream *output_stream,
goto error_out;
}
- if (channel->reply_buffer_pos < G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE)
+ if (channel->priv->reply_buffer_pos < G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE)
{
- channel->reply_buffer_pos += bytes_written;
+ channel->priv->reply_buffer_pos += bytes_written;
/* Write more of reply header if needed */
- if (channel->reply_buffer_pos < G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE)
+ if (channel->priv->reply_buffer_pos < G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE)
{
- g_output_stream_write_async (channel->reply_stream,
- channel->reply_buffer + channel->reply_buffer_pos,
- G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE - channel->reply_buffer_pos,
+ g_output_stream_write_async (channel->priv->reply_stream,
+ channel->priv->reply_buffer + channel->priv->reply_buffer_pos,
+ G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE - channel->priv->reply_buffer_pos,
0,
send_reply_cb, channel,
NULL);
@@ -334,15 +341,15 @@ send_reply_cb (GOutputStream *output_stream,
bytes_written = 0;
}
- channel->output_data_pos += bytes_written;
+ channel->priv->output_data_pos += bytes_written;
/* Write more of output_data if needed */
- if (channel->output_data != NULL &&
- channel->output_data_pos < channel->output_data_size)
+ if (channel->priv->output_data != NULL &&
+ channel->priv->output_data_pos < channel->priv->output_data_size)
{
- g_output_stream_write_async (channel->reply_stream,
- channel->output_data + channel->output_data_pos,
- channel->output_data_size - channel->output_data_pos,
+ g_output_stream_write_async (channel->priv->reply_stream,
+ channel->priv->output_data + channel->priv->output_data_pos,
+ channel->priv->output_data_size - channel->priv->output_data_pos,
0,
send_reply_cb, channel,
NULL);
@@ -352,23 +359,23 @@ send_reply_cb (GOutputStream *output_stream,
error_out:
/* Sent full reply */
- channel->output_data = NULL;
+ channel->priv->output_data = NULL;
- job = channel->current_job;
- channel->current_job = NULL;
+ job = channel->priv->current_job;
+ channel->priv->current_job = NULL;
g_vfs_job_emit_finished (job);
if (G_IS_VFS_JOB_CLOSE_READ (job))
{
g_vfs_job_source_closed (G_VFS_JOB_SOURCE (channel));
- channel->backend_handle = NULL;
+ channel->priv->backend_handle = NULL;
}
- else if (channel->connection_closed)
+ else if (channel->priv->connection_closed)
{
- channel->current_job = g_vfs_job_close_read_new (channel, channel->backend_handle,
- channel->backend);
- channel->current_job_seq_nr = 0;
- g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->current_job);
+ channel->priv->current_job = g_vfs_job_close_read_new (channel, channel->priv->backend_handle,
+ channel->priv->backend);
+ channel->priv->current_job_seq_nr = 0;
+ g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->priv->current_job);
}
g_object_unref (job);
@@ -383,16 +390,16 @@ send_reply (GVfsReadChannel *channel,
gsize data_len)
{
- channel->output_data = data;
- channel->output_data_size = data_len;
- channel->output_data_pos = 0;
+ channel->priv->output_data = data;
+ channel->priv->output_data_size = data_len;
+ channel->priv->output_data_pos = 0;
if (use_header)
{
- channel->reply_buffer_pos = 0;
+ channel->priv->reply_buffer_pos = 0;
- g_output_stream_write_async (channel->reply_stream,
- channel->reply_buffer,
+ g_output_stream_write_async (channel->priv->reply_stream,
+ channel->priv->reply_buffer,
G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE,
0,
send_reply_cb, channel,
@@ -400,11 +407,11 @@ send_reply (GVfsReadChannel *channel,
}
else
{
- channel->reply_buffer_pos = G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE;
+ channel->priv->reply_buffer_pos = G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE;
- g_output_stream_write_async (channel->reply_stream,
- channel->output_data,
- channel->output_data_size,
+ g_output_stream_write_async (channel->priv->reply_stream,
+ channel->priv->output_data,
+ channel->priv->output_data_size,
0,
send_reply_cb, channel,
NULL);
@@ -420,7 +427,7 @@ g_vfs_read_channel_send_error (GVfsReadChannel *read_channel,
char *data;
gsize data_len;
- data = g_error_to_daemon_reply (error, read_channel->current_job_seq_nr, &data_len);
+ data = g_error_to_daemon_reply (error, read_channel->priv->current_job_seq_nr, &data_len);
send_reply (read_channel, FALSE, data, data_len);
}
@@ -433,9 +440,9 @@ g_vfs_read_channel_send_seek_offset (GVfsReadChannel *read_channel,
{
GVfsDaemonSocketProtocolReply *reply;
- reply = (GVfsDaemonSocketProtocolReply *)read_channel->reply_buffer;
+ reply = (GVfsDaemonSocketProtocolReply *)read_channel->priv->reply_buffer;
reply->type = g_htonl (G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SEEK_POS);
- reply->seq_nr = g_htonl (read_channel->current_job_seq_nr);
+ reply->seq_nr = g_htonl (read_channel->priv->current_job_seq_nr);
reply->arg1 = g_htonl (offset & 0xffffffff);
reply->arg2 = g_htonl (offset >> 32);
@@ -449,9 +456,9 @@ g_vfs_read_channel_send_closed (GVfsReadChannel *read_channel)
{
GVfsDaemonSocketProtocolReply *reply;
- reply = (GVfsDaemonSocketProtocolReply *)read_channel->reply_buffer;
+ reply = (GVfsDaemonSocketProtocolReply *)read_channel->priv->reply_buffer;
reply->type = g_htonl (G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED);
- reply->seq_nr = g_htonl (read_channel->current_job_seq_nr);
+ reply->seq_nr = g_htonl (read_channel->priv->current_job_seq_nr);
reply->arg1 = g_htonl (0);
reply->arg2 = g_htonl (0);
@@ -467,11 +474,11 @@ g_vfs_read_channel_send_data (GVfsReadChannel *read_channel,
{
GVfsDaemonSocketProtocolReply *reply;
- reply = (GVfsDaemonSocketProtocolReply *)read_channel->reply_buffer;
+ reply = (GVfsDaemonSocketProtocolReply *)read_channel->priv->reply_buffer;
reply->type = g_htonl (G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_DATA);
- reply->seq_nr = g_htonl (read_channel->current_job_seq_nr);
+ reply->seq_nr = g_htonl (read_channel->priv->current_job_seq_nr);
reply->arg1 = g_htonl (count);
- reply->arg2 = g_htonl (read_channel->seek_generation);
+ reply->arg2 = g_htonl (read_channel->priv->seek_generation);
send_reply (read_channel, TRUE, buffer, count);
}
@@ -494,10 +501,10 @@ g_vfs_read_channel_new (GVfsBackend *backend,
}
channel = g_object_new (G_TYPE_VFS_READ_CHANNEL, NULL);
- channel->backend = backend;
- channel->command_stream = g_input_stream_socket_new (socket_fds[0], TRUE);
- channel->reply_stream = g_output_stream_socket_new (socket_fds[0], FALSE);
- channel->remote_fd = socket_fds[1];
+ channel->priv->backend = backend;
+ channel->priv->command_stream = g_input_stream_socket_new (socket_fds[0], TRUE);
+ channel->priv->reply_stream = g_output_stream_socket_new (socket_fds[0], FALSE);
+ channel->priv->remote_fd = socket_fds[1];
start_request_reader (channel);
@@ -508,20 +515,20 @@ int
g_vfs_read_channel_steal_remote_fd (GVfsReadChannel *channel)
{
int fd;
- fd = channel->remote_fd;
- channel->remote_fd = -1;
+ fd = channel->priv->remote_fd;
+ channel->priv->remote_fd = -1;
return fd;
}
GVfsBackend *
g_vfs_read_channel_get_backend (GVfsReadChannel *read_channel)
{
- return read_channel->backend;
+ return read_channel->priv->backend;
}
void
g_vfs_read_channel_set_backend_handle (GVfsReadChannel *read_channel,
GVfsBackendHandle backend_handle)
{
- read_channel->backend_handle = backend_handle;
+ read_channel->priv->backend_handle = backend_handle;
}
diff --git a/daemon/gvfsreadchannel.h b/daemon/gvfsreadchannel.h
index 7139bf58..11e845bf 100644
--- a/daemon/gvfsreadchannel.h
+++ b/daemon/gvfsreadchannel.h
@@ -17,6 +17,14 @@ G_BEGIN_DECLS
typedef struct _GVfsReadChannel GVfsReadChannel;
typedef struct _GVfsReadChannelClass GVfsReadChannelClass;
+typedef struct _GVfsReadChannelPrivate GVfsReadChannelPrivate;
+
+struct _GVfsReadChannel
+{
+ GObject parent_instance;
+
+ GVfsReadChannelPrivate *priv;
+};
struct _GVfsReadChannelClass
{