brasero r664 - in trunk: . data po src src/plugins/checksum



Author: philippr
Date: Sat Mar  8 14:23:27 2008
New Revision: 664
URL: http://svn.gnome.org/viewvc/brasero?rev=664&view=rev

Log:
	Last patch to remove the last bits of nautilus-burn library
	Now we rely on HAL for device detection and GIO for all mounting/unmounting/ejection which means you must have gvfs module for HAL installed
	Some fixes and memleak fixes
	Removed Application from Categories in desktop file

	* configure.in:
	* data/brasero.desktop.in.in:
	* src/Makefile.am:
	* src/brasero-blank-dialog.c: (brasero_blank_dialog_drive_changed),
	(brasero_blank_dialog_init):
	* src/brasero-dest-selection.c:
	(brasero_dest_selection_check_same_src_dest),
	(brasero_dest_selection_drive_properties),
	(brasero_dest_selection_set_drive_properties),
	(brasero_dest_selection_caps_changed),
	(brasero_dest_selection_output_changed),
	(brasero_dest_selection_set_property):
	* src/brasero-disc-copy-dialog.c: (brasero_disc_copy_dialog_init):
	* src/brasero-disc-option-dialog.c:
	(brasero_disc_option_dialog_get_default_label):
	* src/brasero-drive-info.c: (brasero_drive_info_set_medium),
	(brasero_drive_info_finalize):
	* src/brasero-drive-selection.c:
	(brasero_drive_selection_drive_changed_cb),
	(brasero_drive_selection_get_drive):
	* src/brasero-eject-dialog.c: (brasero_eject_dialog_drive_changed),
	(brasero_eject_dialog_activate), (brasero_eject_dialog_cancel),
	(brasero_eject_dialog_class_init), (brasero_eject_dialog_init):
	* src/brasero-medium-selection.c:
	(brasero_medium_selection_set_active),
	(brasero_medium_selection_get_active),
	(brasero_medium_selection_show_type),
	(brasero_medium_selection_medium_added_cb),
	(brasero_medium_selection_medium_removed_cb),
	(brasero_medium_selection_init),
	(brasero_medium_selection_finalize):
	* src/brasero-project-size.c:
	(brasero_project_size_get_media_string),
	(brasero_project_size_build_menu),
	(brasero_project_size_add_real_medias):
	* src/brasero-sum-dialog.c: (brasero_sum_dialog_drive_changed),
	(brasero_sum_dialog_class_init), (brasero_sum_dialog_init):
	* src/brasero-tool-dialog.c: (brasero_tool_dialog_run),
	(brasero_tool_dialog_drive_changed_cb),
	(brasero_tool_dialog_cancel), (brasero_tool_dialog_init):
	* src/brasero-tool-dialog.h:
	* src/brasero-utils.c: (brasero_utils_get_time_string_from_size):
	* src/burn-basics.c: (brasero_burn_library_shutdown):
	* src/burn-drive.c: (brasero_drive_is_fake),
	(brasero_drive_get_hal_context), (brasero_drive_is_door_open),
	(brasero_drive_lock), (brasero_drive_unlock),
	(brasero_drive_get_display_name), (brasero_drive_get_device),
	(brasero_drive_get_udi), (brasero_drive_get_medium),
	(brasero_drive_set_medium), (brasero_drive_get_caps),
	(brasero_drive_finalize), (brasero_drive_init_real),
	(brasero_drive_set_property), (brasero_drive_get_property),
	(brasero_drive_class_init), (brasero_drive_new):
	* src/burn-drive.h:
	* src/burn-job.c: (brasero_job_get_max_speed):
	* src/burn-medium-monitor.c:
	(brasero_medium_monitor_drive_inserted),
	(brasero_medium_monitor_medium_inserted),
	(brasero_medium_monitor_inserted_cb),
	(brasero_medium_monitor_removed_cb),
	(brasero_medium_monitor_add_file), (brasero_medium_monitor_init),
	(brasero_medium_monitor_finalize),
	(brasero_medium_monitor_get_default):
	* src/burn-medium.c: (brasero_medium_finalize),
	(brasero_medium_set_property), (brasero_medium_get_property),
	(brasero_medium_class_init), (brasero_medium_can_be_written),
	(brasero_medium_can_be_rewritten), (brasero_medium_get_drive),
	(brasero_medium_get_udi), (brasero_medium_get_type):
	* src/burn-medium.h:
	* src/burn-session.c: (brasero_burn_session_set_image_output_full),
	(brasero_burn_session_get_dest_media):
	* src/burn-task-ctx.c:
	* src/burn-volume-obj.c: (brasero_volume_get_gvolume),
	(brasero_volume_is_mounted), (brasero_volume_get_mount_point),
	(brasero_volume_wait_for_operation_end),
	(brasero_volume_operation_end), (brasero_volume_umount_finish),
	(brasero_volume_umount), (brasero_volume_mount_finish),
	(brasero_volume_mount), (brasero_volume_eject_finish),
	(brasero_volume_eject), (brasero_volume_cancel_current_operation),
	(brasero_volume_get_display_label), (brasero_volume_init),
	(brasero_volume_finalize), (brasero_volume_class_init),
	(brasero_volume_new):
	* src/burn-volume-obj.h:
	* src/burn.c: (brasero_burn_eject_dest_media),
	(brasero_burn_eject_src_media), (brasero_burn_lock_src_media),
	(brasero_burn_lock_rewritable_media),
	(brasero_burn_lock_dest_media), (brasero_burn_mount_media),
	(brasero_burn_lock_checksum_media),
	(brasero_burn_unlock_src_media), (brasero_burn_unlock_dest_media),
	(brasero_burn_run_eraser), (brasero_burn_run_imager),
	(brasero_burn_run_recorder), (brasero_burn_check_real),
	(brasero_burn_class_init):
	* src/main.c: (on_erase_cb), (on_eject_cb),
	(on_integrity_check_cb):
	* src/plugins/checksum/burn-md5sum-file.c:
	(brasero_md5sum_file_disc_files):
	* src/scsi-eject.c: (brasero_mmc1_load_cd):
	* src/scsi-mech-status.c: (brasero_mmc1_mech_status):
	* src/scsi-mech-status.h:
	* src/scsi-mmc1.h:
	* src/scsi-opcodes.h:

Added:
   trunk/src/burn-volume-obj.c
   trunk/src/burn-volume-obj.h
   trunk/src/scsi-eject.c
   trunk/src/scsi-mech-status.c
   trunk/src/scsi-mech-status.h
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/data/brasero.desktop.in.in
   trunk/po/ChangeLog
   trunk/po/POTFILES.in
   trunk/src/Makefile.am
   trunk/src/brasero-blank-dialog.c
   trunk/src/brasero-dest-selection.c
   trunk/src/brasero-disc-copy-dialog.c
   trunk/src/brasero-disc-option-dialog.c
   trunk/src/brasero-drive-info.c
   trunk/src/brasero-drive-selection.c
   trunk/src/brasero-eject-dialog.c
   trunk/src/brasero-medium-selection.c
   trunk/src/brasero-project-size.c
   trunk/src/brasero-sum-dialog.c
   trunk/src/brasero-tool-dialog.c
   trunk/src/brasero-tool-dialog.h
   trunk/src/brasero-utils.c
   trunk/src/burn-basics.c
   trunk/src/burn-dbus.c
   trunk/src/burn-drive.c
   trunk/src/burn-drive.h
   trunk/src/burn-job.c
   trunk/src/burn-medium-monitor.c
   trunk/src/burn-medium.c
   trunk/src/burn-medium.h
   trunk/src/burn-session.c
   trunk/src/burn-task-ctx.c
   trunk/src/burn.c
   trunk/src/main.c
   trunk/src/plugins/checksum/burn-md5sum-file.c
   trunk/src/scsi-mmc1.h
   trunk/src/scsi-opcodes.h

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Sat Mar  8 14:23:27 2008
@@ -74,7 +74,7 @@
 GSTREAMER_REQUIRED=0.10.6
 GSTREAMER_BASE_REQUIRED=0.10.0
 LIBXML2_REQUIRED=2.6.0
-NAUTILUS_BURN_REQUIRED=2.16.0
+HAL_REQUIRED=0.5
 
 dnl ** used by brasero and one plugin
 PKG_CHECK_MODULES(BRASERO_GSTREAMER, 		\
@@ -99,7 +99,6 @@
 
 dnl ** used by brasero and all modules
 PKG_CHECK_MODULES(BRASERO_BASE, 		\
-	libnautilus-burn >= $NAUTILUS_BURN_REQUIRED		\
 	gconf-2.0 >= $GCONF_REQUIRED		\
 	glib-2.0 >= $GLIB_REQUIRED)
 
@@ -111,6 +110,7 @@
 
 dnl ** used only by brasero app itself ***
 PKG_CHECK_MODULES(BRASERO,			\
+	hal >= $HAL_REQUIRED		\
 	gmodule-2.0 >= $GMODULE_REQUIRED 	\
 	gdk-2.0 >= $GDK_REQUIRED	\
 	gtk+-2.0 >= $GTK_REQUIRED		\

Modified: trunk/data/brasero.desktop.in.in
==============================================================================
--- trunk/data/brasero.desktop.in.in	(original)
+++ trunk/data/brasero.desktop.in.in	Sat Mar  8 14:23:27 2008
@@ -2,7 +2,7 @@
 _Name=Brasero Disc Burning
 _GenericName=Disc Burning Application
 _Comment=Write and copy CD / DVD
-Categories=GNOME;Application;AudioVideo;
+Categories=GNOME;AudioVideo;DiscBurning;
 Encoding=UTF-8
 Exec=brasero %U
 Icon=brasero

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Sat Mar  8 14:23:27 2008
@@ -95,6 +95,5 @@
 src/brasero-data-vfs.c
 src/brasero-io.c
 src/brasero-medium-selection.c
-src/brasero-medium-selection.c
-src/burn-drive.c
 src/burn-drive.c
+src/burn-volume-obj.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sat Mar  8 14:23:27 2008
@@ -235,7 +235,12 @@
 	burn-medium-monitor.c         \
 	burn-medium-monitor.h         \
 	burn-drive.h         \
-	burn-drive.c 
+	burn-drive.c         \
+	burn-volume-obj.c         \
+	burn-volume-obj.h         \
+	scsi-eject.c         \
+	scsi-mech-status.c         \
+	scsi-mech-status.h 
 
 if BUILD_INOTIFY
 brasero_SOURCES += brasero-file-monitor.c brasero-file-monitor.h

Modified: trunk/src/brasero-blank-dialog.c
==============================================================================
--- trunk/src/brasero-blank-dialog.c	(original)
+++ trunk/src/brasero-blank-dialog.c	Sat Mar  8 14:23:27 2008
@@ -177,7 +177,11 @@
 
 	priv = BRASERO_BLANK_DIALOG_PRIVATE (dialog);
 
-	drive = brasero_medium_get_drive (medium);
+	if (medium)
+		drive = brasero_medium_get_drive (medium);
+	else
+		drive = NULL;
+
 	brasero_burn_session_set_burner (priv->session, drive);
 }
 
@@ -367,7 +371,9 @@
 				        BRASERO_BURN_FLAG_EJECT|
 				        BRASERO_BURN_FLAG_NOGRACE);
 	brasero_burn_session_set_burner (priv->session, drive);
-	g_object_unref (drive);
+
+	if (medium)
+		g_object_unref (medium);
 
 	priv->output_sig = g_signal_connect (priv->session,
 					     "output-changed",

Modified: trunk/src/brasero-dest-selection.c
==============================================================================
--- trunk/src/brasero-dest-selection.c	(original)
+++ trunk/src/brasero-dest-selection.c	Sat Mar  8 14:23:27 2008
@@ -161,7 +161,6 @@
 
 	medium = brasero_drive_get_medium (drive);
 	media = brasero_medium_get_status (medium);;
-	g_object_unref (drive);
 
 	if (media == BRASERO_MEDIUM_NONE)
 		return FALSE;
@@ -203,7 +202,6 @@
 	brasero_drive_properties_set_drive (BRASERO_DRIVE_PROPERTIES (priv->drive_prop),
 					    drive,
 					    rate);
-	g_object_unref (drive);
 
 	flags = brasero_burn_session_get_flags (priv->session);
 	if (!brasero_dest_selection_check_same_src_dest (self)) {
@@ -231,7 +229,6 @@
 	gtk_widget_show_all (priv->drive_prop);
 	result = gtk_dialog_run (GTK_DIALOG (priv->drive_prop));
 	if (result != GTK_RESPONSE_ACCEPT) {
-		g_object_unref (drive);
 		gtk_widget_destroy (priv->drive_prop);
 		priv->drive_prop = NULL;
 		return;
@@ -839,6 +836,7 @@
 			       0,
 			       FALSE);
 		gtk_widget_set_sensitive (priv->button, FALSE);
+		gtk_widget_set_sensitive (priv->copies_box, FALSE);
 		return;
 	}
 
@@ -849,6 +847,7 @@
 			       0,
 			       FALSE);
 		gtk_widget_set_sensitive (priv->button, FALSE);
+		gtk_widget_set_sensitive (priv->copies_box, FALSE);
 		return;
 	}
 
@@ -920,6 +919,7 @@
 
 		/* set new ones */
 		flags = gconf_value_get_int (value);
