summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackendcomputer.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-01-09 14:49:05 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-01-09 14:49:05 +0000
commit23730c607ca8ae5a6f8d84d623e7b21bdd5bd1c3 (patch)
tree1f4c6e149a351d32ba92a9ba71c6856ce771d81e /daemon/gvfsbackendcomputer.c
parentca250f832f62324f0bef8fab968d681d03a84a57 (diff)
downloadgvfs-23730c607ca8ae5a6f8d84d623e7b21bdd5bd1c3.tar.gz
Add g_mount_source_get_operation() that lets you handle a remote
2008-01-09 Alexander Larsson <alexl@redhat.com> * common/gmountsource.[ch]: Add g_mount_source_get_operation() that lets you handle a remote GMountSource as if it was a GMountOperation. * common/gmountoperationdbus.c: * programs/gvfs-mount.c: Update to new GMountOperation APIs * client/gdaemonfile.c: * daemon/gvfsjobmountmountable.[ch]: Also let you return target by uri, as not all targets are from gvfs. * daemon/gvfsbackendcomputer.c: Initial cut at mount_mountable svn path=/trunk/; revision=1085
Diffstat (limited to 'daemon/gvfsbackendcomputer.c')
-rw-r--r--daemon/gvfsbackendcomputer.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/daemon/gvfsbackendcomputer.c b/daemon/gvfsbackendcomputer.c
index 90cf7fb8..bb3cd40c 100644
--- a/daemon/gvfsbackendcomputer.c
+++ b/daemon/gvfsbackendcomputer.c
@@ -48,6 +48,7 @@
#include "gvfsjobclosewrite.h"
#include "gvfsjobseekwrite.h"
#include "gvfsjobsetdisplayname.h"
+#include "gvfsjobmountmountable.h"
#include "gvfsjobqueryinfo.h"
#include "gvfsjobdelete.h"
#include "gvfsjobqueryfsinfo.h"
@@ -718,6 +719,51 @@ try_create_dir_monitor (GVfsBackend *backend,
return TRUE;
}
+static void
+mount_volume_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GVfsJobMountMountable *job = user_data;
+ GError *error;
+ GMount *mount;
+ GVolume *volume;
+ GFile *root;
+ char *uri;
+
+ volume = G_VOLUME (source_object);
+
+ /* TODO: We're leaking the GMountOperation here */
+
+ error = NULL;
+ if (g_volume_mount_finish (volume, res, &error))
+ {
+ mount = g_volume_get_mount (volume);
+
+ if (mount)
+ {
+ root = g_mount_get_root (mount);
+ uri = g_file_get_uri (root);
+ g_vfs_job_mount_mountable_set_target_uri (job,
+ uri,
+ FALSE);
+ g_free (uri);
+ g_object_unref (root);
+ g_object_unref (mount);
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+ }
+ else
+ g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ _("Can't find mount for mounted volume"));
+ }
+ else
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+ g_error_free (error);
+ }
+}
+
static gboolean
try_mount_mountable (GVfsBackend *backend,
GVfsJobMountMountable *job,
@@ -725,6 +771,7 @@ try_mount_mountable (GVfsBackend *backend,
GMountSource *mount_source)
{
ComputerFile *file;
+ GMountOperation *mount_op;
file = lookup (G_VFS_BACKEND_COMPUTER (backend),
G_VFS_JOB (job), filename);
@@ -735,22 +782,22 @@ try_mount_mountable (GVfsBackend *backend,
_("Can't open directory"));
else if (file != NULL)
{
-#if 0
if (file->volume)
{
- /* TODO: Implement */
+ mount_op = g_mount_source_get_operation (mount_source);
g_volume_mount (file->volume,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
+ mount_op,
+ G_VFS_JOB (job)->cancellable,
+ mount_volume_cb,
+ job);
}
+#if 0
else if (file->drive)
{
/* TODO: Poll for media? */
}
- else
#endif
+ else
{
g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
@@ -788,4 +835,5 @@ g_vfs_backend_computer_class_init (GVfsBackendComputerClass *klass)
backend_class->try_query_info = try_query_info;
backend_class->try_enumerate = try_enumerate;
backend_class->try_create_dir_monitor = try_create_dir_monitor;
+ backend_class->try_mount_mountable = try_mount_mountable;
}