[Utopia] Workaround to correctly handle Non-CDROM removable devices



Hi!

Yesterday I updated Ubuntu's Utopia stack to the newest versions; to
get it actually working, I had to fix gvm_media_changed() since this
does not handle USB/FireWire devices yet; thus such devices are simply
ignored with the new hal 0.2.98 (it worked fine with 0.2.92).

The reason seems to be that the new hal now correctly handles the
storage.removable attribute which causes gvm_media_changed() to be
called. Attached patch falls back to the old behaviour of just
mounting the device if gvm_media_changed() cannot handle the device
(i. e. if it's no CD-ROM).

Thanks for considering and have a nice day,

Martin
-- 
Martin Pitt                       http://www.piware.de
Ubuntu Developer            http://www.ubuntulinux.org
Debian GNU/Linux Developer       http://www.debian.org
diff -Nur gnome-volume-manager-1.0.2/src/manager.c gnome-volume-manager-1.0.2.new/src/manager.c
--- gnome-volume-manager-1.0.2/src/manager.c	2004-08-30 16:53:09.000000000 +0200
+++ gnome-volume-manager-1.0.2.new/src/manager.c	2004-09-27 10:23:59.356691680 +0200
@@ -658,10 +658,11 @@
  *
  * At the moment, we only handle CD-ROM and DVD drives.
  */
-static void
+static gboolean
 gvm_media_changed (const char *udi, const char *storage_device)
 {
 	char *media_type;
+	gboolean handled = FALSE;
 
 	/*
 	 * Get HAL's interpretation of our media type.  Note that we must check
@@ -674,12 +675,15 @@
 		return;
 	}
 
-	if (!g_strcasecmp (media_type, "cdrom"))
+	if (!g_strcasecmp (media_type, "cdrom")) {
 		gvm_cdrom_policy (udi);
+		handled = TRUE;
+	}
 
 	/* other media_types go here */
 
 	hal_free_string (media_type);
+	return handled;
 }
 
 /** Invoked when a device is added to the Global Device List. 
@@ -726,14 +730,16 @@
 	 * Does this device support removable media?  Note that we
 	 * check storage_device and not our own UDI
 	 */
+
 	if (hal_device_get_property_bool (hal_ctx, storage_device,
 					  "storage.removable")) {
 		/* we handle media change events separately */
 		dbg ("Changed: %s\n", device);
-		gvm_media_changed (udi, storage_device);
-		goto out;
+		if (gvm_media_changed (udi, storage_device))
+		    goto out;
 	}
 	
+	
 	/* folks, we have a new device! */
 	dbg ("Added: %s\n", device);
 	

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]