+		gconf_value_free (value);
 		brasero_burn_session_add_flag (priv->session, flags);
 
 		/* NOTE: of course NO_TMP is not possible; DAO and BLANK_BEFORE
@@ -964,8 +964,6 @@
 		gtk_widget_set_sensitive (priv->button, (result == BRASERO_BURN_OK));
 	}
 
-	g_object_unref (drive);
-
 	key = g_strdup_printf ("%s/tmpdir", BRASERO_DRIVE_PROPERTIES_KEY);
 	path = gconf_client_get_string (client, key, NULL);
 	brasero_burn_session_set_tmpdir (priv->session, path);
@@ -1208,8 +1206,6 @@
 		brasero_dest_selection_check_drive_settings (self, drive);
 	else
 		brasero_dest_selection_check_image_settings (self);
-
-	g_object_unref (drive);
 }
 
 static void
@@ -1237,6 +1233,11 @@
 	if (drive)
 		g_object_unref (drive);
 
+	if (!burner) {
+		brasero_dest_selection_set_drive_properties (self);
+		return;
+	}
+
 	if (!brasero_drive_is_fake (burner)) {
 		gint numcopies;
 
@@ -1408,7 +1409,9 @@
 
 		drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (object));
 		brasero_burn_session_set_burner (session, drive);
-		g_object_unref (drive);
+
+		if (drive)
+			g_object_unref (drive);
 
 		if (brasero_burn_session_same_src_dest_drive (priv->session))
 			brasero_drive_selection_set_same_src_dest (BRASERO_DRIVE_SELECTION (object));

Modified: trunk/src/brasero-disc-copy-dialog.c
==============================================================================
--- trunk/src/brasero-disc-copy-dialog.c	(original)
+++ trunk/src/brasero-disc-copy-dialog.c	Sat Mar  8 14:23:27 2008
@@ -101,6 +101,7 @@
 {
 	gboolean valid;
 	GtkWidget *button;
+	BraseroDrive *drive, *src_drive;
 	BraseroDiscCopyDialogPrivate *priv;
 
 	priv = BRASERO_DISC_COPY_DIALOG_PRIVATE (obj);
@@ -167,14 +168,10 @@
 						BRASERO_MEDIA_TYPE_REWRITABLE|
 						BRASERO_MEDIA_TYPE_FILE);
 
-	BraseroDrive *drive, *src_drive;
-
 	drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (priv->selection));
 	brasero_burn_session_set_burner (priv->session, drive);
-	g_print ("%p\n", drive);
 
 	src_drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (priv->source));
-	g_print ("%p\n", src_drive);
 
 	if (brasero_burn_session_same_src_dest_drive (priv->session)) {
 		BraseroMedia media;
@@ -202,6 +199,9 @@
 		g_object_unref (caps);
 	}
 
+	g_object_unref (src_drive);
+	g_object_unref (drive);
+
 	brasero_disc_copy_dialog_set_burn_button_state (obj, valid);
 }
 

Modified: trunk/src/brasero-disc-option-dialog.c
==============================================================================
--- trunk/src/brasero-disc-option-dialog.c	(original)
+++ trunk/src/brasero-disc-option-dialog.c	Sat Mar  8 14:23:27 2008
@@ -42,6 +42,7 @@
 #include "brasero-utils.h"
 #include "burn-basics.h"
 #include "burn-medium.h"
+#include "burn-volume-obj.h"
 #include "burn-session.h"
 #include "burn-caps.h"
 #include "burn-plugin-manager.h"
@@ -156,7 +157,7 @@
 
 		flags = brasero_burn_session_get_flags (priv->session);
 		if (flags & BRASERO_BURN_FLAG_MERGE)
-			title_str = brasero_drive_get_volume_label (drive);
+			title_str = brasero_volume_get_display_label (BRASERO_VOLUME (drive), FALSE);
 
 		if (!title_str || title_str [0] == '\0')
 			title_str = g_strdup_printf (_("Data disc (%s)"), buffer);

Modified: trunk/src/brasero-drive-info.c
==============================================================================
--- trunk/src/brasero-drive-info.c	(original)
+++ trunk/src/brasero-drive-info.c	Sat Mar  8 14:23:27 2008
@@ -45,8 +45,6 @@
 typedef struct _BraseroDriveInfoPrivate BraseroDriveInfoPrivate;
 struct _BraseroDriveInfoPrivate
 {
-	BraseroMedium *medium;
-
 	GtkWidget *notebook;
 	GtkWidget *image;
 
@@ -246,11 +244,6 @@
 
 	priv = BRASERO_DRIVE_INFO_PRIVATE (self);
 
-	if (priv->medium) {
-		g_object_ref (priv->medium);
-		priv->medium = NULL;
-	}
-
 	gtk_widget_hide (priv->warning);
 	if (medium && (brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE)) {
 		gtk_widget_show (priv->image_path);
@@ -351,10 +344,6 @@
 	BraseroDriveInfoPrivate *priv;
 
 	priv = BRASERO_DRIVE_INFO_PRIVATE (object);
-	if (priv->medium) {
-		g_object_unref (priv->medium);
-		priv->medium = NULL;
-	}
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }

Modified: trunk/src/brasero-drive-selection.c
==============================================================================
--- trunk/src/brasero-drive-selection.c	(original)
+++ trunk/src/brasero-drive-selection.c	Sat Mar  8 14:23:27 2008
@@ -74,6 +74,7 @@
 	priv = BRASERO_DRIVE_SELECTION_PRIVATE (self);
 
 	medium = brasero_medium_selection_get_active (BRASERO_MEDIUM_SELECTION (priv->selection));
+
 	if (medium)
 		drive = brasero_medium_get_drive (medium);
 	else
@@ -82,7 +83,6 @@
 	brasero_drive_info_set_medium (BRASERO_DRIVE_INFO (priv->info), medium);
 
 	if (priv->locked_drive && priv->locked_drive != drive) {
-	    	gtk_widget_set_sensitive (priv->selection, TRUE);
 		brasero_drive_unlock (priv->locked_drive);
 		g_object_unref (priv->locked_drive);
 		priv->locked_drive = NULL;
@@ -90,25 +90,39 @@
 
 	if (!drive) {
 	    	gtk_widget_set_sensitive (priv->selection, FALSE);
+	    	gtk_widget_set_sensitive (priv->info, FALSE);
+
 		g_signal_emit (self,
 			       brasero_drive_selection_signals [DRIVE_CHANGED_SIGNAL],
 			       0,
-			       drive);
+			       NULL);
+
+		if (medium)
+			g_object_unref (medium);
 		return;
 	}
 
+	gtk_widget_set_sensitive (priv->info, TRUE);
+
 	if (brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE) {
 		g_signal_emit (self,
 			       brasero_drive_selection_signals [DRIVE_CHANGED_SIGNAL],
 			       0,
 			       drive);
+		
+		if (medium)
+			g_object_unref (medium);
 		return;
 	}
 
+	gtk_widget_set_sensitive (priv->selection, (priv->locked_drive == NULL));
 	g_signal_emit (self,
 		       brasero_drive_selection_signals [DRIVE_CHANGED_SIGNAL],
 		       0,
 		       drive);
+
+	if (medium)
+		g_object_unref (medium);
 }
 
 void
@@ -169,6 +183,9 @@
 		return NULL;
 
 	drive = brasero_medium_get_drive (medium);
+	g_object_unref (medium);
+
+	g_object_ref (drive);
 	return drive;
 }
 
@@ -195,8 +212,8 @@
 		priv->locked_drive = drive;
 		if (priv->locked_drive)
 			brasero_drive_lock (priv->locked_drive,
-						  _("ongoing burning process"),
-						  NULL);
+					    _("ongoing burning process"),
+					    NULL);
 	}
 }
 

Modified: trunk/src/brasero-eject-dialog.c
==============================================================================
--- trunk/src/brasero-eject-dialog.c	(original)
+++ trunk/src/brasero-eject-dialog.c	Sat Mar  8 14:23:27 2008
@@ -34,7 +34,8 @@
 
 #include "brasero-eject-dialog.h"
 #include "brasero-tool-dialog.h"
-#include "burn-drive.h"
+#include "burn-medium.h"
+#include "burn-volume-obj.h"
 #include "burn-debug.h"
 #include "brasero-utils.h"
 #include "burn.h"
@@ -45,24 +46,19 @@
 brasero_eject_dialog_drive_changed (BraseroToolDialog *dialog,
 				    BraseroMedium *medium)
 {
-	brasero_tool_dialog_set_valid (dialog, BRASERO_MEDIUM_VALID (brasero_medium_get_status (medium)));
-}
-
-static gpointer
-_eject_async (gpointer data)
-{
-	BraseroDrive *drive = BRASERO_DRIVE (data);
-
-	brasero_drive_eject (drive);
-	g_object_unref (drive);
-
-	return NULL;
+	if (medium)
+		brasero_tool_dialog_set_valid (dialog, BRASERO_MEDIUM_VALID (brasero_medium_get_status (medium)));
+	else
+		brasero_tool_dialog_set_valid (dialog, FALSE);
 }
 
 static gboolean
 brasero_eject_dialog_activate (BraseroToolDialog *dialog,
 			       BraseroMedium *medium)
 {
+	BraseroDrive *drive;
+	GError *error = NULL;
+
 	/* In here we could also remove the lock held by any app (including 
 	 * brasero) through brasero_drive_unlock. We'd need a warning
 	 * dialog though which would identify why the lock is held and even
@@ -72,23 +68,21 @@
 	/* NOTE 2: we'd need also the ability to reset the drive through a SCSI
 	 * command. The problem is brasero may need to be privileged then as
 	 * cdrecord/cdrdao seem to be. */
-
-	GError *error = NULL;
-	BraseroDrive *drive;
-
-	BRASERO_BURN_LOG ("Asynchronous ejection");
-
 	drive = brasero_medium_get_drive (medium);
-	g_object_ref (drive);
-	g_thread_create (_eject_async, drive, FALSE, &error);
-	if (error) {
-		g_warning ("Could not create thread %s\n", error->message);
-		g_error_free (error);
+	BRASERO_BURN_LOG ("Asynchronous ejection of %s", brasero_drive_get_device (drive));
 
-		g_object_unref (drive);
-		g_object_ref (drive);
-	}
+	brasero_drive_unlock (drive);
 
+	/*if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))
+	&& !brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, &error)) {
+		BRASERO_BURN_LOG ("Error unlocking medium: %s", error?error->message:"Unknown error");
+		return TRUE;
+	}*/
+
+	if (!brasero_volume_eject (BRASERO_VOLUME (medium), TRUE, &error)) {
+		BRASERO_BURN_LOG ("Error ejecting medium: %s", error?error->message:"Unknown error");
+		return TRUE;
+	}
 
 	/* we'd need also to check what are the results of our operations namely
 	 * if we succeded to eject. To do that, the problem is the same as above
@@ -97,11 +91,24 @@
 	 * closed now as ejection is not instantaneous.
 	 * A message box announcing the results of the operation would be a good
 	 * thing as well probably. */
-	if (brasero_drive_is_door_open (drive)) {
+	if (!brasero_drive_is_door_open (drive)) {
 		//gtk_message_dialog_new ();
 	}
 	
-	return BRASERO_BURN_OK;
+	return TRUE;
+}
+
+static void
+brasero_eject_dialog_cancel (BraseroToolDialog *dialog)
+{
+	BraseroMedium *medium;
+
+	medium = brasero_tool_dialog_get_medium (dialog);
+
+	if (medium) {
+		brasero_volume_cancel_current_operation (BRASERO_VOLUME (medium));
+		g_object_unref (medium);
+	}
 }
 
 static void
@@ -110,16 +117,28 @@
 	BraseroToolDialogClass *tool_dialog_class = BRASERO_TOOL_DIALOG_CLASS (klass);
 
 	tool_dialog_class->activate = brasero_eject_dialog_activate;
+	tool_dialog_class->cancel = brasero_eject_dialog_cancel;
+
 	tool_dialog_class->drive_changed = brasero_eject_dialog_drive_changed;
 }
 
 static void
 brasero_eject_dialog_init (BraseroEjectDialog *obj)
 {
+	BraseroMedium *medium;
+
 	brasero_tool_dialog_set_button (BRASERO_TOOL_DIALOG (obj),
 					_("_Eject"),
 					NULL,
 					"media-eject");
+
+	medium = brasero_tool_dialog_get_medium (BRASERO_TOOL_DIALOG (obj));
+	if (medium) {
+		brasero_tool_dialog_set_valid (BRASERO_TOOL_DIALOG (obj), BRASERO_MEDIUM_VALID (brasero_medium_get_status (medium)));
+		g_object_unref (medium);
+	}
+	else
+		brasero_tool_dialog_set_valid (BRASERO_TOOL_DIALOG (obj), FALSE);
 }
 
 GtkWidget *

Modified: trunk/src/brasero-medium-selection.c
==============================================================================
--- trunk/src/brasero-medium-selection.c	(original)
+++ trunk/src/brasero-medium-selection.c	Sat Mar  8 14:23:27 2008
@@ -34,6 +34,7 @@
 
 #include "brasero-medium-selection.h"
 #include "burn-medium.h"
+#include "burn-volume-obj.h"
 #include "burn-basics.h"
 
 typedef struct _BraseroMediumSelectionPrivate BraseroMediumSelectionPrivate;
@@ -91,6 +92,7 @@
 				    -1);
 
 		if (medium == iter_medium) {
+			g_object_unref (iter_medium);
 			gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
 			g_signal_emit (self,
 				       medium_selection_signals [MEDIUM_CHANGED],
@@ -98,6 +100,7 @@
 			break;
 		}
 
+		g_object_unref (iter_medium);
 	} while (gtk_tree_model_iter_next (model, &iter));
 }
 
@@ -115,11 +118,6 @@
 	gtk_tree_model_get (model, &iter,
 			    MEDIUM_COL, &medium,
 			    -1);
-
-	if (!medium)
-		return NULL;
-
-	g_object_ref (medium);
 	return medium;
 }
 
@@ -146,6 +144,7 @@
 	if (gtk_tree_model_get_iter_first (model, &iter)) {
 		/* First filter */
 		do {
+			GSList *node;
 			BraseroMedium *medium;
 
 			gtk_tree_model_get (model, &iter,
@@ -159,15 +158,18 @@
 				break;
 			}
 
-			if (!g_slist_find (list, medium)) {
+			node = g_slist_find (list, medium);
+			g_object_unref (medium);
+
+			if (!node) {
 				if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
 					continue;
 
 				break;
 			}
 
-			list = g_slist_remove (list, medium);
-			g_object_unref (medium);
+			g_object_unref (node->data);
+			list = g_slist_delete_link (list, node);
 		} while (gtk_tree_model_iter_next (model, &iter));
 	}
 
@@ -180,7 +182,7 @@
 
 			medium = item->data;
 
-			medium_name = brasero_medium_get_label (medium, TRUE);
+			medium_name = brasero_volume_get_display_label (BRASERO_VOLUME (medium), TRUE);
 			medium_icon = brasero_medium_get_icon (medium);
 
 			gtk_list_store_append (GTK_LIST_STORE (model), &iter);
@@ -257,11 +259,13 @@
 		gtk_tree_model_get (model, &iter,
 				    MEDIUM_COL, &tmp,
 				    -1);
-		if (!medium)
+		if (!tmp)
 			gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+		else
+			g_object_unref (tmp);
 	}
 
-	medium_name = brasero_medium_get_label (medium, TRUE);
+	medium_name = brasero_volume_get_display_label (BRASERO_VOLUME (medium), TRUE);
 	medium_icon = brasero_medium_get_icon (medium);
 	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
 	gtk_list_store_set (GTK_LIST_STORE (model), &iter,
@@ -299,9 +303,12 @@
 				    -1);
 
 		if (medium == iter_medium) {
+			g_object_unref (iter_medium);
 			gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 			break;
 		}
+
+		g_object_unref (iter_medium);
 	} while (gtk_tree_model_iter_next (model, &iter));
 
 	if (!gtk_tree_model_get_iter_first (model, &iter)) {
@@ -355,6 +362,7 @@
 				    G_TYPE_STRING);
 
 	gtk_combo_box_set_model (GTK_COMBO_BOX (object), GTK_TREE_MODEL (model));
+	g_object_unref (model);
 
 /*	renderer = gtk_cell_renderer_pixbuf_new ();
 	g_object_set (renderer, "follow-state", TRUE, NULL);
@@ -383,8 +391,8 @@
 
 	g_signal_handler_disconnect (monitor, priv->added_sig);
 	g_signal_handler_disconnect (monitor, priv->removed_sig);
-	priv->added_sig = 0;
 	priv->removed_sig = 0;
+	priv->added_sig = 0;
 
 	g_object_unref (monitor);
 

Modified: trunk/src/brasero-project-size.c
==============================================================================
--- trunk/src/brasero-project-size.c	(original)
+++ trunk/src/brasero-project-size.c	Sat Mar  8 14:23:27 2008
@@ -38,7 +38,7 @@
 
 #include "brasero-project-size.h"
 #include "burn-caps.h"
-#include "burn-volume.h"
+#include "burn-volume-obj.h"
 #include "brasero-utils.h"
 #include "burn-medium-monitor.h"
 #include "burn-medium.h"
@@ -511,7 +511,7 @@
 		gchar *name;
 
 		/* this is a busy drive */
-		name = brasero_medium_get_label (drive->medium, FALSE);
+		name = brasero_volume_get_display_label (BRASERO_VOLUME (drive->medium), FALSE);
 		disc_sectors_str = g_strdup_printf (_("<i>%s</i> is busy"), name);
 		g_free (name);
 
@@ -522,7 +522,7 @@
 		gchar *name;
 
 		/* this is a drive probably not fully supported by brasero */
-		name = brasero_medium_get_label (drive->medium, FALSE);
+		name = brasero_volume_get_display_label (BRASERO_VOLUME (drive->medium), FALSE);
 		disc_sectors_str = g_strdup_printf (_("<i>%s</i> not properly supported"), name);
 		g_free (name);
 
@@ -533,7 +533,7 @@
 		gchar *name;
 
 		/* this is an unsupported medium */
-		name = brasero_medium_get_label (drive->medium, FALSE);
+		name = brasero_volume_get_display_label (BRASERO_VOLUME (drive->medium), FALSE);
 		disc_sectors_str = g_strdup_printf (_("The disc in <i>%s</i> is not supported"), name);
 		g_free (name);
 
@@ -548,7 +548,7 @@
 	if (drive->medium) {
 		/* we ellipsize to max characters to avoid having
 		 * a too long string with the drive full name. */
-		drive_name = brasero_medium_get_label (drive->medium, TRUE);
+		drive_name = brasero_volume_get_display_label (BRASERO_VOLUME (drive->medium), TRUE);
 /*		if (strlen (drive_name) > 19) {
 			gchar *tmp;
 
@@ -1070,7 +1070,7 @@
 		if (drive->medium) {
 			gchar *name;
 
-			name = brasero_medium_get_label (drive->medium, FALSE);
+			name = brasero_volume_get_display_label (BRASERO_VOLUME (drive->medium), FALSE);
 			label = g_strdup_printf ("%s %s", size_str, name);
 			g_free (name);
 		}
@@ -1602,30 +1602,26 @@
 	BraseroMediumMonitor *monitor;
 
 	monitor = brasero_medium_monitor_get_default ();
+	g_signal_connect (monitor,
+			  "medium-added",
+			  G_CALLBACK (brasero_project_size_disc_added_cb),
+			  self);
+	g_signal_connect (monitor,
+			  "medium-removed",
+			  G_CALLBACK (brasero_project_size_disc_removed_cb),
+			  self);
 	list = brasero_medium_monitor_get_media (monitor,
 						 BRASERO_MEDIA_TYPE_WRITABLE|
 						 BRASERO_MEDIA_TYPE_REWRITABLE);
 	g_object_unref (monitor);
 
 	for (iter = list; iter; iter = iter->next) {
-		BraseroMediumMonitor *monitor;
 		BraseroDriveSize *drive;
 
 		drive = g_new0 (BraseroDriveSize, 1);
 		drive->medium = iter->data;
 		self->priv->drives = g_list_prepend (self->priv->drives, drive);
 
-		/* add a callback if media changes */
-		monitor = brasero_medium_monitor_get_default ();
-		g_signal_connect (monitor,
-				  "medium-added",
-				  G_CALLBACK (brasero_project_size_disc_added_cb),
-				  self);
-		g_signal_connect (monitor,
-				  "medium-removed",
-				  G_CALLBACK (brasero_project_size_disc_removed_cb),
-				  self);
-
 		/* get all the information about the current media */
 		drive->media = brasero_medium_get_status (drive->medium);
 		if (!BRASERO_MEDIUM_VALID (drive->media))

Modified: trunk/src/brasero-sum-dialog.c
==============================================================================
--- trunk/src/brasero-sum-dialog.c	(original)
+++ trunk/src/brasero-sum-dialog.c	Sat Mar  8 14:23:27 2008
@@ -587,6 +587,16 @@
 }
 
 static void
