diff options
author | David Zeuthen <davidz@redhat.com> | 2009-06-30 23:19:01 -0400 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2009-07-08 13:53:04 +0200 |
commit | 8af5a5581e11d9c07e8ba3a17eb2cc93b5c70631 (patch) | |
tree | 47206e3fdc7532a97deacb836ec5c79042661421 /common/gmountoperationdbus.c | |
parent | c33e26d3914e0659d4a317fda7fe9acbb6269dc9 (diff) | |
download | gvfs-8af5a5581e11d9c07e8ba3a17eb2cc93b5c70631.tar.gz |
Bug 587484 – Interaction when unmounting mounts and misc fixes
- Port everything to use _with_operation() variants of unmount/eject
methods
- Add support for g_file_poll_mountable()
- new job class: GVfsJobPollMountable
- Pass mount operation for unmount/eject ops on GDaemonFile and
GDaemonMount
- receive in the appropriate GVfsJob classes
- also pass unmount flags where it was missing
- port all backends to use this
- Teach GMountSource and GMountOperationDBus about the new
GMountOperation::show-processes signal
- also provide new API
- g_mount_source_is_dummy() - e.g. when the client didn't
passed NULL for the GMountOperation
- g_mount_source_abort() - to send the ::abort signal to the
client-side GMountOperation
- make the client-side of GMountSource return ::reply with
NOT_HANDLED when we do an abort
- Refactor the mount operation handling in GProxyVolumeMonitor
- Pass mount operation for unmount/ejects in GProxyVolumeMonitor
- Pass the process id of the actual reader/writer in OpenForRead
and OpenForWrite daemon methods
- add some private API for making the FUSE client set the
pid of the POSIX client (otherwise it looks like the FUSE
client is blocking) and pass the right pid.
This is because the FUSE client is basically impersonating the
POSIX processes.
- Make the process id mentioned above available in appropriate
GVfsJob classes
- GVfsJobOpenForRead
- GVfsJobOpenForWrite
- GVfsChannel
- Provide API to get a list of all blocking clients, e.g. an array
of GPid
- g_vfs_daemon_get_blocking_processes()
- Provide convenience API to easily doing the right thing on unmount;
e.g. interact with the user about blocking processes - see the gphoto2
backend for example usage
- g_vfs_backend_has_blocking_processes()
- g_vfs_backend_unmount_with_operation() and
g_vfs_backend_unmount_with_operation_finish()
- Only the gphoto2 backend supports ::show-processes right now. Support
for other backends will be added shortly.
- Implement support for ::show-processes in the GDU volume monitor
- right now we don't support "Unmount Anyway" since it requires
ABI changes in libgdu.so - this will be changed as soon as there's
a new gnome-disk-utility release
Diffstat (limited to 'common/gmountoperationdbus.c')
-rw-r--r-- | common/gmountoperationdbus.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/common/gmountoperationdbus.c b/common/gmountoperationdbus.c index b8ac4f7d..9122042e 100644 --- a/common/gmountoperationdbus.c +++ b/common/gmountoperationdbus.c @@ -51,6 +51,8 @@ static void mount_op_ask_password (GMountOperationDBus *op_d DBusMessage *message); static void mount_op_ask_question (GMountOperationDBus *op_dbus, DBusMessage *message); +static void mount_op_show_processes (GMountOperationDBus *op_dbus, + DBusMessage *message); static void mount_op_aborted (GMountOperationDBus *op_dbus, DBusMessage *message); @@ -135,6 +137,10 @@ mount_op_message_function (DBusConnection *connection, mount_op_ask_question (op_dbus, message); else if (dbus_message_is_method_call (message, G_VFS_DBUS_MOUNT_OPERATION_INTERFACE, + G_VFS_DBUS_MOUNT_OPERATION_OP_SHOW_PROCESSES)) + mount_op_show_processes (op_dbus, message); + else if (dbus_message_is_method_call (message, + G_VFS_DBUS_MOUNT_OPERATION_INTERFACE, G_VFS_DBUS_MOUNT_OPERATION_OP_ABORTED)) mount_op_aborted (op_dbus, message); else @@ -320,8 +326,91 @@ mount_op_ask_question (GMountOperationDBus *op_dbus, } static void +show_processes_reply (GMountOperation *op, + GMountOperationResult result, + gpointer data) +{ + DBusMessage *reply = data; + guint32 choice; + dbus_bool_t handled, abort_dbus; + GMountOperationDBus *op_dbus; + + op_dbus = g_object_get_data (G_OBJECT (op), "dbus-op"); + + handled = (result != G_MOUNT_OPERATION_UNHANDLED); + abort_dbus = (result == G_MOUNT_OPERATION_ABORTED); + + choice = g_mount_operation_get_choice (op); + + _g_dbus_message_append_args (reply, + DBUS_TYPE_BOOLEAN, &handled, + DBUS_TYPE_BOOLEAN, &abort_dbus, + DBUS_TYPE_UINT32, &choice, + 0); + + mount_op_send_reply (op_dbus, reply); +} + +static void +mount_op_show_processes (GMountOperationDBus *op_dbus, + DBusMessage *message) +{ + const char *message_string; + char **choices; + int num_choices; + gint32 **process_pids; + int num_process_pids; + DBusMessage *reply; + DBusError error; + DBusMessageIter iter; + GArray *processes; + + reply = NULL; + + dbus_message_iter_init (message, &iter); + dbus_error_init (&error); + if (!_g_dbus_message_iter_get_args (&iter, + &error, + DBUS_TYPE_STRING, &message_string, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &choices, &num_choices, + DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, + &process_pids, &num_process_pids, + 0)) + { + reply = dbus_message_new_error (message, error.name, error.message); + if (reply == NULL) + _g_dbus_oom (); + if (!dbus_connection_send (op_dbus->connection, reply, NULL)) + _g_dbus_oom (); + dbus_message_unref (reply); + dbus_error_free (&error); + return; + } + + processes = g_array_sized_new (FALSE, FALSE, sizeof (GPid), num_process_pids); + g_array_append_vals (processes, process_pids, num_process_pids); + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + _g_dbus_oom (); + + g_signal_connect (op_dbus->op, "reply", (GCallback)show_processes_reply, reply); + + g_signal_emit_by_name (op_dbus->op, "show_processes", + message_string, + processes, + choices); + + dbus_free_string_array (choices); + g_array_unref (processes); +} + +static void mount_op_aborted (GMountOperationDBus *op_dbus, DBusMessage *message) { + /* also emit reply to make the all DBus ops return */ + g_mount_operation_reply (op_dbus->op, G_MOUNT_OPERATION_UNHANDLED); g_signal_emit_by_name (op_dbus->op, "aborted"); } |