Ask to unmount the disc via dbus/hal, although it isn't as much of a silver bullet as I wish. It unmounts discs from EFM fine, but Thunar isn't so compliant.

This commit is contained in:
Jaime Thomas 2009-04-29 02:46:32 +00:00
parent a3360d81a2
commit d54838db08
4 changed files with 107 additions and 51 deletions

View File

@ -84,7 +84,6 @@ struct _Ecdb_Drive_Info
unsigned char support_multisession:1;
/* Mark this as being stale */
unsigned char fresh_info:1;
/* Disc info */

View File

@ -10,6 +10,9 @@ static void _page_hide_finished(void *data, Evas_Object *o,
const char *source);
static void _page_del(void *data, Evas *e, Evas_Object *obj, void *ev);
static void _ecdb_erase_do_erase(Ecdb_Page *page, Ecdb_Erase_Project *proj);
void _ecdb_erase_unmount_cb(void *data, void *reply_data, DBusError *err);
static void
_page_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
void *ev __UNUSED__)
@ -54,13 +57,11 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__,
{
Ecdb_Erase_Project *proj;
Ecdb_Page *page;
char buf[1024];
int idx;
page = data;
proj = evas_object_data_get(page->erase, "proj");
snprintf(buf, sizeof(buf), "Commencing...");
edje_object_part_text_set(page->erase, "progress_text", buf);
edje_object_part_text_set(page->erase, "progress_text", "Commencing...");
idx = ecdb_combo_selected_get(ECDB_PROJECT(proj)->drive_combo);
if (idx < 0)
@ -95,31 +96,12 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__,
return;
}
if (!ecdb_aquire_drive(ECDB_PROJECT(proj)))
{
EINA_ERROR_PWARN("Couldn't grab the drive!\n");
edje_object_part_text_set(page->erase, "progress_text",
"Couldn't grab the drive!");
}
proj->quick = ecdb_check_checked_get(proj->speed);
// TODO: Error Messages here
if (!ecdb_erase_disc(proj, page))
{
EINA_ERROR_PINFO("Disc not erasable!\n");
snprintf(buf, sizeof(buf), "Disc not erasable!");
edje_object_part_text_set(page->erase, "progress_text", buf);
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
return;
}
edje_object_signal_emit(page->erase, "ecdb,erase,start", "ecdb");
Evas_Object *objs[] = {proj->speed, ECDB_PROJECT(proj)->ret,
ECDB_PROJECT(proj)->begin,
ECDB_PROJECT(proj)->drive_combo, NULL};
for (idx = 0; objs[idx] != NULL; idx++)
edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb");
/* Apparently DBus doesn't tell you when a disc has been mounted
* or unmounted, so do this every time regardless...
*/
ecdb_hal_request_unmount(ECDB_PROJECT(proj)->drive,
_ecdb_erase_unmount_cb,
page);
}
void
@ -230,3 +212,88 @@ ecdb_erase_cleanup(Ecdb_Page *page)
proj->speed = 0;
}
static void
_ecdb_erase_do_erase(Ecdb_Page *page, Ecdb_Erase_Project *proj)
{
int idx;
if (!proj)
{
EINA_ERROR_PWARN("NULL project!\n");
return;
}
if (!page)
{
EINA_ERROR_PWARN("NULL page!\n");
return;
}
if (!ecdb_aquire_drive(ECDB_PROJECT(proj)))
{
EINA_ERROR_PWARN("Couldn't grab the drive!\n");
edje_object_part_text_set(page->erase, "progress_text",
"Couldn't grab the drive!");
}
proj->quick = ecdb_check_checked_get(proj->speed);
if (!ecdb_erase_disc(proj, page))
{
EINA_ERROR_PINFO("Disc not erasable!\n");
edje_object_part_text_set(page->erase, "progress_text",
"Disc not erasable!");
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
return;
}
edje_object_signal_emit(page->erase, "ecdb,erase,start", "ecdb");
Evas_Object *objs[] = {proj->speed, ECDB_PROJECT(proj)->ret,
ECDB_PROJECT(proj)->begin,
ECDB_PROJECT(proj)->drive_combo, NULL};
for (idx = 0; objs[idx] != NULL; idx++)
edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb");
}
void
_ecdb_erase_unmount_cb(void *data, void *reply_data __UNUSED__, DBusError *err)
{
Ecdb_Erase_Project *proj;
Ecdb_Page *page;
page = data;
if (!page)
{
EINA_ERROR_PWARN("NULL page!\n");
return;
}
proj = evas_object_data_get(page->erase, "proj");
if (!proj)
{
EINA_ERROR_PWARN("NULL project!\n");
return;
}
if (dbus_error_is_set(err))
{
if (!strcmp(err->name, "org.freedesktop.Hal.Device.Volume.NotMounted"))
{
// This case is totally fine for our uses
_ecdb_erase_do_erase(page, proj);
}
else
{
edje_object_part_text_set(page->erase, "progress_text",
"Cannot unmount drive!");
EINA_ERROR_PWARN("Unmount error:\n%s\n%s\n", err->name, err->message);
}
dbus_error_free(err);
}
else
{
_ecdb_erase_do_erase(page, proj);
}
}

View File

@ -6,10 +6,11 @@ void _ecdb_hal_volume_all_cb(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_volume_removed_cb(void *data, DBusMessage *msg);
void _ecdb_hal_volume_added_cb(void *data, DBusMessage *msg);
void _ecdb_hal_volume_prop_modified(void *data, DBusMessage *msg);
void _ecdb_hal_volume_cb(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_unmount_cb(void *data, void *reply_data, DBusError *error);
void _ecdb_hal_volumes_init(void);
static void _ecdb_hal_volumes_init(void);
void
_ecdb_hal_device_handle(void *data, void *reply_data, DBusError *error)
@ -202,27 +203,14 @@ ecdb_hal_shutdown(void)
}
void
ecdb_hal_request_unmount(Ecdb_Drive_Info *drive)
ecdb_hal_request_unmount(Ecdb_Drive_Info *drive, E_DBus_Callback_Func cb,
void *data)
{
e_hal_device_volume_unmount(em->conn, drive->udi, NULL,
_ecdb_hal_unmount_cb, drive);
e_hal_device_volume_unmount(em->conn, drive->disc_udi, NULL,
cb, data);
}
void
_ecdb_hal_unmount_cb(void *data, void *reply_data __UNUSED__, DBusError *error)
{
Ecdb_Drive_Info *drive;
drive = data;
if (dbus_error_is_set(error))
{
EINA_ERROR_PWARN("Unmount Error: %s %s\n", error->name, error->message);
dbus_error_free(error);
}
}
void
static void
_ecdb_hal_volumes_init()
{
@ -324,12 +312,12 @@ _ecdb_hal_volume_handle(void *data, void *reply_data, DBusError *error)
if (e_hal_property_bool_get(ret, "volume.disc.is_rewritable", NULL))
drive->status |= ECDB_DISC_REWRITABLE;
drive->type = e_hal_property_string_get(ret, "volume.disc.type", NULL);
drive->type = e_hal_property_string_get(ret, "volume.disc.type",
NULL);
/* Also refresh the drive, for write speeds */
e_hal_device_get_all_properties(em->conn, udi,
_ecdb_hal_device_handle, udi);
break;
}
}

View File

@ -4,6 +4,8 @@
int ecdb_hal_init(void);
void ecdb_hal_shutdown(void);
void ecdb_hal_request_unmount(Ecdb_Drive_Info *drive);
void ecdb_hal_request_unmount(Ecdb_Drive_Info *drive,
E_DBus_Callback_Func cb,
void *data);
#endif