+brasero_sum_dialog_drive_changed (BraseroToolDialog *dialog,
+				  BraseroMedium *medium)
+{
+	if (medium)
+		brasero_tool_dialog_set_valid (dialog, BRASERO_MEDIUM_VALID (brasero_medium_get_status (medium)));
+	else
+		brasero_tool_dialog_set_valid (dialog, FALSE);
+}
+
+static void
 brasero_sum_dialog_finalize (GObject *object)
 {
 	BraseroSumDialog *cobj;
@@ -614,12 +624,14 @@
 	object_class->finalize = brasero_sum_dialog_finalize;
 
 	tool_dialog_class->activate = brasero_sum_dialog_activate;
+	tool_dialog_class->drive_changed = brasero_sum_dialog_drive_changed;
 }
 
 static void
 brasero_sum_dialog_init (BraseroSumDialog *obj)
 {
 	GtkWidget *box;
+	BraseroMedium *medium;
 
 	obj->priv = g_new0 (BraseroSumDialogPrivate, 1);
 
@@ -659,6 +671,14 @@
 					_("_Check"),
 					GTK_STOCK_FIND,
 					NULL);
+
+	medium = brasero_tool_dialog_get_medium (BRASERO_TOOL_DIALOG (obj));
+	if (medium) {
+		brasero_tool_dialog_set_valid (BRASERO_TOOL_DIALOG (obj), BRASERO_MEDIUM_VALID (brasero_medium_get_status (medium)));
+		g_object_unref (medium);
+	}
+	else
+		brasero_tool_dialog_set_valid (BRASERO_TOOL_DIALOG (obj), FALSE);
 }
 
 GtkWidget *

Modified: trunk/src/brasero-tool-dialog.c
==============================================================================
--- trunk/src/brasero-tool-dialog.c	(original)
+++ trunk/src/brasero-tool-dialog.c	Sat Mar  8 14:23:27 2008
@@ -247,10 +247,11 @@
 		close = klass->activate (self, medium);
 	self->priv->running = FALSE;
 
-	g_object_unref (medium);
-
 	if (close || self->priv->close) {
 		gtk_widget_destroy (GTK_WIDGET (self));
+
+		if (medium)
+			g_object_unref (medium);
 		return;
 	}
 
@@ -262,6 +263,9 @@
 	gtk_widget_set_sensitive (self->priv->lower_box, FALSE);
 
 	brasero_burn_progress_reset (BRASERO_BURN_PROGRESS (self->priv->progress));
+
+	if (medium)
+		g_object_unref (medium);
 }
 
 static void
@@ -337,10 +341,13 @@
 
 static void
 brasero_tool_dialog_drive_changed_cb (BraseroDriveSelection *selection,
-				      BraseroMedium *medium,
+				      BraseroDrive *drive,
 				      BraseroToolDialog *self)
 {
 	BraseroToolDialogClass *klass;
+	BraseroMedium *medium;
+
+	medium = brasero_drive_get_medium (drive);
 
 	klass = BRASERO_TOOL_DIALOG_GET_CLASS (self);
 	if (klass->drive_changed)
@@ -390,6 +397,11 @@
 brasero_tool_dialog_cancel (BraseroToolDialog *self)
 {
 	BraseroBurnResult result = BRASERO_BURN_OK;
+	BraseroToolDialogClass *klass;
+
+	klass = BRASERO_TOOL_DIALOG_GET_CLASS (self);
+	if (klass->cancel)
+		klass->cancel (self);
 
 	if (self->priv->burn)
 		result = brasero_burn_cancel (self->priv->burn, TRUE);
@@ -463,12 +475,14 @@
 
 	/* upper part */
 	obj->priv->upper_box = gtk_vbox_new (FALSE, 0);
+	gtk_widget_show (GTK_WIDGET (obj->priv->upper_box));
 	obj->priv->selector = brasero_drive_selection_new ();
+	gtk_widget_show (GTK_WIDGET (obj->priv->selector));
 	gtk_widget_set_tooltip_text (obj->priv->selector,
-				     _("Choose the drive that holds the media"));
+				     _("Choose a media"));
 
 	gtk_box_pack_start (GTK_BOX (obj->priv->upper_box),
-			    brasero_utils_pack_properties (_("<b>Select a recorder:</b>"),
+			    brasero_utils_pack_properties (_("<b>Select a disc</b>"),
 							   obj->priv->selector,
 							   NULL),
 			    FALSE, FALSE, 0);
@@ -477,14 +491,11 @@
 						BRASERO_MEDIA_TYPE_REWRITABLE|
 						BRASERO_MEDIA_TYPE_READABLE);
 
-	gtk_widget_show_all (GTK_WIDGET (obj->priv->upper_box));
-
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (obj)->vbox),
 			    obj->priv->upper_box,
 			    FALSE,
 			    FALSE,
 			    0);
-	gtk_widget_show_all (GTK_WIDGET (obj->priv->upper_box));
 
 	/* lower part */
 	obj->priv->lower_box = gtk_vbox_new (FALSE, 0);

Modified: trunk/src/brasero-tool-dialog.h
==============================================================================
--- trunk/src/brasero-tool-dialog.h	(original)
+++ trunk/src/brasero-tool-dialog.h	Sat Mar  8 14:23:27 2008
@@ -59,6 +59,7 @@
 
 	gboolean	(*activate)		(BraseroToolDialog *dialog,
 						 BraseroMedium *medium);
+	void		(*cancel)		(BraseroToolDialog *dialog);
 	void		(*drive_changed)	(BraseroToolDialog *dialog,
 						 BraseroMedium *medium);
 };

Modified: trunk/src/brasero-utils.c
==============================================================================
--- trunk/src/brasero-utils.c	(original)
+++ trunk/src/brasero-utils.c	Sat Mar  8 14:23:27 2008
@@ -287,7 +287,7 @@
 	int minute = 0;
 	gint64 time = 0.0;
 
-	time = NAUTILUS_BURN_DRIVE_SIZE_TO_TIME (size);
+	time = BRASERO_BYTES_TO_DURATION (size);
 	minute = time / 60;
 	if (!round)
 		second = time % 60;

Modified: trunk/src/burn-basics.c
==============================================================================
--- trunk/src/burn-basics.c	(original)
+++ trunk/src/burn-basics.c	Sat Mar  8 14:23:27 2008
@@ -108,6 +108,7 @@
 		g_object_unref (plugin_manager);
 		plugin_manager = NULL;
 	}
+
 	if (medium_manager) {
 		g_object_unref (medium_manager);
 		medium_manager = NULL;

Modified: trunk/src/burn-dbus.c
==============================================================================
--- trunk/src/burn-dbus.c	(original)
+++ trunk/src/burn-dbus.c	Sat Mar  8 14:23:27 2008
@@ -15,7 +15,7 @@
 void 
 brasero_uninhibit_suspend (guint cookie)
 {
-  	DBusGProxy	*proxy;
+	DBusGProxy	*proxy;
 	gboolean	res;
 	GError		*error = NULL;
 	DBusGConnection *conn	= NULL;

Modified: trunk/src/burn-drive.c
==============================================================================
--- trunk/src/burn-drive.c	(original)
+++ trunk/src/burn-drive.c	Sat Mar  8 14:23:27 2008
@@ -33,19 +33,22 @@
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
 
+#include <libhal.h>
 #include <gio/gio.h>
 
-#include <nautilus-burn-drive-monitor.h>
-
 #include "burn-basics.h"
 #include "burn-medium.h"
 #include "burn-drive.h"
 
+#include "scsi-mmc1.h"
+
 typedef struct _BraseroDrivePrivate BraseroDrivePrivate;
 struct _BraseroDrivePrivate
 {
 	BraseroMedium *medium;
-	NautilusBurnDrive *ndrive;
+	BraseroDriveCaps caps;
+	gchar *path;
+	gchar *udi;
 };
 
 #define BRASERO_DRIVE_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DRIVE, BraseroDrivePrivate))
@@ -59,513 +62,154 @@
 
 enum {
 	PROP_NONE	= 0,
-	PROP_DRIVE
+	PROP_DEVICE,
+	PROP_UDI
 };
 
 G_DEFINE_TYPE (BraseroDrive, brasero_drive, G_TYPE_OBJECT);
 
+static LibHalContext *hal_context = NULL;
+
 gboolean
-brasero_drive_eject (BraseroDrive *drive)
+brasero_drive_is_fake (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
 
-	priv = BRASERO_DRIVE_PRIVATE (drive);
-	return nautilus_burn_drive_eject (priv->ndrive);
-}
-
-typedef struct {
-	gboolean    timeout;
-	gboolean    command_ok;
-	guint       timeout_tag;
-	GMainLoop  *loop;
-	GPtrArray  *argv;
-	GError     *error;
-} CommandData;
-
-static void
-free_command_data (CommandData *unmount_data)
-{
-	g_ptr_array_add (unmount_data->argv, NULL);
-	g_strfreev ((gchar**) unmount_data->argv->pdata);
-	g_ptr_array_free (unmount_data->argv, FALSE);
-
-	g_free (unmount_data);
-}
-
-static gboolean
-command_done (gpointer data)
-{
-	CommandData *unmount_data;
-	unmount_data = data;
-
-	if (unmount_data->timeout_tag != 0) {
-		g_source_remove (unmount_data->timeout_tag);
-	}
-
-	if (unmount_data->loop != NULL &&
-	    g_main_loop_is_running (unmount_data->loop)) {
-		g_main_loop_quit (unmount_data->loop);
-	}
-
-	if (unmount_data->timeout) {
-		/* We timed out, so unmount_data wasn't freed
-		   at mainloop exit. */
-		free_command_data (unmount_data);
-	}
-
-	return FALSE;
-}
-
-static gboolean
-command_timeout (gpointer data)
-{
-	CommandData *unmount_data;
-	unmount_data = data;
-
-	/* We're sure, the callback hasn't been run, so just say
-	   we were interrupted and return from the mainloop */
-
-	unmount_data->command_ok = FALSE;
-	unmount_data->timeout_tag = 0;
-	unmount_data->timeout = TRUE;
-
-	if (g_main_loop_is_running (unmount_data->loop)) {
-		g_main_loop_quit (unmount_data->loop);
-	}
-
-	return FALSE;
-}
-
-/* Returns the full command */
-static const gchar *locations [] = {
-	"/bin",
-	"/sbin",
-	"/usr/sbin",
-	NULL
-};
-
-static gchar *
-try_hidden_locations (const gchar *name) {
-	int i;
-
-	for (i = 0; locations [i]; i++) {
-		gchar *path;
-
-		path = g_build_path (G_DIR_SEPARATOR_S,
-				     locations [i],
-				     name,
-				     NULL);
-		if (g_file_test (path, G_FILE_TEST_EXISTS))
-			return path;
-
-		g_free (path);
-	}
-
-	return NULL;
+	priv = BRASERO_DRIVE_PRIVATE (self);
+	return (priv->path == NULL);
 }
 
-static gboolean
-create_command (const gchar *device,
-		GPtrArray *argv,
-		gboolean mount)
+static LibHalContext *
+brasero_drive_get_hal_context (void)
 {
-	gchar *gnome_mount_path;
-	gchar *pmount_path;
-	gchar *str;
-
-	/* try to see if gnome-mount is available */
-	gnome_mount_path = g_find_program_in_path ("gnome-mount");
-	if (gnome_mount_path) {
-		g_ptr_array_add (argv, gnome_mount_path);
-		str = g_strdup_printf ("--device=%s", device);
-		g_ptr_array_add (argv, str);
-
-		if (!mount) {
-			str = g_strdup ("--unmount");
-			g_ptr_array_add (argv, str);
-		}
+	DBusError error;
+	DBusConnection *dbus_connection;
 
-		str = g_strdup ("--no-ui");
-		g_ptr_array_add (argv, str);
+	if (hal_context)
+		return hal_context;
 
-		str = g_strdup ("-t");
-		g_ptr_array_add (argv, str);
-
-		g_ptr_array_add (argv, NULL);
-		return TRUE;
-	}
-
-	/* see if pmount or pumount are on the file system (used by ubuntu) */
-	if (mount)
-		pmount_path = g_find_program_in_path ("pmount");
-	else
-		pmount_path = g_find_program_in_path ("pumount");
-
-	if (pmount_path) {
-		g_ptr_array_add (argv, pmount_path);
-		g_ptr_array_add (argv, g_strdup (device));
-	}
-	else if (!mount) {
-		/* try to use traditional ways */
-		str = g_find_program_in_path ("umount");
-
-		if (!str)
-			str = try_hidden_locations ("umount");
-
-		if (!str) {
-			g_ptr_array_add (argv, NULL);
-			g_strfreev ((gchar**) argv->pdata);
-			g_ptr_array_free (argv, FALSE);
-			return FALSE;
-		}
-
-		g_ptr_array_add (argv, str);
-		g_ptr_array_add (argv, g_strdup (device));
+	hal_context = libhal_ctx_new ();
+	if (hal_context == NULL) {
+		g_warning ("Cannot initialize hal library.");
+		goto error;
 	}
-	else {
-		/* try to use traditional ways */
-		str = g_find_program_in_path ("mount");
-
-		if (!str)
-			str = try_hidden_locations ("mount");
-
-		if (!str) {
-			g_ptr_array_add (argv, NULL);
-			g_strfreev ((gchar**) argv->pdata);
-			g_ptr_array_free (argv, FALSE);
-			return FALSE;
-		}
 
-		g_ptr_array_add (argv, str);
-		g_ptr_array_add (argv, g_strdup (device));
+	dbus_error_init (&error);
+	dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (dbus_error_is_set (&error)) {
+		g_warning ("Cannot connect to DBus %s.", error.message);
+		dbus_error_free (&error);
+		goto error;
 	}
 
-	g_ptr_array_add (argv, NULL);
-
-	return TRUE;
-}
-
-static void *
-command_thread_start (void *arg)
-{
-	GError      *error;
-	CommandData *data;
-	gint         exit_status;
-
-	data = arg;
-
-	data->command_ok = TRUE;
-
-	error = NULL;
-	if (g_spawn_sync (NULL,
-			  (char **) data->argv->pdata,
-			  NULL,
-			  0,
-			  NULL, NULL,
-			  NULL,
-			  NULL,
-			  &exit_status,
-			  &error)) {
-		if (exit_status == 0) {
-			data->command_ok = TRUE;
-		} else {
-			data->command_ok = FALSE;
-		}
-
-		/* Delay a bit to make sure unmount finishes */
-		sleep (2);
-	} else {
-		/* spawn failure */
-		if (error)
-			g_propagate_error (&data->error, error);
-
-		data->command_ok = FALSE;
+	libhal_ctx_set_dbus_connection (hal_context, dbus_connection);
+	if (libhal_ctx_init (hal_context, &error) == FALSE) {
+		g_warning ("Failed to initialize hal : %s", error.message);
+		dbus_error_free (&error);
+		goto error;
 	}
 
-	g_idle_add (command_done, data);
-
-	g_thread_exit (NULL);
+	return hal_context;
 
+error:
+	libhal_ctx_shutdown (hal_context, NULL);
+	libhal_ctx_free (hal_context);
+	hal_context = NULL;
 	return NULL;
 }
 
-static gboolean
-launch_command (NautilusBurnDrive *drive,
-		gboolean mount,
-		GError **error)
-{
-	GPtrArray *argv;
-	CommandData *data;
-	gboolean command_ok;
-	const gchar *device;
-
-	g_return_val_if_fail (drive != NULL, FALSE);
-
-	/* fetches the device for the drive */
-	device = nautilus_burn_drive_get_device (drive);
-	if (device == NULL)
-		return FALSE;
-
-	/* create the appropriate command */
-	argv = g_ptr_array_new ();
-	if (!create_command (device, argv, mount)) {
-		g_set_error (error,
-			     G_SPAWN_ERROR,
-			     G_SPAWN_ERROR_NOENT,
-			     _("(u)mount command could not be found in the path"));
-		return FALSE;
-	}
-
-	command_ok = FALSE;
-
-	data = g_new0 (CommandData, 1);
-	data->loop = g_main_loop_new (NULL, FALSE);
-	data->argv = argv;
-	data->timeout_tag = g_timeout_add (5 * 1000, command_timeout, data);
-
-	g_thread_create (command_thread_start,
-			 data,
-			 FALSE,
-			 NULL);
-
-	g_main_loop_run (data->loop);
-	g_main_loop_unref (data->loop);
-	data->loop = NULL;
-
-	/* WORKAROUND: on my system (fedora 6/7) gnome-mount manages to unmount
-	 * a volume but returns an error since it can't remove the mount point
-	 * directory. So to avoid that (after all we don't care about this kind
-	 * of error since in the end the volume gets unmounted) we only error
-	 * out if the volume wasn't unmounted (which makes it our only criterium
-	 * for success/failure) */
-	if (mount != nautilus_burn_drive_is_mounted (drive)) {
-		command_ok = FALSE;
-
-		if (data->error)
-			g_propagate_error (error, data->error);
-		else
-			g_set_error (error,
-				     BRASERO_BURN_ERROR,
-				     BRASERO_BURN_ERROR_GENERAL,
-				     _("the drive could not be mounted"));
-	}
-	else
-		command_ok = TRUE;
-
-	/* Don't free data if mount operation still running. */
-	if (!data->timeout)
-		free_command_data (data);
-
-	return command_ok;
-}
-
 gboolean
-brasero_drive_mount (BraseroDrive *drive, GError **error)
+brasero_drive_is_door_open (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
+	BraseroDeviceHandle *handle;
+	BraseroScsiMechStatusHdr hdr;
 
-	priv = BRASERO_DRIVE_PRIVATE (drive);
+	priv = BRASERO_DRIVE_PRIVATE (self);
 
-	return launch_command (priv->ndrive, TRUE, error);
-}
+	handle = brasero_device_handle_open (priv->path, NULL);
+	if (!handle)
+		return FALSE;
 
-gboolean
-brasero_drive_unmount (BraseroDrive *drive, GError **error)
-{
-	BraseroDrivePrivate *priv;
+	brasero_mmc1_mech_status (handle,
+				  &hdr,
+				  NULL);
 
-	priv = BRASERO_DRIVE_PRIVATE (drive);
+	brasero_device_handle_close (handle);
 
-	return launch_command (priv->ndrive, FALSE, error);
+	return hdr.door_open;
 }
 
 gboolean
-brasero_drive_unmount_wait (BraseroDrive *self)
+brasero_drive_lock (BraseroDrive *self,
+		    const gchar *reason,
+		    gchar **reason_for_failure)
 {
 	BraseroDrivePrivate *priv;
+	LibHalContext *ctx;
+	DBusError error;
+	gboolean result;
+	gchar *failure;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
 
-	return nautilus_burn_drive_unmount (priv->ndrive);
-}
-
-static GDrive *
-brasero_drive_get_gdrive (BraseroDrive *drive)
-{
-	BraseroDrivePrivate *priv;
-	GVolumeMonitor *monitor;
-	GList *drives;
-	GList *iter;
-
-	priv = BRASERO_DRIVE_PRIVATE (drive);
+	ctx = brasero_drive_get_hal_context ();
 
-	monitor = g_volume_monitor_get ();
-	drives = g_volume_monitor_get_connected_drives (monitor);
-	for (iter = drives; iter; iter = iter->next) {
-		GDrive *vfs_drive;
-		GList *vol_iter;
-		GList *volumes;
-
-		vfs_drive = iter->data;
-		if (!g_drive_has_media (vfs_drive))
-			continue;
-
-		/* FIXME: try to see if we can get the identifier for drive */
-		volumes = g_drive_get_volumes (vfs_drive);
-		for (vol_iter = volumes; vol_iter; vol_iter = vol_iter->next) {
-			GVolume *volume;
-			gchar *device_path;
-
-			volume = vol_iter->data;
-			device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
-			if (!strcmp (device_path, nautilus_burn_drive_get_device (priv->ndrive))) {
-
-				g_object_ref (vfs_drive);
-
-				g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
-				g_list_free (volumes);
-
-				g_list_foreach (drives, (GFunc) g_object_unref, NULL);
-				g_list_free (drives);
-
-				g_free (device_path);
-				return vfs_drive;
-			}
-			g_free (device_path);
-		}
-		g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
-		g_list_free (volumes);
-	}
-	g_list_foreach (drives, (GFunc) g_object_unref, NULL);
-	g_list_free (drives);
-
-	return NULL;
-}
+	dbus_error_init (&error);
+	result = libhal_device_lock (ctx,
+				     priv->udi,
+				     reason,
+				     &failure,
+				     &error);
 
-gchar *
-brasero_drive_get_mount_point (BraseroDrive *drive,
-			       GError **error)
-{
-	gchar *mount_point = NULL;
-	gchar *local_path = NULL;
-	GDrive *vfsdrive = NULL;
-	GList *iter, *volumes;
-
-	/* get the uri for the mount point */
-	vfsdrive = brasero_drive_get_gdrive (drive);
-	volumes = g_drive_get_volumes (vfsdrive);
-	g_object_unref (vfsdrive);
-
-	for (iter = volumes; iter; iter = iter->next) {
-		GVolume *volume;
-		GMount *mount;
-		GFile *root;
-
-		volume = iter->data;
-
-		mount = g_volume_get_mount (volume);
-		if (!mount)
-			continue;
-
-		root = g_mount_get_root (mount);
-		g_object_unref (mount);
-
-		mount_point = g_file_get_uri (root);
-		g_object_unref (root);
-
-		if (mount_point)
-			break;
-	}
-	g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
-	g_list_free (volumes);
-
-	if (!mount_point || strncmp (mount_point, "file://", 7)) {
-		/* mount point won't be usable */
-		if (mount_point) {
-			g_free (mount_point);
-			mount_point = NULL;
-		}
-
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_GENERAL,
-			     _("the disc mount point could not be retrieved."));
-	}
-	else {
-		gchar *tmp;
-
-		local_path = g_filename_from_uri (mount_point, NULL, NULL);
-		tmp = local_path;
-		local_path = g_strdup (local_path);
-		g_free (tmp);
-		
-		g_free (mount_point);
-	}
+	if (dbus_error_is_set (&error))
+		dbus_error_free (&error);
 
-	return local_path;
-}
+	if (reason_for_failure)
+		*reason_for_failure = g_strdup (failure);
 
-gboolean
-brasero_drive_is_mounted (BraseroDrive *self)
-{
-	BraseroDrivePrivate *priv;
+	if (failure)
+		dbus_free (failure);
 
-	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_is_mounted (priv->ndrive);
+	return result;
 }
 
 gboolean
-brasero_drive_is_door_open (BraseroDrive *self)
+brasero_drive_unlock (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
+	LibHalContext *ctx;
+	DBusError error;
+	gboolean result;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_door_is_open (priv->ndrive);	
-}
 
-gboolean
-brasero_drive_lock (BraseroDrive *self,
-		    const gchar *reason,
-		    gchar **reason_for_failure)
-{
-	BraseroDrivePrivate *priv;
+	ctx = brasero_drive_get_hal_context ();
 
-	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_lock (priv->ndrive, reason, reason_for_failure);
-}
+	dbus_error_init (&error);
+	result = libhal_device_unlock (ctx,
+				       priv->udi,
+				       &error);
 
-gboolean
-brasero_drive_unlock (BraseroDrive *self)
-{
-	BraseroDrivePrivate *priv;
+	if (dbus_error_is_set (&error))
+		dbus_error_free (&error);
 
-	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_unlock (priv->ndrive);
+	return result;
 }
 
 gchar *
 brasero_drive_get_display_name (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
+	LibHalContext *ctx;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_get_name_for_display (priv->ndrive);
-}
-
-gchar *
-brasero_drive_get_volume_label (BraseroDrive *self)
-{
-	BraseroDrivePrivate *priv;
-	gchar *label;
 
-	priv = BRASERO_DRIVE_PRIVATE (self);
-	label = nautilus_burn_drive_get_media_label (priv->ndrive);
-	if (label && label [0] == '\0') {
-		g_free (label);
-		return NULL;
-	}
-
-	return label;
+	ctx = brasero_drive_get_hal_context ();
+	return libhal_device_get_property_string (ctx,
+						  priv->udi,
+						  "storage.model",
+						  NULL);
 }
 
 const gchar *
@@ -574,11 +218,11 @@
 	BraseroDrivePrivate *priv;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_get_device (priv->ndrive);
+	return priv->path;
 }
 
-BraseroMedium *
-brasero_drive_get_medium (BraseroDrive *self)
+const gchar *
+brasero_drive_get_udi (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
 
@@ -586,11 +230,11 @@
 		return NULL;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
-	return priv->medium;
+	return priv->udi;
 }
 
-NautilusBurnDrive *
-brasero_drive_get_nautilus_drive (BraseroDrive *self)
+BraseroMedium *
+brasero_drive_get_medium (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
 
@@ -598,7 +242,7 @@
 		return NULL;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
-	return priv->ndrive;
+	return priv->medium;
 }
 
 void
@@ -626,35 +270,17 @@
 		g_signal_emit (self,
 			       drive_signals [MEDIUM_INSERTED],
 			       0,
-			       priv->medium);
+			       medium);
 	}
 }
 
