gvfs r1093 - in trunk: . client common daemon
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1093 - in trunk: . client common daemon
- Date: Fri, 11 Jan 2008 09:17:28 +0000 (GMT)
Author: alexl
Date: Fri Jan 11 09:17:28 2008
New Revision: 1093
URL: http://svn.gnome.org/viewvc/gvfs?rev=1093&view=rev
Log:
2008-01-11 Alexander Larsson <alexl redhat com>
* client/gdaemonfile.c:
* common/gvfsdaemonprotocol.h:
Implement unmount_mountable and eject_mountable
on client side.
* common/gmountoperationdbus.c:
Fix warnings
* daemon/gvfsbackend.[ch]:
* daemon/gvfsjobunmountmountable.[ch]:
Add unmount_mountable and eject_mountable in daemon.
* daemon/gvfsbackendcomputer.c:
Implement unmount_mountable and eject_mountable
* daemon/gvfsbackendlocaltest.c:
Update to latest API
* daemon/gvfsbackendsftp.c:
Fix indentation
* daemon/gvfsjobunmount.c:
Always allow unmount if unmount is not
implemented.
Modified:
trunk/ChangeLog
trunk/client/gdaemonfile.c
trunk/common/gmountoperationdbus.c
trunk/common/gvfsdaemonprotocol.h
trunk/daemon/gvfsbackend.c
trunk/daemon/gvfsbackend.h
trunk/daemon/gvfsbackendcomputer.c
trunk/daemon/gvfsbackendlocaltest.c
trunk/daemon/gvfsbackendsftp.c
trunk/daemon/gvfsjobunmount.c
trunk/daemon/gvfsjobunmountmountable.c
trunk/daemon/gvfsjobunmountmountable.h
Modified: trunk/client/gdaemonfile.c
==============================================================================
--- trunk/client/gdaemonfile.c (original)
+++ trunk/client/gdaemonfile.c Fri Jan 11 09:17:28 2008
@@ -821,19 +821,22 @@
static void
g_daemon_file_query_info_async (GFile *file,
const char *attributes,
- GFileQueryInfoFlags flags,
+ GFileQueryInfoFlags flags,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ guint32 dbus_flags;
+
+ dbus_flags = flags;
do_async_path_call (file,
G_VFS_DBUS_MOUNT_OP_QUERY_INFO,
cancellable,
callback, user_data,
query_info_async_cb, NULL, NULL,
DBUS_TYPE_STRING, &attributes,
- DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_UINT32, &dbus_flags,
0);
}
@@ -1300,6 +1303,83 @@
return NULL;
}
+static void
+eject_mountable_async_cb (DBusMessage *reply,
+ DBusConnection *connection,
+ GSimpleAsyncResult *result,
+ GCancellable *cancellable,
+ gpointer callback_data)
+{
+ g_simple_async_result_complete (result);
+}
+
+static void
+g_daemon_file_eject_mountable (GFile *file,
+ GMountUnmountFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ guint32 dbus_flags;
+
+ dbus_flags = flags;
+ do_async_path_call (file,
+ G_VFS_DBUS_MOUNT_OP_EJECT_MOUNTABLE,
+ cancellable,
+ callback, user_data,
+ eject_mountable_async_cb,
+ NULL, NULL,
+ DBUS_TYPE_UINT32, &dbus_flags,
+ 0);
+}
+
+static gboolean
+g_daemon_file_eject_mountable_finish (GFile *file,
+ GAsyncResult *result,
+ GError **error)
+{
+ return TRUE;
+}
+
+static void
+unmount_mountable_async_cb (DBusMessage *reply,
+ DBusConnection *connection,
+ GSimpleAsyncResult *result,
+ GCancellable *cancellable,
+ gpointer callback_data)
+{
+ g_simple_async_result_complete (result);
+}
+
+static void
+g_daemon_file_unmount_mountable (GFile *file,
+ GMountUnmountFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ guint32 dbus_flags;
+
+ dbus_flags = flags;
+ do_async_path_call (file,
+ G_VFS_DBUS_MOUNT_OP_UNMOUNT_MOUNTABLE,
+ cancellable,
+ callback, user_data,
+ eject_mountable_async_cb,
+ NULL, NULL,
+ DBUS_TYPE_UINT32, &dbus_flags,
+ 0);
+}
+
+static gboolean
+g_daemon_file_unmount_mountable_finish (GFile *file,
+ GAsyncResult *result,
+ GError **error)
+{
+ return TRUE;
+}
+
+
typedef struct {
GFile *file;
GMountOperation *mount_operation;
@@ -1986,6 +2066,10 @@
iface->mount_enclosing_volume_finish = g_daemon_file_mount_enclosing_volume_finish;
iface->mount_mountable = g_daemon_file_mount_mountable;
iface->mount_mountable_finish = g_daemon_file_mount_mountable_finish;
+ iface->unmount_mountable = g_daemon_file_unmount_mountable;
+ iface->unmount_mountable_finish = g_daemon_file_unmount_mountable_finish;
+ iface->eject_mountable = g_daemon_file_eject_mountable;
+ iface->eject_mountable_finish = g_daemon_file_eject_mountable_finish;
iface->query_filesystem_info = g_daemon_file_query_filesystem_info;
iface->set_display_name = g_daemon_file_set_display_name;
iface->delete_file = g_daemon_file_delete;
Modified: trunk/common/gmountoperationdbus.c
==============================================================================
--- trunk/common/gmountoperationdbus.c (original)
+++ trunk/common/gmountoperationdbus.c Fri Jan 11 09:17:28 2008
@@ -201,12 +201,10 @@
DBusMessage *message)
{
const char *message_string, *default_user, *default_domain;
- dbus_bool_t handled = FALSE;
guint32 flags;
DBusMessageIter iter;
DBusMessage *reply;
DBusError error;
- gboolean res;
reply = NULL;
Modified: trunk/common/gvfsdaemonprotocol.h
==============================================================================
--- trunk/common/gvfsdaemonprotocol.h (original)
+++ trunk/common/gvfsdaemonprotocol.h Fri Jan 11 09:17:28 2008
@@ -33,6 +33,8 @@
#define G_VFS_DBUS_MOUNT_OP_CREATE_DIR_MONITOR "CreateDirectoryMonitor"
#define G_VFS_DBUS_MOUNT_OP_CREATE_FILE_MONITOR "CreateFileMonitor"
#define G_VFS_DBUS_MOUNT_OP_MOUNT_MOUNTABLE "MountMountable"
+#define G_VFS_DBUS_MOUNT_OP_UNMOUNT_MOUNTABLE "UnountMountable"
+#define G_VFS_DBUS_MOUNT_OP_EJECT_MOUNTABLE "EjectMountable"
#define G_VFS_DBUS_MOUNT_OP_SET_DISPLAY_NAME "SetDisplayName"
#define G_VFS_DBUS_MOUNT_OP_DELETE "Delete"
#define G_VFS_DBUS_MOUNT_OP_TRASH "Trash"
Modified: trunk/daemon/gvfsbackend.c
==============================================================================
--- trunk/daemon/gvfsbackend.c (original)
+++ trunk/daemon/gvfsbackend.c Fri Jan 11 09:17:28 2008
@@ -44,6 +44,7 @@
#include <gvfsjobtrash.h>
#include <gvfsjobunmount.h>
#include <gvfsjobmountmountable.h>
+#include <gvfsjobunmountmountable.h>
#include <gvfsjobmakedirectory.h>
#include <gvfsjobmakesymlink.h>
#include <gvfsjobcreatemonitor.h>
@@ -407,6 +408,14 @@
job = g_vfs_job_mount_mountable_new (connection, message, backend);
else if (dbus_message_is_method_call (message,
G_VFS_DBUS_MOUNT_INTERFACE,
+ G_VFS_DBUS_MOUNT_OP_UNMOUNT_MOUNTABLE))
+ job = g_vfs_job_unmount_mountable_new (connection, message, backend, FALSE);
+ else if (dbus_message_is_method_call (message,
+ G_VFS_DBUS_MOUNT_INTERFACE,
+ G_VFS_DBUS_MOUNT_OP_EJECT_MOUNTABLE))
+ job = g_vfs_job_unmount_mountable_new (connection, message, backend, TRUE);
+ else if (dbus_message_is_method_call (message,
+ G_VFS_DBUS_MOUNT_INTERFACE,
G_VFS_DBUS_MOUNT_OP_SET_DISPLAY_NAME))
job = g_vfs_job_set_display_name_new (connection, message, backend);
else if (dbus_message_is_method_call (message,
Modified: trunk/daemon/gvfsbackend.h
==============================================================================
--- trunk/daemon/gvfsbackend.h (original)
+++ trunk/daemon/gvfsbackend.h Fri Jan 11 09:17:28 2008
@@ -116,16 +116,20 @@
GMountSource *mount_source);
void (*unmount_mountable) (GVfsBackend *backend,
GVfsJobUnmountMountable *job,
- const char *filename);
+ const char *filename,
+ GMountUnmountFlags flags);
gboolean (*try_unmount_mountable)(GVfsBackend *backend,
- GVfsJobUnmountMountable *job,
- const char *filename);
+ GVfsJobUnmountMountable *job,
+ const char *filename,
+ GMountUnmountFlags flags);
void (*eject_mountable) (GVfsBackend *backend,
GVfsJobUnmountMountable *job,
- const char *filename);
+ const char *filename,
+ GMountUnmountFlags flags);
gboolean (*try_eject_mountable)(GVfsBackend *backend,
- GVfsJobUnmountMountable *job,
- const char *filename);
+ GVfsJobUnmountMountable *job,
+ const char *filename,
+ GMountUnmountFlags flags);
void (*open_for_read) (GVfsBackend *backend,
GVfsJobOpenForRead *job,
const char *filename);
Modified: trunk/daemon/gvfsbackendcomputer.c
==============================================================================
--- trunk/daemon/gvfsbackendcomputer.c (original)
+++ trunk/daemon/gvfsbackendcomputer.c Fri Jan 11 09:17:28 2008
@@ -328,7 +328,7 @@
{
volume = ll->data;
- file = g_slice_new (ComputerFile);
+ file = g_slice_new0 (ComputerFile);
file->drive = g_object_ref (drive);
file->volume = volume; /* Takes ref */
file->mount = g_volume_get_mount (volume);
@@ -614,6 +614,8 @@
g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT, file->can_eject);
g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, FALSE);
+ g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, FALSE);
+ g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH, FALSE);
}
static gboolean
@@ -779,7 +781,7 @@
if (file == &root)
g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
G_IO_ERROR_NOT_MOUNTABLE_FILE,
- _("Can't open directory"));
+ _("Not a mountable file"));
else if (file != NULL)
{
if (file->volume)
@@ -808,18 +810,178 @@
return TRUE;
}
+static void
+unmount_mount_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GVfsJobMountMountable *job = user_data;
+ GError *error;
+ GMount *mount;
+
+ mount = G_MOUNT (source_object);
+
+ error = NULL;
+ if (g_mount_unmount_finish (mount, res, &error))
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
+}
+
+
static gboolean
try_unmount_mountable (GVfsBackend *backend,
- GVfsJobMountMountable *job,
- const char *filename)
+ GVfsJobUnmountMountable *job,
+ const char *filename,
+ GMountUnmountFlags flags)
{
+ ComputerFile *file;
+
+ file = lookup (G_VFS_BACKEND_COMPUTER (backend),
+ G_VFS_JOB (job), filename);
+
+ if (file == &root)
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
+ G_IO_ERROR_NOT_MOUNTABLE_FILE,
+ _("Not a mountable file"));
+ else if (file != NULL)
+ {
+ if (file->mount)
+ {
+ g_mount_unmount (file->mount,
+ flags,
+ G_VFS_JOB (job)->cancellable,
+ unmount_mount_cb,
+ job);
+ }
+ else
+ {
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Can't unmount file"));
+ }
+ }
+
+ return TRUE;
+}
+
+static void
+eject_mount_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GVfsJobMountMountable *job = user_data;
+ GError *error;
+ GMount *mount;
+
+ mount = G_MOUNT (source_object);
+
+ error = NULL;
+ if (g_mount_eject_finish (mount, res, &error))
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
+}
+
+static void
+eject_volume_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GVfsJobMountMountable *job = user_data;
+ GError *error;
+ GVolume *volume;
+
+ volume = G_VOLUME (source_object);
+
+ error = NULL;
+ if (g_volume_eject_finish (volume, res, &error))
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
+}
+
+
+static void
+eject_drive_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GVfsJobMountMountable *job = user_data;
+ GError *error;
+ GDrive *drive;
+
+ drive = G_DRIVE (source_object);
+
+ error = NULL;
+ if (g_drive_eject_finish (drive, res, &error))
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
}
static gboolean
try_eject_mountable (GVfsBackend *backend,
- GVfsJobMountMountable *job,
- const char *filename)
+ GVfsJobUnmountMountable *job,
+ const char *filename,
+ GMountUnmountFlags flags)
{
+ ComputerFile *file;
+
+ file = lookup (G_VFS_BACKEND_COMPUTER (backend),
+ G_VFS_JOB (job), filename);
+
+ if (file == &root)
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
+ G_IO_ERROR_NOT_MOUNTABLE_FILE,
+ _("Not a mountable file"));
+ else if (file != NULL)
+ {
+ if (file->mount)
+ {
+ g_mount_eject (file->mount,
+ flags,
+ G_VFS_JOB (job)->cancellable,
+ eject_mount_cb,
+ job);
+ }
+ else if (file->volume)
+ {
+ g_volume_eject (file->volume,
+ flags,
+ G_VFS_JOB (job)->cancellable,
+ eject_volume_cb,
+ job);
+ }
+ else if (file->drive)
+ {
+ g_drive_eject (file->drive,
+ flags,
+ G_VFS_JOB (job)->cancellable,
+ eject_drive_cb,
+ job);
+ }
+ else
+ {
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Can't eject file"));
+ }
+ }
+
+ return TRUE;
}
static void
@@ -836,4 +998,6 @@
backend_class->try_enumerate = try_enumerate;
backend_class->try_create_dir_monitor = try_create_dir_monitor;
backend_class->try_mount_mountable = try_mount_mountable;
+ backend_class->try_unmount_mountable = try_unmount_mountable;
+ backend_class->try_eject_mountable = try_eject_mountable;
}
Modified: trunk/daemon/gvfsbackendlocaltest.c
==============================================================================
--- trunk/daemon/gvfsbackendlocaltest.c (original)
+++ trunk/daemon/gvfsbackendlocaltest.c Fri Jan 11 09:17:28 2008
@@ -705,7 +705,6 @@
typedef struct {
GVfsMonitor *vfs_monitor;
GObject *monitor;
- GMountSpec *mount_spec;
} MonitorProxy;
static void
@@ -713,7 +712,6 @@
{
g_print ("(II) monitor_proxy_free \n");
g_object_unref (proxy->monitor);
- g_mount_spec_unref (proxy->mount_spec);
g_free (proxy);
}
@@ -724,31 +722,26 @@
GFileMonitorEvent event_type,
MonitorProxy *proxy)
{
- GMountSpec *file_spec;
char *file_path;
- GMountSpec *other_file_spec;
char *other_file_path;
- file_spec = proxy->mount_spec;
file_path = g_file_get_path (file);
g_print ("(II) monitor_proxy_changed: file_path = '%s' \n", file_path);
if (other_file)
{
- other_file_spec = proxy->mount_spec;
other_file_path = g_file_get_path (other_file);
- g_print ("(II) monitor_proxy_changed: other_file_path == '%s' \n", other_file_path);
+ g_print ("(II) monitor_proxy_changed: other_file_path == '%s' \n", other_file_path);
}
else
{
- other_file_spec = NULL;
other_file_path = NULL;
}
g_vfs_monitor_emit_event (proxy->vfs_monitor,
event_type,
- file_spec, file_path,
- other_file_spec, other_file_path);
+ file_path,
+ other_file_path);
g_free (file_path);
g_free (other_file_path);
@@ -775,17 +768,19 @@
if (monitor)
{
proxy = g_new0 (MonitorProxy, 1);
- proxy->vfs_monitor = g_vfs_monitor_new (g_vfs_backend_get_daemon (backend));
+ proxy->vfs_monitor = g_vfs_monitor_new (backend);
proxy->monitor = monitor;
- proxy->mount_spec = g_mount_spec_ref (op_backend->mount_spec);
- g_object_set_data_full (G_OBJECT (proxy->vfs_monitor), "monitor-proxy", proxy, (GDestroyNotify) monitor_proxy_free); //* hmm?
+ g_object_set_data_full (G_OBJECT (proxy->vfs_monitor), "monitor-proxy",
+ proxy, (GDestroyNotify) monitor_proxy_free); //* hmm?
g_signal_connect (monitor, "changed", G_CALLBACK (proxy_changed), proxy);
- g_vfs_job_create_monitor_set_obj_path (job, g_vfs_monitor_get_object_path (proxy->vfs_monitor));
-
- inject_error (backend, G_VFS_JOB (job), GVFS_JOB_CREATE_DIR_MONITOR);
- g_print ("(II) create_dir_file_monitor success. \n");
+ g_vfs_job_create_monitor_set_monitor (job, proxy->vfs_monitor);
+
+ g_object_unref (proxy->vfs_monitor);
+
+ inject_error (backend, G_VFS_JOB (job), GVFS_JOB_CREATE_DIR_MONITOR);
+ g_print ("(II) create_dir_file_monitor success. \n");
}
else
{
Modified: trunk/daemon/gvfsbackendsftp.c
==============================================================================
--- trunk/daemon/gvfsbackendsftp.c (original)
+++ trunk/daemon/gvfsbackendsftp.c Fri Jan 11 09:17:28 2008
@@ -844,8 +844,8 @@
{
backend->reply_size_read = 0;
g_input_stream_read_async (backend->reply_stream,
- &backend->reply_size, 4,
- 0, NULL, read_reply_async_got_len, backend);
+ &backend->reply_size, 4,
+ 0, NULL, read_reply_async_got_len, backend);
}
static void send_command (GVfsBackendSftp *backend);
Modified: trunk/daemon/gvfsjobunmount.c
==============================================================================
--- trunk/daemon/gvfsjobunmount.c (original)
+++ trunk/daemon/gvfsjobunmount.c Fri Jan 11 09:17:28 2008
@@ -100,13 +100,6 @@
GVfsJobUnmount *op_job = G_VFS_JOB_UNMOUNT (job);
GVfsBackendClass *class = G_VFS_BACKEND_GET_CLASS (op_job->backend);
- if (class->unmount == NULL)
- {
- g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported by backend"));
- return;
- }
-
class->unmount (op_job->backend,
op_job);
}
@@ -118,7 +111,16 @@
GVfsBackendClass *class = G_VFS_BACKEND_GET_CLASS (op_job->backend);
if (class->try_unmount == NULL)
- return FALSE;
+ {
+ if (class->unmount == NULL)
+ {
+ /* If unmount is not implemented we always succeed */
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ return TRUE;
+ }
+
+ return FALSE;
+ }
return class->try_unmount (op_job->backend,
op_job);
Modified: trunk/daemon/gvfsjobunmountmountable.c
==============================================================================
--- trunk/daemon/gvfsjobunmountmountable.c (original)
+++ trunk/daemon/gvfsjobunmountmountable.c Fri Jan 11 09:17:28 2008
@@ -84,7 +84,7 @@
DBusMessageIter iter;
DBusError derror;
char *path;
- const char *dbus_id, *obj_path;
+ guint32 flags;
dbus_error_init (&derror);
dbus_message_iter_init (message, &iter);
@@ -92,8 +92,7 @@
path = NULL;
if (!_g_dbus_message_iter_get_args (&iter, &derror,
G_DBUS_TYPE_CSTRING, &path,
- DBUS_TYPE_STRING, &dbus_id,
- DBUS_TYPE_OBJECT_PATH, &obj_path,
+ DBUS_TYPE_UINT32, &flags,
0))
{
g_free (path);
@@ -114,6 +113,7 @@
job->filename = path;
job->backend = backend;
job->eject = eject;
+ job->flags = flags;
return G_VFS_JOB (job);
}
@@ -135,7 +135,8 @@
class->eject_mountable (op_job->backend,
op_job,
- op_job->filename);
+ op_job->filename,
+ op_job->flags);
}
else
{
@@ -148,7 +149,8 @@
class->unmount_mountable (op_job->backend,
op_job,
- op_job->filename);
+ op_job->filename,
+ op_job->flags);
}
}
@@ -165,7 +167,8 @@
return class->try_eject_mountable (op_job->backend,
op_job,
- op_job->filename);
+ op_job->filename,
+ op_job->flags);
}
else
{
@@ -174,7 +177,8 @@
return class->try_unmount_mountable (op_job->backend,
op_job,
- op_job->filename);
+ op_job->filename,
+ op_job->flags);
}
}
Modified: trunk/daemon/gvfsjobunmountmountable.h
==============================================================================
--- trunk/daemon/gvfsjobunmountmountable.h (original)
+++ trunk/daemon/gvfsjobunmountmountable.h Fri Jan 11 09:17:28 2008
@@ -46,6 +46,7 @@
GVfsBackend *backend;
char *filename;
gboolean eject;
+ GMountUnmountFlags flags;
};
struct _GVfsJobUnmountMountableClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]