summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2003-11-05 16:20:01 +0000
committerAlexander Larsson <alexl@src.gnome.org>2003-11-05 16:20:01 +0000
commit3613a86b2039395b3ee229c901a00e35b85865b6 (patch)
treecdbbfdc443182435f71d4c230400c9bfb084d7e2 /libnautilus-private
parentfb27d9086b6448e10a535c6cc4a52ee919096dc5 (diff)
downloadnautilus-3613a86b2039395b3ee229c901a00e35b85865b6.tar.gz
Require new gnome-vfs
2003-11-05 Alexander Larsson <alexl@redhat.com> * configure.in: Require new gnome-vfs * components/tree/nautilus-tree-view.c: * libnautilus-private/nautilus-desktop-link-monitor.c: * libnautilus-private/nautilus-desktop-link.[ch]: * libnautilus-private/nautilus-monitor.c: * libnautilus-private/nautilus-trash-directory.c: * libnautilus-private/nautilus-trash-monitor.[ch]: * src/nautilus-application.c: Use gnome-vfs-volume-manager instead of nautilus-volume-manager.c * libnautilus-private/nautilus-desktop-icon-file.c: Set the volume on the nautilusfile * libnautilus-private/nautilus-directory-async.c: Load volume info from link * libnautilus-private/nautilus-file-attributes.h: * libnautilus-private/nautilus-mime-actions.c: Add new VOLUMES attribute * libnautilus-private/nautilus-file-private.h: Add has_volume and has_drive to NautilusFile * libnautilus-private/nautilus-file.[ch]: Add has_volume and has_drive to NautilusFile Volumes/drives are sorted separately * libnautilus-private/nautilus-link-desktop-file.[ch]: * libnautilus-private/nautilus-link.[ch]: Read drive and volume id from links * src/file-manager/fm-desktop-icon-view.c: * src/file-manager/nautilus-desktop-icon-view-ui.xml: Remove volume ops. Remove disks menu * src/file-manager/fm-directory-view.c: * src/file-manager/nautilus-directory-view-ui.xml: Implement volume ops using gnome-vfs * src/file-manager/fm-properties-window.c: Handle drives/volumes * src/nautilus-window.c: Make a nicer title for some specific locations * libnautilus-private/nautilus-volume-monitor.[ch]: * libnautilus-private/Makefile.am remove this old crap
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/Makefile.am2
-rw-r--r--libnautilus-private/nautilus-desktop-icon-file.c5
-rw-r--r--libnautilus-private/nautilus-desktop-link-monitor.c109
-rw-r--r--libnautilus-private/nautilus-desktop-link.c52
-rw-r--r--libnautilus-private/nautilus-desktop-link.h6
-rw-r--r--libnautilus-private/nautilus-directory-async.c52
-rw-r--r--libnautilus-private/nautilus-file-attributes.h1
-rw-r--r--libnautilus-private/nautilus-file-private.h11
-rw-r--r--libnautilus-private/nautilus-file.c113
-rw-r--r--libnautilus-private/nautilus-file.h7
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.c65
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.h56
-rw-r--r--libnautilus-private/nautilus-link.c58
-rw-r--r--libnautilus-private/nautilus-link.h16
-rw-r--r--libnautilus-private/nautilus-mime-actions.c3
-rw-r--r--libnautilus-private/nautilus-monitor.c22
-rw-r--r--libnautilus-private/nautilus-trash-directory.c79
-rw-r--r--libnautilus-private/nautilus-trash-monitor.c111
-rw-r--r--libnautilus-private/nautilus-trash-monitor.h4
-rw-r--r--libnautilus-private/nautilus-volume-monitor.c2399
-rw-r--r--libnautilus-private/nautilus-volume-monitor.h117
21 files changed, 414 insertions, 2874 deletions
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index 27a17e7ef..8d66a8601 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -176,8 +176,6 @@ libnautilus_private_la_SOURCES = \
nautilus-vfs-file.h \
nautilus-view-identifier.c \
nautilus-view-identifier.h \
- nautilus-volume-monitor.c \
- nautilus-volume-monitor.h \
$(NULL)
fsattributesdir = $(datadir)/nautilus
diff --git a/libnautilus-private/nautilus-desktop-icon-file.c b/libnautilus-private/nautilus-desktop-icon-file.c
index bb9535e99..2f482a291 100644
--- a/libnautilus-private/nautilus-desktop-icon-file.c
+++ b/libnautilus-private/nautilus-desktop-icon-file.c
@@ -179,6 +179,7 @@ update_info_from_link (NautilusDesktopIconFile *icon_file)
NautilusFile *file;
GnomeVFSFileInfo *file_info;
NautilusDesktopLink *link;
+ GnomeVFSVolume *volume;
file = NAUTILUS_FILE (icon_file);
@@ -204,6 +205,10 @@ update_info_from_link (NautilusDesktopIconFile *icon_file)
GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE |
GNOME_VFS_FILE_INFO_FIELDS_SIZE |
GNOME_VFS_FILE_INFO_FIELDS_LINK_COUNT;
+
+ volume = nautilus_desktop_link_get_volume (link);
+ nautilus_file_set_volume (file, volume);
+ gnome_vfs_volume_unref (volume);
file->details->file_info_is_up_to_date = TRUE;
diff --git a/libnautilus-private/nautilus-desktop-link-monitor.c b/libnautilus-private/nautilus-desktop-link-monitor.c
index da3fb979f..ff5fc1c00 100644
--- a/libnautilus-private/nautilus-desktop-link-monitor.c
+++ b/libnautilus-private/nautilus-desktop-link-monitor.c
@@ -39,6 +39,7 @@
#include <gtk/gtkstock.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomevfs/gnome-vfs.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <string.h>
@@ -48,6 +49,9 @@ struct NautilusDesktopLinkMonitorDetails {
NautilusDesktopLink *home_link;
NautilusDesktopLink *trash_link;
+ gulong mount_id;
+ gulong unmount_id;
+
GList *volume_links;
};
@@ -108,76 +112,25 @@ nautilus_desktop_link_monitor_delete_link (NautilusDesktopLinkMonitor *monitor,
}
}
-
-static gboolean
-volume_name_exists (NautilusDesktopLinkMonitor *monitor,
- const char *name)
-{
- GList *l;
- char *other_name;
-
- for (l = monitor->details->volume_links; l != NULL; l = l->next) {
- other_name = nautilus_desktop_link_get_display_name (l->data);
- if (strcmp (name, other_name) == 0) {
- g_free (other_name);
- return TRUE;
- }
- g_free (other_name);
- }
- return FALSE;
-}
-
static void
create_volume_link (NautilusDesktopLinkMonitor *monitor,
- const NautilusVolume *volume)
+ GnomeVFSVolume *volume)
{
NautilusDesktopLink *link;
- char *volume_name;
- char *unique_name;
- int index;
- if (nautilus_volume_is_in_removable_blacklist (volume)) {
+ if (!gnome_vfs_volume_is_user_visible (volume)) {
return;
}
- /* FIXME bugzilla.gnome.org 45412: Design a comprehensive desktop mounting strategy */
- if (!nautilus_volume_is_removable (volume)) {
- return;
- }
-
- volume_name = nautilus_volume_get_name (volume);
- index = 1;
-
- unique_name = g_strdup (volume_name);
- while (volume_name_exists (monitor, unique_name)) {
- g_free (unique_name);
- index++;
- unique_name = g_strdup_printf ("%s (%d)", volume_name, index);
- }
-
- if (index != 1) {
- nautilus_volume_monitor_set_volume_name (nautilus_volume_monitor_get (),
- volume, unique_name);
- }
- g_free (volume_name);
- g_free (unique_name);
-
link = nautilus_desktop_link_new_from_volume (volume);
monitor->details->volume_links = g_list_prepend (monitor->details->volume_links, link);
}
-static gboolean
-create_one_volume_link (const NautilusVolume *volume, gpointer callback_data)
-{
- create_volume_link (NAUTILUS_DESKTOP_LINK_MONITOR (callback_data),
- volume);
- return TRUE;
-}
static void
-volume_mounted_callback (NautilusVolumeMonitor *volume_monitor,
- NautilusVolume *volume,
+volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
+ GnomeVFSVolume *volume,
NautilusDesktopLinkMonitor *monitor)
{
create_volume_link (monitor, volume);
@@ -185,29 +138,28 @@ volume_mounted_callback (NautilusVolumeMonitor *volume_monitor,
static void
-volume_unmounted_callback (NautilusVolumeMonitor *volume_monitor,
- NautilusVolume *volume,
+volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
+ GnomeVFSVolume *volume,
NautilusDesktopLinkMonitor *monitor)
{
GList *l;
NautilusDesktopLink *link;
- char *mount_path;
+ GnomeVFSVolume *other_volume;
link = NULL;
for (l = monitor->details->volume_links; l != NULL; l = l->next) {
- mount_path = nautilus_desktop_link_get_mount_path (l->data);
-
- if (strcmp (mount_path, nautilus_volume_get_mount_path (volume)) == 0) {
+ other_volume = nautilus_desktop_link_get_volume (l->data);
+ if (volume == other_volume) {
+ gnome_vfs_volume_unref (other_volume);
link = l->data;
- g_free (mount_path);
break;
}
- g_free (mount_path);
+ gnome_vfs_volume_unref (other_volume);
}
if (link) {
- g_object_unref (link);
monitor->details->volume_links = g_list_remove (monitor->details->volume_links, link);
+ g_object_unref (link);
}
}
@@ -254,6 +206,9 @@ static void
nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
{
NautilusDesktopLinkMonitor *monitor;
+ GList *l, *volumes;
+ GnomeVFSVolume *volume;
+ GnomeVFSVolumeMonitor *volume_monitor;
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (object);
@@ -270,9 +225,14 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
monitor->details->trash_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_TRASH);
}
- nautilus_volume_monitor_each_mounted_volume (nautilus_volume_monitor_get (),
- create_one_volume_link,
- monitor);
+ volume_monitor = gnome_vfs_get_volume_monitor ();
+ volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
+ for (l = volumes; l != NULL; l = l->next) {
+ volume = l->data;
+ create_volume_link (monitor, volume);
+ gnome_vfs_volume_unref (volume);
+ }
+ g_list_free (volumes);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE,
desktop_home_visible_changed,
@@ -282,10 +242,10 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
monitor);
- g_signal_connect_object (nautilus_volume_monitor_get (), "volume_mounted",
- G_CALLBACK (volume_mounted_callback), monitor, 0);
- g_signal_connect_object (nautilus_volume_monitor_get (), "volume_unmounted",
- G_CALLBACK (volume_unmounted_callback), monitor, 0);
+ monitor->details->mount_id = g_signal_connect_object (volume_monitor, "volume_mounted",
+ G_CALLBACK (volume_mounted_callback), monitor, 0);
+ monitor->details->unmount_id = g_signal_connect_object (volume_monitor, "volume_unmounted",
+ G_CALLBACK (volume_unmounted_callback), monitor, 0);
}
@@ -319,6 +279,13 @@ desktop_link_monitor_finalize (GObject *object)
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE,
desktop_trash_visible_changed,
monitor);
+
+ if (monitor->details->mount_id != 0) {
+ g_source_remove (monitor->details->mount_id);
+ }
+ if (monitor->details->unmount_id != 0) {
+ g_source_remove (monitor->details->unmount_id);
+ }
g_free (monitor->details);
diff --git a/libnautilus-private/nautilus-desktop-link.c b/libnautilus-private/nautilus-desktop-link.c
index d48938530..f5279f33b 100644
--- a/libnautilus-private/nautilus-desktop-link.c
+++ b/libnautilus-private/nautilus-desktop-link.c
@@ -53,7 +53,7 @@ struct NautilusDesktopLinkDetails {
gulong trash_state_handler;
/* Just for volume icons: */
- char *mount_path;
+ GnomeVFSVolume *volume;
};
static void nautilus_desktop_link_init (gpointer object,
@@ -162,49 +162,45 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
}
NautilusDesktopLink *
-nautilus_desktop_link_new_from_volume (const NautilusVolume *volume)
+nautilus_desktop_link_new_from_volume (GnomeVFSVolume *volume)
{
NautilusDesktopLink *link;
- const char *mount_path;
- char *underscore_mount_path, *p;
+ GnomeVFSDrive *drive;
+ char *name;
link = NAUTILUS_DESKTOP_LINK (g_object_new (NAUTILUS_TYPE_DESKTOP_LINK, NULL));
link->details->type = NAUTILUS_DESKTOP_LINK_VOLUME;
- mount_path = nautilus_volume_get_mount_path (volume);
- link->details->mount_path = g_strdup (mount_path);
-
- /* Convert slashes in the mount path to underscores and skip
- first slash */
- while (*mount_path == '/') {
- mount_path ++;
- }
- underscore_mount_path = g_strdup (mount_path);
- for (p = underscore_mount_path; *p != 0; p++) {
- if (*p == '/') {
- *p = '_';
- }
- }
+ link->details->volume = gnome_vfs_volume_ref (volume);
- link->details->filename = g_strconcat ("mount_", underscore_mount_path, NULL);
- g_free (underscore_mount_path);
+ /* We try to use the drive name to get somewhat stable filenames
+ for metadata */
+ drive = gnome_vfs_volume_get_drive (volume);
+ if (drive != NULL) {
+ name = gnome_vfs_drive_get_display_name (drive);
+ } else {
+ name = gnome_vfs_volume_get_display_name (volume);
+ }
+ gnome_vfs_drive_unref (drive);
- link->details->display_name = nautilus_volume_get_name (volume);
+ link->details->filename = g_strconcat (name, ".volume", NULL);
+ g_free (name);
- link->details->activation_uri = nautilus_volume_get_target_uri (volume);
- link->details->icon = nautilus_volume_get_icon (volume);
+ link->details->display_name = gnome_vfs_volume_get_display_name (volume);
+
+ link->details->activation_uri = gnome_vfs_volume_get_activation_uri (volume);
+ link->details->icon = gnome_vfs_volume_get_icon (volume);
create_icon_file (link);
return link;
}
-char *
-nautilus_desktop_link_get_mount_path (NautilusDesktopLink *link)
+GnomeVFSVolume *
+nautilus_desktop_link_get_volume (NautilusDesktopLink *link)
{
- g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME);
- return g_strdup (link->details->mount_path);
+ return gnome_vfs_volume_ref (link->details->volume);
}
@@ -368,7 +364,7 @@ desktop_link_finalize (GObject *object)
}
if (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME) {
- g_free (link->details->mount_path);
+ gnome_vfs_volume_unref (link->details->volume);
}
g_free (link->details->filename);
diff --git a/libnautilus-private/nautilus-desktop-link.h b/libnautilus-private/nautilus-desktop-link.h
index b5cf379cf..d6dede899 100644
--- a/libnautilus-private/nautilus-desktop-link.h
+++ b/libnautilus-private/nautilus-desktop-link.h
@@ -26,7 +26,7 @@
#define NAUTILUS_DESKTOP_LINK_H
#include <libnautilus-private/nautilus-file.h>
-#include <libnautilus-private/nautilus-volume-monitor.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
#define NAUTILUS_TYPE_DESKTOP_LINK \
(nautilus_desktop_link_get_type ())
@@ -59,7 +59,7 @@ typedef enum {
GType nautilus_desktop_link_get_type (void);
NautilusDesktopLink * nautilus_desktop_link_new (NautilusDesktopLinkType type);
-NautilusDesktopLink * nautilus_desktop_link_new_from_volume (const NautilusVolume *volume);
+NautilusDesktopLink * nautilus_desktop_link_new_from_volume (GnomeVFSVolume *volume);
NautilusDesktopLinkType nautilus_desktop_link_get_link_type (NautilusDesktopLink *link);
char * nautilus_desktop_link_get_file_name (NautilusDesktopLink *link);
char * nautilus_desktop_link_get_display_name (NautilusDesktopLink *link);
@@ -68,7 +68,7 @@ char * nautilus_desktop_link_get_activation_uri (NautilusDeskto
gboolean nautilus_desktop_link_get_date (NautilusDesktopLink *link,
NautilusDateType date_type,
time_t *date);
-char * nautilus_desktop_link_get_mount_path (NautilusDesktopLink *link);
+GnomeVFSVolume * nautilus_desktop_link_get_volume (NautilusDesktopLink *link);
gboolean nautilus_desktop_link_can_rename (NautilusDesktopLink *link);
gboolean nautilus_desktop_link_rename (NautilusDesktopLink *link,
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index 4aa4229e8..343dd4db3 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -40,6 +40,7 @@
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-mime-monitor.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libxml/parser.h>
#include <stdio.h>
#include <stdlib.h>
@@ -119,7 +120,9 @@ static void link_info_done (NautilusDirectory *directory,
NautilusFile *file,
const char *uri,
const char *name,
- const char *icon);
+ const char *icon,
+ gulong drive_id,
+ gulong volume_id);
static gboolean file_needs_high_priority_work_done (NautilusDirectory *directory,
NautilusFile *file);
static gboolean file_needs_low_priority_work_done (NautilusDirectory *directory,
@@ -539,6 +542,10 @@ nautilus_directory_set_up_request (Request *request,
request->file_info = TRUE;
request->link_info = TRUE;
}
+
+ if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_VOLUMES) {
+ request->link_info = TRUE;
+ }
if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME) {
request->file_info = TRUE;
@@ -1727,7 +1734,7 @@ lacks_link_info (NautilusFile *file)
should_look_for_dot_directory_file (file)) {
return TRUE;
} else {
- link_info_done (file->details->directory, file, NULL, NULL, NULL);
+ link_info_done (file->details->directory, file, NULL, NULL, NULL, 0, 0);
return FALSE;
}
} else {
@@ -2887,8 +2894,14 @@ link_info_done (NautilusDirectory *directory,
NautilusFile *file,
const char *uri,
const char *name,
- const char *icon)
+ const char *icon,
+ gulong drive_id,
+ gulong volume_id)
{
+ GnomeVFSVolumeMonitor *monitor;
+ GnomeVFSVolume *volume;
+ GnomeVFSDrive *drive;
+
file->details->link_info_is_up_to_date = TRUE;
file->details->got_link_info = TRUE;
@@ -2900,6 +2913,22 @@ link_info_done (NautilusDirectory *directory,
file->details->custom_icon = g_strdup (icon);
nautilus_file_clear_cached_display_name (file);
+ volume = NULL;
+ if (volume_id != 0) {
+ monitor = gnome_vfs_get_volume_monitor ();
+ volume = gnome_vfs_volume_monitor_get_volume_by_id (monitor, volume_id);
+ }
+ nautilus_file_set_volume (file, volume);
+ gnome_vfs_volume_unref (volume);
+
+ drive = NULL;
+ if (drive_id != 0) {
+ monitor = gnome_vfs_get_volume_monitor ();
+ drive = gnome_vfs_volume_monitor_get_drive_by_id (monitor, drive_id);
+ }
+ nautilus_file_set_drive (file, drive);
+ gnome_vfs_drive_unref (drive);
+
nautilus_directory_async_state_changed (directory);
}
@@ -2914,7 +2943,9 @@ static void
link_info_read_done (NautilusDirectory *directory,
const char *uri,
const char *name,
- const char *icon)
+ const char *icon,
+ gulong drive_id,
+ gulong volume_id)
{
NautilusFile *file;
@@ -2923,7 +2954,7 @@ link_info_read_done (NautilusDirectory *directory,
directory->details->link_info_read_state = NULL;
nautilus_file_ref (file);
- link_info_done (directory, file, uri, name, icon);
+ link_info_done (directory, file, uri, name, icon, drive_id, volume_id);
nautilus_file_changed (file);
if (!should_read_link_info_sync (file)) {
@@ -2942,6 +2973,7 @@ link_info_nautilus_link_read_callback (GnomeVFSResult result,
{
NautilusDirectory *directory;
char *buffer, *uri, *name, *icon;
+ gulong drive_id, volume_id;
directory = NAUTILUS_DIRECTORY (callback_data);
@@ -2954,17 +2986,17 @@ link_info_nautilus_link_read_callback (GnomeVFSResult result,
uri = NULL;
name = NULL;
icon = NULL;
+ volume_id = drive_id = 0;
} else {
/* The libxml parser requires a zero-terminated array. */
buffer = g_realloc (file_contents, bytes_read + 1);
buffer[bytes_read] = '\0';
- uri = nautilus_link_get_link_uri_given_file_contents (NULL, buffer, bytes_read);
- name = nautilus_link_get_link_name_given_file_contents (NULL, buffer, bytes_read);
- icon = nautilus_link_get_link_icon_given_file_contents (NULL, buffer, bytes_read);
+ nautilus_link_get_link_info_given_file_contents (buffer, bytes_read,
+ &uri, &name, &icon, &drive_id, &volume_id);
g_free (buffer);
}
- link_info_read_done (directory, uri, name, icon);
+ link_info_read_done (directory, uri, name, icon, drive_id, volume_id);
g_free (uri);
g_free (name);
g_free (icon);
@@ -3065,7 +3097,7 @@ link_info_start (NautilusDirectory *directory,
/* If it's not a link we are done. If it is, we need to read it. */
if (!(nautilus_style_link || (is_directory && dot_directory_uri != NULL) )) {
- link_info_done (directory, file, NULL, NULL, NULL);
+ link_info_done (directory, file, NULL, NULL, NULL, 0, 0);
} else if (should_read_link_info_sync (file)) {
directory->details->link_info_read_state = g_new0 (LinkInfoReadState, 1);
directory->details->link_info_read_state->file = file;
diff --git a/libnautilus-private/nautilus-file-attributes.h b/libnautilus-private/nautilus-file-attributes.h
index a34bba663..38e1da94f 100644
--- a/libnautilus-private/nautilus-file-attributes.h
+++ b/libnautilus-private/nautilus-file-attributes.h
@@ -42,6 +42,7 @@ typedef enum {
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE = 1 << 9,
NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT = 1 << 10,
NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME = 1 << 11,
+ NAUTILUS_FILE_ATTRIBUTE_VOLUMES = 1 << 12,
} NautilusFileAttributes;
#endif /* NAUTILUS_FILE_ATTRIBUTES_H */
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h
index 47a49d3a6..443f57da7 100644
--- a/libnautilus-private/nautilus-file-private.h
+++ b/libnautilus-private/nautilus-file-private.h
@@ -126,7 +126,11 @@ struct NautilusFileDetails
eel_boolean_bit got_link_info : 1;
eel_boolean_bit link_info_is_up_to_date : 1;
- eel_boolean_bit is_thumbnailing : 1;
+ eel_boolean_bit is_thumbnailing : 1;
+
+ eel_boolean_bit has_volume : 1;
+ eel_boolean_bit has_drive : 1;
+
};
NautilusFile *nautilus_file_new_from_info (NautilusDirectory *directory,
@@ -180,5 +184,10 @@ GnomeVFSFileInfo * nautilus_file_peek_vfs_file_info (NautilusFil
void nautilus_file_set_is_thumbnailing (NautilusFile *file,
gboolean is_thumbnailing);
+/* Volumes: */
+void nautilus_file_set_drive (NautilusFile *file,
+ GnomeVFSDrive *drive);
+void nautilus_file_set_volume (NautilusFile *file,
+ GnomeVFSVolume *volume);
#endif
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 2fbbbc831..7f11963d4 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -43,7 +43,6 @@
#include "nautilus-trash-directory.h"
#include "nautilus-trash-file.h"
#include "nautilus-vfs-file.h"
-#include "nautilus-volume-monitor.h"
#include <eel/eel-debug.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
@@ -57,6 +56,9 @@
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <libgnomevfs/gnome-vfs-drive.h>
#include <libxml/parser.h>
#include <pwd.h>
#include <stdlib.h>
@@ -830,6 +832,63 @@ nautilus_file_can_rename (NautilusFile *file)
return can_rename;
}
+gboolean
+nautilus_file_has_volume (NautilusFile *file)
+{
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+
+ return file->details->has_volume;
+}
+
+gboolean
+nautilus_file_has_drive (NautilusFile *file)
+{
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+
+ return file->details->has_drive;
+}
+
+void
+nautilus_file_set_volume (NautilusFile *file,
+ GnomeVFSVolume *volume)
+{
+ file->details->has_volume = volume != NULL;
+ gnome_vfs_volume_ref (volume);
+ g_object_set_data_full (G_OBJECT (file),
+ "nautilus_file_volume",
+ volume,
+ (GDestroyNotify)gnome_vfs_volume_unref);
+
+}
+
+void
+nautilus_file_set_drive (NautilusFile *file,
+ GnomeVFSDrive *drive)
+{
+ file->details->has_drive = drive != NULL;
+ gnome_vfs_drive_ref (drive);
+ g_object_set_data_full (G_OBJECT (file),
+ "nautilus_file_drive",
+ drive,
+ (GDestroyNotify)gnome_vfs_drive_unref);
+}
+
+
+GnomeVFSVolume *
+nautilus_file_get_volume (NautilusFile *file)
+{
+ return g_object_get_data (G_OBJECT (file),
+ "nautilus_file_volume");
+
+}
+
+GnomeVFSDrive *
+nautilus_file_get_drive (NautilusFile *file)
+{
+ return g_object_get_data (G_OBJECT (file),
+ "nautilus_file_drive");
+}
+
static GnomeVFSURI *
nautilus_file_get_gnome_vfs_uri (NautilusFile *file)
{
@@ -1978,7 +2037,46 @@ nautilus_file_compare_for_sort_internal (NautilusFile *file_1,
NautilusFileSortType sort_type)
{
int compare;
+ GnomeVFSDrive *drive1, *drive2;
+ GnomeVFSVolume *volume1, *volume2;
+ if (file_1 == file_2) {
+ return 0;
+ }
+
+ /* Always sort drives/volumes separately: */
+ if (file_1->details->has_drive != file_2->details->has_drive) {
+ if (file_1->details->has_drive) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ if (file_1->details->has_drive) {
+ drive1 = nautilus_file_get_drive (file_1);
+ drive2 = nautilus_file_get_drive (file_2);
+ compare = gnome_vfs_drive_compare (drive1, drive2);
+ if (compare != 0) {
+ return compare;
+ }
+ }
+
+ if (file_1->details->has_volume != file_2->details->has_volume) {
+ if (file_1->details->has_volume) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ if (file_1->details->has_volume) {
+ volume1 = nautilus_file_get_volume (file_1);
+ volume2 = nautilus_file_get_volume (file_2);
+ compare = gnome_vfs_volume_compare (volume1, volume2);
+ if (compare != 0) {
+ return compare;
+ }
+ }
+
switch (sort_type) {
case NAUTILUS_FILE_SORT_BY_DISPLAY_NAME:
compare = compare_by_display_name (file_1, file_2);
@@ -4709,20 +4807,18 @@ nautilus_file_get_volume_name (NautilusFile *file)
char *local_path;
char *file_uri;
char *volume_name;
- NautilusVolume *volume;
+ GnomeVFSVolume *volume;
file_uri = nautilus_file_get_uri (file);
local_path = gnome_vfs_get_local_path_from_uri (file_uri);
- volume = nautilus_volume_monitor_get_volume_for_path (nautilus_volume_monitor_get (), local_path);
+ volume = gnome_vfs_volume_monitor_get_volume_for_path (gnome_vfs_get_volume_monitor (), local_path);
g_free (file_uri);
g_free (local_path);
if (volume != NULL) {
- volume_name = nautilus_volume_get_name (volume);
- if (volume_name == NULL) {
- return g_strdup (nautilus_volume_get_mount_path (volume));
- }
+ volume_name = gnome_vfs_volume_get_display_name (volume);
+ gnome_vfs_volume_unref (volume);
return volume_name;
} else {
return NULL;
@@ -5307,7 +5403,8 @@ nautilus_file_get_all_attributes (void)
NAUTILUS_FILE_ATTRIBUTE_METADATA |
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
+ NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME |
+ NAUTILUS_FILE_ATTRIBUTE_VOLUMES;
}
void
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 2582ab375..b8dec39a0 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -27,6 +27,7 @@
#include <gtk/gtkobject.h>
#include <libgnomevfs/gnome-vfs-types.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
#include <libnautilus-private/nautilus-file-attributes.h>
/* NautilusFile is an object used to represent a single element of a
@@ -189,6 +190,12 @@ gboolean nautilus_file_can_write (Nautilu
gboolean nautilus_file_can_execute (NautilusFile *file);
gboolean nautilus_file_can_rename (NautilusFile *file);
+/* Volumes. */
+gboolean nautilus_file_has_volume (NautilusFile *file);
+gboolean nautilus_file_has_drive (NautilusFile *file);
+GnomeVFSVolume * nautilus_file_get_volume (NautilusFile *file);
+GnomeVFSDrive * nautilus_file_get_drive (NautilusFile *file);
+
/* Basic operations for file objects. */
void nautilus_file_set_owner (NautilusFile *file,
const char *user_name_or_id,
diff --git a/libnautilus-private/nautilus-link-desktop-file.c b/libnautilus-private/nautilus-link-desktop-file.c
index 1f4be8dfc..f6ad946ff 100644
--- a/libnautilus-private/nautilus-link-desktop-file.c
+++ b/libnautilus-private/nautilus-link-desktop-file.c
@@ -368,59 +368,38 @@ nautilus_link_desktop_file_local_get_link_uri (const char *uri)
return retval;
}
-char *
-nautilus_link_desktop_file_get_link_uri_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size)
+void
+nautilus_link_desktop_file_get_link_info_given_file_contents (const char *file_contents,
+ int link_file_size,
+ char **uri,
+ char **name,
+ char **icon,
+ gulong *drive_id,
+ gulong *volume_id)
{
GnomeDesktopItem *desktop_file;
- char *retval;
+ const char *id;
- desktop_file = gnome_desktop_item_new_from_string (uri, link_file_contents, link_file_size, 0, NULL);
+ desktop_file = gnome_desktop_item_new_from_string (NULL, file_contents, link_file_size, 0, NULL);
if (desktop_file == NULL) {
- return NULL;
+ return;
}
- retval = nautilus_link_desktop_file_get_link_uri_from_desktop (desktop_file);
-
- gnome_desktop_item_unref (desktop_file);
- return retval;
-}
-
-char *
-nautilus_link_desktop_file_get_link_name_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size)
-{
- GnomeDesktopItem *desktop_file;
- char *retval;
+
+ *uri = nautilus_link_desktop_file_get_link_uri_from_desktop (desktop_file);
+ *name = nautilus_link_desktop_file_get_link_name_from_desktop (desktop_file);
+ *icon = nautilus_link_desktop_file_get_link_icon_from_desktop (desktop_file);
- desktop_file = gnome_desktop_item_new_from_string (uri, link_file_contents, link_file_size, 0, NULL);
- if (desktop_file == NULL) {
- return NULL;
+ id = gnome_desktop_item_get_string (desktop_file, "X-Gnome-Volume");
+ if (id != NULL) {
+ *volume_id = atol (id);
}
- retval = nautilus_link_desktop_file_get_link_name_from_desktop (desktop_file);
- gnome_desktop_item_unref (desktop_file);
- return retval;
-}
-
-
-char *
-nautilus_link_desktop_file_get_link_icon_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size)
-{
- GnomeDesktopItem *desktop_file;
- char *retval;
-
- desktop_file = gnome_desktop_item_new_from_string (uri, link_file_contents, link_file_size, 0, NULL);
- if (desktop_file == NULL) {
- return NULL;
+ id = gnome_desktop_item_get_string (desktop_file, "X-Gnome-Drive");
+ if (id != NULL) {
+ *drive_id = atol (id);
}
- retval = nautilus_link_desktop_file_get_link_icon_from_desktop (desktop_file);
-
+
gnome_desktop_item_unref (desktop_file);
- return retval;
}
diff --git a/libnautilus-private/nautilus-link-desktop-file.h b/libnautilus-private/nautilus-link-desktop-file.h
index 25c9e9164..f97f05a5b 100644
--- a/libnautilus-private/nautilus-link-desktop-file.h
+++ b/libnautilus-private/nautilus-link-desktop-file.h
@@ -27,34 +27,32 @@
#include <libnautilus-private/nautilus-link.h>
-gboolean nautilus_link_desktop_file_local_create (const char *directory_uri,
- const char *name,
- const char *image,
- const char *target_uri,
- const GdkPoint *point,
- int screen,
- NautilusLinkType type);
-gboolean nautilus_link_desktop_file_local_set_icon (const char *uri,
- const char *icon_name);
-gboolean nautilus_link_desktop_file_local_set_text (const char *uri,
- const char *text);
-char * nautilus_link_desktop_file_local_get_text (const char *uri);
-char * nautilus_link_desktop_file_local_get_additional_text (const char *uri);
-NautilusLinkType nautilus_link_desktop_file_local_get_link_type (const char *uri);
-char * nautilus_link_desktop_file_local_get_link_uri (const char *uri);
-gboolean nautilus_link_desktop_file_local_is_utf8 (const char *uri);
-char * nautilus_link_desktop_file_get_link_uri_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size);
-char * nautilus_link_desktop_file_get_link_name_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size);
-char * nautilus_link_desktop_file_get_link_icon_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size);
-void nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopItem *entry,
- const char *dest_uri,
- const GdkPoint *position,
- int screen);
+gboolean nautilus_link_desktop_file_local_create (const char *directory_uri,
+ const char *name,
+ const char *image,
+ const char *target_uri,
+ const GdkPoint *point,
+ int screen,
+ NautilusLinkType type);
+gboolean nautilus_link_desktop_file_local_set_icon (const char *uri,
+ const char *icon_name);
+gboolean nautilus_link_desktop_file_local_set_text (const char *uri,
+ const char *text);
+char * nautilus_link_desktop_file_local_get_text (const char *uri);
+char * nautilus_link_desktop_file_local_get_additional_text (const char *uri);
+NautilusLinkType nautilus_link_desktop_file_local_get_link_type (const char *uri);
+char * nautilus_link_desktop_file_local_get_link_uri (const char *uri);
+gboolean nautilus_link_desktop_file_local_is_utf8 (const char *uri);
+void nautilus_link_desktop_file_get_link_info_given_file_contents (const char *file_contents,
+ int link_file_size,
+ char **uri,
+ char **name,
+ char **icon,
+ gulong *drive_id,
+ gulong *volume_id);
+void nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopItem *entry,
+ const char *dest_uri,
+ const GdkPoint *position,
+ int screen);
#endif /* NAUTILUS_LINK_DESKTOP_FILE_H */
diff --git a/libnautilus-private/nautilus-link.c b/libnautilus-private/nautilus-link.c
index 251575d6b..53dbc14c2 100644
--- a/libnautilus-private/nautilus-link.c
+++ b/libnautilus-private/nautilus-link.c
@@ -242,48 +242,30 @@ nautilus_link_local_is_utf8 (const char *uri,
}
}
-char *
-nautilus_link_get_link_uri_given_file_contents (const char *uri,
- const char *file_contents,
- int file_size)
-{
- switch (get_link_style_for_data (file_contents, file_size)) {
- case desktop:
- return nautilus_link_desktop_file_get_link_uri_given_file_contents (uri, file_contents, file_size);
- case historical:
- return nautilus_link_historical_get_link_uri_given_file_contents (file_contents, file_size);
- default:
- return NULL;
- }
-}
-
-char *
-nautilus_link_get_link_name_given_file_contents (const char *uri,
- const char *file_contents,
- int file_size)
-{
- switch (get_link_style_for_data (file_contents, file_size)) {
- case desktop:
- return nautilus_link_desktop_file_get_link_name_given_file_contents (uri, file_contents, file_size);
- case historical:
- return NULL;
- default:
- return NULL;
- }
-}
-
-char *
-nautilus_link_get_link_icon_given_file_contents (const char *uri,
- const char *file_contents,
- int file_size)
+void
+nautilus_link_get_link_info_given_file_contents (const char *file_contents,
+ int link_file_size,
+ char **uri,
+ char **name,
+ char **icon,
+ gulong *drive_id,
+ gulong *volume_id)
{
- switch (get_link_style_for_data (file_contents, file_size)) {
+ *uri = NULL;
+ *name = NULL;
+ *icon = NULL;
+ *drive_id = 0;
+ *volume_id = 0;
+
+ switch (get_link_style_for_data (file_contents, link_file_size)) {
case desktop:
- return nautilus_link_desktop_file_get_link_icon_given_file_contents (uri, file_contents, file_size);
+ return nautilus_link_desktop_file_get_link_info_given_file_contents (file_contents, link_file_size, uri, name, icon, drive_id, volume_id);
case historical:
- return nautilus_link_historical_get_link_icon_given_file_contents (file_contents, file_size);
+ *uri = nautilus_link_historical_get_link_uri_given_file_contents (file_contents, link_file_size);
+ *icon = nautilus_link_historical_get_link_icon_given_file_contents (file_contents, link_file_size);
+ break;
default:
- return NULL;
+ return;
}
}
diff --git a/libnautilus-private/nautilus-link.h b/libnautilus-private/nautilus-link.h
index e185fc8a9..508aa99fa 100644
--- a/libnautilus-private/nautilus-link.h
+++ b/libnautilus-private/nautilus-link.h
@@ -121,15 +121,13 @@ gboolean nautilus_link_local_is_utf8 (const char
* contents of a file already in memory.
*/
char * nautilus_link_local_get_link_uri (const char *uri);
-char * nautilus_link_get_link_uri_given_file_contents (const char *uri,
- const char *link_file_contents,
- int link_file_size);
-char * nautilus_link_get_link_name_given_file_contents (const char *uri,
- const char *file_contents,
- int link_file_size);
-char * nautilus_link_get_link_icon_given_file_contents (const char *uri,
- const char *file_contents,
- int link_file_size);
+void nautilus_link_get_link_info_given_file_contents (const char *file_contents,
+ int link_file_size,
+ char **uri,
+ char **name,
+ char **icon,
+ gulong *drive_id,
+ gulong *volume_id);
void nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *item,
const char *dest_uri,
const GdkPoint *position,
diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c
index 30cf8ec7d..406ef8347 100644
--- a/libnautilus-private/nautilus-mime-actions.c
+++ b/libnautilus-private/nautilus-mime-actions.c
@@ -95,7 +95,8 @@ nautilus_mime_actions_check_if_full_attributes_ready (NautilusFile *file)
NautilusFileAttributes
nautilus_mime_actions_get_minimum_file_attributes (void)
{
- return NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
+ return NAUTILUS_FILE_ATTRIBUTE_VOLUMES |
+ NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
NAUTILUS_FILE_ATTRIBUTE_METADATA |
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE;
}
diff --git a/libnautilus-private/nautilus-monitor.c b/libnautilus-private/nautilus-monitor.c
index cd2de5b22..da66ce6a6 100644
--- a/libnautilus-private/nautilus-monitor.c
+++ b/libnautilus-private/nautilus-monitor.c
@@ -28,11 +28,11 @@
#include "nautilus-monitor.h"
#include "nautilus-file-changes-queue.h"
#include "nautilus-file-utilities.h"
-#include "nautilus-volume-monitor.h"
#include <libgnome/gnome-util.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
struct NautilusMonitor {
GnomeVFSMonitorHandle *handle;
@@ -69,17 +69,19 @@ nautilus_monitor_active (void)
static gboolean
path_is_on_readonly_volume (const char *path)
{
- NautilusVolumeMonitor *volume_monitor;
- NautilusVolume *volume;
-
- volume_monitor = nautilus_volume_monitor_get ();
- volume = nautilus_volume_monitor_get_volume_for_path (volume_monitor,
- path);
+ GnomeVFSVolumeMonitor *volume_monitor;
+ GnomeVFSVolume *volume;
+ gboolean res;
+
+ volume_monitor = gnome_vfs_get_volume_monitor ();
+ volume = gnome_vfs_volume_monitor_get_volume_for_path (volume_monitor,
+ path);
+ res = FALSE;
if (volume != NULL) {
- return nautilus_volume_is_read_only (volume);
- } else {
- return FALSE;
+ res = gnome_vfs_volume_is_read_only (volume);
+ gnome_vfs_volume_unref (volume);
}
+ return res;
}
static gboolean call_consume_changes_idle_id = 0;
diff --git a/libnautilus-private/nautilus-trash-directory.c b/libnautilus-private/nautilus-trash-directory.c
index c71fd5ed6..3361f4f35 100644
--- a/libnautilus-private/nautilus-trash-directory.c
+++ b/libnautilus-private/nautilus-trash-directory.c
@@ -28,7 +28,6 @@
#include "nautilus-directory-private.h"
#include "nautilus-trash-monitor.h"
-#include "nautilus-volume-monitor.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <gtk/gtkmain.h>
@@ -36,6 +35,7 @@
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-macros.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
struct NautilusTrashDirectoryDetails {
GHashTable *volumes;
@@ -43,14 +43,14 @@ struct NautilusTrashDirectoryDetails {
typedef struct {
NautilusTrashDirectory *trash;
- NautilusVolume *volume;
+ GnomeVFSVolume *volume;
GnomeVFSAsyncHandle *handle;
NautilusDirectory *real_directory;
} TrashVolume;
static void add_volume (NautilusTrashDirectory *trash,
- NautilusVolume *volume);
+ GnomeVFSVolume *volume);
GNOME_CLASS_BOILERPLATE (NautilusTrashDirectory, nautilus_trash_directory,
NautilusMergedDirectory, NAUTILUS_TYPE_MERGED_DIRECTORY)
@@ -131,12 +131,11 @@ find_directory_callback (GnomeVFSAsyncHandle *handle,
static gboolean
get_trash_volume (NautilusTrashDirectory *trash,
- NautilusVolume *volume,
+ GnomeVFSVolume *volume,
TrashVolume **trash_volume,
GnomeVFSURI **volume_mount_uri)
{
char *uri_str;
- NautilusVolume *volume_copy;
/* Quick out if we already know about this volume. */
*trash_volume = g_hash_table_lookup (trash->details->volumes,
@@ -146,11 +145,11 @@ get_trash_volume (NautilusTrashDirectory *trash,
return FALSE;
}
- if (!nautilus_volume_should_integrate_trash (volume)) {
+ if (!gnome_vfs_volume_handles_trash (volume)) {
return FALSE;
}
-
- uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
+
+ uri_str = gnome_vfs_volume_get_activation_uri (volume);
*volume_mount_uri = gnome_vfs_uri_new (uri_str);
g_free (uri_str);
@@ -158,9 +157,8 @@ get_trash_volume (NautilusTrashDirectory *trash,
/* Make the structure used to track the trash for this volume. */
*trash_volume = g_new0 (TrashVolume, 1);
(*trash_volume)->trash = trash;
- volume_copy = nautilus_volume_copy (volume);
- (*trash_volume)->volume = volume_copy;
- g_hash_table_insert (trash->details->volumes, volume_copy, *trash_volume);
+ (*trash_volume)->volume = gnome_vfs_volume_ref (volume);
+ g_hash_table_insert (trash->details->volumes, volume, *trash_volume);
}
return TRUE;
@@ -168,7 +166,7 @@ get_trash_volume (NautilusTrashDirectory *trash,
static void
add_volume (NautilusTrashDirectory *trash,
- NautilusVolume *volume)
+ GnomeVFSVolume *volume)
{
TrashVolume *trash_volume;
GnomeVFSURI *volume_mount_uri;
@@ -202,7 +200,7 @@ add_volume (NautilusTrashDirectory *trash,
static void
check_trash_created (NautilusTrashDirectory *trash,
- NautilusVolume *volume)
+ GnomeVFSVolume *volume)
{
GnomeVFSResult result;
TrashVolume *trash_volume;
@@ -258,13 +256,13 @@ remove_trash_volume (TrashVolume *trash_volume, gboolean finalizing)
}
nautilus_directory_unref (trash_volume->real_directory);
}
- nautilus_volume_free (trash_volume->volume);
+ gnome_vfs_volume_unref (trash_volume->volume);
g_free (trash_volume);
}
static void
remove_volume (NautilusTrashDirectory *trash,
- NautilusVolume *volume)
+ GnomeVFSVolume *volume)
{
TrashVolume *trash_volume;
@@ -275,36 +273,26 @@ remove_volume (NautilusTrashDirectory *trash,
}
}
-static gboolean
-add_one_volume (const NautilusVolume *volume,
- gpointer callback_data)
-{
- /* The const is a kinda silly idea which we must cast away. */
- add_volume (NAUTILUS_TRASH_DIRECTORY (callback_data),
- (NautilusVolume *) volume);
- return FALSE; /* don't stop iterating */
-}
-
static void
-check_trash_directory_added_callback (NautilusVolumeMonitor *monitor,
- NautilusVolume *volume,
- NautilusTrashDirectory *trash)
+check_trash_directory_added_callback (GnomeVFSVolumeMonitor *monitor,
+ GnomeVFSVolume *volume,
+ NautilusTrashDirectory *trash)
{
check_trash_created (trash, volume);
}
static void
-volume_unmount_started_callback (NautilusVolumeMonitor *monitor,
- NautilusVolume *volume,
- NautilusTrashDirectory *trash)
+volume_unmount_started_callback (GnomeVFSVolumeMonitor *monitor,
+ GnomeVFSVolume *volume,
+ NautilusTrashDirectory *trash)
{
remove_volume (trash, volume);
}
static void
-volume_mounted_callback (NautilusVolumeMonitor *monitor,
- NautilusVolume *volume,
- NautilusTrashDirectory *trash)
+volume_mounted_callback (GnomeVFSVolumeMonitor *monitor,
+ GnomeVFSVolume *volume,
+ NautilusTrashDirectory *trash)
{
add_volume (trash, volume);
}
@@ -312,17 +300,16 @@ volume_mounted_callback (NautilusVolumeMonitor *monitor,
static void
nautilus_trash_directory_instance_init (NautilusTrashDirectory *trash)
{
- NautilusVolumeMonitor *volume_monitor;
+ GnomeVFSVolumeMonitor *volume_monitor;
trash->details = g_new0 (NautilusTrashDirectoryDetails, 1);
- trash->details->volumes = g_hash_table_new ((GHashFunc)nautilus_volume_hash,
- (GEqualFunc)nautilus_volume_is_equal);
+ trash->details->volumes = g_hash_table_new (NULL, NULL);
- volume_monitor = nautilus_volume_monitor_get ();
+ volume_monitor = gnome_vfs_get_volume_monitor ();
g_signal_connect_object (volume_monitor, "volume_mounted",
G_CALLBACK (volume_mounted_callback), trash, 0);
- g_signal_connect_object (volume_monitor, "volume_unmount_started",
+ g_signal_connect_object (volume_monitor, "volume_pre_unmount",
G_CALLBACK (volume_unmount_started_callback), trash, 0);
}
@@ -334,14 +321,20 @@ nautilus_trash_directory_instance_init (NautilusTrashDirectory *trash)
void
nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash)
{
- NautilusVolumeMonitor *volume_monitor;
+ GnomeVFSVolumeMonitor *volume_monitor;
+ GList *volumes, *l;
- volume_monitor = nautilus_volume_monitor_get ();
+ volume_monitor = gnome_vfs_get_volume_monitor ();
g_signal_connect_object (nautilus_trash_monitor_get (), "check_trash_directory_added",
G_CALLBACK (check_trash_directory_added_callback), trash, 0);
- nautilus_volume_monitor_each_mounted_volume
- (volume_monitor, add_one_volume, trash);
+
+ volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
+ for (l = volumes; l != NULL; l = l->next) {
+ add_volume (trash, l->data);
+ gnome_vfs_volume_unref (l->data);
+ }
+ g_list_free (volumes);
}
static void
diff --git a/libnautilus-private/nautilus-trash-monitor.c b/libnautilus-private/nautilus-trash-monitor.c
index 85a49dfb8..0ed96af5d 100644
--- a/libnautilus-private/nautilus-trash-monitor.c
+++ b/libnautilus-private/nautilus-trash-monitor.c
@@ -38,6 +38,7 @@
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
struct NautilusTrashMonitorDetails {
NautilusDirectory *trash_directory;
@@ -203,83 +204,73 @@ nautilus_trash_monitor_is_empty (void)
return nautilus_trash_monitor_get ()->details->empty;
}
-static gboolean
-add_one_volume_trash (const NautilusVolume *volume,
- gpointer callback_data)
+GList *
+nautilus_trash_monitor_get_trash_directories (void)
{
+ GList *result;
char *uri_str;
GnomeVFSURI *volume_mount_point_uri;
GnomeVFSURI *trash_uri;
- GList **result;
-
- result = (GList **) callback_data;
+ GnomeVFSVolume *volume;
+ GList *l, *volumes;
- if (nautilus_volume_should_integrate_trash (volume)) {
-
- /* Get the uri of the volume mount point as the place
- * "near" which to look for trash on the given volume.
- */
- uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
- volume_mount_point_uri = gnome_vfs_uri_new (uri_str);
- g_free (uri_str);
-
- g_assert (volume_mount_point_uri != NULL);
-
- /* Look for trash. It is OK to use a sync call here because
- * the options we use (don't create, don't look for it if we
- * already don't know where it is) do not cause any IO.
- */
- if (gnome_vfs_find_directory (volume_mount_point_uri,
- GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
- FALSE, FALSE, 0777) == GNOME_VFS_OK) {
+ result = NULL;
+
+ /* Collect the trash directories on all the mounted volumes. */
+ volumes = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
+ for (l = volumes; l != NULL; l = l->next) {
+ volume = l->data;
+ if (gnome_vfs_volume_handles_trash (volume)) {
- /* found trash, put it on the list */
- *result = g_list_prepend (*result, trash_uri);
+ /* Get the uri of the volume mount point as the place
+ * "near" which to look for trash on the given volume.
+ */
+ uri_str = gnome_vfs_volume_get_activation_uri (volume);
+ volume_mount_point_uri = gnome_vfs_uri_new (uri_str);
+ g_free (uri_str);
+
+ g_assert (volume_mount_point_uri != NULL);
+
+ /* Look for trash. It is OK to use a sync call here because
+ * the options we use (don't create, don't look for it if we
+ * already don't know where it is) do not cause any IO.
+ */
+ if (gnome_vfs_find_directory (volume_mount_point_uri,
+ GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
+ FALSE, FALSE, 0777) == GNOME_VFS_OK) {
+
+ /* found trash, put it on the list */
+ result = g_list_prepend (result, trash_uri);
+ }
+
+ gnome_vfs_uri_unref (volume_mount_point_uri);
}
- gnome_vfs_uri_unref (volume_mount_point_uri);
+ gnome_vfs_volume_unref (volume);
}
-
- /* don't stop iterating */
- return FALSE;
-}
-
-GList *
-nautilus_trash_monitor_get_trash_directories (void)
-{
- GList *result;
-
- result = NULL;
-
- /* Collect the trash directories on all the mounted volumes. */
- nautilus_volume_monitor_each_mounted_volume
- (nautilus_volume_monitor_get (), add_one_volume_trash, &result);
-
+ g_list_free (volumes);
+
return result;
}
-static gboolean
-add_one_trash_directory_if_needed (const NautilusVolume *volume,
- gpointer callback_data)
-{
- NautilusTrashMonitor *trash_monitor;
-
- trash_monitor = NAUTILUS_TRASH_MONITOR (callback_data);
- g_signal_emit (trash_monitor,
- signals[CHECK_TRASH_DIRECTORY_ADDED], 0,
- volume);
-
- return FALSE;
-}
-
void
nautilus_trash_monitor_add_new_trash_directories (void)
{
NautilusTrashMonitor *trash_monitor;
+ GList *l, *volumes;
+ GnomeVFSVolume *volume;
trash_monitor = nautilus_trash_monitor_get ();
- nautilus_volume_monitor_each_mounted_volume
- (nautilus_volume_monitor_get (), add_one_trash_directory_if_needed,
- trash_monitor);
+ volumes = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
+ for (l = volumes; l != NULL; l = l->next) {
+ volume = l->data;
+
+ g_signal_emit (trash_monitor,
+ signals[CHECK_TRASH_DIRECTORY_ADDED], 0,
+ volume);
+
+ gnome_vfs_volume_unref (volume);
+ }
+ g_list_free (volumes);
}
diff --git a/libnautilus-private/nautilus-trash-monitor.h b/libnautilus-private/nautilus-trash-monitor.h
index 226fa1f12..d7e055976 100644
--- a/libnautilus-private/nautilus-trash-monitor.h
+++ b/libnautilus-private/nautilus-trash-monitor.h
@@ -27,7 +27,7 @@
#define NAUTILUS_TRASH_MONITOR_H
#include <gtk/gtkobject.h>
-#include <libnautilus-private/nautilus-volume-monitor.h>
+#include <libgnomevfs/gnome-vfs-volume.h>
typedef struct NautilusTrashMonitor NautilusTrashMonitor;
typedef struct NautilusTrashMonitorClass NautilusTrashMonitorClass;
@@ -55,7 +55,7 @@ struct NautilusTrashMonitorClass {
void (* trash_state_changed) (NautilusTrashMonitor *trash_monitor,
gboolean new_state);
void (* check_trash_directory_added) (NautilusTrashMonitor *trash_monitor,
- NautilusVolume *volume);
+ GnomeVFSVolume *volume);
};
GtkType nautilus_trash_monitor_get_type (void);
diff --git a/libnautilus-private/nautilus-volume-monitor.c b/libnautilus-private/nautilus-volume-monitor.c
deleted file mode 100644
index af01fc091..000000000
--- a/libnautilus-private/nautilus-volume-monitor.c
+++ /dev/null
@@ -1,2399 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-volume-monitor.c - Desktop volume mounting routines.
-
- Copyright (C) 2000, 2001 Eazel, Inc.
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Gene Z. Ragan <gzr@eazel.com>
- Seth Nickell <snickell@stanford.edu>
-*/
-
-#include <config.h>
-#include "nautilus-volume-monitor.h"
-
-#include "nautilus-cdrom-extensions.h"
-#include "nautilus-directory-notify.h"
-#include "nautilus-file-utilities.h"
-#include "nautilus-iso9660.h"
-#include "nautilus-volume-monitor.h"
-#include <eel/eel-debug.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string-list.h>
-#include <eel/eel-string.h>
-#include <eel/eel-xml-extensions.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <gtk/gtkmain.h>
-#include <libgnome/gnome-config.h>
-#include <libgnome/gnome-exec.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-messagebox.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#ifdef HAVE_SYS_VFSTAB_H
-#include <sys/vfstab.h>
-#elif HAVE_FSTAB_H
-#include <fstab.h>
-#endif
-
-#if defined(HAVE_SYS_MNTCTL_H) && defined(HAVE_SYS_VMOUNT_H) && defined(HAVE_SYS_VFS_H)
-
-#include <sys/mntctl.h>
-#include <sys/vfs.h>
-#include <sys/vmount.h>
-#include <fshelp.h>
-
-#define AIX_MNT 1
-
-#endif /* HAVE_SYS_MNTCTL_H && HAVE_SYS_VMOUNT_H && HAVE_SYS_VFS_H*/
-
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#ifndef __CYGWIN__
-#define MOUNT_TABLE_PATH _PATH_MNTTAB
-#else
-#define MOUNT_TABLE_PATH MOUNTED
-#endif
-#elif defined (HAVE_SYS_MNTTAB_H)
-#define SOLARIS_MNT 1
-#include <sys/mnttab.h>
-#define MOUNT_TABLE_PATH "/etc/mnttab"
-#elif defined (AIX_MNT)
-#define MOUNT_TABLE_PATH "/etc/filesystems"
-#else
-/* FIXME: How does this help anything? */
-#define MOUNT_TABLE_PATH ""
-#endif
-
-#ifdef SOLARIS_MNT
-#define USE_VOLRMMOUNT 1
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-#ifdef MIN
-#undef MIN
-#endif
-#ifdef MAX
-#undef MAX
-#endif
-#include <sys/param.h>
-#endif
-
-#ifdef HAVE_SYS_UCRED_H
-#include <sys/ucred.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-
-#ifndef MNTOPT_RO
-#define MNTOPT_RO "ro"
-#endif
-
-#ifndef HAVE_SETMNTENT
-#define setmntent(f,m) fopen(f,m)
-#endif
-#ifndef HAVE_ENDMNTENT
-#define endmntent(f) fclose(f)
-#endif
-
-#ifdef __linux__
-#include <linux/cdrom.h>
-#endif
-
-#ifdef HAVE_CDDA_INTERFACE_H
-#ifdef HAVE_CDDA_PARANOIA_H
-/* Take this out for now */
-/*#define HAVE_CDDA 1*/
-#endif
-#endif
-
-#ifdef HAVE_CDDA
-
-#define size16 short
-#define size32 int
-
-#include <cdda_interface.h>
-#include <cdda_paranoia.h>
-
-#define CD_AUDIO_PATH "/dev/cdrom"
-
-/* This is here to work around a broken header file. cdda_interface.h
- * has a statically defined array of chars that is unused. This will
- * break our build due to our strict error checking.
- */
-char **broken_cdda_interface_h_workaround = strerror_tr;
-
-#endif
-
-#define CHECK_STATUS_INTERVAL 2000
-
-#define FLOPPY_MOUNT_PATH_PREFIX "/mnt/fd"
-
-#ifdef HAVE_SYS_MNTTAB_H
-typedef struct mnttab MountTableEntry;
-#define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->mnt_fstype)
-#elif defined (HAVE_GETMNTINFO)
-typedef struct statfs MountTableEntry;
-#define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->f_fstypename)
-#elif defined(AIX_MNT)
-typedef struct {
- char mnt_mount[PATH_MAX];
- char mnt_special[PATH_MAX];
- char mnt_fstype[16];
- char mnt_options[128];
-} MountTableEntry;
-#else
-typedef struct mntent MountTableEntry;
-#define MOUNT_TABLE_ENTRY_TYPE(ent) ((ent)->mnt_type)
-#endif
-
-typedef struct {
- char *name;
- char *default_volume_name;
- gboolean can_handle_trash;
-} NautilusFileSystemType;
-
-struct NautilusVolume {
- NautilusDeviceType device_type;
- NautilusFileSystemType *file_system_type;
-
- char *device_path;
- char *mount_path;
- char *volume_name;
- dev_t device;
-
- gboolean is_read_only;
- gboolean is_removable;
- gboolean is_audio_cd;
-};
-
-struct NautilusVolumeMonitorDetails
-{
- GnomeVFSMonitorHandle *monitor_handle;
-
- GList *mounts;
- GList *removable_volumes;
- guint mount_volume_timer_id;
- GHashTable *readable_mount_point_names;
- GHashTable *file_system_table;
-};
-
-typedef void (* ChangeNautilusVolumeFunction) (NautilusVolumeMonitor *view,
- NautilusVolume *volume);
-
-static NautilusVolumeMonitor *global_volume_monitor = NULL;
-static const char *floppy_device_path_prefix;
-static const char *noauto_string;
-static gboolean mnttab_exists;
-
-
-/* The NautilusVolumeMonitor signals. */
-enum {
- VOLUME_MOUNTED,
- VOLUME_UNMOUNT_STARTED,
- VOLUME_UNMOUNT_FAILED,
- VOLUME_UNMOUNTED,
- REMOVABLE_VOLUMES_CHANGED,
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL];
-
-
-static void nautilus_volume_monitor_init (NautilusVolumeMonitor *desktop_mounter);
-static void nautilus_volume_monitor_class_init (NautilusVolumeMonitorClass *klass);
-static void nautilus_volume_monitor_dispose (GObject *object);
-static void nautilus_volume_monitor_finalize (GObject *object);
-static char * get_iso9660_volume_name (NautilusVolume *volume,
- int volume_fd);
-static GHashTable * load_file_system_table (void);
-static void mount_volume_activate (NautilusVolumeMonitor *view,
- NautilusVolume *volume);
-static void mount_volume_deactivate (NautilusVolumeMonitor *monitor,
- NautilusVolume *volume);
-static void load_additional_mount_list_info (GList *volume_list);
-static NautilusVolume *create_volume (const char *device_path,
- const char *mount_path);
-static GList * finish_creating_volume_and_prepend (NautilusVolumeMonitor *monitor,
- NautilusVolume *volume,
- const char *file_system_type_name,
- GList *volume_list);
-static void find_volumes (NautilusVolumeMonitor *monitor);
-static void free_mount_list (GList *mount_list);
-static GList * copy_mount_list (GList *mount_list);
-static GList * get_removable_volumes (NautilusVolumeMonitor *monitor);
-static GHashTable * create_readable_mount_point_name_table (void);
-static int get_cdrom_type (const char *vol_dev_path,
- int *fd);
-static void nautilus_file_system_type_free (NautilusFileSystemType *type);
-static gboolean entry_is_supermounted_volume (const MountTableEntry *ent,
- const NautilusVolume *volume);
-
-static void verify_current_mount_state (NautilusVolumeMonitor *monitor);
-
-#ifdef HAVE_CDDA
-static gboolean locate_audio_cd (void);
-#endif
-
-EEL_CLASS_BOILERPLATE (NautilusVolumeMonitor,
- nautilus_volume_monitor,
- GTK_TYPE_OBJECT)
-
-static GHashTable *
-load_file_system_table (void)
-{
- xmlDocPtr doc;
- xmlNodePtr node;
- GHashTable *table;
- char *file_system_attributes_file;
- xmlChar *name, *default_volume_name, *trash;
- NautilusFileSystemType *type;
-
- /* We don't provide a free_key func since the key is freed by the value_free func */
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL, (GDestroyNotify) nautilus_file_system_type_free);
-
- file_system_attributes_file = nautilus_get_data_file_path ("filesystem-attributes.xml");
- if (file_system_attributes_file == NULL) {
- return table;
- }
- doc = xmlParseFile (file_system_attributes_file);
- g_free (file_system_attributes_file);
- if (doc == NULL) {
- return table;
- }
-
- for (node = doc->children->children; node != NULL; node = node->next) {
- name = xmlGetProp (node, "name");
-
- if (name != NULL) {
- default_volume_name = eel_xml_get_property_translated (node, "default_volume_name");
- trash = xmlGetProp (node, "trash");
-
- if (g_hash_table_lookup (table, name) != NULL) {
- g_message ("duplicate entry for file system type %s", name);
- }
- type = g_new (NautilusFileSystemType, 1);
- type->name = g_strdup (name);
- type->default_volume_name = g_strdup (default_volume_name);
- type->can_handle_trash = eel_str_is_equal (trash, "yes");
- g_hash_table_insert (table, type->name, type);
-
- xmlFree (default_volume_name);
- xmlFree (trash);
- }
-
- xmlFree (name);
- }
-
- xmlFreeDoc (doc);
-
- return table;
-}
-
-static void
-update_removable_volumes (NautilusVolumeMonitor *monitor)
-{
- free_mount_list (monitor->details->removable_volumes);
-
- monitor->details->removable_volumes = get_removable_volumes (monitor);
-
- g_signal_emit (monitor, signals[REMOVABLE_VOLUMES_CHANGED], 0);
-
- verify_current_mount_state (monitor);
-}
-
-static void
-fstab_monitor_callback (GnomeVFSMonitorHandle *handle,
- const char *monitor_uri,
- const char *info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer user_data)
-{
- NautilusVolumeMonitor *monitor;
-
- monitor = NAUTILUS_VOLUME_MONITOR (user_data);
-
- update_removable_volumes (monitor);
-}
-
-static void
-nautilus_volume_monitor_init (NautilusVolumeMonitor *monitor)
-{
- /* Set up details */
- monitor->details = g_new0 (NautilusVolumeMonitorDetails, 1);
- monitor->details->readable_mount_point_names = create_readable_mount_point_name_table ();
- monitor->details->file_system_table = load_file_system_table ();
- monitor->details->removable_volumes = get_removable_volumes (monitor);
- find_volumes (monitor);
-
- gnome_vfs_monitor_add (&monitor->details->monitor_handle,
- "file:///etc/fstab",
- GNOME_VFS_MONITOR_FILE,
- fstab_monitor_callback,
- monitor);
-}
-
-static void
-nautilus_volume_monitor_class_init (NautilusVolumeMonitorClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = nautilus_volume_monitor_dispose;
- object_class->finalize = nautilus_volume_monitor_finalize;
-
- signals[VOLUME_MOUNTED]
- = g_signal_new ("volume_mounted",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusVolumeMonitorClass,
- volume_mounted),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- signals[VOLUME_UNMOUNT_STARTED]
- = g_signal_new ("volume_unmount_started",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusVolumeMonitorClass,
- volume_unmount_started),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- signals[VOLUME_UNMOUNT_FAILED]
- = g_signal_new ("volume_unmount_failed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusVolumeMonitorClass,
- volume_unmount_failed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- signals[VOLUME_UNMOUNTED]
- = g_signal_new ("volume_unmounted",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusVolumeMonitorClass,
- volume_unmounted),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- signals[REMOVABLE_VOLUMES_CHANGED]
- = g_signal_new ("removable_volumes_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusVolumeMonitorClass,
- removable_volumes_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /* Check environment a bit. */
- if (g_file_test ("/vol/dev", G_FILE_TEST_EXISTS)) {
- floppy_device_path_prefix = "/vol/dev/diskette/";
- } else {
- floppy_device_path_prefix = "/dev/fd";
- }
- if (g_file_test ("/vol", G_FILE_TEST_EXISTS)) {
- noauto_string = "/vol/";
- } else {
- noauto_string = "/dev/fd";
- }
- mnttab_exists = g_file_test ("/etc/mnttab",
- G_FILE_TEST_EXISTS);
-}
-
-static void
-nautilus_volume_monitor_dispose (GObject *object)
-{
- NautilusVolumeMonitor *monitor;
-
- monitor = NAUTILUS_VOLUME_MONITOR (object);
-
- if (monitor->details->monitor_handle) {
- gnome_vfs_monitor_cancel (monitor->details->monitor_handle);
- monitor->details->monitor_handle = NULL;
- }
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-nautilus_volume_monitor_finalize (GObject *object)
-{
- NautilusVolumeMonitor *monitor;
-
- monitor = NAUTILUS_VOLUME_MONITOR (object);
-
- /* Remove timer function */
- g_source_remove (monitor->details->mount_volume_timer_id);
-
- /* Clean up mount info */
- free_mount_list (monitor->details->mounts);
- free_mount_list (monitor->details->removable_volumes);
-
- /* Clean up readable names table */
- g_hash_table_destroy (monitor->details->readable_mount_point_names);
-
- /* Clean up file system table */
- g_hash_table_destroy (monitor->details->file_system_table);
-
- /* Clean up details */
- g_free (monitor->details);
-
- global_volume_monitor = NULL;
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-unref_global_volume_monitor (void)
-{
- g_object_unref (global_volume_monitor);
-}
-
-/* Return the global instance of the NautilusVolumeMonitor. Create one
- * if we have not done so already
- */
-NautilusVolumeMonitor *
-nautilus_volume_monitor_get (void)
-{
- if (global_volume_monitor == NULL) {
- global_volume_monitor = NAUTILUS_VOLUME_MONITOR
- (g_object_new (nautilus_volume_monitor_get_type(),
- NULL));
- g_object_ref (global_volume_monitor);
- gtk_object_sink (GTK_OBJECT (global_volume_monitor));
- eel_debug_call_at_shutdown (unref_global_volume_monitor);
- }
-
- return global_volume_monitor;
-}
-
-static int
-floppy_sort (const NautilusVolume *volume1, const NautilusVolume *volume2)
-{
- gboolean is_floppy_1, is_floppy_2;
-
- is_floppy_1 = volume1->device_type == NAUTILUS_DEVICE_FLOPPY_DRIVE;
- is_floppy_2 = volume2->device_type == NAUTILUS_DEVICE_FLOPPY_DRIVE;
-
- if (is_floppy_1 && !is_floppy_2) {
- return -1;
- }
- if (!is_floppy_1 && is_floppy_2) {
- return +1;
- }
-
- return 0;
-}
-
-gboolean
-nautilus_volume_is_removable (const NautilusVolume *volume)
-{
- return volume->is_removable;
-}
-
-gboolean
-nautilus_volume_is_read_only (const NautilusVolume *volume)
-{
- return volume->is_read_only;
-}
-
-
-/* nautilus_volume_monitor_get_removable_volumes
- *
- * Accessor. List and internal data is not to be freed.
- */
-
-const GList *
-nautilus_volume_monitor_get_removable_volumes (NautilusVolumeMonitor *monitor)
-{
- return monitor->details->removable_volumes;
-}
-
-/**
- * nautilus_volume_monitor_get_volume_for_path:
- * @path: a local filesystem path
- *
- * Find the volume in which @path resides.
- *
- * Return value: a NautilusVolume for @path, or %NULL if the operation
- * fails, probably because stat() fails on @path.
- *
- **/
-NautilusVolume *
-nautilus_volume_monitor_get_volume_for_path (NautilusVolumeMonitor *monitor,
- const char *path)
-{
- struct stat statbuf;
- dev_t device;
- GList *p;
- NautilusVolume *volume;
-
- if (stat (path, &statbuf) != 0)
- return NULL;
-
- device = statbuf.st_dev;
-
- for (p = monitor->details->mounts; p != NULL; p = p->next) {
- volume = (NautilusVolume *) p->data;
-
- if (volume->device == device) {
- return volume;
- }
- }
-
- return NULL;
-}
-
-#if defined (HAVE_GETMNTINFO) || defined (HAVE_MNTENT_H) || defined (SOLARIS_MNT)
-
-static gboolean
-has_removable_mntent_options (MountTableEntry *ent)
-{
-#ifdef HAVE_HASMNTOPT
- /* Use "owner" or "user" or "users" as our way of determining a removable volume */
- if (hasmntopt (ent, "user") != NULL
- || hasmntopt (ent, "users") != NULL
- || hasmntopt (ent, "owner") != NULL
- || eel_strcmp("supermount", MOUNT_TABLE_ENTRY_TYPE (ent)) == 0) {
- return TRUE;
- }
-#endif
-
-#ifdef SOLARIS_MNT
- if (eel_str_has_prefix (ent->mnt_special, "/vol/")) {
- return TRUE;
- }
-#endif
-
- return FALSE;
-}
-
-#endif
-
-#if defined(AIX_MNT)
-
-/*
- * functions to parse /etc/filesystems
- *
- */
-
-/* aix_fsprop_getc
- *
- * read character, ignoring comments (begin with '*', end with '\n'
- */
-static int
-aix_fs_getc (FILE *fd)
-{
- int c;
-
- while ((c = getc (fd)) == '*') {
- while (((c = getc (fd)) != '\n') && (c != EOF)) {
- }
- }
-}
-
-/* aix_fs_ignorespace
- *
- * eat all continuous spaces in a file
- *
- */
-
-static int
-aix_fs_ignorespace (FILE *fd)
-{
- int c;
-
- while ((c = aix_fs_getc (fd)) != EOF) {
- if (!g_ascii_isspace (c)) {
- ungetc (c,fd);
- return c;
- }
- }
-
- return EOF;
-}
-
-/* aix_fs_getword
- *
- * read one word from file
- */
-
-static int
-aix_fs_getword (FILE *fd, char *word)
-{
- int c;
-
- aix_fs_ignorespace (fd);
-
- while (((c = aix_fs_getc (fd)) != EOF) && !g_ascii_isspace (c)) {
- if (c == '"') {
- while (((c = aix_fs_getc (fd)) != EOF) && (c != '"')) {
- *word++ = c;
- }
- } else {
- *word++ = c;
- }
- }
- *word = 0;
-
- return c;
-}
-
-/* aix_fs_get
- *
- * read mount points properties
- */
-
-static int
-aix_fs_get (FILE *fd, MountTableEntry *prop)
-{
- static char word[PATH_MAX] = { 0 };
- char value[PATH_MAX];
-
- /* read stanza */
-
- if (word[0] == 0) {
- if (aix_fs_getword (fd, word) == EOF)
- return EOF;
- }
-
- word[strlen(word) - 1] = 0;
- strcpy (prop->mnt_mount, word);
-
- /* read attributes and value */
-
- while (aix_fs_getword (fd, word) != EOF) {
- /* test if is attribute or new stanza */
-
- if (word[strlen(word) - 1] == ':') {
- return 0;
- }
-
- /* read "=" */
- aix_fs_getword (fd, value);
-
- /* read value */
- aix_fs_getword (fd, value);
-
- if (strcmp (word, "dev") == 0) {
- strcpy (prop->mnt_special, value);
- } else if (strcmp (word, "vfs") == 0) {
- strcpy (prop->mnt_fstype, value);
- } else if (strcmp (word, "options") == 0) {
- strcpy(prop->mnt_options, value);
- }
- }
-
- return 0;
-}
-#endif
-
-/* get_removable_volumes
- *
- * Returns a list a device paths.
- * Caller needs to free these as well as the list.
- */
-
-static GList *
-get_removable_volumes (NautilusVolumeMonitor *monitor)
-{
- FILE *file;
- GList *volumes;
- MountTableEntry *ent;
- NautilusVolume *volume;
- char * fs_opt;
-#if defined(HAVE_SYS_MNTTAB_H) || defined(AIX_MNT)
- MountTableEntry ent_storage;
-#endif
-#ifdef HAVE_GETMNTINFO
- int count, index;
-#endif
- ent = NULL;
- volume = NULL;
- volumes = NULL;
-
-#ifdef HAVE_GETMNTINFO
- count = getmntinfo (&ent, MNT_WAIT);
- /* getmentinfo returns a pointer to static data. Do not free. */
- for (index = 0; index < count; index++) {
- if (has_removable_mntent_options (&ent[index])) {
- volume = create_volume (ent[index].f_mntfromname,
- ent[index].f_mntonname);
- volume->is_removable = TRUE;
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, ent[index].f_fstypename, volumes);
- }
- }
-#endif
-
- file = setmntent (MOUNT_TABLE_PATH, "r");
- if (file == NULL) {
- return NULL;
- }
-
-#if defined(AIX_MNT)
- ent = &ent_storage;
- while (!aix_fs_get (file, ent)) {
- if (strcmp ("cdrfs", ent->mnt_fstype) == 0) {
- volume = create_volume (ent->mnt_special, ent->mnt_mount);
- volume->is_removable = TRUE;
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, ent->mnt_fstype, volumes);
- }
- }
-#elif defined(HAVE_SYS_MNTTAB_H)
- ent = &ent_storage;
- while (! getmntent (file, ent)) {
- if (eel_str_has_prefix (ent->mnt_special, noauto_string)) {
- volume = create_volume (ent->mnt_special, ent->mnt_mountp);
- volume->is_removable = TRUE;
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, ent->mnt_fstype, volumes);
- }
- }
-#elif defined (HAVE_MNTENT_H)
- while ((ent = getmntent (file)) != NULL) {
- if (has_removable_mntent_options (ent)) {
-#if defined (HAVE_HASMNTOPT)
-
- if (eel_strcmp("supermount", ent->mnt_type) == 0) {
- fs_opt = eel_str_strip_substring_and_after (hasmntopt (ent, "dev="),
- ",");
- volume = create_volume (fs_opt+strlen("dev="), ent->mnt_dir);
- g_free (fs_opt);
-
- } else {
-#endif
- volume = create_volume (ent->mnt_fsname, ent->mnt_dir);
-#if defined (HAVE_HASMNTOPT)
- }
-#endif
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, ent->mnt_type, volumes);
- }
- }
-#endif
-
- endmntent (file);
-
-#ifdef HAVE_CDDA
- volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH);
- volumes = finish_creating_volume_and_prepend (monitor, volume, "cdda", volumes);
-#endif
-
- load_additional_mount_list_info (volumes);
-
- /* Move all floppy mounts to top of list */
- return g_list_sort (g_list_reverse (volumes), (GCompareFunc) floppy_sort);
-}
-
-static gboolean
-entry_is_supermounted_volume (const MountTableEntry *ent, const NautilusVolume *volume)
-{
- gboolean result = FALSE;
-#ifdef HAVE_HASMNTOPT
- char * fs_opt;
-
- if (strcmp (MOUNT_TABLE_ENTRY_TYPE (ent), "supermount") == 0) {
- fs_opt = eel_str_strip_substring_and_after (hasmntopt (ent, "dev="),
- ",");
- result = strcmp (volume->device_path, fs_opt + strlen ("dev=")) == 0;
- g_free (fs_opt);
- }
-#endif
- return result;
-}
-
-#ifndef SOLARIS_MNT
-
-static gboolean
-volume_is_removable (const NautilusVolume *volume)
-{
- gboolean removable;
- FILE *file;
- MountTableEntry *ent;
-#ifdef HAVE_SYS_MNTTAB_H
- MountTableEntry ent_storage;
-#endif
-
- ent = NULL;
-
- file = setmntent (MOUNT_TABLE_PATH, "r");
- if (file == NULL) {
- return FALSE;
- }
-
- removable = FALSE;
-
- /* Search for our device in the fstab */
-#ifdef HAVE_SYS_MNTTAB_H
- ent = &ent_storage;
- while (!getmntent (file, ent)) {
- if (strcmp (volume->device_path, ent->mnt_special) == 0) {
- if (eel_str_has_prefix (ent->mnt_special, noauto_string)) {
- removable = TRUE;
- break;
- }
- }
- }
-#elif defined (HAVE_MNTENT_H)
- while ((ent = getmntent (file)) != NULL) {
- if ((strcmp (volume->device_path, ent->mnt_fsname) == 0
- || entry_is_supermounted_volume (ent, volume))
- && strcmp (volume->mount_path, ent->mnt_dir) == 0
- && has_removable_mntent_options (ent)) {
- removable = TRUE;
- break;
- }
- }
-#endif
-
- endmntent (file);
- return removable;
-}
-
-#endif /* !SOLARIS_MNT */
-
-char *
-nautilus_volume_get_name (const NautilusVolume *volume)
-{
- if (volume->volume_name == NULL) {
- return g_strdup (_("Unknown"));
- }
- return g_strdup (volume->volume_name);
-}
-
-
-char *
-nautilus_volume_get_icon (const NautilusVolume *volume)
-{
- char *icon_name;
-
- icon_name = "gnome-dev-harddisk";
- switch (nautilus_volume_get_device_type (volume)) {
- case NAUTILUS_DEVICE_AUDIO_CD:
- case NAUTILUS_DEVICE_CDROM_DRIVE:
- icon_name = "gnome-dev-cdrom";
- break;
-
- case NAUTILUS_DEVICE_FLOPPY_DRIVE:
- icon_name = "gnome-dev-floppy";
- break;
-
- case NAUTILUS_DEVICE_JAZ_DRIVE:
- icon_name = "gnome-dev-jazdisk";
- break;
-
- case NAUTILUS_DEVICE_MEMORY_STICK:
- icon_name = "gnome-dev-memory";
- break;
-
- case NAUTILUS_DEVICE_NFS:
- icon_name = "gnome-fs-nfs";
- break;
-
- case NAUTILUS_DEVICE_SMB:
- icon_name = "gnome-fs-smb";
- break;
-
- case NAUTILUS_DEVICE_ZIP_DRIVE:
- icon_name = "gnome-dev-zipdisk";
- break;
-
- case NAUTILUS_DEVICE_APPLE:
- case NAUTILUS_DEVICE_WINDOWS:
- case NAUTILUS_DEVICE_CAMERA:
- case NAUTILUS_DEVICE_UNKNOWN:
- break;
- }
-
- return g_strdup (icon_name);
-}
-
-/* modify_volume_name_for_display
- *
- * Modify volume to be in human readable form
- */
-
-static char *
-modify_volume_name_for_display (const char *unmodified_name)
-{
- int index;
- char *name;
-
- if (unmodified_name == NULL) {
- return NULL;
- }
-
- name = g_strdup (unmodified_name);
-
- /* Strip whitespace from the end of the name. */
- g_strchomp (name);
-
- /* The volume name may have '/' characters. We need to convert
- * them to something that's suitable for use in the name of a
- * link on the desktop.
- */
- for (index = 0; ; index++) {
- if (name [index] == '\0') {
- break;
- }
- if (name [index] == '/') {
- name [index] = '-';
- }
- }
-
- /* Save pretty name back into volume info */
- return name;
-}
-
-/* nautilus_volume_monitor_get_target_uri
- *
- * Returns the activation uri of the volume
- */
-
-char *
-nautilus_volume_get_target_uri (const NautilusVolume *volume)
-{
- char *uri, *escaped_path;
-
- if (volume->is_audio_cd) {
- escaped_path = gnome_vfs_escape_path_string (volume->mount_path);
- uri = g_strconcat ("cdda://", escaped_path, NULL);
- g_free (escaped_path);
- return uri;
- } else {
- return gnome_vfs_get_uri_from_local_path (volume->mount_path);
- }
-}
-
-gboolean
-nautilus_volume_should_integrate_trash (const NautilusVolume *volume)
-{
- g_return_val_if_fail (volume != NULL, FALSE);
- return volume->file_system_type != NULL
- && volume->file_system_type->can_handle_trash;
-}
-
-const char *
-nautilus_volume_get_mount_path (const NautilusVolume *volume)
-{
- g_return_val_if_fail (volume != NULL, NULL);
- return volume->mount_path;
-}
-
-const char *
-nautilus_volume_get_device_path (NautilusVolume *volume)
-{
- g_return_val_if_fail (volume != NULL, NULL);
- return volume->device_path;
-}
-
-
-NautilusDeviceType
-nautilus_volume_get_device_type (const NautilusVolume *volume)
-{
- g_return_val_if_fail (volume != NULL, NAUTILUS_DEVICE_UNKNOWN);
- return volume->device_type;
-}
-
-gboolean
-nautilus_volume_is_equal (const NautilusVolume *volume1,
- const NautilusVolume *volume2)
-{
- if (strcmp (volume1->mount_path, volume2->mount_path) != 0) {
- return FALSE;
- }
- if (strcmp (volume1->device_path, volume2->device_path) != 0) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-guint
-nautilus_volume_hash (const NautilusVolume *volume)
-{
- return g_str_hash (volume->mount_path);
-}
-
-
-/* create_readable_mount_point_name_table
- *
- * Create a table with mapping between the mount point names that are found
- * in /etc/fstab and names that are clear and easy to understand.
- */
-static GHashTable *
-create_readable_mount_point_name_table (void)
-{
- GHashTable *table;
-
- table = g_hash_table_new (g_str_hash, g_str_equal);
-
- /* Populate table with items we know localized names for. */
- g_hash_table_insert (table, "floppy", _("Floppy"));
- g_hash_table_insert (table, "cdrom", _("CD-ROM"));
- g_hash_table_insert (table, "zip", _("Zip Drive"));
-
- return table;
-}
-
-static char *
-mount_volume_make_cdrom_name (NautilusVolume *volume)
-{
- char *name;
- int fd, disctype;
-
- disctype = get_cdrom_type (volume->device_path, &fd);
-
- switch (disctype) {
- case CDS_AUDIO:
- name = g_strdup (_("Audio CD"));
- break;
-
- case CDS_DATA_1:
- case CDS_DATA_2:
- case CDS_XA_2_1:
- case CDS_XA_2_2:
- case CDS_MIXED:
- /* Get volume name */
- name = get_iso9660_volume_name (volume, fd);
- break;
-
- default:
- name = g_strdup (_("CD-ROM"));
- }
-
- close (fd);
-
- return name;
-}
-
-static char *
-make_volume_name_from_path (NautilusVolume *volume)
-{
- const char *name;
-
- name = strrchr (volume->mount_path, '/');
- if (name == NULL) {
- if (volume->file_system_type == NULL) {
- return NULL;
- } else {
- return g_strdup (volume->file_system_type->default_volume_name);
- }
- }
- if (name[0] == '/' && name[1] == '\0') {
- return g_strdup (_("Root Volume"));
- }
- return modify_volume_name_for_display (name + 1);
-}
-
-static char *
-mount_volume_make_name (NautilusVolume *volume)
-{
- if (volume->is_audio_cd) {
- return g_strdup (_("Audio CD"));
- } else if (volume->device_type == NAUTILUS_DEVICE_CDROM_DRIVE) {
- return mount_volume_make_cdrom_name (volume);
- } else {
- return make_volume_name_from_path (volume);
- }
-}
-
-
-static void
-mount_volume_activate (NautilusVolumeMonitor *monitor, NautilusVolume *volume)
-{
- g_signal_emit (monitor,
- signals[VOLUME_MOUNTED], 0,
- volume);
-}
-
-
-static void
-eject_device (const char *path)
-{
- char *command;
-
- if (path != NULL) {
- command = g_strdup_printf ("eject %s", path);
- eel_gnome_shell_execute (command);
- g_free (command);
- }
-}
-
-static void
-mount_volume_deactivate (NautilusVolumeMonitor *monitor, NautilusVolume *volume)
-{
- g_signal_emit (monitor,
- signals[VOLUME_UNMOUNTED], 0,
- volume);
-}
-
-static void
-free_mount_list (GList *mount_list)
-{
- g_list_foreach (mount_list, (GFunc) nautilus_volume_free, NULL);
- g_list_free (mount_list);
-}
-
-static GList *
-copy_mount_list (GList *mount_list)
-{
- GList *new_list = NULL;
- GList *list = mount_list;
- NautilusVolume *volume;
-
- while (list) {
- volume = list->data;
-
- new_list = g_list_prepend (new_list, nautilus_volume_copy (volume));
-
- list = list->next;
- }
-
- return g_list_reverse (new_list);
-}
-
-/* List returned, but not the data it contains, must be freed by caller */
-static GList *
-build_volume_list_delta (GList *list_one, GList *list_two)
-{
- GList *ptrOne, *ptrTwo;
- GList *new_list;
- NautilusVolume *volOne, *volTwo, *new_volume;
- gboolean found_match;
-
- new_list = NULL;
-
- for (ptrOne = list_one; ptrOne != NULL; ptrOne = ptrOne->next) {
-
- found_match = FALSE;
- volOne = (NautilusVolume *) ptrOne->data;
-
- for (ptrTwo = list_two; ptrTwo != NULL; ptrTwo = ptrTwo->next) {
-
- volTwo = (NautilusVolume *) ptrTwo->data;
-
- /* Check and see if mount point from list one is in list two */
- if (strcmp (volOne->mount_path, volTwo->mount_path) == 0) {
- found_match = TRUE;
- break;
- }
- }
-
- if (!found_match) {
- /* No match. Add it to the list to be returned; */
- new_volume = nautilus_volume_copy (volOne);
- new_list = g_list_prepend (new_list, new_volume);
- }
- }
-
- return new_list;
-}
-
-
-
-#ifdef AIX_MNT
-
-static GList *
-get_mount_list (NautilusVolumeMonitor *monitor)
-{
- struct vfs_ent *fs_info;
- struct vmount *vmount_info;
- int vmount_number;
- unsigned int vmount_size;
- int current;
- char *device;
- char *mount;
- char* fstype;
- int is_removable;
- int is_readonly;
-
- NautilusVolume *volume;
- GList *volumes = NULL;
-
- if (mntctl (MCTL_QUERY, sizeof (vmount_size), &vmount_size) != 0) {
- g_warning ("Unable to know the number of mounted volumes\n");
-
- return NULL;
- }
-
- vmount_info = (struct vmount*)g_malloc (vmount_size);
- if (vmount_info == NULL) {
- g_warning ("Unable to allocate memory\n");
- return NULL;
- }
-
- vmount_number = mntctl (MCTL_QUERY, vmount_size, vmount_info);
-
- if (vmount_info->vmt_revision != VMT_REVISION) {
- g_warning ("Bad vmount structure revision number, want %d, got %d\n", VMT_REVISION, vmount_info->vmt_revision);
- }
-
- if (vmount_number < 0) {
- g_warning ("Unable to recover mounted volumes information\n");
-
- g_free (vmount_info);
- return NULL;
- }
-
- while (vmount_number > 0) {
- device = vmt2dataptr (vmount_info, VMT_OBJECT);
- mount = vmt2dataptr (vmount_info, VMT_STUB);
- is_removable = (vmount_info->vmt_flags & MNT_REMOVABLE) ? 1 : 0;
- is_readonly = (vmount_info->vmt_flags & MNT_READONLY) ? 1 : 0;
-
- fs_info = getvfsbytype (vmount_info->vmt_gfstype);
-
- if (fs_info == NULL) {
- g_warning ("Unknown FS type !\n");
- fstype = "???";
- } else {
- fstype = fs_info->vfsent_name;
- }
-
- volume = create_volume (device, mount);
- volume->is_removable = is_removable;
- volume->is_read_only = is_readonly;
-
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, fstype, volumes);
-
- /* next entry */
-
- vmount_info = (struct vmount *)( (char*)vmount_info
- + vmount_info->vmt_length);
- vmount_number--;
- }
-
-
- g_free (vmount_info);
-
- return volumes;
-}
-
-#elif defined(SOLARIS_MNT)
-
-static GList *
-get_mount_list (NautilusVolumeMonitor *monitor)
-{
- FILE *fh;
- GList *volumes;
- MountTableEntry ent;
- NautilusVolume *volume;
-
- volumes = NULL;
-
- fh = setmntent (MOUNT_TABLE_PATH, "r");
- if (fh == NULL) {
- return NULL;
- }
-
- while (! getmntent(fh, &ent)) {
- volume = create_volume (ent.mnt_special, ent.mnt_mountp);
- volume->is_removable = has_removable_mntent_options (&ent);
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, ent.mnt_fstype, volumes);
- }
-
- endmntent (fh);
-
- return volumes;
-}
-
-#else /* !AIX_MNT && !SOLARIS_MNT */
-
-static gboolean
-option_list_has_option (const char *optlist,
- const char *option)
-{
- gboolean retval = FALSE;
- char **options;
- int i;
-
- options = g_strsplit (optlist, ",", -1);
-
- for (i = 0; options[i]; i++) {
- if (strcmp (options[i], option) == 0) {
- retval = TRUE;
- break;
- }
- }
-
- g_strfreev (options);
-
- return retval;
-}
-
-static GList *
-get_mount_list (NautilusVolumeMonitor *monitor)
-{
- GList *volumes;
- NautilusVolume *volume;
- static time_t last_mtime = 0;
- static FILE *fh = NULL;
- static GList *saved_list = NULL;
- GList * removable_list;
- const char *file_name;
- const char *separator;
- char line[PATH_MAX * 3];
- char device_name[sizeof (line)];
- EelStringList *list;
- char *device_path, *mount_path, *file_system_type_name;
- struct stat sb;
-
- volumes = NULL;
-
- if (mnttab_exists) {
- file_name = "/etc/mnttab";
- separator = "\t";
- } else {
- file_name = "/proc/mounts";
- separator = " ";
- }
-
- /* /proc/mounts mtime never changes, so stat /etc/mtab.
- * Isn't this lame?
- */
- if (stat ("/etc/mtab", &sb) < 0) {
- g_warning ("Unable to stat %s: %s", file_name,
- g_strerror (errno));
- return NULL;
- }
-
- if (sb.st_mtime == last_mtime) {
- return copy_mount_list (saved_list);
- }
-
- last_mtime = sb.st_mtime;
-
- if (fh == NULL) {
- fh = fopen (file_name, "r");
- if (fh == NULL) {
- g_warning ("Unable to open %s: %s", file_name, strerror (errno));
- return NULL;
- }
- } else {
- rewind (fh);
- }
-
- while (fgets (line, sizeof(line), fh)) {
- if (sscanf (line, "%s", device_name) != 1) {
- continue;
- }
-
- list = eel_string_list_new_from_tokens (line, separator, FALSE);
- if (list == NULL) {
- continue;
- }
-
- /* The string list needs to have at least 3 items per line.
- * We need to find at least device path, mount path and file system type.
- */
- if (eel_string_list_get_length (list) >= 3) {
- device_path = eel_string_list_nth (list, 0);
- mount_path = eel_string_list_nth (list, 1);
- file_system_type_name = eel_string_list_nth (list, 2);
- /* For supermount, search info in removable list */
- if (eel_strcmp ("supermount", file_system_type_name) == 0) {
- removable_list = monitor->details->removable_volumes;
- while (removable_list) {
- volume = (NautilusVolume *) removable_list->data;
- if (eel_strcmp (mount_path, volume->mount_path) == 0) {
- g_free (device_path);
- device_path = g_strdup (volume->device_path);
- break;
- }
- removable_list = removable_list->next;
- }
- }
- volume = create_volume (device_path, mount_path);
- if (eel_string_list_get_length (list) >= 4 &&
- option_list_has_option (eel_string_list_peek_nth (list, 3), MNTOPT_RO))
- volume->is_read_only = TRUE;
- volumes = finish_creating_volume_and_prepend
- (monitor, volume, file_system_type_name, volumes);
-
- g_free (device_path);
- g_free (mount_path);
- g_free (file_system_type_name);
- }
-
- eel_string_list_free (list);
- }
-
- free_mount_list (saved_list);
- saved_list = volumes;
-
- return copy_mount_list (volumes);
-}
-
-#endif /* !SOLARIS_MNT */
-
-
-static GList *
-get_current_mount_list (NautilusVolumeMonitor *monitor)
-{
- GList *volumes;
-#ifdef HAVE_CDDA
- NautilusVolume *volume;
-#endif
-
- volumes = get_mount_list (monitor);
-
-#ifdef HAVE_CDDA
- /* CD Audio tricks */
- if (locate_audio_cd ()) {
- volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH);
- volume->volume_name = mount_volume_make_name (volume);
- volumes = finish_creating_volume_and_prepend (monitor, volume, "cdda", volumes);
- }
-#endif
-
- return g_list_reverse (volumes);
-}
-
-
-static gboolean
-mount_lists_are_identical (GList *list_a, GList *list_b)
-{
- GList *p, *q;
- NautilusVolume *volumeOne, *volumeTwo;
-
- for (p = list_a, q = list_b; p != NULL && q != NULL; p = p->next, q = q->next) {
- volumeOne = p->data;
- volumeTwo = q->data;
-
- if (strcmp (volumeOne->device_path, volumeTwo->device_path) != 0) {
- return FALSE;
- }
- }
- return p == NULL && q == NULL;
-}
-
-static void
-verify_current_mount_state (NautilusVolumeMonitor *monitor)
-{
- GList *current_mounts, *new_mounts, *old_mounts, *node;
-
- /* Get all current mounts */
- current_mounts = get_current_mount_list (monitor);
- if (current_mounts == NULL) {
- return;
- }
-
- /* If the new list is the same of the current list, bail. */
- if (mount_lists_are_identical (current_mounts, monitor->details->mounts)) {
- free_mount_list (current_mounts);
- return;
- }
-
- /* Process list results to check for a properties that require opening files on disk. */
- load_additional_mount_list_info (current_mounts);
-
- /* Create list of new and old mounts */
- new_mounts = build_volume_list_delta (current_mounts, monitor->details->mounts);
- old_mounts = build_volume_list_delta (monitor->details->mounts, current_mounts);
-
- /* Free previous mount list and replace with new */
- free_mount_list (monitor->details->mounts);
- monitor->details->mounts = current_mounts;
-
- /* Check and see if we have new mounts to add */
- for (node = new_mounts; node != NULL; node = node->next) {
- mount_volume_activate (monitor, node->data);
- }
-
- /* Check and see if we have old mounts to remove */
- for (node = old_mounts; node != NULL; node = node->next) {
- mount_volume_deactivate (monitor, node->data);
- }
-
- free_mount_list (old_mounts);
- free_mount_list (new_mounts);
-}
-
-static int
-mount_volumes_check_status (NautilusVolumeMonitor *monitor)
-{
- verify_current_mount_state (monitor);
- return TRUE;
-}
-
-static int
-get_cdrom_type (const char *vol_dev_path, int* fd)
-{
-#ifdef SOLARIS_MNT
- GString *new_dev_path;
- struct cdrom_tocentry entry;
- struct cdrom_tochdr header;
- int type;
-
- /* For ioctl call to work dev_path has to be /vol/dev/rdsk.
- * There has to be a nicer way to do this.
- */
- new_dev_path = g_string_new (vol_dev_path);
- new_dev_path = g_string_insert_c (new_dev_path, 9, 'r');
- *fd = open (new_dev_path->str, O_RDONLY | O_NONBLOCK);
- g_string_free (new_dev_path, TRUE);
-
- if (*fd < 0) {
- return CDS_DATA_1;
- }
-
- if (ioctl (*fd, CDROMREADTOCHDR, &header) == 0) {
- return CDS_DATA_1;
- }
-
- type = CDS_DATA_1;
-
- for (entry.cdte_track = 1;
- entry.cdte_track <= header.cdth_trk1;
- entry.cdte_track++) {
- entry.cdte_format = CDROM_LBA;
- if (ioctl (*fd, CDROMREADTOCENTRY, &entry) == 0) {
- if (entry.cdte_ctrl & CDROM_DATA_TRACK) {
- type = CDS_AUDIO;
- break;
- }
- }
- }
-
- return type;
-#elif defined(AIX_MNT)
- return CDS_NO_INFO;
-#else
- *fd = open (vol_dev_path, O_RDONLY|O_NONBLOCK);
- return ioctl (*fd, CDROM_DISC_STATUS, CDSL_CURRENT);
-#endif
-}
-
-static gboolean
-mount_volume_iso9660_add (NautilusVolume *volume)
-{
- /* Don't mark loopback mounts as cdroms. */
- if (!eel_str_has_prefix (volume->device_path, "/dev/loop")) {
- volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE;
- }
-
- return TRUE;
-}
-
-/* This is intended mainly for adding removable volumes from /etc/fstab.
- * The auto type will not show up in /proc/mounts.
- */
-static gboolean
-mount_volume_auto_add (NautilusVolume *volume)
-{
- if (eel_str_has_prefix (volume->device_path, floppy_device_path_prefix)) {
- volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE;
- }
- /* FIXME: add cdroms to this too */
- return TRUE;
-}
-
-static gboolean
-mount_volume_cdda_add (NautilusVolume *volume)
-{
- volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE;
- volume->is_audio_cd = TRUE;
- return TRUE;
-}
-
-static gboolean
-mount_volume_nfs_add (NautilusVolume *volume)
-{
- /* We need to filter out autofs magic NFS directories. These entries will have the text
- * "(pid" in the first element of its entry in /proc/mounts. An example would be eazel:(pid1234)
- * or eazel(pid1234). If we signal that the volume monitor has added this type of file system
- * the trash monitor will become confused and recurse indefinitely.
- */
-
- if (strstr (volume->device_path, "(pid") != NULL) {
- return FALSE;
- }
-
- volume->device_type = NAUTILUS_DEVICE_NFS;
-
- return TRUE;
-}
-
-static void
-find_volumes (NautilusVolumeMonitor *monitor)
-{
- /* make sure the mount states of disks are set up */
- mount_volumes_check_status (monitor);
- load_additional_mount_list_info (monitor->details->mounts);
-
- /* Add a timer function to check for status change in mounted volumes periodically */
- monitor->details->mount_volume_timer_id =
- g_timeout_add (CHECK_STATUS_INTERVAL,
- (GtkFunction) mount_volumes_check_status,
- monitor);
-}
-
-void
-nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor,
- NautilusEachVolumeCallback function,
- gpointer context)
-{
- GList *p;
- NautilusVolume *volume;
-
- for (p = monitor->details->mounts; p != NULL; p = p->next) {
- volume = (NautilusVolume *) p->data;
- (* function) (volume, context);
- }
-}
-
-
-gboolean
-nautilus_volume_monitor_volume_is_mounted (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume)
-{
- GList *p;
- NautilusVolume *new_volume;
-
- for (p = monitor->details->mounts; p != NULL; p = p->next) {
- new_volume = (NautilusVolume *)p->data;
-
- if (strcmp (new_volume->mount_path, volume->mount_path) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-#ifdef USE_VOLRMMOUNT
-
-static const char *volrmmount_locations [] = {
- "/usr/bin/volrmmount",
- NULL
-};
-
-#define MOUNT_COMMAND volrmmount_locations
-#define MOUNT_SEPARATOR " -i "
-#define UMOUNT_COMMAND volrmmount_locations
-#define UMOUNT_SEPARATOR " -e "
-
-#else
-
-static const char *mount_known_locations [] = {
- "/sbin/mount", "/bin/mount",
- "/usr/sbin/mount", "/usr/bin/mount",
- NULL
-};
-
-static const char *umount_known_locations [] = {
- "/sbin/umount", "/bin/umount",
- "/usr/sbin/umount", "/usr/bin/umount",
- NULL
-};
-
-#define MOUNT_COMMAND mount_known_locations
-#define MOUNT_SEPARATOR " "
-#define UMOUNT_COMMAND umount_known_locations
-#define UMOUNT_SEPARATOR " "
-
-#endif /* USE_VOLRMMOUNT */
-
-/* Returns the full path to the queried command */
-static const char *
-find_command (const char **known_locations)
-{
- int i;
-
- for (i = 0; known_locations [i]; i++){
- if (g_file_test (known_locations [i], G_FILE_TEST_EXISTS))
- return known_locations [i];
- }
- return NULL;
-}
-
-/* Pipes are guaranteed to be able to hold at least 4096 bytes */
-/* More than that would be unportable */
-#define MAX_PIPE_SIZE 4096
-
-static int error_pipe[2]; /* File descriptors of error pipe */
-static int old_error; /* File descriptor of old standard error */
-
-/* Creates a pipe to hold standard error for a later analysis. */
-static void
-open_error_pipe (void)
-{
- pipe (error_pipe);
-
- old_error = dup (2);
- if (old_error < 0 || close(2) || dup (error_pipe[1]) != 2) {
- close (error_pipe[0]);
- close (error_pipe[1]);
- }
-
- close (error_pipe[1]);
-}
-
-typedef struct {
- char *command;
- char *mount_point;
- char *device_path;
- gboolean should_mount;
- gboolean should_eject;
-} MountThreadInfo;
-
-typedef struct {
- char *message;
- char *detailed_message;
- char *mount_point;
- gboolean mount;
-} MountStatusInfo;
-
-
-static gboolean
-display_mount_error (gpointer callback_data)
-{
- MountStatusInfo *info;
- const char *title;
- NautilusVolumeMonitor *monitor;
- NautilusVolume *volume;
- GList *p;
-
- info = callback_data;
-
- title = info->mount ? _("Mount Error") : _("Unmount Error");
-
- eel_show_error_dialog_with_details
- (info->message, title, info->detailed_message, NULL);
-
- if (!info->mount) {
- /* Locate volume in current list */
- monitor = nautilus_volume_monitor_get ();
- for (p = monitor->details->mounts; p != NULL; p = p->next) {
- volume = (NautilusVolume *)p->data;
- if (strcmp (volume->mount_path, info->mount_point) == 0) {
- g_signal_emit (monitor, signals[VOLUME_UNMOUNT_FAILED], 0, volume);
- break;
- }
- }
- }
-
- g_free (info->mount_point);
- g_free (info->message);
- g_free (info->detailed_message);
- g_free (info);
-
- return FALSE;
-}
-
-static void
-close_error_pipe (gboolean mount, const char *mount_path)
-{
- char *message;
- char detailed_msg[MAX_PIPE_SIZE];
- int length;
- gboolean is_floppy;
- MountStatusInfo *info;
-
- if (old_error < 0) {
- return;
- }
-
- close (2);
- dup (old_error);
- close (old_error);
-
- /* FIXME: This keeps reading into the same buffer over and
- * over again and makes no attempt to save bytes from any
- * calls other than the last read call.
- */
- do {
- length = read (error_pipe[0], detailed_msg, MAX_PIPE_SIZE);
- } while (length < 0);
-
- if (length >= 0) {
- detailed_msg[length] = 0;
- }
-
- close (error_pipe[0]);
-
- /* No output to show */
- if (length == 0) {
- return;
- }
-
- is_floppy = strstr (mount_path, "floppy") != NULL;
-
- /* Determine a user readable message from the obscure pipe error */
- if (mount) {
- if (strstr (detailed_msg, "is write-protected, mounting read-only") != NULL) {
- /* This is not an error. Just an informative message from mount. */
- return;
- } else if ((strstr (detailed_msg, "is not a valid block device") != NULL) ||
- (strstr (detailed_msg, "No medium found") != NULL)) {
- /* No media in drive */
- if (is_floppy) {
- /* Handle floppy case */
- message = g_strdup_printf (_("Nautilus was unable to mount the floppy drive. "
- "There is probably no floppy in the drive."));
- } else {
- /* All others */
- message = g_strdup_printf (_("Nautilus was unable to mount the volume. "
- "There is probably no media in the device."));
- }
- } else if (strstr (detailed_msg, "wrong fs type, bad option, bad superblock on") != NULL) {
- /* Unknown filesystem */
- if (is_floppy) {
- message = g_strdup_printf (_("Nautilus was unable to mount the floppy drive. "
- "The floppy is probably in a format that cannot be mounted."));
- } else {
- message = g_strdup_printf (_("Nautilus was unable to mount the selected volume. "
- "The volume is probably in a format that cannot be mounted."));
- }
- } else {
- if (is_floppy) {
- message = g_strdup (_("Nautilus was unable to mount the selected floppy drive."));
- } else {
- message = g_strdup (_("Nautilus was unable to mount the selected volume."));
- }
- }
- } else {
- /* FIXME: Should we parse this message and report something more meaningful? */
- message = g_strdup (_("Nautilus was unable to unmount the selected volume."));
- }
-
- /* Set up info and pass it to callback to display dialog. We do this because this
- routine may be called from a thread */
- info = g_new0 (MountStatusInfo, 1);
- info->message = message;
- info->detailed_message = g_strdup (detailed_msg);
- info->mount_point = g_strdup (mount_path);
- info->mount = mount;
- g_idle_add (display_mount_error, info);
-}
-
-
-static void *
-mount_unmount_callback (void *arg)
-{
- FILE *file;
- MountThreadInfo *info;
- const char *old_locale;
-
- info = arg;
-
- if (info != NULL) {
- old_locale = g_getenv ("LC_ALL");
- eel_setenv ("LC_ALL", "C", TRUE);
-
- if (info->command != NULL) {
- open_error_pipe ();
- file = popen (info->command, "r");
- close_error_pipe (info->should_mount, info->mount_point);
- pclose (file);
- g_free (info->command);
- }
-
- if (info->should_eject) {
- eject_device (info->device_path?info->device_path:info->mount_point);
- }
-
- if (old_locale != NULL) {
- eel_setenv ("LC_ALL", old_locale, TRUE);
- } else {
- eel_unsetenv("LC_ALL");
- }
-
- g_free (info->mount_point);
- g_free (info->device_path);
- g_free (info);
- }
-
- pthread_exit (NULL);
-
- return NULL;
-}
-
-
-void
-nautilus_volume_monitor_mount_unmount_removable (NautilusVolumeMonitor *monitor,
- const char *mount_point,
- gboolean should_mount,
- gboolean should_eject)
-{
- const char *command;
- GList *p;
- NautilusVolume *volume;
- char *command_string;
- MountThreadInfo *mount_info;
- pthread_t mount_thread;
- const char *name;
-
- volume = NULL;
-
- /* Check and see if volume exists in mounts already */
- for (p = monitor->details->mounts; p != NULL; p = p->next) {
- volume = (NautilusVolume *)p->data;
- if (strcmp (volume->mount_path, mount_point) == 0) {
- if (should_mount) {
- return;
- } else {
- break;
- }
- }
- }
-
-#ifdef USE_VOLRMMOUNT
- name = strrchr (mount_point, '/');
- if (name != NULL) {
- name = name + 1;
- } else {
- name = mount_point;
- }
-#else
- name = mount_point;
-#endif
-
- if (should_mount) {
- command = find_command (MOUNT_COMMAND);
- command_string = g_strconcat (command, MOUNT_SEPARATOR, name, NULL);
- } else {
- command = find_command (UMOUNT_COMMAND);
- command_string = g_strconcat (command, UMOUNT_SEPARATOR, name, NULL);
- if (volume != NULL) {
- g_signal_emit (monitor, signals[VOLUME_UNMOUNT_STARTED], 0, volume);
- }
- }
-
- mount_info = g_new0 (MountThreadInfo, 1);
- /* Don't run mount/umount on supermount mount point, it is useless */
- if ((volume->file_system_type == NULL)
- || (strcmp (volume->file_system_type->name,"supermount") != 0)) {
- mount_info->command = g_strdup (command_string);
- }
- mount_info->mount_point = g_strdup (mount_point);
- if (volume) {
- mount_info->device_path = g_strdup (volume->device_path);
- }
- mount_info->should_mount = should_mount;
- mount_info->should_eject = should_eject;
-
- pthread_create (&mount_thread, NULL, mount_unmount_callback, mount_info);
-
- g_free (command_string);
-}
-
-
-void
-nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume, const char *volume_name)
-{
- GList *node;
- NautilusVolume *found_volume;
-
- /* Find volume and set new name */
- for (node = monitor->details->mounts; node != NULL; node = node->next) {
- found_volume = node->data;
- if ((strcmp (found_volume->device_path, volume->device_path) == 0)
- && (strcmp (found_volume->mount_path, volume->mount_path) == 0)) {
- g_free (found_volume->volume_name);
- found_volume->volume_name = g_strdup (volume_name);
- return;
- }
- }
-}
-
-static NautilusVolume *
-create_volume (const char *device_path, const char *mount_path)
-{
- NautilusVolume *volume;
-
- volume = g_new0 (NautilusVolume, 1);
-
- volume->device_path = g_strdup (device_path);
- volume->mount_path = g_strdup (mount_path);
-
- return volume;
-}
-
-NautilusVolume *
-nautilus_volume_copy (const NautilusVolume *volume)
-{
- NautilusVolume *new_volume;
-
- new_volume = g_new (NautilusVolume, 1);
-
- new_volume->device_type = volume->device_type;
- new_volume->file_system_type = volume->file_system_type;
-
- new_volume->device_path = g_strdup (volume->device_path);
- new_volume->mount_path = g_strdup (volume->mount_path);
- new_volume->volume_name = g_strdup (volume->volume_name);
- new_volume->device = volume->device;
-
- new_volume->is_read_only = volume->is_read_only;
- new_volume->is_removable = volume->is_removable;
- new_volume->is_audio_cd = volume->is_audio_cd;
-
- return new_volume;
-}
-
-void
-nautilus_volume_free (NautilusVolume *volume)
-{
- g_free (volume->device_path);
- g_free (volume->mount_path);
- g_free (volume->volume_name);
- g_free (volume);
-}
-
-static void
-nautilus_file_system_type_free (NautilusFileSystemType *type)
-{
- g_free (type->name);
- g_free (type->default_volume_name);
- g_free (type);
-}
-
-#ifdef __linux__
-static int
-get_iso9660_volume_name_data_track_offset (int fd)
-{
- struct cdrom_tocentry toc;
- char toc_header[2];
- int i, offset;
-
- if (ioctl (fd, CDROMREADTOCHDR, &toc_header)) {
- return 0;
- }
-
- for (i = toc_header[0]; i <= toc_header[1]; i++) {
- memset (&toc, 0, sizeof (struct cdrom_tocentry));
- toc.cdte_track = i;
- toc.cdte_format = CDROM_MSF;
- if (ioctl (fd, CDROMREADTOCENTRY, &toc)) {
- return 0;
- }
-
- if (toc.cdte_ctrl & CDROM_DATA_TRACK) {
- offset = ((i == 1) ? 0 :
- (int)toc.cdte_addr.msf.frame +
- (int)toc.cdte_addr.msf.second*75 +
- (int)toc.cdte_addr.msf.minute*75*60 - 150);
- return offset;
- }
- }
-
- return 0;
-}
-#endif
-
-static char *
-get_iso9660_volume_name (NautilusVolume *volume, int fd)
-{
- struct iso_primary_descriptor iso_buffer;
- int offset;
-
-#ifdef __linux__
- offset = get_iso9660_volume_name_data_track_offset (fd);
-#else
- offset = 0;
-#endif
-
- lseek (fd, (off_t) 2048*(offset+16), SEEK_SET);
- read (fd, &iso_buffer, 2048);
-
- if (iso_buffer.volume_id == NULL) {
- return g_strdup (_("ISO 9660 Volume"));
- }
-
- return modify_volume_name_for_display (iso_buffer.volume_id);
-}
-
-static void
-load_additional_mount_list_info (GList *volume_list)
-{
- GList *node;
- NautilusVolume *volume;
-
- for (node = volume_list; node != NULL; node = node->next) {
- volume = node->data;
-
-#if !defined(SOLARIS_MNT) && !defined(AIX_MNT)
- /* These are set up by get_current_mount_list for Solaris&AIX.*/
- volume->is_removable = volume_is_removable (volume);
-#endif
- if (volume->volume_name == NULL) {
- volume->volume_name = mount_volume_make_name (volume);
- }
- }
-}
-
-static gboolean
-finish_creating_volume (NautilusVolumeMonitor *monitor, NautilusVolume *volume,
- const char *file_system_type_name)
-{
- gboolean ok;
- const char *name;
- struct stat statbuf;
-
- if (stat (volume->mount_path, &statbuf) == 0) {
- volume->device = statbuf.st_dev;
- }
-
- volume->file_system_type = g_hash_table_lookup
- (monitor->details->file_system_table, file_system_type_name);
-
- if (strcmp (file_system_type_name, "auto") == 0) {
- ok = mount_volume_auto_add (volume);
- } else if (strcmp (file_system_type_name, "cdda") == 0) {
- ok = mount_volume_cdda_add (volume);
- } else if (strcmp (file_system_type_name, "iso9660") == 0) {
- ok = mount_volume_iso9660_add (volume);
- } else if (strcmp (file_system_type_name, "nfs") == 0) {
- ok = mount_volume_nfs_add (volume);
- volume->is_removable = FALSE;
- return ok;
- } else if (strcmp (file_system_type_name, "smbfs") == 0) {
- volume->device_type = NAUTILUS_DEVICE_SMB;
- volume->is_removable = TRUE;
- return TRUE;
- } else if ((strcmp (file_system_type_name, "hfs") == 0)
- || (strcmp (file_system_type_name, "hfsplus") == 0)) {
- volume->device_type = NAUTILUS_DEVICE_APPLE;
- ok = TRUE;
- } else if ((strcmp (file_system_type_name, "vfat") == 0)
- || (strcmp (file_system_type_name, "fat") == 0)
- || (strcmp (file_system_type_name, "ntfs") == 0)
- || (strcmp (file_system_type_name, "msdos") == 0)) {
- volume->device_type = NAUTILUS_DEVICE_WINDOWS;
- ok = TRUE;
- } else {
- ok = TRUE;
- }
-
- if (!ok) {
- return FALSE;
- }
-
- /* Identify device type */
- if (eel_str_has_prefix (volume->device_path, floppy_device_path_prefix)) {
- volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (volume->device_path, "/dev/floppy")) {
- volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (volume->device_path, "/dev/cdrom")) {
- volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (volume->mount_path, "/mnt/")) {
- name = volume->mount_path + strlen ("/mnt/");
-
- if (eel_str_has_prefix (name, "cdrom")
- || eel_str_has_prefix (name, "burn")) {
- volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "floppy")) {
- volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "zip")) {
- volume->device_type = NAUTILUS_DEVICE_ZIP_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "jaz")) {
- volume->device_type = NAUTILUS_DEVICE_JAZ_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "camera")) {
- volume->device_type = NAUTILUS_DEVICE_CAMERA;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "memstick")
- || eel_str_has_prefix (name, "ram")) {
- volume->device_type = NAUTILUS_DEVICE_MEMORY_STICK;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "ipod")) {
- volume->device_type = NAUTILUS_DEVICE_APPLE;
- volume->is_removable = TRUE;
- } else {
- volume->is_removable = FALSE;
- }
- } else if (eel_str_has_prefix (volume->device_path, "/vol/")) {
- name = volume->mount_path + strlen ("/");
-
- if (eel_str_has_prefix (name, "cdrom")) {
- volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "floppy")) {
- volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (volume->device_path, floppy_device_path_prefix)) {
- volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "rmdisk")) {
- volume->device_type = NAUTILUS_DEVICE_ZIP_DRIVE;
- volume->is_removable = TRUE;
- if (eel_str_has_suffix (volume->device_path, ":c")) {
- volume->device_path = eel_str_strip_trailing_str
- (volume->device_path, ":c");
- }
- } else if (eel_str_has_prefix (name, "jaz")) {
- volume->device_type = NAUTILUS_DEVICE_JAZ_DRIVE;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "camera")) {
- volume->device_type = NAUTILUS_DEVICE_CAMERA;
- volume->is_removable = TRUE;
- } else if (eel_str_has_prefix (name, "memstick")) {
- volume->device_type = NAUTILUS_DEVICE_MEMORY_STICK;
- volume->is_removable = TRUE;
- } else {
- volume->is_removable = FALSE;
- }
- }
-
- return TRUE;
-}
-
-static GList *
-finish_creating_volume_and_prepend (NautilusVolumeMonitor *monitor,
- NautilusVolume *volume,
- const char *file_system_type_name,
- GList *list)
-{
- if (finish_creating_volume (monitor, volume, file_system_type_name)) {
- list = g_list_prepend (list, volume);
- } else {
- nautilus_volume_free (volume);
- }
- return list;
-}
-
-char *
-nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume)
-{
- const char *found_name;
- char *name;
-
- g_return_val_if_fail (monitor != NULL, NULL);
- g_return_val_if_fail (volume != NULL, NULL);
-
- name = g_path_get_basename (volume->mount_path);
-
- /* Look for a match in our localized mount name list */
- found_name = g_hash_table_lookup (monitor->details->readable_mount_point_names, name);
- if (found_name != NULL) {
- g_free (name);
- return g_strdup (found_name);
- } else {
- return name;
- }
-}
-
-/*
- * HORRORS OF HORROR.
- * This really should be fixed to not be needed (if it is?).
- * I just moved it from the desktop icon code so it can be shared
- * between the desktop icons and the sidebar tree.
-*/
-
-gboolean
-nautilus_volume_is_in_removable_blacklist (const NautilusVolume *volume)
-{
- char *blacklist[] = { "/proc", "/boot" };
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (blacklist); i++) {
- if (strcmp (blacklist[i], nautilus_volume_get_mount_path (volume)) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-#ifdef HAVE_CDDA
-
-static gboolean
-locate_audio_cd (void)
-{
- cdrom_drive *drive;
- gboolean opened;
-
- drive = cdda_identify (CD_AUDIO_PATH, FALSE, NULL);
- if (drive == NULL) {
- return FALSE;
- }
-
- /* Turn off verbosity */
- cdda_verbose_set (drive, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
-
- /* Open drive */
- switch (cdda_open (drive)) {
- case -2:
- case -3:
- case -4:
- case -5:
- /*g_message ("Unable to open disc. Is there an audio CD in the drive?");*/
- opened = FALSE;
- break;
-
- case -6:
- /*g_message ("CDDA method could not find a way to read audio from this drive.");*/
- opened = FALSE;
- break;
-
- case 0:
- opened = TRUE;
- break;
-
- default:
- /*g_message ("Unable to open disc.");*/
- opened = FALSE;
- break;
- }
- cdda_close (drive);
-
- return opened;
-}
-
-#endif /* HAVE_CDDA */
diff --git a/libnautilus-private/nautilus-volume-monitor.h b/libnautilus-private/nautilus-volume-monitor.h
deleted file mode 100644
index 45fd12ab2..000000000
--- a/libnautilus-private/nautilus-volume-monitor.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-volume-monitor.h - interface for desktop mounting functions.
-
- Copyright (C) 2000 Eazel, Inc.
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Gene Z. Ragan <gzr@eazel.com>
-*/
-
-#ifndef NAUTILUS_VOLUME_MONITOR_H
-#define NAUTILUS_VOLUME_MONITOR_H
-
-#include <gtk/gtkobject.h>
-
-typedef struct NautilusVolumeMonitor NautilusVolumeMonitor;
-typedef struct NautilusVolumeMonitorClass NautilusVolumeMonitorClass;
-typedef struct NautilusVolumeMonitorDetails NautilusVolumeMonitorDetails;
-
-#define NAUTILUS_TYPE_VOLUME_MONITOR (nautilus_volume_monitor_get_type())
-#define NAUTILUS_VOLUME_MONITOR(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VOLUME_MONITOR, NautilusVolumeMonitor))
-#define NAUTILUS_VOLUME_MONITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VOLUME_MONITOR, NautilusVolumeMonitorClass))
-#define NAUTILUS_IS_VOLUME_MONITOR(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VOLUME_MONITOR))
-
-struct NautilusVolumeMonitor {
- GtkObject parent;
- NautilusVolumeMonitorDetails *details;
-};
-
-typedef struct NautilusVolume NautilusVolume;
-
-struct NautilusVolumeMonitorClass {
- GtkObjectClass parent_class;
-
- /* Signals */
- void (* volume_mounted) (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume);
- void (* volume_unmount_started) (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume);
- void (* volume_unmount_failed) (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume);
- void (* volume_unmounted) (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume);
-
- void (* removable_volumes_changed) (NautilusVolumeMonitor *monitor);
-};
-
-typedef enum {
- NAUTILUS_DEVICE_UNKNOWN,
- NAUTILUS_DEVICE_AUDIO_CD,
- NAUTILUS_DEVICE_CAMERA,
- NAUTILUS_DEVICE_CDROM_DRIVE,
- NAUTILUS_DEVICE_FLOPPY_DRIVE,
- NAUTILUS_DEVICE_JAZ_DRIVE,
- NAUTILUS_DEVICE_MEMORY_STICK,
- NAUTILUS_DEVICE_NFS,
- NAUTILUS_DEVICE_ZIP_DRIVE,
- NAUTILUS_DEVICE_SMB,
- NAUTILUS_DEVICE_APPLE,
- NAUTILUS_DEVICE_WINDOWS
-} NautilusDeviceType;
-
-typedef gboolean (* NautilusEachVolumeCallback) (const NautilusVolume *, gpointer callback_data);
-
-GType nautilus_volume_monitor_get_type (void);
-NautilusVolumeMonitor *nautilus_volume_monitor_get (void);
-void nautilus_volume_monitor_mount_unmount_removable (NautilusVolumeMonitor *monitor,
- const char *mount_point,
- gboolean should_mount,
- gboolean should_eject);
-gboolean nautilus_volume_monitor_volume_is_mounted (NautilusVolumeMonitor *monitor,
- const NautilusVolume *mount_point);
-void nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor,
- NautilusEachVolumeCallback callback,
- gpointer callback_data);
-const GList * nautilus_volume_monitor_get_removable_volumes (NautilusVolumeMonitor *monitor);
-char * nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume);
-void nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monitor,
- const NautilusVolume *volume,
- const char *volume_name);
-NautilusVolume *nautilus_volume_monitor_get_volume_for_path (NautilusVolumeMonitor *monitor,
- const char *path);
-
-/* Volume operations. */
-char * nautilus_volume_get_name (const NautilusVolume *volume);
-char * nautilus_volume_get_icon (const NautilusVolume *volume);
-NautilusDeviceType nautilus_volume_get_device_type (const NautilusVolume *volume);
-gboolean nautilus_volume_is_removable (const NautilusVolume *volume);
-gboolean nautilus_volume_is_read_only (const NautilusVolume *volume);
-gboolean nautilus_volume_should_integrate_trash (const NautilusVolume *volume);
-const char * nautilus_volume_get_mount_path (const NautilusVolume *volume);
-char * nautilus_volume_get_target_uri (const NautilusVolume *volume);
-const char * nautilus_volume_get_device_path (NautilusVolume *volume);
-
-NautilusVolume * nautilus_volume_copy (const NautilusVolume *volume);
-void nautilus_volume_free (NautilusVolume *volume);
-guint nautilus_volume_hash (const NautilusVolume *volume);
-gboolean nautilus_volume_is_equal (const NautilusVolume *volume1,
- const NautilusVolume *volume2);
-gboolean nautilus_volume_is_in_removable_blacklist (const NautilusVolume *volume);
-
-#endif /* NAUTILUS_VOLUME_MONITOR_H */