-gboolean
-brasero_drive_can_write (BraseroDrive *self)
-{
-	BraseroDrivePrivate *priv;
-
-	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_can_write (priv->ndrive);
-}
-
-gboolean
-brasero_drive_can_rewrite (BraseroDrive *self)
+BraseroDriveCaps
+brasero_drive_get_caps (BraseroDrive *self)
 {
 	BraseroDrivePrivate *priv;
 
 	priv = BRASERO_DRIVE_PRIVATE (self);
-	return nautilus_burn_drive_can_rewrite (priv->ndrive);
-}
-
-gboolean
-brasero_drive_is_fake (BraseroDrive *self)
-{
-	BraseroDrivePrivate *priv;
-
-	priv = BRASERO_DRIVE_PRIVATE (self);
-	return (nautilus_burn_drive_get_drive_type (priv->ndrive) == NAUTILUS_BURN_DRIVE_TYPE_FILE);
+	return priv->caps;
 }
 
 static void
@@ -667,10 +293,14 @@
 	BraseroDrivePrivate *priv;
 
 	priv = BRASERO_DRIVE_PRIVATE (object);
+	if (priv->path) {
+		g_free (priv->path);
+		priv->path = NULL;
+	}
 
-	if (priv->ndrive) {
-		g_object_unref (priv->ndrive);
-		priv->ndrive = NULL;
+	if (priv->udi) {
+		g_free (priv->udi);
+		priv->udi = NULL;
 	}
 
 	if (priv->medium) {
@@ -682,7 +312,44 @@
 }
 
 static void
-brasero_drive_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+brasero_drive_init_real (BraseroDrive *drive)
+{
+	BraseroDrivePrivate *priv;
+	LibHalContext *ctx;
+
+	priv = BRASERO_DRIVE_PRIVATE (drive);
+
+	ctx = brasero_drive_get_hal_context ();
+
+	priv->path = libhal_device_get_property_string (ctx, priv->udi, "block.device", NULL);
+	if (priv->path [0] == '\0') {
+		g_free (priv->path);
+		priv->path = NULL;
+	}
+
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.cdr", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_CDR;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.cdrw", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_CDRW;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.dvdr", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_DVDR;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.dvdrw", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_DVDRW;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.dvdplusr", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_DVDR_PLUS;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.dvdplusrw", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_DVDRW_PLUS;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.dvdplusrdl", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_DVDR_PLUS_DL;
+	if (libhal_device_get_property_bool (ctx, priv->udi, "storage.cdrom.dvdplusrwdl", NULL))
+		priv->caps |= BRASERO_DRIVE_CAPS_DVDRW_PLUS_DL;
+}
+
+static void
+brasero_drive_set_property (GObject *object,
+			    guint prop_id,
+			    const GValue *value,
+			    GParamSpec *pspec)
 {
 	BraseroDrivePrivate *priv;
 
@@ -692,9 +359,10 @@
 
 	switch (prop_id)
 	{
-	case PROP_DRIVE:
-		priv->ndrive = g_value_get_object (value);
-		g_object_ref (priv->ndrive);
+	case PROP_UDI:
+		priv->udi = g_strdup (g_value_get_string (value));
+		if (priv->udi)
+			brasero_drive_init_real (BRASERO_DRIVE (object));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -703,7 +371,10 @@
 }
 
 static void
-brasero_drive_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+brasero_drive_get_property (GObject *object,
+			    guint prop_id,
+			    GValue *value,
+			    GParamSpec *pspec)
 {
 	BraseroDrivePrivate *priv;
 
@@ -713,9 +384,8 @@
 
 	switch (prop_id)
 	{
-	case PROP_DRIVE:
-		g_object_ref (priv->ndrive);
-		g_value_set_object (value, priv->ndrive);
+	case PROP_UDI:
+		g_value_set_string (value, g_strdup (priv->udi));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -747,7 +417,7 @@
 	drive_signals[MEDIUM_REMOVED] =
 		g_signal_new ("medium_removed",
 		              G_OBJECT_CLASS_TYPE (klass),
-		              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION,
+		              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 		              0,
 		              NULL, NULL,
 		              g_cclosure_marshal_VOID__OBJECT,
@@ -755,18 +425,18 @@
 		              BRASERO_TYPE_MEDIUM);
 
 	g_object_class_install_property (object_class,
-	                                 PROP_DRIVE,
-	                                 g_param_spec_object ("drive",
-	                                                      "drive",
-	                                                      "drive in which medium is inserted",
-	                                                      NAUTILUS_BURN_TYPE_DRIVE,
+	                                 PROP_UDI,
+	                                 g_param_spec_string("udi",
+	                                                      "udi",
+	                                                      "HAL udi",
+	                                                      NULL,
 	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 BraseroDrive *
-brasero_drive_new (NautilusBurnDrive *drive)
+brasero_drive_new (const gchar *udi)
 {
 	return g_object_new (BRASERO_TYPE_DRIVE,
-			     "drive", drive,
+			     "udi", udi,
 			     NULL);
 }

Modified: trunk/src/burn-drive.h
==============================================================================
--- trunk/src/burn-drive.h	(original)
+++ trunk/src/burn-drive.h	Sat Mar  8 14:23:27 2008
@@ -24,8 +24,6 @@
 
 #include <glib-object.h>
 
-#include <nautilus-burn-drive.h>
-
 #ifndef _BURN_DRIVE_H_
 #define _BURN_DRIVE_H_
 
@@ -33,6 +31,21 @@
 
 G_BEGIN_DECLS
 
+typedef enum {
+	BRASERO_DRIVE_CAPS_NONE			= 0,
+	BRASERO_DRIVE_CAPS_CDR			= 1,
+	BRASERO_DRIVE_CAPS_CDRW			= 1 << 1,
+	BRASERO_DRIVE_CAPS_DVDR			= 1 << 2,
+	BRASERO_DRIVE_CAPS_DVDRW		= 1 << 3,
+	BRASERO_DRIVE_CAPS_DVDR_PLUS		= 1 << 4,
+	BRASERO_DRIVE_CAPS_DVDRW_PLUS		= 1 << 5,
+	BRASERO_DRIVE_CAPS_DVDR_PLUS_DL		= 1 << 6,
+	BRASERO_DRIVE_CAPS_DVDRW_PLUS_DL	= 1 << 7,
+	BRASERO_DRIVE_CAPS_DVDRAM		= 1 << 9,
+	BRASERO_DRIVE_CAPS_BDR			= 1 << 8,
+	BRASERO_DRIVE_CAPS_BDRW			= 1 << 9
+} BraseroDriveCaps;
+
 #define BRASERO_TYPE_DRIVE             (brasero_drive_get_type ())
 #define BRASERO_DRIVE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_DRIVE, BraseroDrive))
 #define BRASERO_DRIVE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_DRIVE, BraseroDriveClass))
@@ -55,10 +68,7 @@
 GType brasero_drive_get_type (void) G_GNUC_CONST;
 
 BraseroDrive *
-brasero_drive_new (NautilusBurnDrive *drive);
-
-NautilusBurnDrive *
-brasero_drive_get_nautilus_drive (BraseroDrive *drive);
+brasero_drive_new (const gchar *udi);
 
 void
 brasero_drive_set_medium (BraseroDrive *drive,
@@ -67,54 +77,30 @@
 BraseroMedium *
 brasero_drive_get_medium (BraseroDrive *drive);
 
-gboolean
-brasero_drive_is_fake (BraseroDrive *self);
-
-gchar *
-brasero_drive_get_display_name (BraseroDrive *self);
-
-gchar *
-brasero_drive_get_volume_label (BraseroDrive *self);
-
 const gchar *
-brasero_drive_get_device (BraseroDrive *self);
-
-gboolean
-brasero_drive_can_write (BraseroDrive *self);
+brasero_drive_get_udi (BraseroDrive *drive);
 
 gboolean
-brasero_drive_can_rewrite (BraseroDrive *self);
+brasero_drive_is_fake (BraseroDrive *drive);
 
-gboolean
-brasero_drive_eject (BraseroDrive *drive);
-
-gboolean
-brasero_drive_mount (BraseroDrive *drive,
-		     GError **error);
-
-gboolean
-brasero_drive_unmount (BraseroDrive *drive,
-		       GError **error);
+gchar *
+brasero_drive_get_display_name (BraseroDrive *drive);
 
-gboolean
-brasero_drive_unmount_wait (BraseroDrive *drive);
+const gchar *
+brasero_drive_get_device (BraseroDrive *drive);
 
-gboolean
-brasero_drive_is_mounted (BraseroDrive *self);
+BraseroDriveCaps
+brasero_drive_get_caps (BraseroDrive *drive);
 
 gboolean
-brasero_drive_is_door_open (BraseroDrive *self);
-
-gchar *
-brasero_drive_get_mount_point (BraseroDrive *drive,
-			       GError **error);
+brasero_drive_is_door_open (BraseroDrive *drive);
 
 gboolean
-brasero_drive_lock (BraseroDrive *self,
+brasero_drive_lock (BraseroDrive *drive,
 		    const gchar *reason,
 		    gchar **reason_for_failure);
 gboolean
-brasero_drive_unlock (BraseroDrive *self);
+brasero_drive_unlock (BraseroDrive *drive);
 
 G_END_DECLS
 

Modified: trunk/src/burn-job.c
==============================================================================
--- trunk/src/burn-job.c	(original)
+++ trunk/src/burn-job.c	Sat Mar  8 14:23:27 2008
@@ -1448,9 +1448,9 @@
 	rate = brasero_medium_get_max_write_speed (medium);
 	media = brasero_medium_get_status (medium);
 	if (media & BRASERO_MEDIUM_DVD)
-		*speed = NAUTILUS_BURN_DRIVE_DVD_SPEED (rate);
+		*speed = BRASERO_RATE_TO_SPEED_DVD (rate);
 	else 
-		*speed = NAUTILUS_BURN_DRIVE_CD_SPEED (rate);
+		*speed = BRASERO_RATE_TO_SPEED_CD (rate);
 
 	return BRASERO_BURN_OK;
 }

Modified: trunk/src/burn-medium-monitor.c
==============================================================================
--- trunk/src/burn-medium-monitor.c	(original)
+++ trunk/src/burn-medium-monitor.c	Sat Mar  8 14:23:27 2008
@@ -25,15 +25,23 @@
 #  include <config.h>
 #endif
 
+#include <string.h>
+
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
-#include <nautilus-burn-init.h>
-#include <nautilus-burn-drive-monitor.h>
+#include <gio/gio.h>
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <libhal.h>
 
 #include "burn-drive.h"
 
 #include "burn-medium.h"
+#include "burn-volume-obj.h"
 #include "burn-medium-monitor.h"
 
 typedef struct _BraseroMediumMonitorPrivate BraseroMediumMonitorPrivate;
@@ -42,7 +50,8 @@
 	GSList *media;
 	GSList *drives;
 
-	NautilusBurnDriveMonitor *monitor;
+	LibHalContext *ctx;
+	GVolumeMonitor *gmonitor;
 };
 
 #define BRASERO_MEDIUM_MONITOR_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_MEDIUM_MONITOR, BraseroMediumMonitorPrivate))
@@ -111,38 +120,62 @@
 }
 
 static void
-brasero_medium_monitor_inserted_cb (NautilusBurnDriveMonitor *monitor,
-				    NautilusBurnDrive *ndrive,
-				    BraseroMediumMonitor *self)
+brasero_medium_monitor_drive_inserted (LibHalContext *ctx,
+				       const gchar *udi)
 {
 	BraseroMediumMonitorPrivate *priv;
+	BraseroMediumMonitor *self;
+	BraseroDrive *drive = NULL;
+
+	self = libhal_ctx_get_user_data (ctx);
+	priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
+
+	drive = brasero_drive_new (udi);
+	priv->drives = g_slist_prepend (priv->drives, drive);
+}
+
+static void
+brasero_medium_monitor_medium_inserted (LibHalContext *ctx,
+					const gchar *udi)
+{
+	BraseroMediumMonitorPrivate *priv;
+	BraseroMediumMonitor *self;
 	BraseroDrive *drive = NULL;
 	BraseroMedium *medium;
+	gchar *drive_path;
 	GSList *iter;
 
+	drive_path = libhal_device_get_property_string (ctx,
+							udi,
+							"block.device",
+							NULL);
+	if (!drive_path)
+		return;
+
+	self = libhal_ctx_get_user_data (ctx);
 	priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
 
-	/* the drive must have been created first */
+	/* Search the drive */
 	for (iter = priv->drives; iter; iter = iter->next) {
 		BraseroDrive *tmp;
 
 		tmp = iter->data;
-		if (nautilus_burn_drive_equal (brasero_drive_get_nautilus_drive (tmp), ndrive)) {
+		if (!brasero_drive_get_device (tmp))
+			continue;
+
+		if (!strcmp (brasero_drive_get_device (tmp), drive_path)) {
 			drive = tmp;
 			break;
 		}
 	}
+	g_free (drive_path);
 
-	if (!drive) {
-		drive = brasero_drive_new (ndrive);
-		priv->drives = g_slist_prepend (priv->drives, drive);
-	}
-
-	medium = brasero_medium_new (drive);
+	if (!drive)
+		return;
 
+	/* Create medium */
+	medium = BRASERO_MEDIUM (brasero_volume_new (drive, udi));
 	priv->media = g_slist_prepend (priv->media, medium);
-	g_object_ref (medium);
-
 	brasero_drive_set_medium (drive, medium);
 
 	g_signal_emit (self,
@@ -152,26 +185,43 @@
 }
 
 static void
-brasero_medium_monitor_removed_cb (NautilusBurnDriveMonitor *monitor,
-				   NautilusBurnDrive *ndrive,
-				   BraseroMediumMonitor *self)
+brasero_medium_monitor_inserted_cb (LibHalContext *ctx,
+				    const char *udi)
+{
+	if (libhal_device_property_exists (ctx, udi, "volume.is_disc", NULL)
+	&&  libhal_device_get_property_bool (ctx, udi, "volume.is_disc", NULL))
+		brasero_medium_monitor_medium_inserted (ctx, udi);
+	else if (libhal_device_property_exists (ctx, udi, "storage.cdrom", NULL)
+	     &&  libhal_device_get_property_bool (ctx, udi, "storage.cdrom", NULL))
+		brasero_medium_monitor_drive_inserted (ctx, udi);
+}
+
+static void
+brasero_medium_monitor_removed_cb (LibHalContext *ctx,
+				   const char *udi)
 {
 	BraseroMediumMonitorPrivate *priv;
+	BraseroMediumMonitor *self;
 	GSList *iter;
 
+	self = libhal_ctx_get_user_data (ctx);
 	priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
-	for (iter = priv->drives; iter; iter = iter->next) {
-		BraseroDrive *drive;
 
-		drive = iter->data;
-		if (nautilus_burn_drive_equal (brasero_drive_get_nautilus_drive (drive), ndrive)) {
-			BraseroMedium *medium;
+	for (iter = priv->media; iter; iter = iter->next) {
+		const gchar *device_udi;
+		BraseroMedium *medium;
 
-			medium = brasero_drive_get_medium (drive);
-			brasero_drive_set_medium (drive, NULL);
+		medium = iter->data;
+		device_udi = brasero_medium_get_udi (medium);
+		if (!device_udi)
+			continue;
 
-			if (!medium)
-				return;
+		if (!strcmp (device_udi, udi)) {
+			BraseroDrive *drive;
+
+			drive = brasero_medium_get_drive (medium);
+			if (drive)
+				brasero_drive_set_medium (drive, NULL);
 
 			priv->media = g_slist_remove (priv->media, medium);
 			g_signal_emit (self,
@@ -180,14 +230,44 @@
 				       medium);
 
 			g_object_unref (medium);
+			break;
+		}
+	}
+
+	for (iter = priv->drives; iter; iter = iter->next) {
+		const gchar *device_udi;
+		BraseroDrive *drive;
 
+		drive = iter->data;
+		device_udi = brasero_drive_get_udi (drive);
+		if (!device_udi)
+			continue;
+
+		if (!strcmp (device_udi, udi)) {
+			BraseroMedium *medium;
+
+			medium = brasero_drive_get_medium (drive);
+			brasero_drive_set_medium (drive, NULL);
+
+			if (medium) {
+				priv->media = g_slist_remove (priv->media, medium);
+				g_signal_emit (self,
+					       medium_monitor_signals [MEDIUM_REMOVED],
+					       0,
+					       medium);
+				g_object_unref (medium);
+				return;
+			}
+
+			priv->drives = g_slist_remove (priv->drives, drive);
+			g_object_unref (drive);
 			break;
 		}
 	}
 }
 
 static void
-brasero_burn_medium_monitor_add_file (BraseroMediumMonitor *self)
+brasero_medium_monitor_add_file (BraseroMediumMonitor *self)
 {
 	BraseroMediumMonitorPrivate *priv;
 	BraseroMedium *medium;
@@ -195,60 +275,124 @@
 
 	priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
 
-	drive = brasero_drive_new (nautilus_burn_drive_monitor_get_drive_for_image (priv->monitor));
+	drive = brasero_drive_new (NULL);
 	priv->drives = g_slist_prepend (priv->drives, drive);
-	g_object_ref (drive);
 	
-	medium = g_object_new (BRASERO_TYPE_MEDIUM,
+	medium = g_object_new (BRASERO_TYPE_VOLUME,
 			       "drive", drive,
 			       NULL);
 	priv->media = g_slist_prepend (priv->media, medium);
-	g_object_ref (medium);
+	brasero_drive_set_medium (drive, medium);
 }
 
 static void
 brasero_medium_monitor_init (BraseroMediumMonitor *object)
 {
+	DBusError error;
+	int nb_devices, i;
+	char **devices = NULL;
+	DBusConnection *dbus_connection;
 	BraseroMediumMonitorPrivate *priv;
-	GList *iter, *list;
 
 	priv = BRASERO_MEDIUM_MONITOR_PRIVATE (object);
 
-	nautilus_burn_init ();
-	priv->monitor = nautilus_burn_get_drive_monitor ();
+	/* This must done early on. GVolumeMonitor when it relies on HAL (like
+	 * us) must be able to update its list of volumes before us so it must
+	 * connect to HAL before us. */
+	priv->gmonitor = g_volume_monitor_get ();
+
+	/* initialize the connection with hal */
+	priv->ctx = libhal_ctx_new ();
+	if (priv->ctx == NULL) {
+		g_warning ("Cannot initialize hal library\n");
+		goto error;
+	}
 
-	list = nautilus_burn_drive_monitor_get_drives (priv->monitor);
-	for (iter = list; iter; iter = iter->next) {
-		BraseroDrive *drive;
-		BraseroMedium *medium;
-		NautilusBurnDrive *ndrive;
+	dbus_error_init (&error);
+	dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (dbus_error_is_set (&error)) {
+		g_warning ("Cannot connect to DBus %s\n", error.message);
+		dbus_error_free (&error);
+		goto error;
+	}
+
+	dbus_connection_setup_with_g_main (dbus_connection, NULL);
+	libhal_ctx_set_dbus_connection (priv->ctx, dbus_connection);
+
+	libhal_ctx_set_user_data (priv->ctx, object);
+	libhal_ctx_set_cache (priv->ctx, FALSE);
+
+	/* monitor devices addition and removal */
+	libhal_ctx_set_device_added (priv->ctx, brasero_medium_monitor_inserted_cb);
+	libhal_ctx_set_device_removed (priv->ctx, brasero_medium_monitor_removed_cb);
+
+	if (libhal_ctx_init (priv->ctx, &error) == FALSE) {
+		g_warning ("Failed to initialize hal : %s\n", error.message);
+		dbus_error_free (&error);
+		goto error;
+	}
+
+	/* Now we get the list and cache it */
+	devices = libhal_find_device_by_capability (priv->ctx,
+						    "storage.cdrom", &nb_devices,
+						    &error);
+	if (dbus_error_is_set (&error)) {
+		g_warning ("Hal is not running : %s\n", error.message);
+		dbus_error_free (&error);
+		goto error;
+	}
 
-		ndrive = iter->data;
+	for (i = 0; i < nb_devices; i++) {
+		int j;
+		int nb_volumes;
+		BraseroDrive *drive;
+		char **volumes = NULL;
 
-		drive = brasero_drive_new (ndrive);
+		/* create the drive */
+		drive = brasero_drive_new (devices [i]);
 		priv->drives = g_slist_prepend (priv->drives, drive);
-		if (nautilus_burn_drive_get_media_type (ndrive) < NAUTILUS_BURN_MEDIA_TYPE_CD)
-			continue;
 
-		medium = brasero_medium_new (drive);
-		if (!medium)
-			continue;
+		/* Now search for a possible medium inside */
+		volumes = libhal_manager_find_device_string_match (priv->ctx,
+								   "info.parent",
+								   devices [i],
+								   &nb_volumes,
+								   &error);
+		if (dbus_error_is_set (&error)) {
+			g_warning ("Hal connection problem :  %s\n",
+				   error.message);
+			dbus_error_free (&error);
+
+			if (volumes)
+				libhal_free_string_array (volumes);
+			goto error;
+		}
 
-		brasero_drive_set_medium (drive, medium);
-		priv->media = g_slist_prepend (priv->media, medium);
+		for (j = 0; j < nb_volumes; j++) {
+			BraseroMedium *medium;
+
+			medium = BRASERO_MEDIUM (brasero_volume_new (drive, volumes [j]));
+			priv->media = g_slist_prepend (priv->media, medium);
+			brasero_drive_set_medium (drive, medium);
+		}
+
+		libhal_free_string_array (volumes);
 	}
-	g_list_free (list);
+	libhal_free_string_array (devices);
+
+	brasero_medium_monitor_add_file (object);
+
+	return;
 
-	brasero_burn_medium_monitor_add_file (object);
+      error:
+	libhal_ctx_shutdown (priv->ctx, NULL);
+	libhal_ctx_free (priv->ctx);
+	priv->ctx = NULL;
 
-	g_signal_connect (priv->monitor,
-			  "media-added",
-			  G_CALLBACK (brasero_medium_monitor_inserted_cb),
-			  object);
-	g_signal_connect (priv->monitor,
-			  "media-removed",
-			  G_CALLBACK (brasero_medium_monitor_removed_cb),
-			  object);
+	if (devices)
+		libhal_free_string_array (devices);
+
+	return;
 }
 
 static void
@@ -258,18 +402,33 @@
 
 	priv = BRASERO_MEDIUM_MONITOR_PRIVATE (object);
 
-	if (priv->monitor) {
-		g_object_unref (priv->monitor);
-		priv->monitor = NULL;
-	}
-
 	if (priv->media) {
 		g_slist_foreach (priv->media, (GFunc) g_object_unref, NULL);
 		g_slist_free (priv->media);
 		priv->media = NULL;
 	}
 
-	nautilus_burn_shutdown ();
+	if (priv->drives) {
+		g_slist_foreach (priv->drives, (GFunc) g_object_unref, NULL);
+		g_slist_free (priv->drives);
+		priv->drives = NULL;
+	}
+
+	if (priv->ctx) {
+		DBusConnection *connection;
+
+		connection = libhal_ctx_get_dbus_connection (priv->ctx);
+		dbus_connection_unref (connection);
+
+		libhal_ctx_shutdown (priv->ctx, NULL);
+		libhal_ctx_free (priv->ctx);
+		priv->ctx = NULL;
+	}
+
+	if (priv->gmonitor) {
+		g_object_unref (priv->gmonitor);
+		priv->gmonitor = NULL;
+	}
 
 	G_OBJECT_CLASS (brasero_medium_monitor_parent_class)->finalize (object);
 }
@@ -315,6 +474,5 @@
 	}
 
 	singleton = g_object_new (BRASERO_TYPE_MEDIUM_MONITOR, NULL);
-	g_object_ref (singleton);
 	return singleton;
 }

Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c	(original)
+++ trunk/src/burn-medium.c	Sat Mar  8 14:23:27 2008
@@ -91,6 +91,8 @@
 	const gchar *type;
 	const gchar *icon;
 
+	gchar *udi;
+
 	gint max_rd;
 	gint max_wrt;
 
@@ -119,7 +121,8 @@
 enum
 {
 	PROP_0,
-	PROP_DRIVE
+	PROP_DRIVE,
+	PROP_UDI
 };
 
 static GObjectClass* parent_class = NULL;
@@ -2084,6 +2087,11 @@
 
 	priv = BRASERO_MEDIUM_PRIVATE (object);
 
+	if (priv->udi) {
+		g_free (priv->udi);
+		priv->udi = NULL;
+	}
+
 	if (priv->retry_id) {
 		g_source_remove (priv->retry_id);
 		priv->retry_id = 0;
@@ -2099,7 +2107,6 @@
 	g_slist_free (priv->tracks);
 	priv->tracks = NULL;
 
-	g_object_unref (priv->drive);
 	priv->drive = NULL;
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -2116,9 +2123,14 @@
 
 	switch (prop_id)
 	{
+	case PROP_UDI:
+		priv->udi = g_strdup (g_value_get_string (value));
+		break;
 	case PROP_DRIVE:
+		/* we don't ref the drive here as it would create a circular
+		 * dependency where the drive would hold a reference on the 
+		 * medium and the medium on the drive */
 		priv->drive = g_value_get_object (value);
-		g_object_ref (priv->drive);
 
 		if (brasero_drive_is_fake (priv->drive)) {
 			brasero_medium_init_file (BRASERO_MEDIUM (object));
@@ -2145,9 +2157,11 @@
 	switch (prop_id)
 	{
 	case PROP_DRIVE:
-		g_object_ref (priv->drive);
 		g_value_set_object (value, priv->drive);
 		break;
+	case PROP_UDI:
+		g_value_set_string (value, g_strdup (priv->udi));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -2173,12 +2187,20 @@
 	                                                      "drive in which medium is inserted",
 	                                                      BRASERO_TYPE_DRIVE,
 	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+	g_object_class_install_property (object_class,
+	                                 PROP_UDI,
+	                                 g_param_spec_string ("udi",
+	                                                      "udi",
+	                                                      "HAL udi",
+	                                                      NULL,
+	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 gboolean
 brasero_medium_can_be_written (BraseroMedium *self)
 {
 	BraseroMediumPrivate *priv;
+	BraseroDriveCaps caps;
 
 	priv = BRASERO_MEDIUM_PRIVATE (self);
 
@@ -2189,13 +2211,42 @@
 	if (priv->info & BRASERO_MEDIUM_FILE)
 		return FALSE;
 
-	return brasero_drive_can_write (priv->drive);
+	caps = brasero_drive_get_caps (priv->drive);
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_CDR))
+		return (caps & BRASERO_DRIVE_CAPS_CDR) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDR))
+		return (caps & BRASERO_DRIVE_CAPS_DVDR) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDR_PLUS))
+		return (caps & BRASERO_DRIVE_CAPS_DVDR_PLUS) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_CDRW))
+		return (caps & BRASERO_DRIVE_CAPS_CDRW) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_RESTRICTED))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_PLUS))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW_PLUS) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDR_PLUS_DL))
+		return (caps & BRASERO_DRIVE_CAPS_DVDR_PLUS_DL) != 0;
+
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_PLUS_DL))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW_PLUS_DL) != 0;
+
+	return FALSE;
 }
 
 gboolean
 brasero_medium_can_be_rewritten (BraseroMedium *self)
 {
 	BraseroMediumPrivate *priv;
+	BraseroDriveCaps caps;
 
 	priv = BRASERO_MEDIUM_PRIVATE (self);
 
@@ -2203,118 +2254,23 @@
 	||   (priv->info & BRASERO_MEDIUM_FILE))
 		return FALSE;
 
