summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 13:33:57 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 13:33:57 +0000
commit6637fd2856bd457fddf130cc28786fec2c82cb93 (patch)
treeb1e08e322e04b359c6f0e68cf22255f68c485555
parent397de26bd252cc5f386c2bda03b5307e4e98d75c (diff)
downloadgvfs-6637fd2856bd457fddf130cc28786fec2c82cb93.tar.gz
Add cancellation to mount operations
Implement base GFile mountable functions Original git commit by Alexander Larsson <alexl@redhat.com> at 1178801245 +0200 svn path=/trunk/; revision=544
-rw-r--r--client/gdaemonfile.c24
-rw-r--r--common/gvfsdaemonprotocol.h1
-rw-r--r--gio/gfile.c65
-rw-r--r--gio/gfile.h46
-rw-r--r--programs/gvfs-mount.c2
5 files changed, 112 insertions, 26 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 49779653..f6c33224 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -877,12 +877,29 @@ g_daemon_file_replace (GFile *file,
static void
+mount_mountable_cb (DBusMessage *reply,
+ DBusConnection *connection,
+ GError *io_error,
+ GCancellable *cancellable,
+ GAsyncReadyCallback op_callback,
+ gpointer op_callback_data,
+ gpointer callback_data)
+{
+}
+
+static void
g_daemon_file_mount_mountable (GFile *file,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
-
+ do_async_path_call (file,
+ G_VFS_DBUS_MOUNT_OP_MOUNT_MOUNTABLE,
+ cancellable,
+ callback, user_data,
+ mount_mountable_cb, file,
+ 0);
}
static GFile *
@@ -902,6 +919,7 @@ typedef struct {
static void g_daemon_file_mount_for_location (GFile *location,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -939,6 +957,7 @@ mount_reply (DBusMessage *reply,
static void
g_daemon_file_mount_for_location (GFile *location,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -975,7 +994,8 @@ g_daemon_file_mount_for_location (GFile *location,
data->file = g_object_ref (location);
if (mount_operation)
data->mount_operation = g_object_ref (mount_operation);
-
+
+ /* TODO: Ignoring cancellable here */
_g_dbus_connection_call_async (NULL, message,
G_VFS_DBUS_MOUNT_TIMEOUT_MSECS,
mount_reply, data);
diff --git a/common/gvfsdaemonprotocol.h b/common/gvfsdaemonprotocol.h
index 3ba17ef0..7aa97560 100644
--- a/common/gvfsdaemonprotocol.h
+++ b/common/gvfsdaemonprotocol.h
@@ -25,6 +25,7 @@ G_BEGIN_DECLS
#define G_VFS_DBUS_MOUNT_OP_OPEN_FOR_WRITE "OpenForWrite"
#define G_VFS_DBUS_MOUNT_OP_GET_INFO "GetInfo"
#define G_VFS_DBUS_MOUNT_OP_ENUMERATE "Enumerate"
+#define G_VFS_DBUS_MOUNT_OP_MOUNT_MOUNTABLE "MountMountable"
/* mount daemons that support mounting more mounts implement this,
and set the dbus name in the mountable description file */
diff --git a/gio/gfile.c b/gio/gfile.c
index ff40216f..b8e34ee6 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -744,9 +744,19 @@ g_file_set_attribute_int64 (GFile *file,
void
g_file_mount_mountable (GFile *file,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ GFileIface *iface;
+
+ iface = G_FILE_GET_IFACE (file);
+ (* iface->mount_mountable) (file,
+ mount_operation,
+ cancellable,
+ callback,
+ user_data);
+
}
GFile *
@@ -754,14 +764,32 @@ g_file_mount_mountable_finish (GFile *file,
GAsyncResult *result,
GError **error)
{
- return NULL;
+ GFileIface *iface;
+
+ if (G_IS_SIMPLE_ASYNC_RESULT (result))
+ {
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ if (g_simple_async_result_propagate_error (simple, error))
+ return NULL;
+ }
+
+ iface = G_FILE_GET_IFACE (file);
+ return (* iface->mount_mountable_finish) (file, result, error);
}
void
g_file_unmount_mountable (GFile *file,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ GFileIface *iface;
+
+ iface = G_FILE_GET_IFACE (file);
+ (* iface->unmount_mountable) (file,
+ cancellable,
+ callback,
+ user_data);
}
gboolean
@@ -769,14 +797,32 @@ g_file_unmount_mountable_finish (GFile *file,
GAsyncResult *result,
GError **error)
{
- return TRUE;
+ GFileIface *iface;
+
+ if (G_IS_SIMPLE_ASYNC_RESULT (result))
+ {
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+ }
+
+ iface = G_FILE_GET_IFACE (file);
+ return (* iface->unmount_mountable_finish) (file, result, error);
}
void
g_file_eject_mountable (GFile *file,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ GFileIface *iface;
+
+ iface = G_FILE_GET_IFACE (file);
+ (* iface->eject_mountable) (file,
+ cancellable,
+ callback,
+ user_data);
}
gboolean
@@ -784,7 +830,17 @@ g_file_eject_mountable_finish (GFile *file,
GAsyncResult *result,
GError **error)
{
- return TRUE;
+ GFileIface *iface;
+
+ if (G_IS_SIMPLE_ASYNC_RESULT (result))
+ {
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+ }
+
+ iface = G_FILE_GET_IFACE (file);
+ return (* iface->eject_mountable_finish) (file, result, error);
}
GDirectoryMonitor*
@@ -942,6 +998,7 @@ g_file_get_for_commandline_arg (const char *arg)
void
g_mount_for_location (GFile *location,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -959,7 +1016,7 @@ g_mount_for_location (GFile *location,
return;
}
- return (* iface->mount_for_location) (location, mount_operation, callback, user_data);
+ return (* iface->mount_for_location) (location, mount_operation, cancellable, callback, user_data);
}
diff --git a/gio/gfile.h b/gio/gfile.h
index 7eab5260..70747420 100644
--- a/gio/gfile.h
+++ b/gio/gfile.h
@@ -125,29 +125,33 @@ struct _GFileIface
GAsyncResult *res,
GError **error);
- void (*mount_mountable) (GFile *file,
- GMountOperation *mount_operation,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFile * (*mount_mountable_finish) (GFile *file,
- GAsyncResult *result,
- GError **error);
- void (*unmount_mountable) (GFile *file,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*unmount_mountable_finish) (GFile *file,
- GAsyncResult *result,
- GError **error);
- void (*eject_mountable) (GFile *file,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*eject_mountable_finish) (GFile *file,
- GAsyncResult *result,
- GError **error);
+ void (*mount_mountable) (GFile *file,
+ GMountOperation *mount_operation,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ GFile * (*mount_mountable_finish) (GFile *file,
+ GAsyncResult *result,
+ GError **error);
+ void (*unmount_mountable) (GFile *file,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*unmount_mountable_finish) (GFile *file,
+ GAsyncResult *result,
+ GError **error);
+ void (*eject_mountable) (GFile *file,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*eject_mountable_finish) (GFile *file,
+ GAsyncResult *result,
+ GError **error);
void (*mount_for_location) (GFile *location,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*mount_for_location_finish) (GFile *location,
@@ -288,6 +292,7 @@ gboolean g_file_set_attribute_int64 (GFile *fi
void g_mount_for_location (GFile *location,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean g_mount_for_location_finish (GFile *location,
@@ -295,18 +300,21 @@ gboolean g_mount_for_location_finish (GFile *lo
GError **error);
void g_file_mount_mountable (GFile *file,
GMountOperation *mount_operation,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GFile * g_file_mount_mountable_finish (GFile *file,
GAsyncResult *result,
GError **error);
void g_file_unmount_mountable (GFile *file,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean g_file_unmount_mountable_finish (GFile *file,
GAsyncResult *result,
GError **error);
void g_file_eject_mountable (GFile *file,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean g_file_eject_mountable_finish (GFile *file,
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c
index 215d9278..f53cdbff 100644
--- a/programs/gvfs-mount.c
+++ b/programs/gvfs-mount.c
@@ -104,7 +104,7 @@ mount (GFile *file)
g_signal_connect (op, "ask_password", (GCallback)ask_password_cb, NULL);
- g_mount_for_location (file, op, mount_done_cb, op);
+ g_mount_for_location (file, op, NULL, mount_done_cb, op);
outstanding_mounts++;
}