diff options
author | David Zeuthen <davidz@redhat.com> | 2008-02-25 11:17:08 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2008-02-25 11:17:08 +0000 |
commit | fd09daa489fbf2158472c4a7f3b4e92bf8f4ec0c (patch) | |
tree | acfdb20f29bf00584ade92c855d65c7dec241264 /client | |
parent | 08ef6a83f785d5ac1eb423f8253c6455ad596232 (diff) | |
download | gvfs-fd09daa489fbf2158472c4a7f3b4e92bf8f4ec0c.tar.gz |
Prefer to return a GDaemonMount from an existing GDaemonVolumeMonitor
2008-02-24 David Zeuthen <davidz@redhat.com>
* client/gdaemonfile.c:
* client/gdaemonvolumemonitor.c:
* client/gdaemonvolumemonitor.h: Prefer to return a GDaemonMount
from an existing GDaemonVolumeMonitor rather than rolling our own
for GDaemonFile's g_file_find_enclosing_mount()
implementation. This is to ensure that g_mount_get_volume() will
work properly with mounts that are adopted by GVolume objects from
other volume monitors.
* configure.ac: Check for libgphoto2
* daemon/Makefile.am:
* daemon/gvfsbackendcdda.c: Use HAL to detect when the disc is
removed and then forcibly unmount the mount. Report size of
disc. Hint the file manager to preview files.
* hal/ghaldrive.c:
* hal/ghalmount.c:
* hal/ghalvolume.c:
* hal/ghalvolumemonitor.c:
* hal/ghalvolumemonitor.h:
* hal/hal-pool.c: Ensure that audio and blank CD's are
displayed (#514139). Read info.desktop.[icon|name] properties
from hal and use these if found. Use proper icon for audio players
and make the gphoto2 detection support it as well. Also check for
subsystem when filtering on hal capabilities. Also revert the
commit to ignore NFS mounts as gio will now only report an user
visible mount if it's in /media or $HOME. Make LUKS encrypted
volumes work.
* daemon/Makefile.am:
* daemon/gphoto2.mount.in:
* daemon/gvfsbackendgphoto2.c:
Land the gphoto2 backend.
* programs/Makefile.am:
* programs/gvfs-ls.c: Make the --hidden option work. Default
to short listing and add a --long option. Implement new options
--show-completions and --show-mounts that can be used for
shell completions.
* programs/gvfs-tree.c: New program
* programs/gvfs-bash-completion.sh: Bash completion for gvfs;
uses the new --show-completions and --show-mounts options in
gvfs-ls.
svn path=/trunk/; revision=1359
Diffstat (limited to 'client')
-rw-r--r-- | client/gdaemonfile.c | 7 | ||||
-rw-r--r-- | client/gdaemonvolumemonitor.c | 55 | ||||
-rw-r--r-- | client/gdaemonvolumemonitor.h | 3 |
3 files changed, 61 insertions, 4 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c index 65c01f66..29808a91 100644 --- a/client/gdaemonfile.c +++ b/client/gdaemonfile.c @@ -1530,7 +1530,12 @@ g_daemon_file_find_enclosing_mount (GFile *file, if (mount_info->user_visible) { - mount = g_daemon_mount_new (mount_info, NULL); + /* if we have a daemon volume monitor then return one of it's mounts */ + mount = g_daemon_volume_monitor_find_mount_by_mount_info (mount_info); + if (mount == NULL) + { + mount = g_daemon_mount_new (mount_info, NULL); + } g_mount_info_unref (mount_info); if (mount) diff --git a/client/gdaemonvolumemonitor.c b/client/gdaemonvolumemonitor.c index 0efd0464..8179031e 100644 --- a/client/gdaemonvolumemonitor.c +++ b/client/gdaemonvolumemonitor.c @@ -1,3 +1,5 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + /* GIO - GLib Input, Output and Streaming Library * * Copyright (C) 2006-2007 Red Hat, Inc. @@ -31,6 +33,9 @@ #include "gdaemonvfs.h" #include "gmounttracker.h" +static GStaticRecMutex _the_daemon_volume_monitor_mutex = G_STATIC_REC_MUTEX_INIT; +static GDaemonVolumeMonitor *_the_daemon_volume_monitor; + struct _GDaemonVolumeMonitor { GVolumeMonitor parent; @@ -46,11 +51,15 @@ get_mounts (GVolumeMonitor *volume_monitor) GDaemonVolumeMonitor *monitor; GList *l; + g_static_rec_mutex_lock (&_the_daemon_volume_monitor_mutex); + monitor = G_DAEMON_VOLUME_MONITOR (volume_monitor); l = g_list_copy (monitor->mounts); g_list_foreach (l, (GFunc)g_object_ref, NULL); + g_static_rec_mutex_unlock (&_the_daemon_volume_monitor_mutex); + return l; } @@ -103,17 +112,42 @@ find_mount_by_mount_info (GDaemonVolumeMonitor *daemon_monitor, GMountInfo *moun return found_mount; } +GDaemonMount * +g_daemon_volume_monitor_find_mount_by_mount_info (GMountInfo *mount_info) +{ + GDaemonMount *daemon_mount; + + if (_the_daemon_volume_monitor == NULL) + { + return NULL; + } + + g_static_rec_mutex_lock (&_the_daemon_volume_monitor_mutex); + + daemon_mount = find_mount_by_mount_info (_the_daemon_volume_monitor, mount_info); + if (daemon_mount != NULL) + { + g_object_ref (daemon_mount); + } + + g_static_rec_mutex_unlock (&_the_daemon_volume_monitor_mutex); + + return daemon_mount; +} + static void mount_added (GDaemonVolumeMonitor *daemon_monitor, GMountInfo *mount_info) { GDaemonMount *mount; GVolume *volume; + g_static_rec_mutex_lock (&_the_daemon_volume_monitor_mutex); + mount = find_mount_by_mount_info (daemon_monitor, mount_info); if (mount) { g_warning (G_STRLOC ": Mount was added twice!"); - return; + goto out; } if (mount_info->user_visible) @@ -125,6 +159,9 @@ mount_added (GDaemonVolumeMonitor *daemon_monitor, GMountInfo *mount_info) daemon_monitor->mounts = g_list_prepend (daemon_monitor->mounts, mount); g_signal_emit_by_name (daemon_monitor, "mount_added", mount); } + + out: + g_static_rec_mutex_unlock (&_the_daemon_volume_monitor_mutex); } static void @@ -132,18 +169,23 @@ mount_removed (GDaemonVolumeMonitor *daemon_monitor, GMountInfo *mount_info) { GDaemonMount *mount; + g_static_rec_mutex_lock (&_the_daemon_volume_monitor_mutex); + mount = find_mount_by_mount_info (daemon_monitor, mount_info); if (!mount) { if (mount_info->user_visible) g_warning (G_STRLOC ": An unknown mount was removed!"); - return; + goto out; } daemon_monitor->mounts = g_list_remove (daemon_monitor->mounts, mount); g_signal_emit_by_name (daemon_monitor, "mount_removed", mount); g_signal_emit_by_name (mount, "unmounted"); g_object_unref (mount); + + out: + g_static_rec_mutex_unlock (&_the_daemon_volume_monitor_mutex); } static void @@ -154,6 +196,8 @@ g_daemon_volume_monitor_init (GDaemonVolumeMonitor *daemon_monitor) GMountInfo *info; GVolume *volume; + _the_daemon_volume_monitor = daemon_monitor; + daemon_monitor->mount_tracker = g_mount_tracker_new (_g_daemon_vfs_get_async_bus ()); g_signal_connect_swapped (daemon_monitor->mount_tracker, "mounted", @@ -186,6 +230,8 @@ g_daemon_volume_monitor_finalize (GObject *object) { GDaemonVolumeMonitor *monitor; + g_static_rec_mutex_lock (&_the_daemon_volume_monitor_mutex); + monitor = G_DAEMON_VOLUME_MONITOR (object); g_signal_handlers_disconnect_by_func (monitor->mount_tracker, mount_added, monitor); @@ -198,6 +244,10 @@ g_daemon_volume_monitor_finalize (GObject *object) if (G_OBJECT_CLASS (g_daemon_volume_monitor_parent_class)->finalize) (*G_OBJECT_CLASS (g_daemon_volume_monitor_parent_class)->finalize) (object); + + _the_daemon_volume_monitor = NULL; + + g_static_rec_mutex_unlock (&_the_daemon_volume_monitor_mutex); } static void @@ -211,7 +261,6 @@ is_supported (void) GVfs *vfs; gboolean res; - res = FALSE; /* Don't do anything if the default vfs is not DAEMON_VFS */ diff --git a/client/gdaemonvolumemonitor.h b/client/gdaemonvolumemonitor.h index 2e3e3014..4019ca35 100644 --- a/client/gdaemonvolumemonitor.h +++ b/client/gdaemonvolumemonitor.h @@ -25,6 +25,7 @@ #include <glib-object.h> #include <gio/gio.h> +#include "gmounttracker.h" G_BEGIN_DECLS @@ -52,6 +53,8 @@ void g_daemon_volume_monitor_register_types (GTypeModule *type_module); GVolumeMonitor *g_daemon_volume_monitor_new (void); +GDaemonMount *g_daemon_volume_monitor_find_mount_by_mount_info (GMountInfo *mount_info); + G_END_DECLS #endif /* __G_DAEMON_VOLUME_MONITOR_H__ */ |