-	return brasero_drive_can_rewrite (priv->drive);
-}
-
-gchar *
-brasero_medium_get_label (BraseroMedium *self,
-			  gboolean with_markup)
-{
-	const gchar *type;
-	gchar *label;
-	gchar *name;
-
-	BraseroMediumPrivate *priv;
-
-	priv = BRASERO_MEDIUM_PRIVATE (self);
+	caps = brasero_drive_get_caps (priv->drive);
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_CDRW))
+		return (caps & BRASERO_DRIVE_CAPS_CDRW) != 0;
 
-	if (priv->info & BRASERO_MEDIUM_FILE) {
-		label = g_strdup (_("File Image"));
-		if (!with_markup)
-			return label;
-
-		name = label;
-		label = g_strdup_printf ("<b>%s</b>", label);
-		g_free (name);
-
-		return label;
-	}
-
-	name = brasero_drive_get_volume_label (priv->drive);
-	type = brasero_medium_get_type_string (self);
-
-	if (name && name [0] != '\0') {
-		/* NOTE for translators: the first is the disc type and the
-		 * second the label of the already existing session on this disc. */
-		if (with_markup)
-			label = g_strdup_printf ("<b>Data %s</b>: \"%s\"",
-						 type,
-						 name);
-		else
-			label = g_strdup_printf ("Data %s: \"%s\"",
-						 type,
-						 name);
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW) != 0;
 
