]>
Commit | Line | Data |
---|---|---|
87d163f7 | 1 | ? =0.2.98 |
2 | ? gnome-vfs-new-hal-patch-and-eject-fixes.patch | |
3 | ? imported/Makefile | |
4 | ? imported/Makefile.in | |
5 | ? imported/neon/Makefile.in | |
6 | ? libgnomevfs/s-enum-types-c | |
7 | ? libgnomevfs/s-enum-types-h | |
8 | ? test/test-dns-sd | |
9 | ? test/test-mime-info-cache | |
10 | Index: configure.in | |
11 | =================================================================== | |
12 | RCS file: /cvs/gnome/gnome-vfs/configure.in,v | |
13 | retrieving revision 1.342 | |
14 | diff -u -p -r1.342 configure.in | |
15 | --- configure.in 22 Sep 2004 08:38:38 -0000 1.342 | |
16 | +++ configure.in 24 Sep 2004 22:50:32 -0000 | |
17 | @@ -697,8 +697,8 @@ esac], | |
18 | [ENABLE_HAL=no]) dnl Default value | |
19 | ||
20 | if test "x$ENABLE_HAL" = "xyes"; then | |
21 | - PKG_CHECK_MODULES(HAL, hal >= 0.2.92, | |
22 | - [ USE_HAL="hal >= 0.2.92, dbus-1 >= 0.22, dbus-glib-1 >= 0.22"; AC_DEFINE(USE_HAL, 1, [defined if using libhal])], | |
23 | + PKG_CHECK_MODULES(HAL, hal >= 0.2.98, | |
24 | + [ USE_HAL="hal >= 0.2.98, hal-storage >= 0.2.98, dbus-1 >= 0.22, dbus-glib-1 >= 0.22"; AC_DEFINE(USE_HAL, 1, [defined if using libhal])], | |
25 | [ USE_HAL=""]) | |
26 | else | |
27 | USE_HAL="" | |
28 | Index: libgnomevfs/GNOME_VFS_Daemon.idl | |
29 | =================================================================== | |
30 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/GNOME_VFS_Daemon.idl,v | |
31 | retrieving revision 1.9 | |
32 | diff -u -p -r1.9 GNOME_VFS_Daemon.idl | |
33 | --- libgnomevfs/GNOME_VFS_Daemon.idl 15 Jul 2004 13:21:15 -0000 1.9 | |
34 | +++ libgnomevfs/GNOME_VFS_Daemon.idl 24 Sep 2004 22:50:33 -0000 | |
35 | @@ -63,6 +63,7 @@ module GNOME { | |
36 | boolean is_user_visible; | |
37 | boolean is_connected; | |
38 | string hal_udi; | |
39 | + boolean should_eject; | |
40 | }; | |
41 | ||
42 | typedef sequence<Drive> DriveList; | |
43 | Index: libgnomevfs/gnome-vfs-drive.c | |
44 | =================================================================== | |
45 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-drive.c,v | |
46 | retrieving revision 1.8 | |
47 | diff -u -p -r1.8 gnome-vfs-drive.c | |
48 | --- libgnomevfs/gnome-vfs-drive.c 16 Aug 2004 08:44:06 -0000 1.8 | |
49 | +++ libgnomevfs/gnome-vfs-drive.c 24 Sep 2004 22:50:33 -0000 | |
50 | @@ -582,6 +582,8 @@ gnome_vfs_drive_to_corba (GnomeVFSDrive | |
51 | ||
52 | corba_drive->is_user_visible = drive->priv->is_user_visible; | |
53 | corba_drive->is_connected = drive->priv->is_connected; | |
54 | + | |
55 | + corba_drive->should_eject = drive->priv->should_eject; | |
56 | } | |
57 | ||
58 | GnomeVFSDrive * | |
59 | @@ -617,5 +619,6 @@ _gnome_vfs_drive_from_corba (const GNOME | |
60 | drive->priv->is_user_visible = corba_drive->is_user_visible; | |
61 | drive->priv->is_connected = corba_drive->is_connected; | |
62 | ||
63 | + drive->priv->should_eject = corba_drive->should_eject; | |
64 | return drive; | |
65 | } | |
66 | Index: libgnomevfs/gnome-vfs-hal-mounts.c | |
67 | =================================================================== | |
68 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-hal-mounts.c,v | |
69 | retrieving revision 1.7 | |
70 | diff -u -p -r1.7 gnome-vfs-hal-mounts.c | |
71 | --- libgnomevfs/gnome-vfs-hal-mounts.c 19 Aug 2004 07:34:01 -0000 1.7 | |
72 | +++ libgnomevfs/gnome-vfs-hal-mounts.c 24 Sep 2004 22:50:33 -0000 | |
73 | @@ -1,7 +1,7 @@ | |
74 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ | |
75 | /* gnome-vfs-hal-mounts.c - read and monitor volumes using freedesktop HAL | |
76 | ||
77 | - Copyright (C) 2004 David Zeuthen | |
78 | + Copyright (C) 2004 Red Hat, Inc | |
79 | ||
80 | The Gnome Library is free software; you can redistribute it and/or | |
81 | modify it under the terms of the GNU Library General Public License as | |
82 | @@ -18,7 +18,7 @@ | |
83 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
84 | Boston, MA 02111-1307, USA. | |
85 | ||
86 | - Author: David Zeuthen <david@fubar.dk> | |
87 | + Author: David Zeuthen <davidz@redhat.com> | |
88 | */ | |
89 | ||
90 | #include <config.h> | |
91 | @@ -39,6 +39,7 @@ | |
92 | #include <libgnomevfs/gnome-vfs-i18n.h> | |
93 | ||
94 | #include <libhal.h> | |
95 | +#include <libhal-storage.h> | |
96 | #include <dbus/dbus-glib.h> | |
97 | #include <dbus/dbus-glib-lowlevel.h> | |
98 | ||
99 | @@ -47,1322 +48,549 @@ | |
100 | #include "gnome-vfs-volume-monitor-daemon.h" | |
101 | #include "gnome-vfs-volume-monitor-private.h" | |
102 | ||
103 | -/** Use HAL to retrieve information about drives and volumes. | |
104 | - * | |
105 | - * TODO/QUESTIONS/ISSUES | |
106 | - * | |
107 | - * - Fix HAL so hal_initialize() fails when we cannot connect to the HAL | |
108 | - * daemon; When this works GNOME VFS falls back to mtab/fstab monitoring. | |
109 | - * Which is nice. | |
110 | - * | |
111 | - * - When a recordable disc (CD-R, CD-RW, DVD-R, DVD+RW etc.) is closed | |
112 | - * should we map down to the non-cdrecordable type? E.g. | |
113 | - * | |
114 | - * CD-R, CD-RW |-> CD-ROM | |
115 | - * DVD-R, DVD-RW, DVD+R, DVD+RW, DVD-RAM |-> DVD-ROM | |
116 | - * | |
117 | - * Currently we don't do this. One reason for doing this is that consumers | |
118 | - * might download e.g. a Linux distrobution and burn the ISO's, close the | |
119 | - * disc and then it's a CD-ROM since they can't burn to the disc more | |
120 | - * anyway? Maybe we should do this, but not for RW discs, e.g. only | |
121 | - * | |
122 | - * CD-R |-> CD-ROM | |
123 | - * DVD-R, DVD+R |-> DVD-ROM | |
124 | - * | |
125 | - * when closed; this I think would make sense. Comments? | |
126 | - * | |
127 | - * - When libgphoto2 is completely halificated, get the GNOME VFS backend | |
128 | - * to work and add functionality (in this file) to show a camera icon that | |
129 | - * links to the appropriate GNOME VFS URI. (when the camera is not | |
130 | - * usb-storage based of course) | |
131 | - * | |
132 | - * - Do the same for MP3 players when GNOME VFS backends for these emerge. | |
133 | - * | |
134 | - * NOTE | |
135 | - * | |
136 | - * - For this patch you need a recent version of GNOME VFS that doesn't | |
137 | - * crash when a name contains a '/' character | |
138 | - */ | |
139 | - | |
140 | - | |
141 | -/* If this is defined then only mounted volumes are shown which gives | |
142 | - * a Mac OS X like experience. Otherwise unmounted volumes are shown | |
143 | - * as a drive icon. Obviously, this requires an automounter like | |
144 | - * gnome-volume-manager. | |
145 | - */ | |
146 | -/*#define HAL_ONLY_SHOW_MOUNTED_VOLUMES*/ | |
147 | - | |
148 | -/* If this is defined use the standard icons available. Otherwise new | |
149 | - * a new, more fine grained icon set is used. See below.. | |
150 | - * | |
151 | - */ | |
152 | -/*#define HAL_USE_STOCK_ICONS*/ | |
153 | - | |
154 | - | |
155 | -#ifdef HAL_USE_STOCK_ICONS | |
156 | - | |
157 | -#define HAL_ICON_DRIVE_REMOVABLE "gnome-dev-removable" | |
158 | -#define HAL_ICON_DRIVE_REMOVABLE_USB "gnome-dev-removable" | |
159 | -#define HAL_ICON_DRIVE_REMOVABLE_IEEE1394 "gnome-dev-removable" | |
160 | -#define HAL_ICON_DISC_CDROM "gnome-dev-cdrom" | |
161 | -#define HAL_ICON_DISC_CDR "gnome-dev-cdrom" | |
162 | -#define HAL_ICON_DISC_CDRW "gnome-dev-cdrom" | |
163 | -#define HAL_ICON_DISC_DVDROM "gnome-dev-cdrom" | |
164 | -#define HAL_ICON_DISC_DVDRAM "gnome-dev-cdrom" | |
165 | -#define HAL_ICON_DISC_DVDR "gnome-dev-cdrom" | |
166 | -#define HAL_ICON_DISC_DVDRW "gnome-dev-cdrom" | |
167 | -#define HAL_ICON_DISC_DVDRW_PLUS "gnome-dev-cdrom" | |
168 | -#define HAL_ICON_DISC_DVDR_PLUS "gnome-dev-cdrom" | |
169 | -#define HAL_ICON_MEDIA_COMPACT_FLASH "gnome-dev-harddisk" | |
170 | -#define HAL_ICON_MEDIA_MEMORY_STICK "gnome-dev-harddisk" | |
171 | -#define HAL_ICON_MEDIA_SMART_MEDIA "gnome-dev-harddisk" | |
172 | -#define HAL_ICON_MEDIA_SD_MMC "gnome-dev-harddisk" | |
173 | -#define HAL_ICON_MEDIA_FLOPPY "gnome-dev-floppy" | |
174 | -#define HAL_ICON_MEDIA_HARDDISK "gnome-dev-harddisk" | |
175 | -#define HAL_ICON_MEDIA_HARDDISK_USB "gnome-dev-harddisk" | |
176 | -#define HAL_ICON_MEDIA_HARDDISK_IEEE1394 "gnome-dev-harddisk" | |
177 | -#define HAL_ICON_PORTABLE_AUDIO_PLAYER "gnome-dev-harddisk" | |
178 | -#define HAL_ICON_CAMERA "gnome-dev-harddisk" | |
179 | - | |
180 | -#else | |
181 | - | |
182 | -#define HAL_ICON_DRIVE_REMOVABLE "gnome-dev-removable" | |
183 | -#define HAL_ICON_DRIVE_REMOVABLE_USB "gnome-dev-removable-usb" | |
184 | -#define HAL_ICON_DRIVE_REMOVABLE_IEEE1394 "gnome-dev-removable-ieee1394" | |
185 | -#define HAL_ICON_DISC_CDROM "gnome-dev-cdrom" | |
186 | -#define HAL_ICON_DISC_CDR "gnome-dev-disc-cdr" | |
187 | -#define HAL_ICON_DISC_CDRW "gnome-dev-disc-cdrw" | |
188 | -#define HAL_ICON_DISC_DVDROM "gnome-dev-disc-dvdrom" | |
189 | -#define HAL_ICON_DISC_DVDRAM "gnome-dev-disc-dvdram" | |
190 | -#define HAL_ICON_DISC_DVDR "gnome-dev-disc-dvdr" | |
191 | -#define HAL_ICON_DISC_DVDRW "gnome-dev-disc-dvdrw" | |
192 | -#define HAL_ICON_DISC_DVDRW_PLUS "gnome-dev-disc-dvdrw-plus" | |
193 | -#define HAL_ICON_DISC_DVDR_PLUS "gnome-dev-disc-dvdr-plus" | |
194 | -#define HAL_ICON_MEDIA_COMPACT_FLASH "gnome-dev-media-cf" | |
195 | -#define HAL_ICON_MEDIA_MEMORY_STICK "gnome-dev-media-ms" | |
196 | -#define HAL_ICON_MEDIA_SMART_MEDIA "gnome-dev-media-sm" | |
197 | -#define HAL_ICON_MEDIA_SD_MMC "gnome-dev-media-sdmmc" | |
198 | -#define HAL_ICON_MEDIA_FLOPPY "gnome-dev-floppy" | |
199 | -#define HAL_ICON_MEDIA_HARDDISK "gnome-dev-harddisk" | |
200 | -#define HAL_ICON_MEDIA_HARDDISK_USB "gnome-dev-harddisk-usb" | |
201 | -#define HAL_ICON_MEDIA_HARDDISK_IEEE1394 "gnome-dev-harddisk-ieee1394" | |
202 | -#define HAL_ICON_PORTABLE_AUDIO_PLAYER "gnome-dev-portable-audio-player" | |
203 | -#define HAL_ICON_CAMERA "gnome-dev-camera" | |
204 | - | |
205 | -#endif /* HAL_USE_STOCK_ICONS */ | |
206 | - | |
207 | -typedef struct { | |
208 | - char *udi; | |
209 | - | |
210 | - int device_major; | |
211 | - int device_minor; | |
212 | - char *device_file; | |
213 | - | |
214 | - char *bus; /* ide, scsi, usb, ieee1394, ... */ | |
215 | - char *vendor; /* may be NULL, is never "" */ | |
216 | - char *model; /* may be NULL, is never "" */ | |
217 | - gboolean is_hotpluggable; | |
218 | - gboolean is_removable; | |
219 | - gboolean no_partitions; | |
220 | - char *type; /* disk, cdrom, floppy, compact_flash, | |
221 | - * memory_stick, smart_media, sd_mmc, ... */ | |
222 | - | |
223 | - char *physical_device; /* UDI of physical device, e.g. the | |
224 | - * IDE, USB, IEEE1394 device */ | |
225 | - | |
226 | -} GnomeVFSHalDrive; | |
227 | - | |
228 | typedef struct { | |
229 | - char *udi; | |
230 | - | |
231 | - int device_major; | |
232 | - int device_minor; | |
233 | - char *device_file; | |
234 | - char *volume_label; /* may be NULL, is never "" */ | |
235 | - gboolean is_mounted; | |
236 | - char *mount_point; /* NULL iff !is_mounted */ | |
237 | - char *fstype; /* NULL iff !is_mounted or unknown */ | |
238 | - | |
239 | - gboolean is_disc; | |
240 | - char *disc_type; /* NULL iff !is_disc */ | |
241 | - gboolean disc_has_audio; | |
242 | - gboolean disc_has_data; | |
243 | - gboolean disc_is_appendable; | |
244 | - gboolean disc_is_blank; | |
245 | - gboolean disc_is_rewritable; | |
246 | -} GnomeVFSHalVolume; | |
247 | - | |
248 | -static void | |
249 | -_hal_free_drive (GnomeVFSHalDrive *drive) | |
250 | -{ | |
251 | - if (drive == NULL ) | |
252 | - return; | |
253 | - | |
254 | - free (drive->udi); | |
255 | - hal_free_string (drive->device_file); | |
256 | - hal_free_string (drive->bus); | |
257 | - hal_free_string (drive->vendor); | |
258 | - hal_free_string (drive->model); | |
259 | - hal_free_string (drive->type); | |
260 | -} | |
261 | - | |
262 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
263 | + HalStoragePolicy *hal_storage_policy; | |
264 | +} GnomeVFSHalUserData; | |
265 | ||
266 | static void | |
267 | -_hal_free_vol (GnomeVFSHalVolume *vol) | |
268 | +_hal_mainloop_integration (LibHalContext *ctx, | |
269 | + DBusConnection * dbus_connection) | |
270 | { | |
271 | - if (vol == NULL ) | |
272 | - return; | |
273 | - | |
274 | - free (vol->udi); | |
275 | - hal_free_string (vol->device_file); | |
276 | - hal_free_string (vol->volume_label); | |
277 | - hal_free_string (vol->fstype); | |
278 | - hal_free_string (vol->mount_point); | |
279 | - hal_free_string (vol->disc_type); | |
280 | + dbus_connection_setup_with_g_main (dbus_connection, NULL); | |
281 | } | |
282 | ||
283 | - | |
284 | -/* Given a UDI for a HAL device of capability 'storage', this | |
285 | - * function retrieves all the relevant properties into a convenient | |
286 | - * structure. Returns NULL if UDI is invalid or device is not of | |
287 | - * capability 'storage'. | |
288 | - * | |
289 | - * Free with _hal_free_drive(). | |
290 | - */ | |
291 | -static GnomeVFSHalDrive * | |
292 | -_hal_get_drive (const char *udi, LibHalContext *hal_ctx) | |
293 | +static void | |
294 | +_hal_device_added (LibHalContext *hal_ctx, | |
295 | + const char *udi) | |
296 | { | |
297 | - GnomeVFSHalDrive *drive; | |
298 | - | |
299 | - drive = g_new0 (GnomeVFSHalDrive, 1); | |
300 | - if (drive == NULL) | |
301 | - goto error; | |
302 | - | |
303 | - drive->udi = strdup (udi); | |
304 | - if (drive->udi == NULL) | |
305 | - goto error; | |
306 | - | |
307 | - drive->device_file = hal_device_get_property_string ( | |
308 | - hal_ctx, udi, "block.device"); | |
309 | - if (drive->device_file == NULL) | |
310 | - goto error; | |
311 | - | |
312 | - drive->bus = hal_device_get_property_string ( | |
313 | - hal_ctx, udi, "storage.bus"); | |
314 | - if (drive->bus == NULL) | |
315 | - goto error; | |
316 | - | |
317 | - drive->vendor = hal_device_get_property_string ( | |
318 | - hal_ctx, udi, "storage.vendor"); | |
319 | - if (drive->vendor == NULL) | |
320 | - goto error; | |
321 | - | |
322 | - drive->model = hal_device_get_property_string ( | |
323 | - hal_ctx, udi, "storage.model"); | |
324 | - if (drive->model == NULL) | |
325 | - goto error; | |
326 | - | |
327 | - drive->type = hal_device_get_property_string ( | |
328 | - hal_ctx, udi, "storage.drive_type"); | |
329 | - if (drive->type == NULL) | |
330 | - goto error; | |
331 | + GnomeVFSHalUserData *hal_userdata; | |
332 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
333 | ||
334 | - drive->is_hotpluggable = hal_device_get_property_bool ( | |
335 | - hal_ctx, udi, "storage.hotpluggable"); | |
336 | - | |
337 | - drive->is_removable = hal_device_get_property_bool ( | |
338 | - hal_ctx, udi, "storage.removable"); | |
339 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
340 | + volume_monitor_daemon = hal_userdata->volume_monitor_daemon; | |
341 | ||
342 | - drive->no_partitions = hal_device_get_property_bool ( | |
343 | - hal_ctx, udi, "block.no_partitions"); | |
344 | + /* Handle optical discs without data since these are not handled | |
345 | + * by GNOME VFS | |
346 | + */ | |
347 | + if (hal_device_get_property_bool (hal_ctx, udi, "volume.is_disc")) { | |
348 | + const char *storage_udi; | |
349 | ||
350 | - drive->physical_device = hal_device_get_property_string ( | |
351 | - hal_ctx, udi, "storage.physical_device"); | |
352 | - if (drive->physical_device == NULL) | |
353 | - goto error; | |
354 | - | |
355 | - return drive; | |
356 | -error: | |
357 | - _hal_free_drive (drive); | |
358 | - return NULL; | |
359 | + storage_udi = hal_device_get_property_string (hal_ctx, udi, "block.storage_device"); | |
360 | + if (storage_udi != NULL) { | |
361 | + GnomeVFSDrive *drive; | |
362 | + | |
363 | + drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi ( | |
364 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), storage_udi); | |
365 | + if (drive != NULL) { | |
366 | + /* this function also handles optical discs without data */ | |
367 | + _gnome_vfs_hal_mounts_modify_drive (volume_monitor_daemon, drive); | |
368 | + } | |
369 | + } | |
370 | + } | |
371 | } | |
372 | ||
373 | -/* Given a UDI for a HAL device of capability 'volume', this function | |
374 | - * retrieves all the relevant properties into a convenient structure. | |
375 | - * Returns NULL if UDI is invalid or device is not of capability | |
376 | - * 'volume'. | |
377 | - * | |
378 | - * Free with _hal_free_vol(). | |
379 | - */ | |
380 | -static GnomeVFSHalVolume * | |
381 | -_hal_get_vol (const char *udi, LibHalContext *hal_ctx) | |
382 | +static void | |
383 | +_hal_device_removed (LibHalContext *hal_ctx, const char *udi) | |
384 | { | |
385 | - GnomeVFSHalVolume *vol; | |
386 | - | |
387 | - vol = g_new0 (GnomeVFSHalVolume, 1); | |
388 | - if (vol == NULL) | |
389 | - goto error; | |
390 | - | |
391 | - /* only care about capability volume */ | |
392 | - if (!hal_device_query_capability ( | |
393 | - hal_ctx, | |
394 | - udi, "volume")) | |
395 | - goto error; | |
396 | - | |
397 | - vol->udi = strdup (udi); | |
398 | - if (vol->udi == NULL) | |
399 | - goto error; | |
400 | - | |
401 | - vol->device_major = hal_device_get_property_int ( | |
402 | - hal_ctx, udi, "block.major"); | |
403 | - | |
404 | - vol->device_minor = hal_device_get_property_int ( | |
405 | - hal_ctx, udi, "block.minor"); | |
406 | - | |
407 | - vol->device_file = hal_device_get_property_string ( | |
408 | - hal_ctx, | |
409 | - udi, "block.device"); | |
410 | - if (vol->device_file == NULL) | |
411 | - goto error; | |
412 | - | |
413 | - if (hal_device_property_exists ( | |
414 | - hal_ctx, | |
415 | - udi, "volume.label")) { | |
416 | - vol->volume_label = hal_device_get_property_string ( | |
417 | - hal_ctx, | |
418 | - udi, "volume.label"); | |
419 | - if (strlen (vol->volume_label) == 0) { | |
420 | - hal_free_string (vol->volume_label); | |
421 | - vol->volume_label = NULL; | |
422 | - } | |
423 | - } | |
424 | + GnomeVFSDrive *drive; | |
425 | + GnomeVFSVolume *volume; | |
426 | + GnomeVFSHalUserData *hal_userdata; | |
427 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
428 | + | |
429 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
430 | + volume_monitor_daemon = hal_userdata->volume_monitor_daemon; | |
431 | ||
432 | + drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi ( | |
433 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), udi); | |
434 | ||
435 | - vol->is_mounted = hal_device_get_property_bool ( | |
436 | - hal_ctx, | |
437 | - udi, "volume.is_mounted"); | |
438 | - | |
439 | - if (vol->is_mounted) { | |
440 | - vol->mount_point = hal_device_get_property_string ( | |
441 | - hal_ctx, | |
442 | - udi, "volume.mount_point"); | |
443 | - if (vol->mount_point == NULL || strlen (vol->mount_point) == 0) | |
444 | - goto error; | |
445 | - | |
446 | - } | |
447 | + volume = _gnome_vfs_volume_monitor_find_volume_by_hal_udi ( | |
448 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), udi); | |
449 | ||
450 | - vol->fstype = hal_device_get_property_string ( | |
451 | - hal_ctx, | |
452 | - udi, "volume.fstype"); | |
453 | - if (vol->fstype == NULL) | |
454 | - goto error; | |
455 | - if (strlen(vol->fstype) == 0) { | |
456 | - hal_free_string (vol->fstype); | |
457 | - vol->fstype = NULL; | |
458 | + /* Just remove the drive and or volume here; will also be done in | |
459 | + * update_mtab_volumes and update_fstab_drives in the source file | |
460 | + * gnome-vfs-volume-monitor-daemon.c but that wont matter much. | |
461 | + * | |
462 | + * We need to do this to handle optical discs without data since these | |
463 | + * are not handled by GNOME VFS | |
464 | + */ | |
465 | + if (drive != NULL) { | |
466 | + _gnome_vfs_volume_monitor_disconnected (GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), drive); | |
467 | } | |
468 | ||
469 | - /* optical disc properties */ | |
470 | - if (hal_device_get_property_bool (hal_ctx, | |
471 | - udi, "volume.is_disc")) { | |
472 | - vol->is_disc = TRUE; | |
473 | - | |
474 | - vol->disc_type = hal_device_get_property_string ( | |
475 | - hal_ctx, | |
476 | - udi, "volume.disc.type"); | |
477 | - if (vol->disc_type == NULL || strlen (vol->disc_type) == 0) | |
478 | - goto error; | |
479 | - | |
480 | - vol->disc_has_audio = hal_device_get_property_bool ( | |
481 | - hal_ctx, | |
482 | - udi, "volume.disc.has_audio"); | |
483 | - vol->disc_has_data = hal_device_get_property_bool ( | |
484 | - hal_ctx, | |
485 | - udi, "volume.disc.has_data"); | |
486 | - vol->disc_is_appendable = hal_device_get_property_bool ( | |
487 | - hal_ctx, | |
488 | - udi, "volume.disc.is_appendable"); | |
489 | - vol->disc_is_blank = hal_device_get_property_bool ( | |
490 | - hal_ctx, | |
491 | - udi, "volume.disc.is_blank"); | |
492 | - vol->disc_is_rewritable = hal_device_get_property_bool ( | |
493 | - hal_ctx, | |
494 | - udi, "volume.disc.is_rewritable"); | |
495 | + if (volume != NULL) { | |
496 | + _gnome_vfs_volume_monitor_unmounted (GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), volume); | |
497 | } | |
498 | - | |
499 | - | |
500 | - | |
501 | - return vol; | |
502 | - | |
503 | -error: | |
504 | - _hal_free_vol (vol); | |
505 | - return NULL; | |
506 | } | |
507 | ||
508 | -/** Get the GnomeVFSHalDrive from a GnomeVFSHalVolume. Returns NULL on error. | |
509 | - * | |
510 | - * Free with _hal_free_drive(). | |
511 | - */ | |
512 | -static GnomeVFSHalDrive * | |
513 | -_hal_get_drive_from_vol (GnomeVFSHalVolume *vol, LibHalContext *hal_ctx) | |
514 | +static void | |
515 | +_hal_device_new_capability (LibHalContext *hal_ctx, | |
516 | + const char *udi, | |
517 | + const char *capability) | |
518 | { | |
519 | - const char *storage_udi; | |
520 | - | |
521 | - storage_udi = hal_device_get_property_string ( | |
522 | - hal_ctx, vol->udi, "block.storage_device"); | |
523 | - if (storage_udi == NULL) | |
524 | - goto error; | |
525 | - | |
526 | - return _hal_get_drive (storage_udi, hal_ctx); | |
527 | -error: | |
528 | - return NULL; | |
529 | -} | |
530 | - | |
531 | - | |
532 | - | |
533 | -/***********************************************************************/ | |
534 | + GnomeVFSHalUserData *hal_userdata; | |
535 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
536 | + | |
537 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
538 | + volume_monitor_daemon = hal_userdata->volume_monitor_daemon; | |
539 | ||
540 | -/** If you don't have a recent GNOME VFS you need to uncomment the code | |
541 | - * below | |
542 | - * | |
543 | - * OLD ERROR: Fixup the name given to GnomeVFS, it may not contain | |
544 | - * '/'-characters. Substitute these with '-'. | |
545 | - */ | |
546 | -static void | |
547 | -fixup_name (char *name) | |
548 | -{ | |
549 | - ; | |
550 | - /* | |
551 | - int i; | |
552 | - | |
553 | - for (i=0; name[i]!='\0'; i++) { | |
554 | - if (name[i] == '/') | |
555 | - name[i] = '-'; | |
556 | - } | |
557 | - */ | |
558 | + /* do nothing */ | |
559 | } | |
560 | ||
561 | -/***********************************************************************/ | |
562 | - | |
563 | -static char *_hal_get_vol_name (GnomeVFSHalVolume *vol, | |
564 | - GnomeVFSHalDrive *drive, | |
565 | - LibHalContext *hal_ctx); | |
566 | -static char *_hal_get_vol_icon (GnomeVFSHalVolume *vol, | |
567 | - GnomeVFSHalDrive *drive, | |
568 | - LibHalContext *hal_ctx); | |
569 | -static int _hal_get_vol_type (GnomeVFSHalVolume *vol, | |
570 | - GnomeVFSHalDrive *drive, | |
571 | - LibHalContext *hal_ctx); | |
572 | - | |
573 | - | |
574 | - | |
575 | -/* vol may be NULL */ | |
576 | -static char * | |
577 | -_hal_get_drive_name (GnomeVFSHalVolume *vol, GnomeVFSHalDrive *drive, | |
578 | - LibHalContext *hal_ctx) | |
579 | +static void | |
580 | +_hal_device_lost_capability (LibHalContext *hal_ctx, | |
581 | + const char *udi, | |
582 | + const char *capability) | |
583 | { | |
584 | - char *name; | |
585 | - | |
586 | - | |
587 | -#ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES | |
588 | - /* this is safe, as drives and volumes are 1:1 */ | |
589 | - if (vol != NULL) | |
590 | - return _hal_get_vol_name (vol, drive, hal_ctx); | |
591 | -#else | |
592 | - /* Bork, storage.removable is a bit broken on HAL (I fear only | |
593 | - * .fdi files will fix it), so it's not sane to rely on this.. | |
594 | - * Which is bad, because without computer:/// looks ugly, e.g. | |
595 | - * "<drive_name> : <volume_name>" even for storage that is | |
596 | - * not removable. Bork. | |
597 | - */ | |
598 | - | |
599 | - /* | |
600 | - if (vol != NULL && !drive->is_removable) | |
601 | - return _hal_get_vol_name (vol, drive, hal_ctx); | |
602 | - */ | |
603 | -#endif | |
604 | - | |
605 | - if (strcmp (drive->type, "cdrom") == 0) { | |
606 | - gboolean cdr; | |
607 | - gboolean cdrw; | |
608 | - gboolean dvd; | |
609 | - gboolean dvdplusr; | |
610 | - gboolean dvdplusrw; | |
611 | - gboolean dvdr; | |
612 | - gboolean dvdram; | |
613 | - char *first; | |
614 | - char *second; | |
615 | - | |
616 | - /* use the capabilities of the optical device */ | |
617 | - | |
618 | - cdr = hal_device_get_property_bool ( | |
619 | - hal_ctx, drive->udi, "storage.cdrom.cdr"); | |
620 | - cdrw = hal_device_get_property_bool ( | |
621 | - hal_ctx, drive->udi, "storage.cdrom.cdrw"); | |
622 | - dvd = hal_device_get_property_bool ( | |
623 | - hal_ctx, drive->udi, "storage.cdrom.dvd"); | |
624 | - dvdplusr = hal_device_get_property_bool ( | |
625 | - hal_ctx, drive->udi, "storage.cdrom.dvdplusr"); | |
626 | - dvdplusrw = hal_device_get_property_bool ( | |
627 | - hal_ctx, drive->udi, "storage.cdrom.dvdplusrw"); | |
628 | - dvdr = hal_device_get_property_bool ( | |
629 | - hal_ctx, drive->udi, "storage.cdrom.dvdr"); | |
630 | - dvdram = hal_device_get_property_bool ( | |
631 | - hal_ctx, drive->udi, "storage.cdrom.dvdram"); | |
632 | - | |
633 | - first = "CD-ROM"; | |
634 | - if( cdr ) | |
635 | - first = "CD-R"; | |
636 | - if( cdrw ) | |
637 | - first = "CD-RW"; | |
638 | - | |
639 | - /* Hmm, '/' is not an allowed character, so use '\' instead | |
640 | - * | |
641 | - * TODO: Fix this | |
642 | - */ | |
643 | - second = ""; | |
644 | - if( dvd ) | |
645 | - second = "/DVD-ROM"; | |
646 | - if( dvdplusr ) | |
647 | - second = "/DVD+R"; | |
648 | - if( dvdplusrw ) | |
649 | - second = "/DVD+RW"; | |
650 | - if( dvdr ) | |
651 | - second = "/DVD-R"; | |
652 | - if( dvdram ) | |
653 | - second = "/DVD-RAM"; | |
654 | - if( dvdplusr && dvdr ) | |
96c797b5 | 655 | - second = "/DVD\302\261R"; |
87d163f7 | 656 | - if( dvdplusr && dvdplusrw && dvdr ) |
96c797b5 | 657 | - second = "/DVD\302\261RW"; |
87d163f7 | 658 | - |
659 | - name = g_strdup_printf ("%s%s", first, second); | |
660 | - } else if (strcmp (drive->type, "floppy") == 0) { | |
661 | - /* TODO: Check for LS120 or Zip drive etc. */ | |
662 | - name = g_strdup ("Floppy Drive"); | |
663 | - } else { | |
664 | - name = g_strdup (drive->model); | |
665 | - } | |
666 | - | |
667 | - fixup_name (name); | |
668 | + GnomeVFSHalUserData *hal_userdata; | |
669 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
670 | + | |
671 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
672 | + volume_monitor_daemon = hal_userdata->volume_monitor_daemon; | |
673 | ||
674 | - return name; | |
675 | + /* do nothing */ | |
676 | } | |
677 | ||
678 | -/* vol may be NULL */ | |
679 | -static char * | |
680 | -_hal_get_drive_icon (GnomeVFSHalVolume *vol, GnomeVFSHalDrive *drive, | |
681 | - LibHalContext *hal_ctx) | |
682 | +static void | |
683 | +_hal_device_property_modified (LibHalContext *hal_ctx, | |
684 | + const char *udi, | |
685 | + const char *key, | |
686 | + dbus_bool_t is_removed, | |
687 | + dbus_bool_t is_added) | |
688 | { | |
689 | - char *name; | |
690 | - | |
691 | - if (strcmp (drive->bus, "usb") == 0) { | |
692 | - name = g_strdup (HAL_ICON_DRIVE_REMOVABLE_USB); | |
693 | - } else if (strcmp (drive->bus, "ieee1394") == 0) { | |
694 | - name = g_strdup (HAL_ICON_DRIVE_REMOVABLE_IEEE1394); | |
695 | - } else { | |
696 | - name = g_strdup (HAL_ICON_DRIVE_REMOVABLE); | |
697 | - } | |
698 | + GnomeVFSHalUserData *hal_userdata; | |
699 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
700 | + | |
701 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
702 | + volume_monitor_daemon = hal_userdata->volume_monitor_daemon; | |
703 | ||
704 | - return name; | |
705 | + /* do nothing */ | |
706 | } | |
707 | ||
708 | -/* vol may be NULL */ | |
709 | -static int | |
710 | -_hal_get_drive_type (GnomeVFSHalVolume *vol, GnomeVFSHalDrive *drive, | |
711 | - LibHalContext *hal_ctx) | |
712 | +static void | |
713 | +_hal_device_condition (LibHalContext *hal_ctx, | |
714 | + const char *udi, | |
715 | + const char *condition_name, | |
716 | + DBusMessage *message) | |
717 | { | |
718 | - int type; | |
719 | - | |
720 | - type = GNOME_VFS_DEVICE_TYPE_HARDDRIVE; | |
721 | - | |
722 | - if (strcmp (drive->type, "cdrom") == 0) | |
723 | - type = GNOME_VFS_DEVICE_TYPE_CDROM; | |
724 | - if (strcmp (drive->type, "floppy") == 0) | |
725 | - type = GNOME_VFS_DEVICE_TYPE_FLOPPY; | |
726 | - else if (strcmp (drive->type, "compact_flash") == 0 || | |
727 | - strcmp (drive->type, "memory_stick") == 0 || | |
728 | - strcmp (drive->type, "smart_media") == 0 || | |
729 | - strcmp (drive->type, "sd_mmc") == 0) | |
730 | - type = GNOME_VFS_DEVICE_TYPE_MEMORY_STICK; | |
731 | + GnomeVFSHalUserData *hal_userdata; | |
732 | + GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
733 | + | |
734 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
735 | + volume_monitor_daemon = hal_userdata->volume_monitor_daemon; | |
736 | ||
737 | - return type; | |
738 | + /* do nothing */ | |
739 | } | |
740 | ||
741 | +static LibHalFunctions | |
742 | +hal_functions = { _hal_mainloop_integration, | |
743 | + _hal_device_added, | |
744 | + _hal_device_removed, | |
745 | + _hal_device_new_capability, | |
746 | + _hal_device_lost_capability, | |
747 | + _hal_device_property_modified, | |
748 | + _hal_device_condition }; | |
749 | ||
750 | +static HalStoragePolicyIconPair icon_mapping[] = { | |
751 | + {HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK, "gnome-dev-removable"}, | |
752 | + {HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IDE, "gnome-dev-removable"}, | |
753 | + {HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_SCSI, "gnome-dev-removable"}, | |
754 | + {HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_USB, "gnome-dev-removable-usb"}, | |
755 | + {HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IEEE1394, "gnome-dev-removable-1394"}, | |
756 | + {HAL_STORAGE_ICON_DRIVE_DISK, "gnome-dev-removable"}, | |
757 | + {HAL_STORAGE_ICON_DRIVE_DISK_IDE, "gnome-dev-removable"}, | |
758 | + {HAL_STORAGE_ICON_DRIVE_DISK_SCSI, "gnome-dev-removable"}, | |
759 | + {HAL_STORAGE_ICON_DRIVE_DISK_USB, "gnome-dev-removable-usb"}, | |
760 | + {HAL_STORAGE_ICON_DRIVE_DISK_IEEE1394, "gnome-dev-removable-1394"}, | |
761 | + {HAL_STORAGE_ICON_DRIVE_CDROM, "gnome-dev-removable"}, | |
762 | + {HAL_STORAGE_ICON_DRIVE_CDROM_IDE, "gnome-dev-removable"}, | |
763 | + {HAL_STORAGE_ICON_DRIVE_CDROM_SCSI, "gnome-dev-removable"}, | |
764 | + {HAL_STORAGE_ICON_DRIVE_CDROM_USB, "gnome-dev-removable-usb"}, | |
765 | + {HAL_STORAGE_ICON_DRIVE_CDROM_IEEE1394, "gnome-dev-removable-1394"}, | |
766 | + {HAL_STORAGE_ICON_DRIVE_FLOPPY, "gnome-dev-removable"}, | |
767 | + {HAL_STORAGE_ICON_DRIVE_FLOPPY_IDE, "gnome-dev-removable"}, | |
768 | + {HAL_STORAGE_ICON_DRIVE_FLOPPY_SCSI, "gnome-dev-removable"}, | |
769 | + {HAL_STORAGE_ICON_DRIVE_FLOPPY_USB, "gnome-dev-removable-usb"}, | |
770 | + {HAL_STORAGE_ICON_DRIVE_FLOPPY_IEEE1394, "gnome-dev-removable-1394"}, | |
771 | + {HAL_STORAGE_ICON_DRIVE_TAPE, "gnome-dev-removable"}, | |
772 | + {HAL_STORAGE_ICON_DRIVE_COMPACT_FLASH, "gnome-dev-removable"}, | |
773 | + {HAL_STORAGE_ICON_DRIVE_MEMORY_STICK, "gnome-dev-removable"}, | |
774 | + {HAL_STORAGE_ICON_DRIVE_SMART_MEDIA, "gnome-dev-removable"}, | |
775 | + {HAL_STORAGE_ICON_DRIVE_SD_MMC, "gnome-dev-removable"}, | |
776 | + {HAL_STORAGE_ICON_DRIVE_CAMERA, "gnome-dev-removable"}, | |
777 | + {HAL_STORAGE_ICON_DRIVE_PORTABLE_AUDIO_PLAYER, "gnome-dev-removable"}, | |
778 | + | |
779 | + {HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK, "gnome-dev-harddisk"}, | |
780 | + {HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IDE, "gnome-dev-harddisk"}, | |
781 | + {HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_SCSI, "gnome-dev-harddisk"}, | |
782 | + {HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_USB, "gnome-dev-harddisk-usb"}, | |
783 | + {HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IEEE1394, "gnome-dev-harddisk-1394"}, | |
784 | + {HAL_STORAGE_ICON_VOLUME_DISK, "gnome-dev-harddisk"}, | |
785 | + {HAL_STORAGE_ICON_VOLUME_DISK_IDE, "gnome-dev-harddisk"}, | |
786 | + {HAL_STORAGE_ICON_VOLUME_DISK_SCSI, "gnome-dev-harddisk"}, | |
787 | + {HAL_STORAGE_ICON_VOLUME_DISK_USB, "gnome-dev-harddisk-usb"}, | |
788 | + {HAL_STORAGE_ICON_VOLUME_DISK_IEEE1394, "gnome-dev-harddisk-1394"}, | |
789 | + {HAL_STORAGE_ICON_VOLUME_CDROM, "gnome-dev-cdrom"}, | |
790 | + {HAL_STORAGE_ICON_VOLUME_CDROM_IDE, "gnome-dev-cdrom"}, | |
791 | + {HAL_STORAGE_ICON_VOLUME_CDROM_SCSI, "gnome-dev-cdrom"}, | |
792 | + {HAL_STORAGE_ICON_VOLUME_CDROM_USB, "gnome-dev-cdrom"}, | |
793 | + {HAL_STORAGE_ICON_VOLUME_CDROM_IEEE1394, "gnome-dev-cdrom"}, | |
794 | + {HAL_STORAGE_ICON_VOLUME_FLOPPY, "gnome-dev-floppy"}, | |
795 | + {HAL_STORAGE_ICON_VOLUME_FLOPPY_IDE, "gnome-dev-floppy"}, | |
796 | + {HAL_STORAGE_ICON_VOLUME_FLOPPY_SCSI, "gnome-dev-floppy"}, | |
797 | + {HAL_STORAGE_ICON_VOLUME_FLOPPY_USB, "gnome-dev-floppy"}, | |
798 | + {HAL_STORAGE_ICON_VOLUME_FLOPPY_IEEE1394, "gnome-dev-floppy"}, | |
799 | + {HAL_STORAGE_ICON_VOLUME_TAPE, "gnome-dev-harddisk"}, | |
800 | + {HAL_STORAGE_ICON_VOLUME_COMPACT_FLASH, "gnome-dev-media-cf"}, | |
801 | + {HAL_STORAGE_ICON_VOLUME_MEMORY_STICK, "gnome-dev-media-ms"}, | |
802 | + {HAL_STORAGE_ICON_VOLUME_SMART_MEDIA, "gnome-dev-media-sm"}, | |
803 | + {HAL_STORAGE_ICON_VOLUME_SD_MMC, "gnome-dev-media-sdmmc"}, | |
804 | + {HAL_STORAGE_ICON_VOLUME_CAMERA, "camera"}, | |
805 | + {HAL_STORAGE_ICON_VOLUME_PORTABLE_AUDIO_PLAYER, "gnome-dev-ipod"}, | |
806 | + | |
807 | + {HAL_STORAGE_ICON_DISC_CDROM, "gnome-dev-cdrom"}, | |
808 | + {HAL_STORAGE_ICON_DISC_CDR, "gnome-dev-cdrom"}, | |
809 | + {HAL_STORAGE_ICON_DISC_CDRW, "gnome-dev-cdrom"}, | |
810 | + {HAL_STORAGE_ICON_DISC_DVDROM, "gnome-dev-dvd"}, | |
811 | + {HAL_STORAGE_ICON_DISC_DVDRAM, "gnome-dev-dvd"}, | |
812 | + {HAL_STORAGE_ICON_DISC_DVDR, "gnome-dev-dvd"}, | |
813 | + {HAL_STORAGE_ICON_DISC_DVDRW, "gnome-dev-dvd"}, | |
814 | + {HAL_STORAGE_ICON_DISC_DVDPLUSR, "gnome-dev-dvd"}, | |
815 | + {HAL_STORAGE_ICON_DISC_DVDPLUSRW, "gnome-dev-dvd"}, | |
816 | + | |
817 | +/* | |
818 | + {HAL_STORAGE_ICON_DISC_CDROM, "gnome-dev-disc-cdrom"}, | |
819 | + {HAL_STORAGE_ICON_DISC_CDR, "gnome-dev-disc-cdr"}, | |
820 | + {HAL_STORAGE_ICON_DISC_CDRW, "gnome-dev-disc-cdrw"}, | |
821 | + {HAL_STORAGE_ICON_DISC_DVDROM, "gnome-dev-disc-dvdrom"}, | |
822 | + {HAL_STORAGE_ICON_DISC_DVDRAM, "gnome-dev-disc-dvdram"}, | |
823 | + {HAL_STORAGE_ICON_DISC_DVDR, "gnome-dev-disc-dvdr"}, | |
824 | + {HAL_STORAGE_ICON_DISC_DVDRW, "gnome-dev-disc-dvdrw"}, | |
825 | + {HAL_STORAGE_ICON_DISC_DVDPLUSR, "gnome-dev-disc-dvdr-plus"}, | |
826 | + {HAL_STORAGE_ICON_DISC_DVDPLUSRW, "gnome-dev-disc-dvdrw-plus"}, | |
827 | +*/ | |
828 | ||
829 | -/***********************************************************************/ | |
830 | - | |
831 | -static char * | |
832 | -_hal_get_vol_name (GnomeVFSHalVolume *vol, GnomeVFSHalDrive *drive, | |
833 | - LibHalContext *hal_ctx) | |
834 | -{ | |
835 | - char *name; | |
836 | - | |
837 | - name = NULL; | |
838 | - if (vol->volume_label != NULL ) { | |
839 | - | |
840 | - /* Using the label is the best thing */ | |
841 | - name = g_strdup (vol->volume_label); | |
842 | - | |
843 | - } else if (strcmp (drive->type, "cdrom") == 0) { | |
844 | - | |
845 | - /* If it's a optical disc, use the disc type */ | |
846 | - if (strcmp (vol->disc_type, "cd_rom") == 0) { | |
847 | - name = g_strdup (_("CD-ROM Disc")); | |
848 | - } else if (strcmp (vol->disc_type, "cd_r") == 0) { | |
849 | - if (vol->disc_is_blank) | |
850 | - name = g_strdup (_("Blank CD-R Disc")); | |
851 | - else | |
852 | - name = g_strdup (_("CD-R Disc")); | |
853 | - } else if (strcmp (vol->disc_type, "cd_rw") == 0) { | |
854 | - if (vol->disc_is_blank) | |
855 | - name = g_strdup (_("Blank CD-RW Disc")); | |
856 | - else | |
857 | - name = g_strdup (_("CD-RW Disc")); | |
858 | - } else if (strcmp (vol->disc_type, "dvd_rom") == 0) { | |
859 | - name = g_strdup (_("DVD-ROM Disc")); | |
860 | - } else if (strcmp (vol->disc_type, "dvd_r") == 0) { | |
861 | - if (vol->disc_is_blank) | |
862 | - name = g_strdup (_("Blank DVD-R Disc")); | |
863 | - else | |
864 | - name = g_strdup (_("DVD-R Disc")); | |
865 | - } else if (strcmp (vol->disc_type, "dvd_ram") == 0) { | |
866 | - if (vol->disc_is_blank) | |
867 | - name = g_strdup (_("Blank DVD-RAM Disc")); | |
868 | - else | |
869 | - name = g_strdup (_("DVD-RAM Disc")); | |
870 | - } else if ((strcmp (vol->disc_type, "dvd_rw_restricted_overwrite") == 0) || (strcmp (vol->disc_type, "dvd_rw") == 0)) { | |
871 | - if (vol->disc_is_blank) | |
872 | - name = g_strdup (_("Blank DVD-RW Disc")); | |
873 | - else | |
874 | - name = g_strdup (_("DVD-RW Disc")); | |
875 | - } else if (strcmp (vol->disc_type, "dvd_plus_rw") == 0) { | |
876 | - if (vol->disc_is_blank) | |
877 | - name = g_strdup (_("Blank DVD+RW Disc")); | |
878 | - else | |
879 | - name = g_strdup (_("DVD+RW Disc")); | |
880 | - } else if (strcmp (vol->disc_type, "dvdplusr") == 0) { | |
881 | - if (vol->disc_is_blank) | |
882 | - name = g_strdup (_("Blank DVD+R Disc")); | |
883 | - else | |
884 | - name = g_strdup (_("DVD+R Disc")); | |
885 | - } else { | |
886 | - name = g_strdup (_("Optical Disc")); | |
887 | - } | |
888 | - | |
889 | - /* Special case for pure audio disc */ | |
890 | - if (vol->disc_has_audio && !vol->disc_has_data) { | |
891 | - g_free (name); | |
892 | - name = g_strdup (_("Audio Disc")); | |
893 | - } | |
894 | - | |
895 | - } else if (strcmp (drive->type, "compact_flash") == 0) { | |
896 | - name = g_strdup (_("Compact Flash Media")); | |
897 | - } else if (strcmp (drive->type, "memory_stick") == 0) { | |
898 | - name = g_strdup (_("Memory Stick Media")); | |
899 | - } else if (strcmp (drive->type, "smart_media") == 0) { | |
900 | - name = g_strdup (_("Smart Media Media")); | |
901 | - } else if (strcmp (drive->type, "sd_mmc") == 0) { | |
902 | - name = g_strdup (_("SD/MMC Media")); | |
903 | - } else if (strcmp (drive->type, "floppy") == 0) { | |
904 | - name = g_strdup (_("Floppy Disk")); | |
905 | - } else if (strcmp (drive->type, "disk") == 0) { | |
906 | - | |
907 | - /* Look at the filesystem type, if applicable */ | |
908 | - if (vol->fstype != NULL) { | |
909 | - | |
910 | - if (strcmp (vol->fstype, "hfs") == 0) { | |
911 | - name = g_strdup (_("Mac OS disk")); | |
912 | - } else if (strcmp (vol->fstype, "hfsplus") == 0) { | |
913 | - name = g_strdup (_("Mac OS X disk")); | |
914 | - } else if (strcmp (vol->fstype, "vfat") == 0 || | |
915 | - strcmp (vol->fstype, "fat") == 0 || | |
916 | - strcmp (vol->fstype, "msdos") == 0 || | |
917 | - strcmp (vol->fstype, "msdosfs") == 0 ) { | |
918 | - /* Many cameras and mp3 players use | |
919 | - * FAT and we don't want the volume | |
920 | - * icon to say "DOS Disk"; we'd rather | |
921 | - * want the name of the device as fallback; | |
922 | - * see below.. | |
923 | - */ | |
924 | - ; | |
925 | - /*name = g_strdup (_("DOS Disk"));*/ | |
926 | - } else if (strcmp (vol->fstype, "ntfs") == 0) { | |
927 | - name = g_strdup (_("Windows Disk")); | |
928 | - } else if (strcmp (vol->fstype, "ext2") == 0 || | |
929 | - strcmp (vol->fstype, "ext3") == 0 || | |
930 | - strcmp (vol->fstype, "jfs") == 0 || | |
931 | - strcmp (vol->fstype, "xfs") == 0 || | |
932 | - strcmp (vol->fstype, "reiser") == 0) { | |
933 | - name = g_strdup (_("Linux Disk")); | |
934 | - } | |
935 | - } | |
936 | - } | |
937 | - | |
938 | - /* fallback; use the same name as the drive */ | |
939 | - if (name == NULL) | |
940 | - name = _hal_get_drive_name (NULL, drive, hal_ctx); | |
941 | - | |
942 | - fixup_name (name); | |
943 | + {0x00, NULL} | |
944 | +}; | |
945 | ||
946 | - return name; | |
947 | -} | |
948 | ||
949 | -static char * | |
950 | -_hal_get_vol_icon (GnomeVFSHalVolume *vol, GnomeVFSHalDrive *drive, | |
951 | - LibHalContext *hal_ctx) | |
952 | +gboolean | |
953 | +_gnome_vfs_hal_mounts_init (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) | |
954 | { | |
955 | - char *icon; | |
956 | - char *category; | |
957 | - | |
958 | + GnomeVFSHalUserData *hal_userdata; | |
959 | + HalStoragePolicy *hal_storage_policy; | |
960 | ||
961 | - category = hal_device_get_property_string (hal_ctx, | |
962 | - drive->physical_device, | |
963 | - "info.category"); | |
964 | - if (category != NULL) { | |
965 | - if (strcmp (category, "portable_audio_player") == 0) { | |
966 | - icon = g_strdup (HAL_ICON_PORTABLE_AUDIO_PLAYER); | |
967 | - return icon; | |
968 | - } else if (strcmp (category, "camera") == 0) { | |
969 | - icon = g_strdup (HAL_ICON_CAMERA); | |
970 | - return icon; | |
971 | - } | |
972 | - } | |
973 | - | |
974 | - | |
975 | - if (strcmp (drive->type, "cdrom") == 0) { | |
976 | - | |
977 | - /* If it's a optical disc, use the disc type */ | |
978 | - if (strcmp (vol->disc_type, "cd_rom") == 0) { | |
979 | - icon = g_strdup (HAL_ICON_DISC_CDROM); | |
980 | - } else if (strcmp (vol->disc_type, "cd_r") == 0) { | |
981 | - icon = g_strdup (HAL_ICON_DISC_CDR); | |
982 | - } else if (strcmp (vol->disc_type, "cd_rw") == 0) { | |
983 | - icon = g_strdup (HAL_ICON_DISC_CDRW); | |
984 | - } else if (strcmp (vol->disc_type, "dvd_rom") == 0) { | |
985 | - icon = g_strdup (HAL_ICON_DISC_DVDROM); | |
986 | - } else if (strcmp (vol->disc_type, "dvd_r") == 0) { | |
987 | - icon = g_strdup (HAL_ICON_DISC_DVDR); | |
988 | - } else if (strcmp (vol->disc_type, "dvd_ram") == 0) { | |
989 | - icon = g_strdup (HAL_ICON_DISC_DVDRAM); | |
990 | - } else if ((strcmp (vol->disc_type, "dvd_rw_restricted_overwrite") == 0) || (strcmp (vol->disc_type, "dvd_rw") == 0)) { | |
991 | - icon = g_strdup (HAL_ICON_DISC_DVDRW); | |
992 | - } else if (strcmp (vol->disc_type, "dvd_plus_rw") == 0) { | |
993 | - icon = g_strdup (HAL_ICON_DISC_DVDRW_PLUS); | |
994 | - } else if (strcmp (vol->disc_type, "dvdplusr") == 0) { | |
995 | - icon = g_strdup (HAL_ICON_DISC_DVDR_PLUS); | |
996 | - } else { | |
997 | - icon = g_strdup (HAL_ICON_DISC_CDROM); | |
998 | - } | |
999 | - | |
1000 | - } else if (strcmp (drive->type, "floppy") == 0) { | |
1001 | - icon = g_strdup (HAL_ICON_MEDIA_FLOPPY); | |
1002 | - } else if (strcmp (drive->type, "compact_flash") == 0) { | |
1003 | - icon = g_strdup (HAL_ICON_MEDIA_COMPACT_FLASH); | |
1004 | - } else if (strcmp (drive->type, "memory_stick") == 0) { | |
1005 | - icon = g_strdup (HAL_ICON_MEDIA_MEMORY_STICK); | |
1006 | - } else if (strcmp (drive->type, "smart_media") == 0) { | |
1007 | - icon = g_strdup (HAL_ICON_MEDIA_SMART_MEDIA); | |
1008 | - } else if (strcmp (drive->type, "sd_mmc") == 0) { | |
1009 | - icon = g_strdup (HAL_ICON_MEDIA_SD_MMC); | |
1010 | - } else { | |
1011 | - | |
1012 | - if (strcmp (drive->bus, "usb") == 0) { | |
1013 | - icon = g_strdup (HAL_ICON_MEDIA_HARDDISK_USB); | |
1014 | - } else if (strcmp (drive->bus, "ieee1394") == 0) { | |
1015 | - icon = g_strdup (HAL_ICON_MEDIA_HARDDISK_IEEE1394); | |
1016 | - } else { | |
1017 | - icon = g_strdup (HAL_ICON_MEDIA_HARDDISK); | |
1018 | - } | |
1019 | + /* Initialise the connection to the hal daemon */ | |
1020 | + if ((volume_monitor_daemon->hal_ctx = | |
1021 | + hal_initialize (&hal_functions, FALSE)) == NULL) { | |
1022 | + g_warning ("hal_initialize failed\n"); | |
1023 | + return FALSE; | |
1024 | } | |
1025 | - | |
1026 | - return icon; | |
1027 | -} | |
1028 | - | |
1029 | -static int | |
1030 | -_hal_get_vol_type (GnomeVFSHalVolume *vol, GnomeVFSHalDrive *drive, | |
1031 | - LibHalContext *hal_ctx) | |
1032 | -{ | |
1033 | - return _hal_get_drive_type (NULL, drive, hal_ctx); | |
1034 | -} | |
1035 | - | |
1036 | -/***********************************************************************/ | |
1037 | ||
1038 | -/** This function is used to skip certain volumes/drives we don't | |
1039 | - * want to expose in GnomeVFS. | |
1040 | - * | |
1041 | - */ | |
1042 | -static gboolean | |
1043 | -_hal_old_school_mount_point (GnomeVFSHalDrive *hal_drive, | |
1044 | - GnomeVFSHalVolume *hal_vol, /* may be NULL */ | |
1045 | - char *mount_point) | |
1046 | -{ | |
1047 | - /* Skip standard UNIX-like mount points */ | |
1048 | - if (strcmp (mount_point, "/var") == 0 || | |
1049 | - strcmp (mount_point, "/usr") == 0 || | |
1050 | - strcmp (mount_point, "/bin") == 0 || | |
1051 | - strcmp (mount_point, "/sbin") == 0 || | |
1052 | - strcmp (mount_point, "/boot") == 0 || | |
1053 | - strcmp (mount_point, "/tmp") == 0 || | |
1054 | - strcmp (mount_point, "/opt") == 0 || | |
1055 | - strcmp (mount_point, "/home") == 0 || | |
1056 | - strcmp (mount_point, "/") == 0) | |
1057 | - return TRUE; | |
1058 | ||
1059 | - return FALSE; | |
1060 | + /* Setup GNOME specific policy - right now this is only icons */ | |
1061 | + hal_storage_policy = hal_storage_policy_new (); | |
1062 | + hal_storage_policy_set_icon_mapping (hal_storage_policy, icon_mapping); | |
1063 | + | |
1064 | + /* Tie some data with the libhal context */ | |
1065 | + hal_userdata = g_new0 (GnomeVFSHalUserData, 1); | |
1066 | + hal_userdata->volume_monitor_daemon = volume_monitor_daemon; | |
1067 | + hal_userdata->hal_storage_policy = hal_storage_policy; | |
1068 | + hal_ctx_set_user_data (volume_monitor_daemon->hal_ctx, | |
1069 | + hal_userdata); | |
1070 | + return TRUE; | |
1071 | } | |
1072 | ||
1073 | -/***********************************************************************/ | |
1074 | - | |
1075 | - | |
1076 | -/* Add a drive where the media is not partition based. | |
1077 | - * | |
1078 | - * It's safe to call this function multiple times for the same HAL | |
1079 | - * UDI (Unique Device Identifier). | |
1080 | - */ | |
1081 | -static void | |
1082 | -_hal_add_drive_no_partitions ( | |
1083 | - GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1084 | - const char *udi) | |
1085 | +void | |
1086 | +_gnome_vfs_hal_mounts_shutdown (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) | |
1087 | { | |
1088 | - GnomeVFSHalDrive *hal_drive = NULL; | |
1089 | - LibHalContext *hal_ctx = volume_monitor_daemon->hal_ctx; | |
1090 | - GnomeVFSDrive *drive; | |
1091 | - GnomeVFSVolumeMonitor *volume_monitor = | |
1092 | - GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon); | |
1093 | - char *name = NULL; | |
1094 | - char *icon = NULL; | |
1095 | - GnomeVFSDeviceType device_type = GNOME_VFS_DEVICE_TYPE_HARDDRIVE; | |
1096 | - gboolean computer_visible = TRUE; | |
1097 | - struct fstab *fst; | |
1098 | - char *mount_point = NULL; | |
1099 | - | |
1100 | -#ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES | |
1101 | - return; | |
1102 | -#endif | |
1103 | - | |
1104 | - /* | |
1105 | - * We create the GnomeVFSDrive for such beasts since we can | |
1106 | - * actually do it in advance due to the fact that we already | |
1107 | - * know the device file and the mount point. | |
1108 | - */ | |
1109 | - | |
1110 | - hal_drive = _hal_get_drive (udi, hal_ctx); | |
1111 | - if (hal_drive == NULL) | |
1112 | - goto out; | |
1113 | + GnomeVFSHalUserData *hal_userdata; | |
1114 | ||
1115 | - /* get mount point from /etc/fstab */ | |
1116 | - if (setfsent () == 1) { | |
1117 | - fst = getfsspec (hal_drive->device_file); | |
1118 | - if (fst != NULL ) | |
1119 | - mount_point = strdup (fst->fs_file); | |
1120 | - endfsent (); | |
1121 | - } | |
1122 | - if (mount_point == NULL || mount_point[0] != '/') | |
1123 | - goto out; | |
1124 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (volume_monitor_daemon->hal_ctx); | |
1125 | + hal_storage_policy_free (hal_userdata->hal_storage_policy); | |
1126 | ||
1127 | - /* Include, but hide, drives with a hidden mount point */ | |
1128 | - if (_hal_old_school_mount_point (hal_drive, NULL, mount_point)) { | |
1129 | - computer_visible = FALSE; | |
1130 | - } | |
1131 | - | |
1132 | - /* see if drive was already added */ | |
1133 | - drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi ( | |
1134 | - volume_monitor, udi); | |
1135 | - if (drive == NULL ) { | |
1136 | - | |
1137 | - /* nope, make one */ | |
1138 | - | |
1139 | - name = _hal_get_drive_name (NULL, hal_drive, hal_ctx); | |
1140 | - icon = _hal_get_drive_icon (NULL, hal_drive, hal_ctx); | |
1141 | - device_type = _hal_get_drive_type (NULL, hal_drive, hal_ctx); | |
1142 | - | |
1143 | - drive = g_object_new (GNOME_VFS_TYPE_DRIVE, NULL); | |
1144 | - drive->priv->device_path = g_strdup (hal_drive->device_file); | |
1145 | - | |
1146 | - drive->priv->activation_uri = gnome_vfs_get_uri_from_local_path (mount_point); | |
1147 | - drive->priv->is_connected = TRUE; | |
1148 | - drive->priv->device_type = device_type; | |
1149 | - drive->priv->icon = g_strdup (icon); | |
1150 | - drive->priv->display_name = _gnome_vfs_volume_monitor_uniquify_drive_name (volume_monitor, name); | |
1151 | - drive->priv->is_user_visible = computer_visible; | |
1152 | - drive->priv->volumes = NULL; | |
1153 | - drive->priv->hal_udi = g_strdup (udi); | |
1154 | - | |
1155 | - _gnome_vfs_volume_monitor_connected (volume_monitor, drive); | |
1156 | - gnome_vfs_drive_unref (drive); | |
1157 | + if (hal_shutdown (volume_monitor_daemon->hal_ctx) != 0) { | |
1158 | + g_warning ("hal_shutdown failed\n"); | |
1159 | } | |
1160 | - | |
1161 | -out: | |
1162 | - _hal_free_drive (hal_drive); | |
1163 | - g_free (name); | |
1164 | - g_free (icon); | |
1165 | - free (mount_point); | |
1166 | } | |
1167 | ||
1168 | +/**************************************************************************/ | |
1169 | ||
1170 | -/* Add a hal-volume, that is, a HalDevice of capability 'volume'. | |
1171 | +/** Ask HAL for more information about the drive and modify properties on the | |
1172 | + * GnomeVFSDrive as appropriate. Note that this happens before the object | |
1173 | + * is added to the volume monitor. | |
1174 | * | |
1175 | - * It's safe to call this function multiple times for the same HAL | |
1176 | - * UDI (Unique Device Identifier). | |
1177 | + * @param volume_monitor_daemon Handle to the volume monitor daemon | |
1178 | + * @param drive Handle to the GnomeVFSDrive object | |
1179 | */ | |
1180 | -static void | |
1181 | -_hal_add_volume (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1182 | - const char *udi) | |
1183 | +void | |
1184 | +_gnome_vfs_hal_mounts_modify_drive (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1185 | + GnomeVFSDrive *drive) | |
1186 | { | |
1187 | - GnomeVFSHalVolume *hal_vol = NULL; | |
1188 | - GnomeVFSHalDrive *hal_drive = NULL; | |
1189 | - LibHalContext *hal_ctx = volume_monitor_daemon->hal_ctx; | |
1190 | + char *drive_name; | |
1191 | + char *drive_icon; | |
1192 | + char *unique_drive_name; | |
1193 | + LibHalContext *hal_ctx; | |
1194 | + HalDrive *hal_drive; | |
1195 | + HalVolume *hal_volume; | |
1196 | + GnomeVFSHalUserData *hal_userdata; | |
1197 | + HalStoragePolicy *hal_storage_policy; | |
1198 | + char *target_mount_point; | |
1199 | ||
1200 | - GnomeVFSDrive *drive; | |
1201 | - GnomeVFSVolume *vol; | |
1202 | - GnomeVFSVolumeMonitor *volume_monitor = | |
1203 | - GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon); | |
1204 | - char *name = NULL; | |
1205 | - char *icon = NULL; | |
1206 | - GnomeVFSDeviceType device_type = GNOME_VFS_DEVICE_TYPE_HARDDRIVE; | |
1207 | - gboolean computer_visible = TRUE; | |
1208 | - gboolean desktop_visible = FALSE; | |
1209 | - struct fstab *fst; | |
1210 | - char *mount_point = NULL; | |
1211 | - gboolean is_blank_disc = FALSE; | |
1212 | - gboolean is_audio_disc = FALSE; | |
1213 | - | |
1214 | - /* Only care about capability volume */ | |
1215 | - if (!hal_device_query_capability ( | |
1216 | - volume_monitor_daemon->hal_ctx, | |
1217 | - udi, "volume")) | |
1218 | - { | |
1219 | + hal_drive = NULL; | |
1220 | + hal_volume = NULL; | |
1221 | ||
1222 | - /* And capability block where block.no_partition==TRUE and | |
1223 | - * block.is_volume==FALSE | |
1224 | - */ | |
1225 | - if (hal_device_query_capability ( | |
1226 | - hal_ctx, udi, "block") && | |
1227 | - (hal_device_get_property_bool ( | |
1228 | - hal_ctx, udi, "block.no_partitions")==TRUE) && | |
1229 | - (hal_device_get_property_bool ( | |
1230 | - hal_ctx, udi, "block.is_volume")==FALSE)) { | |
1231 | - /* This represent top-level block devices with | |
1232 | - * media not using partitions.. Such as floppy | |
1233 | - * drives or optical drives.. | |
1234 | - */ | |
1235 | - | |
1236 | - _hal_add_drive_no_partitions ( | |
1237 | - volume_monitor_daemon, udi); | |
1238 | - goto out; | |
1239 | - | |
1240 | - } else { | |
1241 | - /* Nothing we can use... */ | |
1242 | - goto out; | |
1243 | - } | |
1244 | - } | |
1245 | - | |
1246 | - | |
1247 | - /* get HAL drive and volume objects */ | |
1248 | - hal_vol = _hal_get_vol (udi, hal_ctx); | |
1249 | - if (hal_vol == NULL) | |
1250 | - goto out; | |
1251 | - hal_drive = _hal_get_drive_from_vol (hal_vol, hal_ctx); | |
1252 | - if (hal_drive == NULL) | |
1253 | + if ((hal_ctx = volume_monitor_daemon->hal_ctx) == NULL) | |
1254 | goto out; | |
1255 | ||
1256 | - /* See if we should have an icon on the desktop */ | |
1257 | - if (hal_drive->is_hotpluggable || | |
1258 | - hal_vol->is_disc || | |
1259 | - hal_drive->is_removable) | |
1260 | - desktop_visible = TRUE; | |
1261 | - | |
1262 | - /* If we are mounted, use the mount point that HAL knows */ | |
1263 | - if (hal_vol->is_mounted) { | |
1264 | - mount_point = strdup (hal_vol->mount_point); | |
1265 | - } else { | |
1266 | - /* Otherwise... Yuck.. | |
1267 | - * | |
1268 | - * gnome-vfs expects a mount point for a not yet | |
1269 | - * mounted volume which is kind of gross as it may be | |
1270 | - * mounted anywhere by e.g. root in the | |
1271 | - * future. Surely, this is not needed at all, | |
1272 | - * gnome-vfs should just be able to do a 'mount | |
1273 | - * /dev/sda1' or something. | |
1274 | - * | |
1275 | - * Now, HAL *could* monitor the /etc/fstab file and | |
1276 | - * maintain volume.mount_point property while | |
1277 | - * volume.is_mounted is FALSE, but this is unclean and | |
1278 | - * we really want the volume.mount_point to be empty | |
1279 | - * if, and only if, volume.is_mounted is FALSE. | |
1280 | - * | |
1281 | - * So, we just need to read the /etc/fstab here to | |
1282 | - * find the mount point (which is probably created by | |
1283 | - * a callout anyway). Oh well, piece of cake anyway.. | |
1284 | - */ | |
1285 | - if (setfsent () == 1) { | |
1286 | - fst = getfsspec (hal_vol->device_file); | |
1287 | - if (fst != NULL ) | |
1288 | - mount_point = strdup (fst->fs_file); | |
1289 | - endfsent (); | |
1290 | - } | |
1291 | - } | |
1292 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
1293 | + hal_storage_policy = hal_userdata->hal_storage_policy; | |
1294 | ||
1295 | - /* And we do need a mount point, and now we tried so hard to find | |
1296 | - * one.. bail out if we haven't got any.. | |
1297 | - * | |
1298 | - * Further, getfspec above may return 'swap', so only accept a mount | |
1299 | - * point that starts with /. Hmmm.. | |
1300 | - */ | |
1301 | - if (mount_point == NULL || mount_point[0]!='/') | |
1302 | + if (drive == NULL || drive->priv == NULL || drive->priv->device_path == NULL) | |
1303 | goto out; | |
1304 | ||
1305 | - /* bail out if fstype is swap */ | |
1306 | - if (hal_vol->fstype != NULL && strcmp (hal_vol->fstype, "swap") == 0) | |
1307 | + /* Note, the device_path may point to what hal calls a volume, e.g. | |
1308 | + * /dev/sda1 etc, however we get the Drive object for the parent if | |
1309 | + * that is the case. This is a feature of libhal-storage. | |
1310 | + */ | |
1311 | + if ((hal_drive = hal_drive_from_device_file (hal_ctx, drive->priv->device_path)) == NULL) { | |
1312 | + g_warning ("%s: no hal drive for device=%s", __FUNCTION__, drive->priv->device_path); | |
1313 | goto out; | |
1314 | - | |
1315 | - /* see if we're a blank disc instead of being mounted */ | |
1316 | - is_blank_disc = hal_vol->is_disc && hal_vol->disc_is_blank; | |
1317 | - | |
1318 | - /* see if we're a pure audio disc instead of being mounted */ | |
1319 | - is_audio_disc = hal_vol->is_disc && hal_vol->disc_has_audio && | |
1320 | - !hal_vol->disc_has_data; | |
1321 | - | |
1322 | - /* Include, but hide, volumes with a hidden mount point */ | |
1323 | - if (_hal_old_school_mount_point (hal_drive, hal_vol, mount_point)) { | |
1324 | - desktop_visible = FALSE; | |
1325 | - computer_visible = FALSE; | |
1326 | } | |
1327 | ||
1328 | -#ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES | |
1329 | - /* we should also show blank discs */ | |
1330 | - if (!hal_vol->is_mounted && !is_blank_disc) | |
1331 | - goto out; | |
1332 | -#endif | |
1333 | + /* There may not be a volume object associated, so hal_volume may be NULL */ | |
1334 | + hal_volume = hal_volume_from_device_file (hal_ctx, drive->priv->device_path); | |
1335 | ||
1336 | - /* see if it was already added */ | |
1337 | - drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi ( | |
1338 | - volume_monitor, | |
1339 | -#ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES | |
1340 | - udi); | |
1341 | -#else | |
1342 | - hal_drive->no_partitions ? hal_drive->udi : udi); | |
1343 | -#endif | |
1344 | - if (drive == NULL ) { | |
1345 | - | |
1346 | - /* nope, make one */ | |
1347 | - | |
1348 | - name = _hal_get_drive_name (hal_vol, hal_drive, hal_ctx); | |
1349 | - icon = _hal_get_drive_icon (hal_vol, hal_drive, hal_ctx); | |
1350 | - device_type = _hal_get_drive_type (hal_vol, hal_drive, hal_ctx); | |
1351 | - | |
1352 | - drive = g_object_new (GNOME_VFS_TYPE_DRIVE, NULL); | |
1353 | - drive->priv->device_path = g_strdup (hal_vol->device_file); | |
1354 | - | |
1355 | - drive->priv->activation_uri = gnome_vfs_get_uri_from_local_path (mount_point); | |
1356 | - drive->priv->is_connected = TRUE; | |
1357 | - drive->priv->device_type = device_type; | |
1358 | - drive->priv->icon = g_strdup (icon); | |
1359 | - drive->priv->display_name = _gnome_vfs_volume_monitor_uniquify_drive_name (volume_monitor, name); | |
1360 | - drive->priv->is_user_visible = computer_visible; | |
1361 | - drive->priv->volumes = NULL; | |
1362 | - | |
1363 | - drive->priv->hal_udi = g_strdup ( | |
1364 | -#ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES | |
1365 | - udi | |
1366 | -#else | |
1367 | - hal_drive->no_partitions ? hal_drive->udi : udi | |
1368 | -#endif | |
1369 | - ); | |
1370 | - _gnome_vfs_volume_monitor_connected (volume_monitor, drive); | |
1371 | - gnome_vfs_drive_unref (drive); | |
1372 | - } | |
1373 | - | |
1374 | - g_free (name); name = NULL; | |
1375 | - g_free (icon); icon = NULL; | |
1376 | - | |
1377 | - /* drive is now a reference to GnomeVFSDrive */ | |
1378 | - | |
1379 | - /* Only create a GnomeVFSVolume object if the volume is mounted | |
1380 | - * or a blank disc */ | |
1381 | - if (hal_vol->is_mounted || is_blank_disc || is_audio_disc) { | |
1382 | - /* see if hal_vol was already added */ | |
1383 | - vol = _gnome_vfs_volume_monitor_find_volume_by_hal_udi ( | |
1384 | - volume_monitor, udi); | |
1385 | - if (vol == NULL ) { | |
1386 | - | |
1387 | - name = _hal_get_vol_name (hal_vol, hal_drive, hal_ctx); | |
1388 | - icon = _hal_get_vol_icon (hal_vol, hal_drive, hal_ctx); | |
1389 | - device_type = _hal_get_vol_type (hal_vol, hal_drive, hal_ctx); | |
1390 | - | |
1391 | - vol = g_object_new (GNOME_VFS_TYPE_VOLUME, NULL); | |
1392 | - vol->priv->hal_udi = g_strdup (udi); | |
1393 | - vol->priv->volume_type = GNOME_VFS_VOLUME_TYPE_MOUNTPOINT; | |
1394 | + /* For optical discs, we manually add/remove GnomeVFSVolume optical discs without | |
1395 | + * data (e.g. blank and pure audio) since these don't appear in the mounted filesystems | |
1396 | + * file /etc/mtab | |
1397 | + */ | |
1398 | + if (hal_volume != NULL && | |
1399 | + hal_drive_get_type (hal_drive)==HAL_DRIVE_TYPE_CDROM && | |
1400 | + hal_volume_is_disc (hal_volume) && !hal_volume_disc_has_data (hal_volume)) { | |
1401 | + GnomeVFSVolume *volume; | |
1402 | + char *volume_name; | |
1403 | + char *volume_icon; | |
1404 | + | |
1405 | + /* see if we already got a volume */ | |
1406 | + volume = _gnome_vfs_volume_monitor_find_volume_by_device_path ( | |
1407 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), | |
1408 | + hal_drive_get_device_file (hal_drive)); | |
1409 | + if (volume == NULL) { | |
1410 | + | |
1411 | + volume_name = hal_volume_policy_compute_display_name ( | |
1412 | + hal_drive, hal_volume, hal_storage_policy); | |
1413 | + | |
1414 | + /* set icon name; try dedicated icon name first... */ | |
1415 | + if (hal_drive_get_dedicated_icon_volume (hal_drive) != NULL) | |
1416 | + volume_icon = g_strdup (hal_drive_get_dedicated_icon_volume (hal_drive)); | |
1417 | + else | |
1418 | + volume_icon = hal_volume_policy_compute_icon_name ( | |
1419 | + hal_drive, hal_volume, hal_storage_policy); | |
1420 | + | |
1421 | + volume = g_object_new (GNOME_VFS_TYPE_VOLUME, NULL); | |
1422 | + volume->priv->hal_udi = g_strdup (hal_volume_get_udi (hal_volume)); | |
1423 | + volume->priv->volume_type = GNOME_VFS_VOLUME_TYPE_MOUNTPOINT; | |
1424 | ||
1425 | - if (is_blank_disc) { | |
1426 | - vol->priv->device_path = g_strdup (hal_vol->device_file); | |
1427 | - vol->priv->activation_uri = g_strdup ("burn:///"); | |
1428 | - vol->priv->unix_device = makedev (hal_vol->device_major, | |
1429 | - hal_vol->device_minor); | |
1430 | - vol->priv->filesystem_type = g_strdup (hal_vol->fstype); | |
1431 | - | |
1432 | - } else if (is_audio_disc) { | |
1433 | - vol->priv->device_path = g_strdup (hal_vol->device_file); | |
1434 | - vol->priv->activation_uri = g_strdup_printf ( | |
1435 | - "cddb://%s", hal_vol->device_file); | |
1436 | - vol->priv->unix_device = makedev (hal_vol->device_major, | |
1437 | - hal_vol->device_minor); | |
1438 | - vol->priv->filesystem_type = g_strdup (hal_vol->fstype); | |
1439 | - | |
1440 | - } else { | |
1441 | - vol->priv->device_path = g_strdup (hal_vol->device_file); | |
1442 | - vol->priv->activation_uri = gnome_vfs_get_uri_from_local_path (mount_point); | |
1443 | - vol->priv->unix_device = makedev (hal_vol->device_major, | |
1444 | - hal_vol->device_minor); | |
1445 | - vol->priv->filesystem_type = g_strdup (hal_vol->fstype); | |
1446 | + if (hal_volume_disc_is_blank (hal_volume)) { | |
1447 | + /* Blank discs should open the burn:/// location */ | |
1448 | + volume->priv->device_path = g_strdup (hal_volume_get_device_file (hal_volume)); | |
1449 | + volume->priv->activation_uri = g_strdup ("burn:///"); | |
1450 | + volume->priv->unix_device = makedev (hal_volume_get_device_major (hal_volume), | |
1451 | + hal_volume_get_device_minor (hal_volume)); | |
1452 | + volume->priv->filesystem_type = g_strdup (hal_volume_get_fstype (hal_volume)); | |
1453 | + } else if (hal_volume_disc_has_audio (hal_volume)) { | |
1454 | + /* Audio discs with data should open the cdda:///dev/cdrom location */ | |
1455 | + volume->priv->device_path = g_strdup (hal_volume_get_device_file (hal_volume)); | |
1456 | + volume->priv->activation_uri = g_strdup_printf ( | |
1457 | + "cdda://%s", hal_volume_get_device_file (hal_volume)); | |
1458 | + volume->priv->unix_device = makedev (hal_volume_get_device_major (hal_volume), | |
1459 | + hal_volume_get_device_minor (hal_volume)); | |
1460 | + volume->priv->filesystem_type = g_strdup (hal_volume_get_fstype (hal_volume)); | |
1461 | } | |
1462 | - | |
1463 | - vol->priv->is_read_only = FALSE; | |
1464 | - vol->priv->is_mounted = TRUE; | |
1465 | ||
1466 | - vol->priv->device_type = device_type; | |
1467 | + volume->priv->is_read_only = TRUE; | |
1468 | + volume->priv->is_mounted = FALSE; | |
1469 | + | |
1470 | + volume->priv->device_type = GNOME_VFS_DEVICE_TYPE_CDROM; | |
1471 | ||
1472 | - vol->priv->display_name = _gnome_vfs_volume_monitor_uniquify_volume_name (volume_monitor, name); | |
1473 | - vol->priv->icon = g_strdup(icon); | |
1474 | - vol->priv->is_user_visible = desktop_visible; | |
1475 | + volume->priv->display_name = _gnome_vfs_volume_monitor_uniquify_volume_name ( | |
1476 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), volume_name); | |
1477 | + volume->priv->icon = g_strdup (volume_icon); | |
1478 | + volume->priv->is_user_visible = TRUE; | |
1479 | ||
1480 | - vol->priv->drive = drive; | |
1481 | - _gnome_vfs_drive_add_mounted_volume (drive, vol); | |
1482 | + volume->priv->drive = drive; | |
1483 | + _gnome_vfs_drive_add_mounted_volume (drive, volume); | |
1484 | ||
1485 | - _gnome_vfs_volume_monitor_mounted (volume_monitor, vol); gnome_vfs_volume_unref (vol); | |
1486 | + _gnome_vfs_volume_monitor_mounted (GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), volume); | |
1487 | + gnome_vfs_volume_unref (volume); | |
1488 | ||
1489 | + free (volume_name); | |
1490 | + free (volume_icon); | |
1491 | } | |
1492 | - } | |
1493 | - | |
1494 | -out: | |
1495 | - _hal_free_vol (hal_vol); | |
1496 | - _hal_free_drive (hal_drive); | |
1497 | - g_free (name); | |
1498 | - g_free (icon); | |
1499 | - free (mount_point); | |
1500 | -} | |
1501 | - | |
1502 | + } else if (hal_volume == NULL && hal_drive_get_type (hal_drive)==HAL_DRIVE_TYPE_CDROM) { | |
1503 | + GnomeVFSVolume *volume; | |
1504 | ||
1505 | -/* Remove a hal-volume, that is, a HalDevice of capability 'volume'. | |
1506 | - * | |
1507 | - * It's safe to call this function even though the hal-volume doesn't | |
1508 | - * correspond to any (GnomeVFSDrive, GnomeVFSVolume) pair. | |
1509 | - */ | |
1510 | -static void | |
1511 | -_hal_remove_volume (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1512 | - const char *udi) | |
1513 | -{ | |
1514 | - GnomeVFSDrive *drive; | |
1515 | - GnomeVFSVolume *vol; | |
1516 | - GnomeVFSVolumeMonitor *volume_monitor; | |
1517 | - | |
1518 | - volume_monitor = GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon); | |
1519 | - | |
1520 | - drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi ( | |
1521 | - volume_monitor, udi); | |
1522 | - if (drive != NULL ) { | |
1523 | - _gnome_vfs_volume_monitor_disconnected (volume_monitor, drive); | |
1524 | - } | |
1525 | - | |
1526 | - vol = _gnome_vfs_volume_monitor_find_volume_by_hal_udi ( | |
1527 | - volume_monitor, udi); | |
1528 | - if (vol != NULL ) { | |
1529 | - _gnome_vfs_volume_monitor_unmounted (volume_monitor, vol); | |
1530 | - } | |
1531 | -} | |
1532 | - | |
1533 | - | |
1534 | -/* Call when a HAL volume is unmounted. | |
1535 | - * | |
1536 | - * It's safe to call this function even though the hal-volume doesn't | |
1537 | - * correspond to GnomeVFSVolume object. | |
1538 | - */ | |
1539 | -static void | |
1540 | -_hal_volume_unmounted (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1541 | - const char *udi) | |
1542 | -{ | |
1543 | - GnomeVFSVolume *vol; | |
1544 | - GnomeVFSVolumeMonitor *volume_monitor; | |
1545 | - | |
1546 | - volume_monitor = GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon); | |
1547 | - | |
1548 | - vol = _gnome_vfs_volume_monitor_find_volume_by_hal_udi ( | |
1549 | - volume_monitor, udi); | |
1550 | - | |
1551 | - if (vol != NULL ) { | |
1552 | - _gnome_vfs_volume_monitor_unmounted (volume_monitor, vol); | |
1553 | - } | |
1554 | - | |
1555 | -#ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES | |
1556 | - { | |
1557 | - GnomeVFSDrive *drive; | |
1558 | - drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi ( | |
1559 | - volume_monitor, udi); | |
1560 | - if (drive != NULL ) { | |
1561 | - _gnome_vfs_volume_monitor_disconnected (volume_monitor, drive); | |
1562 | + /* Remove GnomeVFSVolume with same device file */ | |
1563 | + | |
1564 | + volume = _gnome_vfs_volume_monitor_find_volume_by_device_path ( | |
1565 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), hal_drive_get_device_file (hal_drive)); | |
1566 | + if (volume != NULL) { | |
1567 | + _gnome_vfs_volume_monitor_unmounted (GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), volume); | |
1568 | } | |
1569 | } | |
1570 | -#endif | |
1571 | ||
1572 | -} | |
1573 | - | |
1574 | - | |
1575 | -void | |
1576 | -_gnome_vfs_monitor_hal_get_volume_list (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) | |
1577 | -{ | |
1578 | - int i; | |
1579 | - int num_hal_volumes; | |
1580 | - char **hal_volumes; | |
1581 | - GnomeVFSVolumeMonitor *volume_monitor; | |
1582 | ||
1583 | + /* Now, modify the drive with the hal stuff, unless we've already done so */ | |
1584 | + if (drive->priv->hal_udi != NULL) | |
1585 | + goto out; | |
1586 | ||
1587 | - volume_monitor = GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon); | |
1588 | - | |
1589 | - hal_volumes = hal_find_device_by_capability ( | |
1590 | - volume_monitor_daemon->hal_ctx, | |
1591 | - "volume", | |
1592 | - &num_hal_volumes); | |
1593 | - for (i=0; i<num_hal_volumes; i++) { | |
1594 | - char *udi; | |
1595 | - | |
1596 | - udi = hal_volumes [i]; | |
1597 | + /* set whether we need to eject */ | |
1598 | + drive->priv->should_eject = hal_drive_requires_eject (hal_drive); | |
1599 | ||
1600 | - _hal_add_volume (volume_monitor_daemon, udi); | |
1601 | + /* set display name */ | |
1602 | + drive_name = hal_drive_policy_compute_display_name (hal_drive, hal_volume, hal_storage_policy); | |
1603 | + unique_drive_name = _gnome_vfs_volume_monitor_uniquify_drive_name ( | |
1604 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), drive_name); | |
1605 | + if (drive->priv->display_name != NULL) | |
1606 | + free (drive->priv->display_name); | |
1607 | + drive->priv->display_name = unique_drive_name; | |
1608 | + free (drive_name); | |
1609 | + | |
1610 | + /* set icon name; try dedicated icon name first... */ | |
1611 | + if (hal_drive_get_dedicated_icon_drive (hal_drive) != NULL) | |
1612 | + drive_icon = g_strdup (hal_drive_get_dedicated_icon_drive (hal_drive)); | |
1613 | + else | |
1614 | + drive_icon = hal_drive_policy_compute_icon_name (hal_drive, hal_volume, hal_storage_policy); | |
1615 | + if (drive->priv->icon != NULL) | |
1616 | + free (drive->priv->icon); | |
1617 | + drive->priv->icon = g_strdup (drive_icon); | |
1618 | + free (drive_icon); | |
1619 | + | |
1620 | + /* figure out target mount point; first see if we're mounted */ | |
1621 | + target_mount_point = NULL; | |
1622 | + if (hal_volume != NULL) { | |
1623 | + const char *str; | |
1624 | + str = hal_volume_get_mount_point (hal_volume); | |
1625 | + if (str != NULL) | |
1626 | + target_mount_point = g_strdup (str); | |
1627 | + } | |
1628 | + | |
1629 | + /* otherwise lookup fstab */ | |
1630 | + if (target_mount_point == NULL && setfsent () == 1) { | |
1631 | + struct fstab *fst; | |
1632 | + fst = getfsspec (drive->priv->device_path); | |
1633 | + if (fst != NULL ) | |
1634 | + target_mount_point = g_strdup (fst->fs_file); | |
1635 | + endfsent (); | |
1636 | } | |
1637 | - hal_free_string_array (hal_volumes); | |
1638 | - | |
1639 | - hal_volumes = hal_find_device_by_capability ( | |
1640 | - volume_monitor_daemon->hal_ctx, | |
1641 | - "block", | |
1642 | - &num_hal_volumes); | |
1643 | - for (i=0; i<num_hal_volumes; i++) { | |
1644 | - char *udi; | |
1645 | ||
1646 | - udi = hal_volumes [i]; | |
1647 | + /* if we don't use removable media and the volume shouldn't be visible, then hide the drive */ | |
1648 | + if(!hal_drive_uses_removable_media (hal_drive) && | |
1649 | + !hal_volume_policy_should_be_visible (hal_drive, hal_volume, hal_storage_policy, target_mount_point)) | |
1650 | + drive->priv->is_user_visible = FALSE; | |
1651 | ||
1652 | - _hal_add_volume (volume_monitor_daemon, udi); | |
1653 | - } | |
1654 | - hal_free_string_array (hal_volumes); | |
1655 | -} | |
1656 | - | |
1657 | -static void | |
1658 | -_hal_mainloop_integration (LibHalContext *ctx, | |
1659 | - DBusConnection * dbus_connection) | |
1660 | -{ | |
1661 | - dbus_connection_setup_with_g_main (dbus_connection, NULL); | |
1662 | -} | |
1663 | + g_free (target_mount_point); | |
1664 | ||
1665 | -static void | |
1666 | -_hal_device_added (LibHalContext *ctx, | |
1667 | - const char *udi) | |
1668 | -{ | |
1669 | - GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
1670 | - volume_monitor_daemon = (GnomeVFSVolumeMonitorDaemon *) | |
1671 | - hal_ctx_get_user_data (ctx); | |
1672 | - _hal_add_volume (volume_monitor_daemon, udi); | |
1673 | -} | |
1674 | + /* set hal udi */ | |
1675 | + drive->priv->hal_udi = g_strdup (hal_drive_get_udi (hal_drive)); | |
1676 | ||
1677 | -static void | |
1678 | -_hal_device_removed (LibHalContext *ctx, | |
1679 | - const char *udi) | |
1680 | -{ | |
1681 | - GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
1682 | - volume_monitor_daemon = (GnomeVFSVolumeMonitorDaemon *) | |
1683 | - hal_ctx_get_user_data (ctx); | |
1684 | - _hal_remove_volume (volume_monitor_daemon, udi); | |
1685 | +out: | |
1686 | + hal_volume_free (hal_volume); | |
1687 | + hal_drive_free (hal_drive); | |
1688 | } | |
1689 | ||
1690 | -static void | |
1691 | -_hal_device_new_capability (LibHalContext *ctx, | |
1692 | - const char *udi, | |
1693 | - const char *capability) | |
1694 | +void | |
1695 | +_gnome_vfs_hal_mounts_modify_volume (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1696 | + GnomeVFSVolume *volume) | |
1697 | { | |
1698 | - GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
1699 | - volume_monitor_daemon = (GnomeVFSVolumeMonitorDaemon *) | |
1700 | - hal_ctx_get_user_data (ctx); | |
1701 | - _hal_add_volume (volume_monitor_daemon, udi); | |
1702 | -} | |
1703 | + char *volume_name; | |
1704 | + char *volume_icon; | |
1705 | + char *unique_volume_name; | |
1706 | + LibHalContext *hal_ctx; | |
1707 | + HalDrive *hal_drive; | |
1708 | + HalVolume *hal_volume; | |
1709 | + GnomeVFSHalUserData *hal_userdata; | |
1710 | + HalStoragePolicy *hal_storage_policy; | |
1711 | + char *target_mount_point; | |
1712 | ||
1713 | -static void | |
1714 | -_hal_device_lost_capability (LibHalContext *ctx, | |
1715 | - const char *udi, | |
1716 | - const char *capability) | |
1717 | -{ | |
1718 | -} | |
1719 | + hal_volume = NULL; | |
1720 | + hal_drive = NULL; | |
1721 | ||
1722 | -static void | |
1723 | -_hal_device_property_modified (LibHalContext *ctx, | |
1724 | - const char *udi, | |
1725 | - const char *key, | |
1726 | - dbus_bool_t is_removed, | |
1727 | - dbus_bool_t is_added) | |
1728 | -{ | |
1729 | - GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
1730 | - volume_monitor_daemon = (GnomeVFSVolumeMonitorDaemon *) | |
1731 | - hal_ctx_get_user_data (ctx); | |
1732 | + if ((hal_ctx = volume_monitor_daemon->hal_ctx) == NULL) | |
1733 | + goto out; | |
1734 | + if (volume == NULL || volume->priv == NULL || volume->priv->device_path == NULL) | |
1735 | + goto out; | |
1736 | ||
1737 | - if (!is_removed && strcmp (key, "volume.is_mounted") == 0) { | |
1738 | - dbus_bool_t is_mounted; | |
1739 | + hal_userdata = (GnomeVFSHalUserData *) hal_ctx_get_user_data (hal_ctx); | |
1740 | + hal_storage_policy = hal_userdata->hal_storage_policy; | |
1741 | ||
1742 | - is_mounted = hal_device_get_property_bool( | |
1743 | - ctx, udi, "volume.is_mounted"); | |
1744 | + /* Now, modify the drive with the hal stuff, unless we've already done so */ | |
1745 | + if (volume->priv->hal_udi != NULL) | |
1746 | + goto out; | |
1747 | ||
1748 | - if( is_mounted ) | |
1749 | - _hal_add_volume (volume_monitor_daemon, udi); | |
1750 | - else | |
1751 | - _hal_volume_unmounted (volume_monitor_daemon, udi); | |
1752 | + /* Note, the device_path points to what hal calls a volume, e.g. | |
1753 | + * /dev/sda1 etc, however we get the Drive object for the parent if | |
1754 | + * that is the case. This is a feature of libhal-storage. | |
1755 | + */ | |
1756 | + if ((hal_drive = hal_drive_from_device_file (hal_ctx, volume->priv->device_path)) == NULL) { | |
1757 | + g_warning ("%s: no hal drive for device=%s", __FUNCTION__, volume->priv->device_path); | |
1758 | + goto out; | |
1759 | } | |
1760 | -} | |
1761 | - | |
1762 | -static void | |
1763 | -_hal_device_condition (LibHalContext *ctx, | |
1764 | - const char *udi, | |
1765 | - const char *condition_name, | |
1766 | - DBusMessage *message) | |
1767 | -{ | |
1768 | - GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon; | |
1769 | - volume_monitor_daemon = (GnomeVFSVolumeMonitorDaemon *) | |
1770 | - hal_ctx_get_user_data (ctx); | |
1771 | - | |
1772 | - if (strcmp (condition_name, "BlockForcedUnmountPartition") == 0) { | |
1773 | - _hal_remove_volume (volume_monitor_daemon, udi); | |
1774 | + if ((hal_volume = hal_volume_from_device_file (hal_ctx, volume->priv->device_path)) == NULL) { | |
1775 | + g_warning ("%s: no hal volume for device=%s", __FUNCTION__, volume->priv->device_path); | |
1776 | + goto out; | |
1777 | } | |
1778 | -} | |
1779 | ||
1780 | -static LibHalFunctions | |
1781 | -hal_functions = { _hal_mainloop_integration, | |
1782 | - _hal_device_added, | |
1783 | - _hal_device_removed, | |
1784 | - _hal_device_new_capability, | |
1785 | - _hal_device_lost_capability, | |
1786 | - _hal_device_property_modified, | |
1787 | - _hal_device_condition }; | |
1788 | + /* set display name */ | |
1789 | + volume_name = hal_volume_policy_compute_display_name (hal_drive, hal_volume, hal_storage_policy); | |
1790 | + unique_volume_name = _gnome_vfs_volume_monitor_uniquify_volume_name ( | |
1791 | + GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon), volume_name); | |
1792 | + if (volume->priv->display_name != NULL) | |
1793 | + free (volume->priv->display_name); | |
1794 | + volume->priv->display_name = unique_volume_name; | |
1795 | + free (volume_name); | |
1796 | + | |
1797 | + /* set icon name; try dedicated icon name first... */ | |
1798 | + if (hal_drive_get_dedicated_icon_volume (hal_drive) != NULL) | |
1799 | + volume_icon = g_strdup (hal_drive_get_dedicated_icon_volume (hal_drive)); | |
1800 | + else | |
1801 | + volume_icon = hal_volume_policy_compute_icon_name (hal_drive, hal_volume, hal_storage_policy); | |
1802 | + if (volume->priv->icon != NULL) | |
1803 | + free (volume->priv->icon); | |
1804 | + volume->priv->icon = g_strdup (volume_icon); | |
1805 | + free (volume_icon); | |
1806 | ||
1807 | -gboolean | |
1808 | -_gnome_vfs_monitor_hal_mounts_init (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) | |
1809 | -{ | |
1810 | - /* initialise the connection to the hal daemon */ | |
1811 | - if ((volume_monitor_daemon->hal_ctx = | |
1812 | - hal_initialize (&hal_functions, FALSE)) == NULL) { | |
1813 | - g_warning ("hal_initialize failed\n"); | |
1814 | - return FALSE; | |
1815 | + /* figure out target mount point; first see if we're mounted */ | |
1816 | + target_mount_point = NULL; | |
1817 | + { | |
1818 | + const char *str; | |
1819 | + str = hal_volume_get_mount_point (hal_volume); | |
1820 | + if (str != NULL) | |
1821 | + target_mount_point = g_strdup (str); | |
1822 | } | |
1823 | ||
1824 | - hal_ctx_set_user_data (volume_monitor_daemon->hal_ctx, | |
1825 | - volume_monitor_daemon); | |
1826 | + /* otherwise lookup fstab */ | |
1827 | + if (target_mount_point == NULL && setfsent () == 1) { | |
1828 | + struct fstab *fst; | |
1829 | + fst = getfsspec (volume->priv->device_path); | |
1830 | + if (fst != NULL ) | |
1831 | + target_mount_point = g_strdup (fst->fs_file); | |
1832 | + endfsent (); | |
1833 | + } | |
1834 | ||
1835 | - hal_device_property_watch_all (volume_monitor_daemon->hal_ctx); | |
1836 | + /* set whether it's visible on the desktop */ | |
1837 | + volume->priv->is_user_visible = | |
1838 | + hal_volume_policy_should_be_visible (hal_drive, hal_volume, hal_storage_policy, target_mount_point) && | |
1839 | + (hal_drive_is_hotpluggable (hal_drive) || hal_drive_uses_removable_media (hal_drive)); | |
1840 | ||
1841 | - return TRUE; | |
1842 | -} | |
1843 | + g_free (target_mount_point); | |
1844 | ||
1845 | -void | |
1846 | -_gnome_vfs_monitor_hal_mounts_shutdown (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) | |
1847 | -{ | |
1848 | - if (hal_shutdown (volume_monitor_daemon->hal_ctx) != 0) { | |
1849 | - g_warning ("hal_shutdown failed\n"); | |
1850 | - } | |
1851 | + /* set hal udi */ | |
1852 | + volume->priv->hal_udi = g_strdup (hal_volume_get_udi (hal_volume)); | |
1853 | +out: | |
1854 | + hal_drive_free (hal_drive); | |
1855 | + hal_volume_free (hal_volume); | |
1856 | } | |
1857 | ||
1858 | #endif /* USE_HAL */ | |
1859 | Index: libgnomevfs/gnome-vfs-hal-mounts.h | |
1860 | =================================================================== | |
1861 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-hal-mounts.h,v | |
1862 | retrieving revision 1.3 | |
1863 | diff -u -p -r1.3 gnome-vfs-hal-mounts.h | |
1864 | --- libgnomevfs/gnome-vfs-hal-mounts.h 19 Aug 2004 07:34:01 -0000 1.3 | |
1865 | +++ libgnomevfs/gnome-vfs-hal-mounts.h 24 Sep 2004 22:50:34 -0000 | |
1866 | @@ -1,7 +1,7 @@ | |
1867 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ | |
1868 | /* gnome-vfs-hal-mounts.h - read and monitor volumes using freedesktop HAL | |
1869 | ||
1870 | - Copyright (C) 2004 David Zeuthen | |
1871 | + Copyright (C) 2004 Red Hat, Inc. | |
1872 | ||
1873 | The Gnome Library is free software; you can redistribute it and/or | |
1874 | modify it under the terms of the GNU Library General Public License as | |
1875 | @@ -18,7 +18,7 @@ | |
1876 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
1877 | Boston, MA 02111-1307, USA. | |
1878 | ||
1879 | - Author: David Zeuthen <david@fubar.dk> | |
1880 | + Author: David Zeuthen <davidz@redhat.com> | |
1881 | */ | |
1882 | ||
1883 | #ifndef GNOME_VFS_HAL_MOUNTS_H | |
1884 | @@ -26,12 +26,14 @@ | |
1885 | ||
1886 | #include "gnome-vfs-volume-monitor-daemon.h" | |
1887 | ||
1888 | -gboolean _gnome_vfs_monitor_hal_mounts_init (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon); | |
1889 | +gboolean _gnome_vfs_hal_mounts_init (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon); | |
1890 | ||
1891 | -void _gnome_vfs_monitor_hal_mounts_shutdown (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon); | |
1892 | - | |
1893 | -void _gnome_vfs_monitor_hal_get_volume_list (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon); | |
1894 | +void _gnome_vfs_hal_mounts_shutdown (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon); | |
1895 | ||
1896 | +void _gnome_vfs_hal_mounts_modify_drive (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1897 | + GnomeVFSDrive *drive); | |
1898 | +void _gnome_vfs_hal_mounts_modify_volume (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon, | |
1899 | + GnomeVFSVolume *volume); | |
1900 | ||
1901 | ||
1902 | #endif /* GNOME_VFS_HAL_MOUNTS_H */ | |
1903 | Index: libgnomevfs/gnome-vfs-volume-monitor-daemon.c | |
1904 | =================================================================== | |
1905 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-daemon.c,v | |
1906 | retrieving revision 1.15 | |
1907 | diff -u -p -r1.15 gnome-vfs-volume-monitor-daemon.c | |
1908 | --- libgnomevfs/gnome-vfs-volume-monitor-daemon.c 22 Sep 2004 08:38:38 -0000 1.15 | |
1909 | +++ libgnomevfs/gnome-vfs-volume-monitor-daemon.c 24 Sep 2004 22:50:34 -0000 | |
1910 | @@ -154,7 +154,7 @@ static void | |
1911 | gnome_vfs_volume_monitor_daemon_init (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) | |
1912 | { | |
1913 | #ifdef USE_HAL | |
1914 | - if (_gnome_vfs_monitor_hal_mounts_init (volume_monitor_daemon)) { | |
1915 | + if (_gnome_vfs_hal_mounts_init (volume_monitor_daemon)) { | |
1916 | /* It worked, do use HAL */ | |
1917 | dont_use_hald = FALSE; | |
1918 | } else { | |
1919 | @@ -163,12 +163,10 @@ gnome_vfs_volume_monitor_daemon_init (Gn | |
1920 | } | |
1921 | #endif /* USE_HAL */ | |
1922 | ||
1923 | - if (dont_use_hald) { | |
1924 | - _gnome_vfs_monitor_unix_mounts (fstab_changed, | |
1925 | - volume_monitor_daemon, | |
1926 | - mtab_changed, | |
1927 | - volume_monitor_daemon); | |
1928 | - } | |
1929 | + _gnome_vfs_monitor_unix_mounts (fstab_changed, | |
1930 | + volume_monitor_daemon, | |
1931 | + mtab_changed, | |
1932 | + volume_monitor_daemon); | |
1933 | ||
1934 | volume_monitor_daemon->gconf_client = gconf_client_get_default (); | |
1935 | gconf_client_add_dir (volume_monitor_daemon->gconf_client, | |
1936 | @@ -185,16 +183,8 @@ gnome_vfs_volume_monitor_daemon_init (Gn | |
1937 | NULL); | |
1938 | ||
1939 | ||
1940 | - if (dont_use_hald) { | |
1941 | - update_fstab_drives (volume_monitor_daemon); | |
1942 | - update_mtab_volumes (volume_monitor_daemon); | |
1943 | - } | |
1944 | -#ifdef USE_HAL | |
1945 | - else { | |
1946 | - _gnome_vfs_monitor_hal_get_volume_list (volume_monitor_daemon); | |
1947 | - } | |
1948 | -#endif /* USE_HAL */ | |
1949 | - | |
1950 | + update_fstab_drives (volume_monitor_daemon); | |
1951 | + update_mtab_volumes (volume_monitor_daemon); | |
1952 | update_connected_servers (volume_monitor_daemon); | |
1953 | } | |
1954 | ||
1955 | @@ -205,15 +195,8 @@ gnome_vfs_volume_monitor_daemon_force_pr | |
1956 | ||
1957 | volume_monitor_daemon = GNOME_VFS_VOLUME_MONITOR_DAEMON (volume_monitor); | |
1958 | ||
1959 | - if (dont_use_hald) { | |
1960 | - update_fstab_drives (volume_monitor_daemon); | |
1961 | - update_mtab_volumes (volume_monitor_daemon); | |
1962 | - } | |
1963 | -#ifdef USE_HAL | |
1964 | - else { | |
1965 | - _gnome_vfs_monitor_hal_get_volume_list (volume_monitor_daemon); | |
1966 | - } | |
1967 | -#endif /* USE_HAL */ | |
1968 | + update_fstab_drives (volume_monitor_daemon); | |
1969 | + update_mtab_volumes (volume_monitor_daemon); | |
1970 | update_connected_servers (volume_monitor_daemon); | |
1971 | } | |
1972 | ||
1973 | @@ -226,22 +209,15 @@ gnome_vfs_volume_monitor_daemon_finalize | |
1974 | ||
1975 | volume_monitor_daemon = GNOME_VFS_VOLUME_MONITOR_DAEMON (object); | |
1976 | ||
1977 | - if (dont_use_hald) { | |
1978 | - _gnome_vfs_stop_monitoring_unix_mounts (); | |
1979 | + _gnome_vfs_stop_monitoring_unix_mounts (); | |
1980 | ||
1981 | - g_list_foreach (volume_monitor_daemon->last_mtab, | |
1982 | - (GFunc)_gnome_vfs_unix_mount_free, NULL); | |
1983 | - g_list_free (volume_monitor_daemon->last_mtab); | |
1984 | - | |
1985 | - g_list_foreach (volume_monitor_daemon->last_fstab, | |
1986 | - (GFunc)_gnome_vfs_unix_mount_point_free, NULL); | |
1987 | - g_list_free (volume_monitor_daemon->last_fstab); | |
1988 | - } | |
1989 | -#ifdef USE_HAL | |
1990 | - else { | |
1991 | - _gnome_vfs_monitor_hal_mounts_shutdown (volume_monitor_daemon); | |
1992 | - } | |
1993 | -#endif /* USE_HAL */ | |
1994 | + g_list_foreach (volume_monitor_daemon->last_mtab, | |
1995 | + (GFunc)_gnome_vfs_unix_mount_free, NULL); | |
1996 | + g_list_free (volume_monitor_daemon->last_mtab); | |
1997 | + | |
1998 | + g_list_foreach (volume_monitor_daemon->last_fstab, | |
1999 | + (GFunc)_gnome_vfs_unix_mount_point_free, NULL); | |
2000 | + g_list_free (volume_monitor_daemon->last_fstab); | |
2001 | ||
2002 | gconf_client_notify_remove (volume_monitor_daemon->gconf_client, | |
2003 | volume_monitor_daemon->connected_id); | |
2004 | @@ -755,12 +731,19 @@ update_fstab_drives (GnomeVFSVolumeMonit | |
2005 | mount = l->data; | |
2006 | ||
2007 | drive = create_drive_from_mount_point (volume_monitor, mount); | |
2008 | + | |
2009 | if (drive != NULL) { | |
2010 | + | |
2011 | +#ifdef USE_HAL | |
2012 | + if (!dont_use_hald) | |
2013 | + _gnome_vfs_hal_mounts_modify_drive (volume_monitor_daemon, drive); | |
2014 | +#endif /* USE_HAL */ | |
2015 | + | |
2016 | _gnome_vfs_volume_monitor_connected (volume_monitor, drive); | |
2017 | gnome_vfs_drive_unref (drive); | |
2018 | } | |
2019 | } | |
2020 | - | |
2021 | + | |
2022 | g_list_free (added); | |
2023 | g_list_free (removed); | |
2024 | g_list_foreach (volume_monitor_daemon->last_fstab, | |
2025 | @@ -1021,6 +1004,10 @@ update_mtab_volumes (GnomeVFSVolumeMonit | |
2026 | ||
2027 | vol = create_vol_from_mount (volume_monitor, mount); | |
2028 | vol->priv->unix_device = unix_device; | |
2029 | +#ifdef USE_HAL | |
2030 | + if (!dont_use_hald) | |
2031 | + _gnome_vfs_hal_mounts_modify_volume (volume_monitor_daemon, vol); | |
2032 | +#endif /* USE_HAL */ | |
2033 | _gnome_vfs_volume_monitor_mounted (volume_monitor, vol); | |
2034 | gnome_vfs_volume_unref (vol); | |
2035 | } | |
2036 | @@ -1033,8 +1020,6 @@ update_mtab_volumes (GnomeVFSVolumeMonit | |
2037 | g_list_free (volume_monitor_daemon->last_mtab); | |
2038 | volume_monitor_daemon->last_mtab = new_mtab; | |
2039 | } | |
2040 | - | |
2041 | - | |
2042 | } | |
2043 | ||
2044 | /************************* connected server ***********************************/ | |
2045 | Index: libgnomevfs/gnome-vfs-volume-monitor-private.h | |
2046 | =================================================================== | |
2047 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-private.h,v | |
2048 | retrieving revision 1.7 | |
2049 | diff -u -p -r1.7 gnome-vfs-volume-monitor-private.h | |
2050 | --- libgnomevfs/gnome-vfs-volume-monitor-private.h 15 Jul 2004 13:21:15 -0000 1.7 | |
2051 | +++ libgnomevfs/gnome-vfs-volume-monitor-private.h 24 Sep 2004 22:50:34 -0000 | |
2052 | @@ -85,6 +85,8 @@ struct _GnomeVFSDrivePrivate { | |
2053 | ||
2054 | /* Only for HAL devices: */ | |
2055 | char *hal_udi; | |
2056 | + | |
2057 | + gboolean should_eject; | |
2058 | }; | |
2059 | ||
2060 | void _gnome_vfs_volume_set_drive (GnomeVFSVolume *volume, | |
2061 | @@ -132,11 +134,17 @@ GnomeVFSVolume *_gnome_vfs_volume_monito | |
2062 | ||
2063 | #ifdef USE_HAL | |
2064 | GnomeVFSVolume *_gnome_vfs_volume_monitor_find_volume_by_hal_udi (GnomeVFSVolumeMonitor *volume_monitor, | |
2065 | - const char *hal_udi); | |
2066 | -GnomeVFSDrive *_gnome_vfs_volume_monitor_find_drive_by_hal_udi (GnomeVFSVolumeMonitor *volume_monitor, | |
2067 | - const char *hal_udi); | |
2068 | + const char *hal_udi); | |
2069 | +GnomeVFSDrive *_gnome_vfs_volume_monitor_find_drive_by_hal_udi (GnomeVFSVolumeMonitor *volume_monitor, | |
2070 | + const char *hal_udi); | |
2071 | ||
2072 | #endif /* USE_HAL */ | |
2073 | + | |
2074 | +GnomeVFSVolume *_gnome_vfs_volume_monitor_find_volume_by_device_path (GnomeVFSVolumeMonitor *volume_monitor, | |
2075 | + const char *device_path); | |
2076 | +GnomeVFSDrive *_gnome_vfs_volume_monitor_find_drive_by_device_path (GnomeVFSVolumeMonitor *volume_monitor, | |
2077 | + const char *device_path); | |
2078 | + | |
2079 | ||
2080 | ||
2081 | char *_gnome_vfs_volume_monitor_uniquify_volume_name (GnomeVFSVolumeMonitor *volume_monitor, | |
2082 | Index: libgnomevfs/gnome-vfs-volume-monitor.c | |
2083 | =================================================================== | |
2084 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor.c,v | |
2085 | retrieving revision 1.9 | |
2086 | diff -u -p -r1.9 gnome-vfs-volume-monitor.c | |
2087 | --- libgnomevfs/gnome-vfs-volume-monitor.c 16 Sep 2004 18:17:27 -0000 1.9 | |
2088 | +++ libgnomevfs/gnome-vfs-volume-monitor.c 24 Sep 2004 22:50:35 -0000 | |
2089 | @@ -344,6 +344,52 @@ _gnome_vfs_volume_monitor_find_drive_by_ | |
2090 | } | |
2091 | #endif /* USE_HAL */ | |
2092 | ||
2093 | +GnomeVFSVolume * | |
2094 | +_gnome_vfs_volume_monitor_find_volume_by_device_path (GnomeVFSVolumeMonitor *volume_monitor, | |
2095 | + const char *device_path) | |
2096 | +{ | |
2097 | + GList *l; | |
2098 | + GnomeVFSVolume *vol, *ret; | |
2099 | + | |
2100 | + /* Doesn't need locks, only called internally on main thread and doesn't write */ | |
2101 | + | |
2102 | + ret = NULL; | |
2103 | + for (l = volume_monitor->priv->mtab_volumes; l != NULL; l = l->next) { | |
2104 | + vol = l->data; | |
2105 | + if (vol->priv != NULL && vol->priv->hal_udi != NULL && | |
2106 | + vol->priv->device_path != NULL && /* Hmm */ | |
2107 | + strcmp (vol->priv->device_path, device_path) == 0) { | |
2108 | + ret = vol; | |
2109 | + break; | |
2110 | + } | |
2111 | + } | |
2112 | + | |
2113 | + return ret; | |
2114 | +} | |
2115 | + | |
2116 | +GnomeVFSDrive * | |
2117 | +_gnome_vfs_volume_monitor_find_drive_by_device_path (GnomeVFSVolumeMonitor *volume_monitor, | |
2118 | + const char *device_path) | |
2119 | +{ | |
2120 | + GList *l; | |
2121 | + GnomeVFSDrive *drive, *ret; | |
2122 | + | |
2123 | + /* Doesn't need locks, only called internally on main thread and doesn't write */ | |
2124 | + | |
2125 | + ret = NULL; | |
2126 | + for (l = volume_monitor->priv->fstab_drives; l != NULL; l = l->next) { | |
2127 | + drive = l->data; | |
2128 | + if (drive->priv != NULL && drive->priv->hal_udi != NULL && | |
2129 | + drive->priv->device_path != NULL && /* Hmm */ | |
2130 | + strcmp (drive->priv->device_path, device_path) == 0) { | |
2131 | + ret = drive; | |
2132 | + break; | |
2133 | + } | |
2134 | + } | |
2135 | + | |
2136 | + return ret; | |
2137 | +} | |
2138 | + | |
2139 | ||
2140 | GnomeVFSVolume * | |
2141 | _gnome_vfs_volume_monitor_find_mtab_volume_by_activation_uri (GnomeVFSVolumeMonitor *volume_monitor, | |
2142 | Index: libgnomevfs/gnome-vfs-volume-ops.c | |
2143 | =================================================================== | |
2144 | RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-ops.c,v | |
2145 | retrieving revision 1.14 | |
2146 | diff -u -p -r1.14 gnome-vfs-volume-ops.c | |
2147 | --- libgnomevfs/gnome-vfs-volume-ops.c 16 Aug 2004 08:44:06 -0000 1.14 | |
2148 | +++ libgnomevfs/gnome-vfs-volume-ops.c 24 Sep 2004 22:50:35 -0000 | |
2149 | @@ -331,15 +331,19 @@ mount_unmount_operation (const char *mou | |
2150 | int i; | |
2151 | ||
2152 | ||
2153 | -#ifdef USE_VOLRMMOUNT | |
2154 | - name = strrchr (mount_point, '/'); | |
2155 | - if (name != NULL) { | |
2156 | - name = name + 1; | |
2157 | - } else { | |
2158 | - name = mount_point; | |
2159 | - } | |
2160 | +#ifdef __linux__ | |
2161 | + name = device_path; | |
2162 | #else | |
2163 | +# ifdef USE_VOLRMMOUNT | |
2164 | + name = strrchr (mount_point, '/'); | |
2165 | + if (name != NULL) { | |
2166 | + name = name + 1; | |
2167 | + } else { | |
2168 | + name = mount_point; | |
2169 | + } | |
2170 | +# else | |
2171 | name = mount_point; | |
2172 | +# endif | |
2173 | #endif | |
2174 | ||
2175 | if (should_mount) { | |
2176 | @@ -501,7 +505,14 @@ gnome_vfs_volume_unmount (GnomeVFSVolume | |
2177 | char *mount_path, *device_path; | |
2178 | char *uri; | |
2179 | GnomeVFSVolumeType type; | |
2180 | - | |
2181 | + | |
2182 | + if (volume->priv->drive != NULL) { | |
2183 | + if (volume->priv->drive->priv->should_eject) { | |
2184 | + gnome_vfs_volume_eject (volume, callback, user_data); | |
2185 | + return; | |
2186 | + } | |
2187 | + } | |
2188 | + | |
2189 | emit_pre_unmount (volume); | |
2190 | ||
2191 | type = gnome_vfs_volume_get_volume_type (volume); | |
2192 | @@ -608,6 +619,11 @@ gnome_vfs_drive_unmount (GnomeVFSDrive | |
2193 | { | |
2194 | GList *vol_list; | |
2195 | GList *current_vol; | |
2196 | + | |
2197 | + if (drive->priv->should_eject) { | |
2198 | + gnome_vfs_drive_eject(drive, callback, user_data); | |
2199 | + return; | |
2200 | + } | |
2201 | ||
2202 | vol_list = gnome_vfs_drive_get_mounted_volumes (drive); | |
2203 |