Some random fixes here and there. There is no more name_find or name_set use.
This commit is contained in:
@@ -1,16 +1,33 @@
|
||||
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
||||
#include "ecdb.h"
|
||||
|
||||
typedef struct Erase_Data Erase_Data;
|
||||
struct Erase_Data
|
||||
{
|
||||
Ecdb_Project *proj;
|
||||
Ecdb_Page *page;
|
||||
};
|
||||
|
||||
static void ecdb_erase_progress_handler(void *data, void *buffer,
|
||||
unsigned int nbyte);
|
||||
int ecdb_erase_finished(void *data, int type, void *event);
|
||||
|
||||
|
||||
// FIXME Make this return an error code
|
||||
int
|
||||
ecdb_erase_disc(Ecdb_Erase_Project *proj)
|
||||
ecdb_erase_disc(Ecdb_Erase_Project *proj, Ecdb_Page *page)
|
||||
{
|
||||
BurnDriveStatus disc_state;
|
||||
pthread_t progress_update;
|
||||
pthread_t progress_update;
|
||||
Erase_Disc *data;
|
||||
|
||||
data = calloc(1, sizeof(Erase_Data));
|
||||
if (!data)
|
||||
{
|
||||
printf("ecdb_erase_disc: NULL data!\n");
|
||||
return FALSE;
|
||||
}
|
||||
data->proj = proj;
|
||||
data->page = page;
|
||||
|
||||
disc_state = burn_disc_get_status(ECDB_PROJECT(proj)->drive->
|
||||
tangible[0].drive);
|
||||
@@ -34,13 +51,13 @@ ecdb_erase_disc(Ecdb_Erase_Project *proj)
|
||||
{
|
||||
printf("Beginning to erase disc!\n");
|
||||
ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_erase_progress_handler,
|
||||
proj);
|
||||
data);
|
||||
burn_disc_erase(ECDB_PROJECT(proj)->drive->tangible[0].drive,
|
||||
proj->quick);
|
||||
pthread_create(&progress_update, NULL, ecdb_drive_progress_update, proj);
|
||||
pthread_detach(progress_update);
|
||||
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
|
||||
(ECDB_DRIVE_ACTION_FINISHED, ecdb_erase_finished, proj);
|
||||
(ECDB_DRIVE_ACTION_FINISHED, ecdb_erase_finished, data);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -54,7 +71,8 @@ static void
|
||||
ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
|
||||
{
|
||||
BurnProgress *p;
|
||||
Evas_Object *swallow;
|
||||
Evas_Object *swallow;
|
||||
Erase_Data *edata;
|
||||
static int last_sector = 0;
|
||||
Edje_Message_Int_Set *progress_msg;
|
||||
|
||||
@@ -83,35 +101,55 @@ ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
|
||||
else
|
||||
{
|
||||
last_sector = p->sectors;
|
||||
}
|
||||
|
||||
edata = data;
|
||||
if (!edata)
|
||||
{
|
||||
printf("ecdb_erase_progress_handler: NULL edata!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!edata->page) || (!edata->proj))
|
||||
{
|
||||
printf("ecdb_erase_progress_handler: NULL page or proj!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (proj->type)
|
||||
{
|
||||
case ECDB_ERASE_PROJECT:
|
||||
swallow = page->erase;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("ecdb_erase_progress_handler: Unrecognized project type!\n")
|
||||
return;
|
||||
}
|
||||
|
||||
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
||||
"erase_page");
|
||||
|
||||
progress_msg = alloca(sizeof(Edje_Message_Int_Set) + (4 * sizeof(int)));
|
||||
progress_msg->count = 5;
|
||||
progress_msg = alloca(sizeof(Edje_Message_Int_Set) + (2 * sizeof(int)));
|
||||
progress_msg->count = 3;
|
||||
progress_msg->val[0] = (int)((double)(last_sector + 1) /
|
||||
(double)p->sectors * 100.0);
|
||||
progress_msg->val[1] = last_sector;
|
||||
progress_msg->val[2] = p->sectors;
|
||||
progress_msg->val[3] = (int)p->buffer_available;
|
||||
progress_msg->val[4] = (int)p->buffer_capacity;
|
||||
edje_object_message_send(swallow, EDJE_MESSAGE_INT_SET, 0, progress_msg);
|
||||
}
|
||||
|
||||
int
|
||||
ecdb_erase_finished(void *data, int type, void *event)
|
||||
{
|
||||
{
|
||||
Erase_Data *ed;
|
||||
Ecdb_Erase_Project *proj;
|
||||
|
||||
proj = data;
|
||||
|
||||
ed = data;
|
||||
proj = ed->proj;
|
||||
|
||||
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);
|
||||
ecore_pipe_del(ECDB_PROJECT(proj)->pipe);
|
||||
ecdb_erase_project_destroy(proj);
|
||||
ecdb_erase_cleanup();
|
||||
ecdb_erase_cleanup(ed->page);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user