-		g_free (name);
-		return label;
-	}
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_RESTRICTED))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW) != 0;
 
-	g_free (name);
-	name = brasero_drive_get_display_name (priv->drive);
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_PLUS))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW_PLUS) != 0;
 
-	if (priv->info & BRASERO_MEDIUM_BLANK) {
-		/* NOTE for translators: the first is the disc type and the
-		 * second the name of the drive this disc is in. */
-		if (with_markup)
-			label = g_strdup_printf (_("<b>Blank %s</b> in %s"),
-						 type,
-						 name);
-		else
-			label = g_strdup_printf (_("Blank %s in %s"),
-						 type,
-						 name);
-	}
-	else if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) {
-		/* NOTE for translators: the first is the disc type and the
-		 * second the name of the drive this disc is in. */
-		if (with_markup)
-			label = g_strdup_printf (_("<b>Audio and data %s</b> in %s"),
-						 type,
-						 name);
-		else
-			label = g_strdup_printf (_("Audio and data %s in %s"),
-						 type,
-						 name);
-	}
-	else if (priv->info & BRASERO_MEDIUM_HAS_AUDIO) {
-		/* NOTE for translators: the first is the disc type and the
-		 * second the name of the drive this disc is in. */
-		if (with_markup)
-			label = g_strdup_printf (_("<b>Audio %s</b> in %s"),
-						 type,
-						 name);
-		else
-			label = g_strdup_printf (_("Audio %s in %s"),
-						 type,
-						 name);
-	}
-	else if (priv->info & BRASERO_MEDIUM_HAS_DATA) {
-		/* NOTE for translators: the first is the disc type and the
-		 * second the name of the drive this disc is in. */
-		if (with_markup)
-			label = g_strdup_printf (_("<b>Data %s</b> in %s"),
-						 type,
-						 name);
-		else
-			label = g_strdup_printf (_("Data %s in %s"),
-						 type,
-						 name);
-	}
-	else {
-		/* NOTE for translators: the first is the disc type and the
-		 * second the name of the drive this disc is in. */
-		if (with_markup)
-			label = g_strdup_printf (_("<b>%s</b> in %s"),
-						 type,
-						 name);
-		else
-			label = g_strdup_printf (_("%s in %s"),
-						 type,
-						 name);
-	}
+	if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_PLUS_DL))
+		return (caps & BRASERO_DRIVE_CAPS_DVDRW_PLUS_DL) != 0;
 
-	g_free (name);
-	return label;
+	return FALSE;
 }
 
 BraseroDrive *
@@ -2322,11 +2278,22 @@
 {
 	BraseroMediumPrivate *priv;
 
+	if (!self)
+		return NULL;
+
 	priv = BRASERO_MEDIUM_PRIVATE (self);
-	g_object_ref (priv->drive);
 	return priv->drive;
 }
 
+const gchar *
+brasero_medium_get_udi (BraseroMedium *self)
+{
+	BraseroMediumPrivate *priv;
+
+	priv = BRASERO_MEDIUM_PRIVATE (self);
+	return priv->udi;
+}
+
 GType
 brasero_medium_get_type (void)
 {
@@ -2354,13 +2321,3 @@
 
 	return our_type;
 }
-
-BraseroMedium *
-brasero_medium_new (BraseroDrive *drive)
-{
-	g_return_val_if_fail (drive != NULL, NULL);
-	return BRASERO_MEDIUM (g_object_new (BRASERO_TYPE_MEDIUM,
-					     "drive", drive,
-					     NULL));
-}
-

Modified: trunk/src/burn-medium.h
==============================================================================
--- trunk/src/burn-medium.h	(original)
+++ trunk/src/burn-medium.h	Sat Mar  8 14:23:27 2008
@@ -62,8 +62,8 @@
 
 GType brasero_medium_get_type (void) G_GNUC_CONST;
 
-BraseroMedium *
-brasero_medium_new (BraseroDrive *drive);
+const gchar *
+brasero_medium_get_udi (BraseroMedium *medium);
 
 typedef enum {
 	BRASERO_MEDIUM_UNSUPPORTED		= -2,
@@ -266,10 +266,6 @@
 const gchar *
 brasero_medium_get_icon (BraseroMedium *medium);
 
-gchar *
-brasero_medium_get_label (BraseroMedium *medium,
-			  gboolean with_markup);
-
 BraseroDrive *
 brasero_medium_get_drive (BraseroMedium *self);
 

Modified: trunk/src/burn-session.c
==============================================================================
--- trunk/src/burn-session.c	(original)
+++ trunk/src/burn-session.c	Sat Mar  8 14:23:27 2008
@@ -95,10 +95,10 @@
 };
 typedef struct _BraseroBurnSessionPrivate BraseroBurnSessionPrivate;
 
-#define BRASERO_BURN_SESSION_WRITE_TO_DISC(priv)	(priv->settings->burner			\
-							&& !brasero_drive_is_fake (priv->settings->burner))
-#define BRASERO_BURN_SESSION_WRITE_TO_FILE(priv)	(priv->settings->burner			\
-							&& brasero_drive_is_fake (priv->settings->burner))
+#define BRASERO_BURN_SESSION_WRITE_TO_DISC(priv)	(priv->settings->burner &&			\
+							!brasero_drive_is_fake (priv->settings->burner))
+#define BRASERO_BURN_SESSION_WRITE_TO_FILE(priv)	(priv->settings->burner &&			\
+							 brasero_drive_is_fake (priv->settings->burner))
 #define BRASERO_STR_EQUAL(a, b)	((!(a) && !(b)) || ((a) && (b) && !strcmp ((a), (b))))
 
 typedef enum {
@@ -719,20 +719,21 @@
 					    const gchar *toc)
 {
 	BraseroBurnSessionPrivate *priv;
-	BraseroMediumMonitor *monitor;
-	GSList *list;
 
 	g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
 
 	priv = BRASERO_BURN_SESSION_PRIVATE (self);
-	monitor = brasero_medium_monitor_get_default ();
 
-	list = brasero_medium_monitor_get_media (monitor, BRASERO_MEDIA_TYPE_FILE);
-	if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv))
-		brasero_burn_session_set_burner (self, list->data);
+	if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
+		BraseroMediumMonitor *monitor;
+		GSList *list;
 
-	g_slist_free (list);
-	g_object_unref (monitor);
+		monitor = brasero_medium_monitor_get_default ();
+		list = brasero_medium_monitor_get_media (monitor, BRASERO_MEDIA_TYPE_FILE);
+		brasero_burn_session_set_burner (self, list->data);
+		g_object_unref (monitor);
+		g_slist_free (list);
+	}
 
 	if (priv->settings->format == format
 	&&  BRASERO_STR_EQUAL (image, priv->settings->image)
@@ -1212,10 +1213,12 @@
 	g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_MEDIUM_NONE);
 
 	priv = BRASERO_BURN_SESSION_PRIVATE (self);
+
 	if (BRASERO_BURN_SESSION_WRITE_TO_FILE (priv))
 		return BRASERO_MEDIUM_FILE;
 
 	medium = brasero_drive_get_medium (priv->settings->burner);
+
 	return brasero_medium_get_status (medium);
 }
 

Modified: trunk/src/burn-task-ctx.c
==============================================================================
--- trunk/src/burn-task-ctx.c	(original)
+++ trunk/src/burn-task-ctx.c	Sat Mar  8 14:23:27 2008
@@ -26,6 +26,8 @@
 #  include <config.h>
 #endif
 
+#include <math.h>
+
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>

