2008-11-03 14:56:30 +00:00
|
|
|
#include "ecdb.h"
|
|
|
|
|
|
|
|
int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
|
2008-11-12 16:06:29 +00:00
|
|
|
static void ecdb_erase_progress_handler(void *data, void *buffer,
|
|
|
|
unsigned int nbyte);
|
|
|
|
int ecdb_erase_finished(void *data, int type, void *event);
|
2008-11-03 14:56:30 +00:00
|
|
|
|
|
|
|
Ecdb_Erase_Project *
|
|
|
|
ecdb_erase_project_new(void)
|
|
|
|
{
|
|
|
|
Ecdb_Erase_Project *proj;
|
|
|
|
|
|
|
|
proj = calloc(1, sizeof(Ecdb_Erase_Project));
|
|
|
|
if (!proj)
|
|
|
|
return NULL;
|
|
|
|
if (!ecdb_erase_project_init(proj))
|
|
|
|
{
|
|
|
|
FREE(proj);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return proj;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_erase_project_init(Ecdb_Erase_Project *proj)
|
|
|
|
{
|
|
|
|
if (!ecdb_project_init(ECDB_PROJECT(proj)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Proper defaults */
|
|
|
|
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_ERASE_PROJECT);
|
|
|
|
proj->quick = TRUE;
|
|
|
|
proj->format = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ecdb_erase_project_destroy(Ecdb_Erase_Project *proj)
|
|
|
|
{
|
|
|
|
ecdb_project_destroy(ECDB_PROJECT(proj));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_erase_disc(Ecdb_Erase_Project *proj)
|
|
|
|
{
|
|
|
|
BurnDriveStatus disc_state;
|
2008-11-03 15:56:34 +00:00
|
|
|
pthread_t progress_update;
|
2008-11-03 14:56:30 +00:00
|
|
|
|
|
|
|
disc_state = burn_disc_get_status(ECDB_PROJECT(proj)->drive->
|
|
|
|
tangible[0].drive);
|
|
|
|
if (disc_state == BURN_DISC_BLANK)
|
|
|
|
{
|
|
|
|
printf("Disc is already blank!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (disc_state == BURN_DISC_EMPTY)
|
|
|
|
{
|
|
|
|
printf("No disc!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (!burn_disc_erasable(ECDB_PROJECT(proj)->drive->
|
|
|
|
tangible[0].drive))
|
|
|
|
{
|
|
|
|
printf("Not able to erase!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (disc_state == BURN_DISC_FULL || BURN_DISC_APPENDABLE)
|
|
|
|
{
|
|
|
|
printf("Beginning to erase disc!\n");
|
2008-11-03 15:56:34 +00:00
|
|
|
ECDB_PROJECT(proj)->pipe = ecore_pipe_add
|
|
|
|
(ecdb_erase_progress_handler,
|
|
|
|
NULL);
|
2008-11-03 14:56:30 +00:00
|
|
|
burn_disc_erase(ECDB_PROJECT(proj)->drive->
|
|
|
|
tangible[0].drive, proj->quick);
|
2008-11-03 15:56:34 +00:00
|
|
|
pthread_create(&progress_update, NULL,
|
|
|
|
ecdb_drive_progress_update, proj);
|
2008-11-03 14:56:30 +00:00
|
|
|
pthread_detach(progress_update);
|
2008-11-12 16:06:29 +00:00
|
|
|
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
|
|
|
|
(ECDB_DRIVE_ACTION_FINISHED,
|
|
|
|
ecdb_erase_finished, proj);
|
2008-11-03 14:56:30 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Not of erasable type\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-03 15:56:34 +00:00
|
|
|
static void
|
2008-11-12 16:06:29 +00:00
|
|
|
ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
|
2008-11-03 15:56:34 +00:00
|
|
|
{
|
|
|
|
BurnProgress *p = buffer;
|
2008-11-05 17:02:35 +00:00
|
|
|
Evas_Object *swallow;
|
|
|
|
char buf[1024];
|
2008-11-03 15:56:34 +00:00
|
|
|
|
2008-11-12 16:06:29 +00:00
|
|
|
// Is this correct?
|
2008-11-16 06:48:08 +00:00
|
|
|
// Check this
|
|
|
|
if (sizeof(buffer) == sizeof(BurnProgress))
|
|
|
|
{
|
|
|
|
p = buffer;
|
|
|
|
}
|
|
|
|
else
|
2008-11-12 16:06:29 +00:00
|
|
|
{
|
|
|
|
ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-05 17:02:35 +00:00
|
|
|
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
|
|
|
"erase_page");
|
|
|
|
snprintf(buf, sizeof(buf), "%d/%d", p->sector, p->sectors);
|
|
|
|
edje_object_part_text_set(swallow, "progress_text", buf);
|
2008-11-03 15:56:34 +00:00
|
|
|
}
|
2008-11-12 16:06:29 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_erase_finished(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecdb_Erase_Project *proj;
|
|
|
|
|
|
|
|
proj = data;
|
|
|
|
|
|
|
|
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
|
|
|
|
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
|
|
|
|
ecore_event_handler_del(ECDB_PROJECT(proj)->ev_handler);
|
|
|
|
ecdb_erase_project_destroy(proj);
|
|
|
|
ecdb_gui_erase_cleanup();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|