[gvfs] afp: volume browsing now works
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] afp: volume browsing now works
- Date: Thu, 25 Aug 2011 19:21:16 +0000 (UTC)
commit a877c0b1863222c1a9ca07aad25065872b0f88fc
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Fri Jun 3 13:53:25 2011 +0200
afp: volume browsing now works
daemon/gvfsafpconnection.c | 55 +++++++++++++++++++------------
daemon/gvfsbackendafp.c | 76 ++++++++++++++++++++++++-------------------
2 files changed, 76 insertions(+), 55 deletions(-)
---
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c
index db77eaf..7fed840 100644
--- a/daemon/gvfsafpconnection.c
+++ b/daemon/gvfsafpconnection.c
@@ -292,21 +292,27 @@ dispatch_reply (GVfsAfpConnection *afp_connection)
RequestData *req_data;
- g_debug ("DISPATCH!!!\n");
- req_data = g_hash_table_lookup (priv->request_hash,
- GUINT_TO_POINTER (priv->read_dsi_header.requestID));
- if (req_data)
+ if (priv->read_dsi_header.command == DSI_TICKLE)
{
- GVfsAfpReply *reply;
-
- reply = g_vfs_afp_reply_new (priv->read_dsi_header.errorCode, priv->data,
- priv->read_dsi_header.totalDataLength);
- req_data->reply_cb (afp_connection, reply, NULL, req_data->user_data);
- g_hash_table_remove (priv->request_hash, GUINT_TO_POINTER (priv->read_dsi_header.requestID));
- return;
+ /* TODO: should send back a DSI_TICKLE command */
}
+
+ else if (priv->read_dsi_header.command == DSI_COMMAND)
+ {
+ req_data = g_hash_table_lookup (priv->request_hash,
+ GUINT_TO_POINTER (priv->read_dsi_header.requestID));
+ if (req_data)
+ {
+ GVfsAfpReply *reply;
- g_free (priv->data);
+ reply = g_vfs_afp_reply_new (priv->read_dsi_header.errorCode, priv->data,
+ priv->read_dsi_header.totalDataLength);
+ req_data->reply_cb (afp_connection, reply, NULL, req_data->user_data);
+ g_hash_table_remove (priv->request_hash, GUINT_TO_POINTER (priv->read_dsi_header.requestID));
+ }
+ }
+ else
+ g_free (priv->data);
}
static void read_reply (GVfsAfpConnection *afp_connection);
@@ -367,6 +373,10 @@ read_dsi_header_cb (GObject *object, GAsyncResult *res, gpointer user_data)
return;
}
+ priv->read_dsi_header.requestID = GUINT16_FROM_BE (priv->read_dsi_header.requestID);
+ priv->read_dsi_header.errorCode = GUINT32_FROM_BE (priv->read_dsi_header.errorCode);
+ priv->read_dsi_header.totalDataLength = GUINT32_FROM_BE (priv->read_dsi_header.totalDataLength);
+
if (priv->read_dsi_header.totalDataLength > 0)
{
priv->data = g_malloc (priv->read_dsi_header.totalDataLength);
@@ -388,7 +398,7 @@ read_reply (GVfsAfpConnection *afp_connection)
GInputStream *input;
input = g_io_stream_get_input_stream (priv->conn);
-
+
priv->bytes_read = 0;
priv->data = NULL;
g_input_stream_read_async (input, &priv->read_dsi_header, sizeof (DSIHeader), 0, NULL,
@@ -406,8 +416,6 @@ write_command_cb (GObject *object, GAsyncResult *res, gpointer user_data)
gssize bytes_written;
GError *err = NULL;
-
- char *data;
gsize size;
bytes_written = g_output_stream_write_finish (output, res, &err);
@@ -418,12 +426,16 @@ write_command_cb (GObject *object, GAsyncResult *res, gpointer user_data)
g_error_free (err);
}
- data = g_vfs_afp_command_get_data (request_data->command);
size = g_vfs_afp_command_get_size (request_data->command);
priv->bytes_written += bytes_written;
if (priv->bytes_written < size)
{
+ char *data;
+
+ data = g_vfs_afp_command_get_data (request_data->command);
+
+
g_output_stream_write_async (output, data + priv->bytes_written,
size - priv->bytes_written, 0, NULL,
write_command_cb, request_data);
@@ -431,7 +443,7 @@ write_command_cb (GObject *object, GAsyncResult *res, gpointer user_data)
}
g_hash_table_insert (priv->request_hash,
- GUINT_TO_POINTER (priv->write_dsi_header.requestID),
+ GUINT_TO_POINTER (GUINT16_FROM_BE (priv->write_dsi_header.requestID)),
request_data);
send_request (request_data->conn);
@@ -451,7 +463,6 @@ write_dsi_header_cb (GObject *object, GAsyncResult *res, gpointer user_data)
gsize size;
bytes_written = g_output_stream_write_finish (output, res, &err);
- g_debug ("Bytes written:%d\n", bytes_written);
if (bytes_written == -1)
{
request_data->reply_cb (request_data->conn, NULL, err, request_data->user_data);
@@ -511,9 +522,9 @@ send_request (GVfsAfpConnection *afp_connection)
priv->write_dsi_header.flags = 0x00;
priv->write_dsi_header.command = dsi_command;
- priv->write_dsi_header.requestID = get_request_id (afp_connection);
- priv->write_dsi_header.writeOffset = writeOffset;
- priv->write_dsi_header.totalDataLength = g_vfs_afp_command_get_size (request_data->command);
+ priv->write_dsi_header.requestID = GUINT16_TO_BE (get_request_id (afp_connection));
+ priv->write_dsi_header.writeOffset = GUINT32_TO_BE (writeOffset);
+ priv->write_dsi_header.totalDataLength = GUINT32_TO_BE (g_vfs_afp_command_get_size (request_data->command));
priv->write_dsi_header.reserved = 0;
priv->bytes_written = 0;
@@ -805,6 +816,8 @@ g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection,
return NULL;
}
+ g_object_unref (conn);
+
return g_vfs_afp_reply_new (dsi_header.errorCode, data,
dsi_header.totalDataLength);
}
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index 6a723ae..09109b6 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -76,7 +76,7 @@ get_srvr_parms_cb (GVfsAfpConnection *afp_connection,
GVfsBackendAfp *afp_backend = G_VFS_BACKEND_AFP (job->backend);
AfpErrorCode error_code;
- guint16 num_volumes, i;
+ guint8 num_volumes, i;
if (!reply)
{
@@ -92,22 +92,27 @@ get_srvr_parms_cb (GVfsAfpConnection *afp_connection,
return;
}
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+
/* server time */
(void)g_data_input_stream_read_int32 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
- num_volumes = g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ num_volumes = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, NULL);
for (i = 0; i < num_volumes; i++)
{
guint8 flags;
char *vol_name;
GFileInfo *info;
+ GIcon *icon;
GMountSpec *mount_spec;
char *uri;
flags = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, NULL);
vol_name = g_vfs_afp_reply_read_pascal (reply);
-
+ if (!vol_name)
+ continue;
+
info = g_file_info_new ();
g_file_info_set_name (info, vol_name);
@@ -118,6 +123,10 @@ get_srvr_parms_cb (GVfsAfpConnection *afp_connection,
g_file_info_set_file_type (info, G_FILE_TYPE_MOUNTABLE);
g_file_info_set_attribute_boolean (info, "afp::volume-password-protected", (flags & 0x01));
+
+ icon = g_themed_icon_new ("folder-remote");
+ g_file_info_set_icon (info, icon);
+ g_object_unref (icon);
mount_spec = g_mount_spec_new ("afp-volume");
g_mount_spec_set (mount_spec, "host",
@@ -146,7 +155,7 @@ get_srvr_parms_cb (GVfsAfpConnection *afp_connection,
g_vfs_job_enumerate_add_info (job, info);
g_object_unref (info);
}
-
+
g_vfs_job_enumerate_done (job);
}
@@ -189,11 +198,39 @@ try_enumerate (GVfsBackend *backend,
g_vfs_afp_connection_queue_command (afp_backend->conn, comm,
get_srvr_parms_cb,
G_VFS_JOB (job)->cancellable, job);
+ g_object_unref (comm);
return TRUE;
}
static gboolean
+try_query_info (GVfsBackend *backend,
+ GVfsJobQueryInfo *job,
+ const char *filename,
+ GFileQueryInfoFlags flags,
+ GFileInfo *info,
+ GFileAttributeMatcher *matcher)
+{
+ if (is_root (filename))
+ {
+ GIcon *icon;
+
+ g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
+ g_file_info_set_name (info, "/");
+ g_file_info_set_display_name (info, g_vfs_backend_get_display_name (backend));
+ g_file_info_set_content_type (info, "inode/directory");
+ icon = g_vfs_backend_get_icon (backend);
+ if (icon != NULL)
+ g_file_info_set_icon (info, icon);
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ }
+ else
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+
+ return TRUE;
+}
+
+static gboolean
do_login (GVfsBackendAfp *afp_backend,
const char *username,
const char *password,
@@ -275,34 +312,6 @@ do_login (GVfsBackendAfp *afp_backend,
return TRUE;
}
-static gboolean
-try_query_info (GVfsBackend *backend,
- GVfsJobQueryInfo *job,
- const char *filename,
- GFileQueryInfoFlags flags,
- GFileInfo *info,
- GFileAttributeMatcher *matcher)
-{
- g_debug ("filename: %s\n", filename);
-
- if (is_root (filename))
- {
- GIcon *icon;
-
- g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
- g_file_info_set_name (info, "/");
- g_file_info_set_display_name (info, g_vfs_backend_get_display_name (backend));
- g_file_info_set_content_type (info, "inode/directory");
- icon = g_vfs_backend_get_icon (backend);
- if (icon != NULL)
- g_file_info_set_icon (info, icon);
- g_vfs_job_succeeded (G_VFS_JOB (job));
- }
- else
- g_vfs_job_succeeded (G_VFS_JOB (job));
-
- return TRUE;
-}
static void
do_mount (GVfsBackend *backend,
GVfsJobMount *job,
@@ -376,7 +385,6 @@ do_mount (GVfsBackend *backend,
char *uam;
uam = g_vfs_afp_reply_read_pascal (reply);
- g_debug ("%s\n", uam);
afp_backend->uams = g_slist_prepend (afp_backend->uams, uam);
}
g_object_unref (reply);
@@ -407,7 +415,7 @@ do_mount (GVfsBackend *backend,
g_vfs_backend_set_display_name (backend, display_name);
g_free (display_name);
- g_vfs_backend_set_icon_name (backend, "network-server-afp");
+ g_vfs_backend_set_icon_name (backend, "network-server");
g_vfs_job_succeeded (G_VFS_JOB (job));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]