Added: trunk/src/burn-volume-obj.c
==============================================================================
--- (empty file)
+++ trunk/src/burn-volume-obj.c	Sat Mar  8 14:23:27 2008
@@ -0,0 +1,593 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ * 
+ * brasero is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with brasero.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include <gio/gio.h>
+
+#include "burn-basics.h"
+#include "burn-volume-obj.h"
+
+typedef struct _BraseroVolumePrivate BraseroVolumePrivate;
+struct _BraseroVolumePrivate
+{
+	GCancellable *cancel;
+
+	GMainLoop *loop;
+	gboolean result;
+	GError *error;
+};
+
+#define BRASERO_VOLUME_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_VOLUME, BraseroVolumePrivate))
+
+enum
+{
+	MOUNTED,
+	UNMOUNTED,
+
+	LAST_SIGNAL
+};
+
+
+static guint volume_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (BraseroVolume, brasero_volume, BRASERO_TYPE_MEDIUM);
+
+static GVolume *
+brasero_volume_get_gvolume (BraseroVolume *self)
+{
+	const gchar *volume_path = NULL;
+	BraseroVolumePrivate *priv;
+	GVolumeMonitor *monitor;
+	GVolume *volume = NULL;
+	BraseroDrive *drive;
+	GList *volumes;
+	GList *iter;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	drive = brasero_medium_get_drive (BRASERO_MEDIUM (self));
+	volume_path = brasero_drive_get_device (drive);
+
+	/* NOTE: medium-monitor already holds a reference for GVolumeMonitor */
+	monitor = g_volume_monitor_get ();
+	volumes = g_volume_monitor_get_volumes (monitor);
+	g_object_unref (monitor);
+
+	for (iter = volumes; iter; iter = iter->next) {
+		gchar *device_path;
+		GVolume *tmp;
+
+		tmp = iter->data;
+		device_path = g_volume_get_identifier (tmp, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+
+		if (!strcmp (device_path, volume_path)) {
+			volume = tmp;
+			g_free (device_path);
+			g_object_ref (volume);
+			break;
+		}
+
+		g_free (device_path);
+	}
+	g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
+	g_list_free (volumes);
+
+	if (!volume)
+		g_warning ("No volume found for medium");
+
+	return volume;
+}
+
+gboolean
+brasero_volume_is_mounted (BraseroVolume *self)
+{
+	GMount *mount;
+	GVolume *volume;
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	volume = brasero_volume_get_gvolume (self);
+	mount = g_volume_get_mount (volume);
+	g_object_unref (volume);
+	if (!mount)
+		return FALSE;
+
+	g_object_unref (mount);
+	return TRUE;
+}
+
+gchar *
+brasero_volume_get_mount_point (BraseroVolume *self,
+				GError **error)
+{
+	BraseroVolumePrivate *priv;
+	gchar *local_path = NULL;
+	GVolume *volume;
+	GMount *mount;
+	GFile *root;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	volume = brasero_volume_get_gvolume (self);
+
+	/* get the uri for the mount point */
+	mount = g_volume_get_mount (volume);
+	g_object_unref (volume);
+	if (!mount)
+		return NULL;
+
+	root = g_mount_get_root (mount);
+	g_object_unref (mount);
+
+	if (!root) {
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     _("the disc mount point could not be retrieved."));
+	}
+	else {
+		local_path = g_file_get_path (root);
+		g_object_unref (root);
+	}
+
+	return local_path;
+}
+
+static gboolean
+brasero_volume_wait_for_operation_end (BraseroVolume *self,
+				       GError **error)
+{
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	priv->loop = g_main_loop_new (NULL, FALSE);
+	g_main_loop_run (priv->loop);
+
+	g_main_loop_unref (priv->loop);
+	priv->loop = NULL;
+
+	if (priv->error) {
+		if (error)
+			g_propagate_error (error, priv->error);
+		else
+			g_error_free (priv->error);
+
+		priv->error = NULL;
+	}
+	g_cancellable_reset (priv->cancel);
+
+	return priv->result;
+}
+
+static void
+brasero_volume_operation_end (BraseroVolume *self)
+{
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+	if (!priv->loop)
+		return;
+
+	if (!g_main_loop_is_running (priv->loop))
+		return;
+
+	g_main_loop_quit (priv->loop);	
+}
+
+static void
+brasero_volume_umount_finish (GObject *source,
+			      GAsyncResult *result,
+			      gpointer user_data)
+{
+	BraseroVolume *self = BRASERO_VOLUME (user_data);
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+	priv->result = g_mount_unmount_finish (G_MOUNT (source),
+					       result,
+					       &priv->error);
+
+	brasero_volume_operation_end (self);
+
+	if (priv->result)
+		g_signal_emit (self,
+			       volume_signals[UNMOUNTED],
+			       0);
+}
+
+gboolean
+brasero_volume_umount (BraseroVolume *self,
+		       gboolean wait,
+		       GError **error)
+{
+	GMount *mount;
+	gboolean result;
+	GVolume *volume;
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	volume = brasero_volume_get_gvolume (self);
+	mount = g_volume_get_mount (volume);
+	g_object_unref (volume);
+
+	if (!mount)
+		return TRUE;
+
+	if (!g_mount_can_unmount (mount))
+		return FALSE;
+
+	if (wait) {
+		g_mount_unmount (mount,
+				 G_MOUNT_UNMOUNT_NONE,
+				 priv->cancel,
+				 brasero_volume_umount_finish,
+				 self);
+		result = brasero_volume_wait_for_operation_end (self, error);
+	}
+	else {
+		g_mount_unmount (mount,
+				 G_MOUNT_UNMOUNT_NONE,
+				 priv->cancel,
+				 NULL,					/* callback */
+				 self);
+		result = TRUE;
+	}
+	g_object_unref (mount);
+
+	return result;
+}
+
+static void
+brasero_volume_mount_finish (GObject *source,
+			     GAsyncResult *result,
+			     gpointer user_data)
+{
+	BraseroVolume *self = BRASERO_VOLUME (user_data);
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+	priv->result = g_volume_mount_finish (G_VOLUME (source),
+					      result,
+					      &priv->error);
+
+	brasero_volume_operation_end (self);
+
+	if (priv->result)
+		g_signal_emit (self,
+			       volume_signals[MOUNTED],
+			       0);
+}
+
+gboolean
+brasero_volume_mount (BraseroVolume *self,
+		      gboolean wait,
+		      GError **error)
+{
+	gboolean result;
+	GVolume *volume;
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	volume = brasero_volume_get_gvolume (self);
+	if (!g_volume_can_mount (volume)) {
+		g_object_unref (volume);
+		return FALSE;
+	}
+
+	if (wait) {
+		g_volume_mount (volume,
+				G_MOUNT_MOUNT_NONE,
+				NULL,					/* authentification */
+				priv->cancel,
+				brasero_volume_mount_finish,
+				self);
+		result = brasero_volume_wait_for_operation_end (self, error);
+	}
+	else {
+		g_volume_mount (volume,
+				G_MOUNT_MOUNT_NONE,
+				NULL,					/* authentification */
+				priv->cancel,
+				NULL,
+				self);
+		result = TRUE;
+	}
+	g_object_unref (volume);
+
+	return result;
+}
+
+static void
+brasero_volume_eject_finish (GObject *source,
+			     GAsyncResult *result,
+			     gpointer user_data)
+{
+	BraseroVolume *self = BRASERO_VOLUME (user_data);
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+	priv->result = g_drive_eject_finish (G_DRIVE (source),
+					     result,
+					     &priv->error);
+
+	brasero_volume_operation_end (self);
+}
+
+gboolean
+brasero_volume_eject (BraseroVolume *self,
+		      gboolean wait,
+		      GError **error)
+{
+	GDrive *drive;
+	gboolean result;
+	GVolume *volume;
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	volume = brasero_volume_get_gvolume (self);
+	drive = g_volume_get_drive (volume);
+	g_object_unref (volume);
+
+	if (!g_drive_can_eject (drive))
+		return FALSE;
+
+	if (wait) {
+		g_drive_eject (drive,
+			       G_MOUNT_UNMOUNT_NONE,
+			       priv->cancel,
+			       brasero_volume_eject_finish,
+			       self);
+		result = brasero_volume_wait_for_operation_end (self, error);
+	}
+	else {
+		g_drive_eject (drive,
+			       G_MOUNT_UNMOUNT_NONE,
+			       priv->cancel,
+			       NULL,
+			       self);
+		result = TRUE;
+	}
+
+	return result;
+}
+
+void
+brasero_volume_cancel_current_operation (BraseroVolume *self)
+{
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);	
+
+	priv->result = FALSE;
+
+	g_cancellable_cancel (priv->cancel);
+	if (priv->loop && g_main_loop_is_running (priv->loop))
+		g_main_loop_quit (priv->loop);
+}
+
+gchar *
+brasero_volume_get_display_label (BraseroVolume *self,
+				  gboolean with_markup)
+{
+	BraseroVolumePrivate *priv;
+	BraseroDrive *drive;
+	BraseroMedia media;
+	const gchar *type;
+	GVolume *volume;
+	gchar *label;
+	gchar *name;
+
+	priv = BRASERO_VOLUME_PRIVATE (self);
+
+	media = brasero_medium_get_status (BRASERO_MEDIUM (self));
+	if (media & BRASERO_MEDIUM_FILE) {
+		label = g_strdup (_("File Image"));
+		if (!with_markup)
+			return label;
+
+		name = label;
+		label = g_strdup_printf ("<b>%s</b>", label);
+		g_free (name);
+
+		return label;
+	}
+
+	type = brasero_medium_get_type_string (BRASERO_MEDIUM (self));
+
+	volume = brasero_volume_get_gvolume (self);
+	name = g_volume_get_name (volume);
+	g_object_unref (volume);
+
+	if (name && name [0] != '\0') {
+		/* NOTE for translators: the first is the disc type and the
+		 * second the label of the already existing session on this disc. */
+		if (with_markup)
+			label = g_strdup_printf ("<b>Data %s</b>: \"%s\"",
+						 type,
+						 name);
+		else
+			label = g_strdup_printf ("Data %s: \"%s\"",
+						 type,
+						 name);
+
+		g_free (name);
+		return label;
+	}
+	g_free (name);
+
+	drive = brasero_medium_get_drive (BRASERO_MEDIUM (self));
+	name = brasero_drive_get_display_name (drive);
+
+	if (media & BRASERO_MEDIUM_BLANK) {
+		/* NOTE for translators: the first is the disc type and the
+		 * second the name of the drive this disc is in. */
+		if (with_markup)
+			label = g_strdup_printf (_("<b>Blank %s</b> in %s"),
+						 type,
+						 name);
+		else
+			label = g_strdup_printf (_("Blank %s in %s"),
+						 type,
+						 name);
+	}
+	else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) {
+		/* NOTE for translators: the first is the disc type and the
+		 * second the name of the drive this disc is in. */
+		if (with_markup)
+			label = g_strdup_printf (_("<b>Audio and data %s</b> in %s"),
+						 type,
+						 name);
+		else
+			label = g_strdup_printf (_("Audio and data %s in %s"),
+						 type,
+						 name);
+	}
+	else if (media & BRASERO_MEDIUM_HAS_AUDIO) {
+		/* NOTE for translators: the first is the disc type and the
+		 * second the name of the drive this disc is in. */
+		if (with_markup)
+			label = g_strdup_printf (_("<b>Audio %s</b> in %s"),
+						 type,
+						 name);
+		else
+			label = g_strdup_printf (_("Audio %s in %s"),
+						 type,
+						 name);
+	}
+	else if (media & BRASERO_MEDIUM_HAS_DATA) {
+		/* NOTE for translators: the first is the disc type and the
+		 * second the name of the drive this disc is in. */
+		if (with_markup)
+			label = g_strdup_printf (_("<b>Data %s</b> in %s"),
+						 type,
+						 name);
+		else
+			label = g_strdup_printf (_("Data %s in %s"),
+						 type,
+						 name);
+	}
+	else {
+		/* NOTE for translators: the first is the disc type and the
+		 * second the name of the drive this disc is in. */
+		if (with_markup)
+			label = g_strdup_printf (_("<b>%s</b> in %s"),
+						 type,
+						 name);
+		else
+			label = g_strdup_printf (_("%s in %s"),
+						 type,
+						 name);
+	}
+
+	g_free (name);
+	return label;
+}
+
+static void
+brasero_volume_init (BraseroVolume *object)
+{
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (object);
+	priv->cancel = g_cancellable_new ();
+}
+
+static void
+brasero_volume_finalize (GObject *object)
+{
+	BraseroVolumePrivate *priv;
+
+	priv = BRASERO_VOLUME_PRIVATE (object);
+
+	if (priv->cancel) {
+		g_cancellable_cancel (priv->cancel);
+		g_object_unref (priv->cancel);
+		priv->cancel = NULL;
+	}
+
+	if (priv->loop && g_main_loop_is_running (priv->loop))
+		g_main_loop_quit (priv->loop);
+
+	G_OBJECT_CLASS (brasero_volume_parent_class)->finalize (object);
+}
+
+static void
+brasero_volume_class_init (BraseroVolumeClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+	g_type_class_add_private (klass, sizeof (BraseroVolumePrivate));
+
+	object_class->finalize = brasero_volume_finalize;
+
+	volume_signals[MOUNTED] =
+		g_signal_new ("mounted",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION,
+		              0,
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0,
+		              G_TYPE_NONE);
+
+	volume_signals[UNMOUNTED] =
+		g_signal_new ("unmounted",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION,
+		              0,
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0,
+		              G_TYPE_NONE);
+}
+
+BraseroVolume *
+brasero_volume_new (BraseroDrive *drive,
+		    const gchar *udi)
+{
+	BraseroVolume *volume;
+
+	g_return_val_if_fail (drive != NULL, NULL);
+	volume = g_object_new (BRASERO_TYPE_VOLUME,
+			       "drive", drive,
+			       "udi", udi,
+			       NULL);
+
+	if (volume)
+		brasero_volume_get_gvolume (volume);
+
+	return volume;
+}

Added: trunk/src/burn-volume-obj.h
==============================================================================
--- (empty file)
+++ trunk/src/burn-volume-obj.h	Sat Mar  8 14:23:27 2008
@@ -0,0 +1,91 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ * 
+ * brasero is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with brasero.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef _BRASERO_VOLUME_H_
+#define _BRASERO_VOLUME_H_
+
+#include <glib-object.h>
+
+#include "burn-drive.h"
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_VOLUME             (brasero_volume_get_type ())
+#define BRASERO_VOLUME(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_VOLUME, BraseroVolume))
+#define BRASERO_VOLUME_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_VOLUME, BraseroVolumeClass))
+#define BRASERO_IS_VOLUME(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_VOLUME))
+#define BRASERO_IS_VOLUME_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_VOLUME))
+#define BRASERO_VOLUME_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_VOLUME, BraseroVolumeClass))
+
+typedef struct _BraseroVolumeClass BraseroVolumeClass;
+typedef struct _BraseroVolume BraseroVolume;
+
+struct _BraseroVolumeClass
+{
+	BraseroMediumClass parent_class;
+};
+
+struct _BraseroVolume
+{
+	BraseroMedium parent_instance;
+};
+
+GType brasero_volume_get_type (void) G_GNUC_CONST;
+
+BraseroVolume *
+brasero_volume_new (BraseroDrive *drive,
+		    const gchar *udi);
+
+gchar *
+brasero_volume_get_display_label (BraseroVolume *volume,
+				  gboolean with_markup);
+
+gboolean
+brasero_volume_is_mounted (BraseroVolume *volume);
+
+gchar *
+brasero_volume_get_mount_point (BraseroVolume *volume,
+				GError **error);
+
+gboolean
+brasero_volume_umount (BraseroVolume *volume,
+		       gboolean wait,
+		       GError **error);
+
+gboolean
+brasero_volume_mount (BraseroVolume *volume,
+		      gboolean wait,
+		      GError **error);
+
+gboolean
+brasero_volume_eject (BraseroVolume *volume,
+		      gboolean wait,
+		      GError **error);
+
+void
+brasero_volume_cancel_current_operation (BraseroVolume *volume);
+
+G_END_DECLS
+
+#endif /* _BRASERO_VOLUME_H_ */

Modified: trunk/src/burn.c
==============================================================================
--- trunk/src/burn.c	(original)
+++ trunk/src/burn.c	Sat Mar  8 14:23:27 2008
@@ -45,7 +45,7 @@
 #include "burn-task-ctx.h"
 #include "burn-task.h"
 #include "burn-caps.h"
-#include "burn-volume.h"
+#include "burn-volume-obj.h"
 #include "burn-drive.h"
 
 #ifdef BUILD_DBUS
@@ -231,41 +231,12 @@
 	return BRASERO_BURN_CANCEL;
 }
 
-static gpointer
-_eject_async (gpointer data)
-{
-	BraseroDrive *drive = BRASERO_DRIVE (data);
-
-	brasero_drive_eject (drive);
-	g_object_unref (drive);
-
-	return NULL;
-}
-
-static void
-brasero_burn_eject_async (BraseroDrive *drive)
-{
-	GError *error = NULL;
-
-	BRASERO_BURN_LOG ("Asynchronous ejection");
-	g_object_ref (drive);
-	g_thread_create (_eject_async, drive, FALSE, &error);
-	if (error) {
-		g_warning ("Could not create thread %s\n", error->message);
-		g_error_free (error);
-
-		g_object_unref (drive);
-		brasero_drive_eject (drive);
-	}
-}
-
 static BraseroBurnResult
 brasero_burn_eject_dest_media (BraseroBurn *self,
 			       GError **error)
 {
 	BraseroBurnPrivate *priv;
 	BraseroMedium *medium;
-	guint elapsed = 0;
 
 	priv = BRASERO_BURN_PRIVATE (self);
 
@@ -273,8 +244,9 @@
 	if (!priv->dest)
 		return BRASERO_BURN_OK;
 
-	if (brasero_drive_is_mounted (priv->dest))
-		brasero_drive_unmount (priv->dest, NULL);
+	medium = brasero_drive_get_medium (priv->dest);
+	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium)))
+		brasero_volume_umount (BRASERO_VOLUME (medium), FALSE, NULL);
 
 	if (priv->dest_locked) {
 		priv->dest_locked = 0;
@@ -292,19 +264,9 @@
 		}
 	}
 
-	brasero_burn_eject_async (priv->dest);
-
-	/* sleep here to make sure that we got time to eject */
+	brasero_volume_eject (BRASERO_VOLUME (medium), TRUE, NULL);
 	medium = brasero_drive_get_medium (priv->dest);
-	while (brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
-		brasero_burn_sleep (self, 500);
-		elapsed += 500;
-
-		if (elapsed > MAX_EJECT_WAIT_TIME)
-			break;
-	}
-
-	if (!medium || brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
+	if (medium && brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
 		gchar *name;
 
 		name = brasero_drive_get_display_name (priv->dest);
@@ -330,17 +292,17 @@
 {
 	BraseroBurnPrivate *priv;
 	BraseroMedium *medium;
-	guint elapsed = 0;
 
 	priv = BRASERO_BURN_PRIVATE (self);
 
 	if (!priv->src)
 		return BRASERO_BURN_OK;
 
-	if (brasero_drive_is_mounted (priv->src)) {
+	medium = brasero_drive_get_medium (priv->src);
+	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
 		BraseroBurnResult result;
 
-		result = brasero_drive_unmount (priv->src, error);
+		result = brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, error);
 		if (result != BRASERO_BURN_OK)
 			return result;
 	}
@@ -361,19 +323,9 @@
 		}
 	}
 
-	brasero_burn_eject_async (priv->src);
-
-	/* sleep here to make sure that we got time to eject */
+	brasero_volume_eject (BRASERO_VOLUME (medium), TRUE, NULL);
 	medium = brasero_drive_get_medium (priv->src);
-	while (brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
-		brasero_burn_sleep (self, 500);
-		elapsed += 500;
-
-		if (elapsed > MAX_EJECT_WAIT_TIME)
-			break;
-	}
-
-	if (brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
+	if (medium && brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
 		gchar *name;
 
 		name = brasero_drive_get_display_name (priv->src);
@@ -510,15 +462,16 @@
 
 
 again:
-	if (brasero_drive_is_mounted (priv->src)) {
-		if (!brasero_drive_unmount_wait (priv->src))
+
+	medium = brasero_drive_get_medium (priv->src);
+	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
+		if (!brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL))
 			g_warning ("Couldn't unmount volume in drive: %s",
 				   brasero_drive_get_device (priv->src));
 	}
 
 	/* NOTE: we used to unmount the media before now we shouldn't need that
 	 * get any information from the drive */
-	medium = brasero_drive_get_medium (priv->src);
 	media = brasero_medium_get_status (medium);
 	if (media == BRASERO_MEDIUM_NONE)
 		error_type = BRASERO_BURN_ERROR_MEDIA_NONE;
@@ -595,7 +548,10 @@
 		return BRASERO_BURN_NOT_SUPPORTED;
 	}
 
