@ -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 ) ;
}
}