-	if (!brasero_drive_can_rewrite (priv->dest)) {
+ again:
+
+	medium = brasero_drive_get_medium (priv->dest);
+	if (!brasero_medium_can_be_rewritten (medium)) {
 		g_set_error (error,
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_GENERAL,
@@ -603,15 +559,12 @@
 		return BRASERO_BURN_NOT_SUPPORTED;
 	}
 
- again:
-
-	if (brasero_drive_is_mounted (priv->dest)) {
-		if (!brasero_drive_unmount (priv->dest, NULL))
+	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
+		if (!brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL))
 			g_warning ("Couldn't unmount volume in drive: %s",
 				   brasero_drive_get_device (priv->dest));
 	}
 
-	medium = brasero_drive_get_medium (priv->dest);
 	media = brasero_medium_get_status (medium);
 	if (media == BRASERO_MEDIUM_NONE)
 		error_type = BRASERO_BURN_ERROR_MEDIA_NONE;
@@ -745,29 +698,30 @@
 
 	brasero_burn_session_get_input_type (priv->session, &input);
 	flags = brasero_burn_session_get_flags (priv->session);
-	if (!brasero_drive_can_write (priv->dest)) {
+
+	result = BRASERO_BURN_OK;
+
+again:
+
+	medium = brasero_drive_get_medium (priv->dest);
+	if (!brasero_medium_can_be_written (medium)) {
 		g_set_error (error,
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_GENERAL,
 			     _("the drive has no burning capabilities"));
 		BRASERO_BURN_NOT_SUPPORTED_LOG (burn);
 	}
-	result = BRASERO_BURN_OK;
-
-again:
 
 	/* if drive is mounted then unmount before checking anything */
-	if (brasero_drive_is_mounted (priv->dest)) {
-		if (!brasero_drive_unmount (priv->dest, NULL))
+	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
+		if (!brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL))
 			g_warning ("Couldn't unmount volume in drive: %s",
 				   brasero_drive_get_device (priv->dest));
 	}
 
 	berror = BRASERO_BURN_ERROR_NONE;
 
-	medium = brasero_drive_get_medium (priv->dest);
 	media = brasero_medium_get_status (medium);
-
 	BRASERO_BURN_LOG_WITH_FULL_TYPE (BRASERO_TRACK_TYPE_DISC,
 					 media,
 					 BRASERO_PLUGIN_IO_NONE,
@@ -941,6 +895,7 @@
 			  GError **error)
 {
 	guint retries = 0;
+	BraseroMedium *medium;
 	BraseroBurnPrivate *priv;
 
 	priv = BRASERO_BURN_PRIVATE (self);
@@ -951,7 +906,8 @@
 		       0,
 		       BRASERO_BURN_ACTION_CHECKSUM);
 
-	while (!brasero_drive_is_mounted (priv->dest)) {
+	medium = brasero_drive_get_medium (priv->dest);
+	while (!brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
 		if (retries++ > MAX_MOUNT_ATTEMPS) {
 			g_set_error (error,
 				     BRASERO_BURN_ERROR,
@@ -961,7 +917,7 @@
 		}
 
 		/* NOTE: we don't really care about the return value */
-		brasero_drive_mount (priv->dest, error);
+		brasero_volume_mount (BRASERO_VOLUME (medium), FALSE, NULL);
 		priv->mounted_by_us = TRUE;
 
 		brasero_burn_sleep (self, MOUNT_TIMEOUT);
@@ -1030,11 +986,11 @@
 	}
 
 	/* if drive is mounted then unmount before checking anything */
-	if (brasero_drive_is_mounted (priv->dest)
-	&& !brasero_drive_unmount (priv->dest, NULL))
+/*	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))
+	&& !brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL))
 		g_warning ("Couldn't unmount volume in drive: %s",
 			   brasero_drive_get_device (priv->dest));
-
+*/
 	priv->dest_locked = 1;
 
 	return BRASERO_BURN_OK;
@@ -1044,6 +1000,7 @@
 brasero_burn_unlock_src_media (BraseroBurn *burn)
 {
 	BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
+	BraseroMedium *medium;
 
 	if (!priv->src)
 		return BRASERO_BURN_OK;
@@ -1053,8 +1010,9 @@
 		return BRASERO_BURN_OK;
 	}
 
+	medium = brasero_drive_get_medium (priv->src);
 	if (priv->mounted_by_us) {
-		brasero_drive_unmount (priv->src, NULL);
+		brasero_volume_umount (BRASERO_VOLUME (medium), FALSE, NULL);
 		priv->mounted_by_us = 0;
 	}
 
@@ -1062,7 +1020,7 @@
 	brasero_drive_unlock (priv->src);
 
 	if (BRASERO_BURN_SESSION_EJECT (priv->session))
-		brasero_burn_eject_async (priv->src);
+		brasero_volume_eject (BRASERO_VOLUME (medium), FALSE, NULL);
 
 	priv->src = NULL;
 	return BRASERO_BURN_OK;
@@ -1072,6 +1030,7 @@
 brasero_burn_unlock_dest_media (BraseroBurn *burn)
 {
 	BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
+	BraseroMedium *medium;
 
 	if (!priv->dest)
 		return BRASERO_BURN_OK;
@@ -1083,9 +1042,10 @@
 
 	priv->dest_locked = 0;
 	brasero_drive_unlock (priv->dest);
+	medium = brasero_drive_get_medium (priv->src);
 
 	if (BRASERO_BURN_SESSION_EJECT (priv->session))
-		brasero_burn_eject_async (priv->dest);
+		brasero_volume_eject (BRASERO_VOLUME (medium), FALSE, NULL);
 
 	priv->dest = NULL;
 	return BRASERO_BURN_OK;
@@ -1241,13 +1201,15 @@
 brasero_burn_run_eraser (BraseroBurn *burn, GError **error)
 {
 	BraseroDrive *drive;
+	BraseroMedium *medium;
 	BraseroBurnPrivate *priv;
 
 	priv = BRASERO_BURN_PRIVATE (burn);
 
 	drive = brasero_burn_session_get_burner (priv->session);
-	if (brasero_drive_is_mounted (drive)
-	&& !brasero_drive_unmount_wait (drive)) {
+	medium = brasero_drive_get_medium (drive);
+	if (brasero_volume_is_mounted (BRASERO_VOLUME (medium))
+	&& !brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL)) {
 		g_set_error (error,
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_BUSY_DRIVE,
@@ -1267,16 +1229,19 @@
 	BraseroBurnError error_code;
 	BraseroBurnResult result;
 	GError *ret_error = NULL;
+	BraseroMedium *medium;
 	BraseroDrive *src;
 
 	src = brasero_burn_session_get_src_drive (priv->session);
 
 start:
 
+	medium = brasero_drive_get_medium (src);
+
 	/* this is just in case */
-	if (src
-	&&  brasero_drive_is_mounted (src)
-	&& !brasero_drive_unmount_wait (src)) {
+	if (medium
+	&&  brasero_volume_is_mounted (BRASERO_VOLUME (medium))
+	&& !brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL)) {
 		g_set_error (error,
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_BUSY_DRIVE,
@@ -1363,27 +1328,31 @@
 	BraseroDrive *burner;
 	GError *ret_error = NULL;
 	BraseroBurnResult result;
+	BraseroMedium *src_medium;
+	BraseroMedium *burnt_medium;
 	BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
 
 	has_slept = FALSE;
 	src = brasero_burn_session_get_src_drive (priv->session);
+	src_medium = brasero_drive_get_medium (src);
 	burner = brasero_burn_session_get_burner (priv->session);
+	burnt_medium = brasero_drive_get_medium (burner);
 
 start:
 
 	/* this is just in case */
 	if (BRASERO_BURN_SESSION_NO_TMP_FILE (priv->session)
-	&&  src
-	&&  brasero_drive_is_mounted (src)
-	&& !brasero_drive_unmount_wait (src)) {
+	&&  src_medium
+	&&  brasero_volume_is_mounted (BRASERO_VOLUME (src_medium))
+	&& !brasero_volume_umount (BRASERO_VOLUME (src_medium), TRUE, NULL)) {
 		g_set_error (error,
 			     BRASERO_BURN_ERROR,
 			     BRASERO_BURN_ERROR_BUSY_DRIVE,
 			     _("the drive seems to be busy"));
 		return BRASERO_BURN_ERR;
 	}
-	else if (brasero_drive_is_mounted (burner)
-	     && !brasero_drive_unmount_wait (burner)) {
+	else if (brasero_volume_is_mounted (BRASERO_VOLUME (burnt_medium))
+	     && !brasero_volume_umount (BRASERO_VOLUME (burnt_medium), TRUE, NULL)) {
 		ret_error = g_error_new (BRASERO_BURN_ERROR,
 					 BRASERO_BURN_ERROR_BUSY_DRIVE,
 					 _("the drive seems to be busy"));
@@ -1638,6 +1607,7 @@
 			 BraseroTrack *track,
 			 GError **error)
 {
+	BraseroMedium *medium;
 	BraseroTrackType type;
 	BraseroBurnResult result;
 	BraseroBurnPrivate *priv;
@@ -1651,9 +1621,10 @@
 	brasero_track_get_type (track, &type);
 
 	/* if the input is a DISC, ask/mount/unmount and lock it (as dest) */
+	medium = brasero_drive_get_medium (priv->dest);
 	if (type.type == BRASERO_TRACK_TYPE_DISC
 	&&  checksum_type == BRASERO_CHECKSUM_MD5_FILE
-	&& !brasero_drive_is_mounted (priv->dest)) {
+	&& !brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
 		result = brasero_burn_mount_media (self, error);
 		if (result != BRASERO_BURN_OK)
 			return result;
@@ -1680,8 +1651,8 @@
 		 * checksum type is NOT FILE_MD5 */
 		if (priv->dest
 		&&  checksum_type == BRASERO_CHECKSUM_MD5
-		&&  brasero_drive_is_mounted (priv->dest)
-		&& !brasero_drive_unmount_wait (priv->dest)) {
+		&&  brasero_volume_is_mounted (BRASERO_VOLUME (medium))
+		&& !brasero_volume_umount (BRASERO_VOLUME (medium), TRUE, NULL)) {
 			g_set_error (error,
 				     BRASERO_BURN_ERROR,
 				     BRASERO_BURN_ERROR_BUSY_DRIVE,
@@ -2518,7 +2489,7 @@
 			      brasero_marshal_INT__OBJECT_INT_INT,
 			      G_TYPE_INT, 
 			      3,
-			      NAUTILUS_BURN_TYPE_DRIVE,
+			      BRASERO_TYPE_DRIVE,
 			      G_TYPE_INT,
 			      G_TYPE_INT);
         brasero_burn_signals [PROGRESS_CHANGED_SIGNAL] =

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Sat Mar  8 14:23:27 2008
@@ -178,7 +178,7 @@
 	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
 
-	gtk_widget_show_all (dialog);
+	gtk_widget_show (dialog);
 }
 
 void
@@ -194,7 +194,7 @@
 	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
 
-	gtk_widget_show_all (dialog);
+	gtk_widget_show (dialog);
 }
 
 void
@@ -210,7 +210,7 @@
 	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
 
-	gtk_widget_show_all (dialog);
+	gtk_widget_show (dialog);
 }
 
 void

Modified: trunk/src/plugins/checksum/burn-md5sum-file.c
==============================================================================
--- trunk/src/plugins/checksum/burn-md5sum-file.c	(original)
+++ trunk/src/plugins/checksum/burn-md5sum-file.c	Sat Mar  8 14:23:27 2008
@@ -45,6 +45,7 @@
 #include "burn-md5sum-file.h"
 #include "burn-volume.h"
 #include "burn-drive.h"
+#include "burn-volume-obj.h"
 
 BRASERO_PLUGIN_BOILERPLATE (BraseroMd5sumFile, brasero_md5sum_file, BRASERO_TYPE_JOB, BraseroJob);
 
@@ -372,7 +373,7 @@
 	const gchar *name;
 	BraseroTrack *track;
 	gboolean has_wrongsums;
-	BraseroDrive *drive;
+	BraseroMedium *medium;
 	BraseroMd5sumFilePrivate *priv;
 	gchar filename [MAXPATHLEN + 1];
 	BraseroBurnResult result = BRASERO_BURN_OK;
@@ -382,8 +383,8 @@
 	has_wrongsums = FALSE;
 
 	brasero_job_get_current_track (BRASERO_JOB (self), &track);
-	drive = brasero_track_get_drive_source (track);
-	root = brasero_drive_get_mount_point (drive, error);
+	medium = brasero_track_get_medium_source (track);
+	root = brasero_volume_get_mount_point (BRASERO_VOLUME (medium), FALSE);
 	if (!root)
 		return BRASERO_BURN_ERR;
 
@@ -395,7 +396,6 @@
 	path = g_build_path (G_DIR_SEPARATOR_S, root, name, NULL);
 
 	file = fopen (path, "r");
-
 	g_free (root);
 	g_free (path);
 	if (!file) {

Added: trunk/src/scsi-eject.c
==============================================================================
--- (empty file)
+++ trunk/src/scsi-eject.c	Sat Mar  8 14:23:27 2008
@@ -0,0 +1,102 @@
+/***************************************************************************
+ *            scsi-eject.c
+ *
+ *  Mon Mar  3 17:40:24 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <fcntl.h>
+
+#include <glib.h>
+
+#include "scsi-error.h"
+#include "scsi-utils.h"
+#include "scsi-base.h"
+#include "scsi-command.h"
+#include "scsi-opcodes.h"
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+
+struct _BraseroLoadCDCDB {
+	uchar opcode;
+
+	uchar immed		:1;
+	uchar res2		:4;
+	uchar res1		:3;
+
+	uchar res3		[2];
+
+	uchar start		:1;
+	uchar load		:1;
+	uchar res4		:6;
+
+	uchar res5		[3];
+	uchar slot;
+	uchar res6		[2];
+
+	uchar ctl;
+};
+
+#else
+
+struct _BraseroLoadCDCDB {
+	uchar opcode;
+
+	uchar res1		:3;
+	uchar res2		:4;
+	uchar immed		:1;
+
+	uchar res3		[2];
+
+	uchar res4		:6;
+	uchar load		:1;
+	uchar start		:1;
+
+	uchar res5		[3];
+	uchar slot;
+	uchar res6		[2];
+
+	uchar ctl;
+};
+
+#endif
+
+typedef struct _BraseroLoadCDCDB BraseroLoadCDCDB;
+
+BRASERO_SCSI_COMMAND_DEFINE (BraseroLoadCDCDB,
+			     LOAD_CD,
+			     O_RDONLY,
+			     BRASERO_SCSI_READ);
+
+BraseroScsiResult
+brasero_mmc1_load_cd (BraseroDeviceHandle *handle,
+		      BraseroScsiErrCode *error)
+{
+	BraseroLoadCDCDB *cdb;
+	BraseroScsiResult res;
+
+	cdb = brasero_scsi_command_new (&info, handle);
+	res = brasero_scsi_command_issue_sync (cdb,
+					       NULL,
+					       0,
+					       error);
+	brasero_scsi_command_free (cdb);
+	return res;
+}

Added: trunk/src/scsi-mech-status.c
==============================================================================
--- (empty file)
+++ trunk/src/scsi-mech-status.c	Sat Mar  8 14:23:27 2008
@@ -0,0 +1,71 @@
+/***************************************************************************
+ *            scsi-mech-status.c
+ *
+ *  Mon Mar  3 17:56:00 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <fcntl.h>
+
+#include <glib.h>
+
+#include "scsi-error.h"
+#include "scsi-utils.h"
+#include "scsi-base.h"
+#include "scsi-command.h"
+#include "scsi-opcodes.h"
+#include "scsi-mech-status.h"
+
+struct _BraseroScsiMechStatusCDB {
+	uchar opcode;
+
+	uchar res1		[7];
+	uchar len		[2];
+	uchar res2;
+
+	uchar ctl;
+};
+
+typedef struct _BraseroScsiMechStatusCDB BraseroScsiMechStatusCDB;
+
+BRASERO_SCSI_COMMAND_DEFINE (BraseroScsiMechStatusCDB,
+			     MECH_STATUS,
+			     O_RDONLY,
+			     BRASERO_SCSI_READ);
+
+BraseroScsiResult
+brasero_mmc1_mech_status (BraseroDeviceHandle *handle,
+			  BraseroScsiMechStatusHdr *hdr,
+			  BraseroScsiErrCode *error)
+{
+	BraseroScsiMechStatusCDB *cdb;
+	BraseroScsiResult res;
+
+	cdb = brasero_scsi_command_new (&info, handle);
+	BRASERO_SET_16 (cdb->len, sizeof (BraseroScsiMechStatusHdr));
+
+	memset (hdr, 0, sizeof (BraseroScsiMechStatusHdr));
+	res = brasero_scsi_command_issue_sync (cdb,
+					       hdr,
+					       sizeof (BraseroScsiMechStatusHdr),
+					       error);
+	brasero_scsi_command_free (cdb);
+	return res;
+}

Added: trunk/src/scsi-mech-status.h
==============================================================================
--- (empty file)
+++ trunk/src/scsi-mech-status.h	Sat Mar  8 14:23:27 2008
@@ -0,0 +1,78 @@
+/***************************************************************************
+ *            scsi-mech-status.h
+ *
+ *  Mon Mar  3 18:07:22 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+ 
+#ifndef _SCSI_MECH_STATUS_H
+#define _SCSI_MECH_STATUS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+
+struct _BraseroScsiMechStatusHdr {
+	uchar current_slot	:5;
+	uchar changer_state	:2;
+	uchar fault		:1;
+
+	uchar res1		:4;
+	uchar door_open		:1;
+	uchar mech_state	:3;
+
+	uchar current_lba	[3];
+
+	uchar number_slot	:6;
+	uchar res2		:2;
+
+	uchar len		[2];
+};
+
+#else
+
+struct _BraseroScsiMechStatusHdr {
+	uchar fault		:1;
+	uchar changer_state	:2;
+	uchar current_slot	:5;
+
+	uchar mech_state	:3;
+	uchar door_open		:1;
+	uchar res1		:4;
+
+	uchar current_lba	[3];
+
+	uchar res2		:2;
+	uchar number_slot	:6;
+
+	uchar len		[2];
+};
+
+#endif
+
+typedef struct _BraseroScsiMechStatusHdr BraseroScsiMechStatusHdr;
+
+G_END_DECLS
+
+#endif /* _SCSI_MECH_STATUS_H */
+
+ 

Modified: trunk/src/scsi-mmc1.h
==============================================================================
--- trunk/src/scsi-mmc1.h	(original)
+++ trunk/src/scsi-mmc1.h	Sat Mar  8 14:23:27 2008
@@ -31,7 +31,7 @@
 #include "scsi-read-disc-info.h"
 #include "scsi-read-toc-pma-atip.h"
 #include "scsi-read-track-information.h"
-
+#include "scsi-mech-status.h"
 
 #ifndef _BURN_MMC1_H
 #define _BURN_MMC1_H
@@ -80,6 +80,10 @@
 			 unsigned char *buffer,
 			 int buffer_len,
 			 BraseroScsiErrCode *error);
+BraseroScsiResult
+brasero_mmc1_mech_status (BraseroDeviceHandle *handle,
+			  BraseroScsiMechStatusHdr *hdr,
+			  BraseroScsiErrCode *error);
 
 G_END_DECLS
 

Modified: trunk/src/scsi-opcodes.h
==============================================================================
--- trunk/src/scsi-opcodes.h	(original)
+++ trunk/src/scsi-opcodes.h	Sat Mar  8 14:23:27 2008
@@ -51,7 +51,8 @@
 #define BRASERO_READ_HEADER_OPCODE			0x44
 #define BRASERO_READ_SUB_CHANNEL_OPCODE			0x42
 #define BRASERO_READ_MASTER_CUE_OPCODE			0x59
-
+#define BRASERO_LOAD_CD_OPCODE				0xA6
+#define BRASERO_MECH_STATUS_OPCODE			0xBD
 #define BRASERO_READ_CD_OPCODE				0xBE
 
 /**



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