Use known data for burning disc initialization, helps to not block the interface.

This commit is contained in:
Jaime Thomas 2009-04-19 23:24:53 +00:00
parent c741e1b580
commit 239ee6e91e
6 changed files with 103 additions and 34 deletions

View File

@ -139,7 +139,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
{ {
Ecdb_Data_Project *proj; Ecdb_Data_Project *proj;
Ecdb_Page *page; Ecdb_Page *page;
char buf[1024]; char *buf;
Ecdb_Burn_Result burn_result; Ecdb_Burn_Result burn_result;
int drive, speed, idx; int drive, speed, idx;
@ -163,9 +163,32 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
while (ECDB_BURN(proj)->files->parent) while (ECDB_BURN(proj)->files->parent)
ECDB_BURN(proj)->files = ECDB_BURN(proj)->files->parent; ECDB_BURN(proj)->files = ECDB_BURN(proj)->files->parent;
snprintf(buf, sizeof(buf), "Commencing..."); if (!ecdb_set_project_drive(ECDB_PROJECT(proj), drive))
edje_object_part_text_set(page->data, "progress_text", buf); {
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), drive)) EINA_ERROR_PWARN("Drive index doesn't exist!\n");
edje_object_part_text_set(page->data, "progress_text",
"Drive doesn't exist!");
return;
}
if (!ECDB_PROJECT(proj)->drive->fresh_info)
{
EINA_ERROR_PDBG("Insert a disc into the drive!\n");
edje_object_part_text_set(page->data, "progress_text",
"Insert a disc into the drive!");
return;
}
if (!((ECDB_PROJECT(proj)->drive->status & ECDB_DISC_BLANK) ||
(ECDB_PROJECT(proj)->drive->status & ECDB_DISC_APPENDABLE)))
{
EINA_ERROR_PDBG("Disc is not blank or appendable!\n");
edje_object_part_text_set(page->data, "progress_text",
"Disc is not blank or appendable!");
return;
}
if (!ecdb_aquire_drive(ECDB_PROJECT(proj)))
{ {
EINA_ERROR_PWARN("Couldn't grab drive!\n"); EINA_ERROR_PWARN("Couldn't grab drive!\n");
edje_object_part_text_set(page->data, "progress_text", edje_object_part_text_set(page->data, "progress_text",
@ -173,6 +196,8 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
return; return;
} }
edje_object_part_text_set(page->data, "progress_text", "Commencing...");
burn_result = ecdb_burn_project(ECDB_BURN(proj), page); burn_result = ecdb_burn_project(ECDB_BURN(proj), page);
switch (burn_result) switch (burn_result)
{ {
@ -191,23 +216,23 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
return; return;
case ECDB_ERROR_IMAGE_CREATE: case ECDB_ERROR_IMAGE_CREATE:
snprintf(buf, sizeof(buf), "Invalid file!"); buf = "Invalid file!";
break; break;
case ECDB_ERROR_SOURCE_ATTACH: case ECDB_ERROR_SOURCE_ATTACH:
snprintf(buf, sizeof(buf), "Couldn't attach source data!"); buf = "Couldn't attach source data!";
break; break;
case ECDB_ERROR_WRITE_MODE: case ECDB_ERROR_WRITE_MODE:
snprintf(buf, sizeof(buf), "No suitable burn mode!"); buf = "No suitable burn mode!";
break; break;
default: default:
snprintf(buf, sizeof(buf), "Unknown error :-("); buf = "Unknown error :-(";
} }
edje_object_part_text_set(page->data, "progress_text", buf); edje_object_part_text_set(page->data, "progress_text", buf);
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 1); burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible); burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
} }

View File

@ -62,7 +62,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
Ecdb_Image_Project *proj; Ecdb_Image_Project *proj;
Ecdb_Page *page; Ecdb_Page *page;
Ecdb_Source *iso_file; Ecdb_Source *iso_file;
char *file, buf[1024]; char *file, *buf;
Ecdb_Burn_Result burn_result; Ecdb_Burn_Result burn_result;
int drive, speed, idx; int drive, speed, idx;
@ -100,9 +100,31 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
else else
ECDB_BURN(proj)->speed = speed; ECDB_BURN(proj)->speed = speed;
snprintf(buf, sizeof(buf), "Commencing..."); if (!ecdb_set_project_drive(ECDB_PROJECT(proj), drive))
edje_object_part_text_set(page->image, "progress_text", buf); {
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), drive)) EINA_ERROR_PWARN("Drive index doesn't exist!\n");
edje_object_part_text_set(page->image, "progress_text",
"Drive index doesn't exist!");
return;
}
if (!ECDB_PROJECT(proj)->drive->fresh_info)
{
EINA_ERROR_PDBG("Insert a disc into the drive!\n");
edje_object_part_text_set(page->image, "progress_text",
"Insert a disc into the drive!");
return;
}
if (!(ECDB_PROJECT(proj)->drive->status & ECDB_DISC_BLANK))
{
EINA_ERROR_PDBG("Insert a blank disc!\n");
edje_object_part_text_set(page->image, "progress_text",
"Insert a blank disc!");
return;
}
if (!ecdb_aquire_drive(ECDB_PROJECT(proj)))
{ {
EINA_ERROR_PWARN("Couldn't grab drive!\n"); EINA_ERROR_PWARN("Couldn't grab drive!\n");
edje_object_part_text_set(page->image, "progress_text", edje_object_part_text_set(page->image, "progress_text",
@ -110,6 +132,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
return; return;
} }
edje_object_part_text_set(page->image, "progress_text", "Commencing...");
burn_result = ecdb_burn_project(ECDB_BURN(proj), page); burn_result = ecdb_burn_project(ECDB_BURN(proj), page);
switch (burn_result) switch (burn_result)
{ {
@ -124,23 +147,23 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
return; return;
case ECDB_ERROR_IMAGE_CREATE: case ECDB_ERROR_IMAGE_CREATE:
snprintf(buf, sizeof(buf), "Invalid file!"); buf = "Invalid file!";
break; break;
case ECDB_ERROR_SOURCE_ATTACH: case ECDB_ERROR_SOURCE_ATTACH:
snprintf(buf, sizeof(buf), "Couldn't attach source data!"); buf = "Couldn't attach source data!";
break; break;
case ECDB_ERROR_WRITE_MODE: case ECDB_ERROR_WRITE_MODE:
snprintf(buf, sizeof(buf), "No suitable burn mode!"); buf = "No suitable burn mode!";
break; break;
default: default:
snprintf(buf, sizeof(buf), "Unknown error :-("); buf = "Unknown error :-(";
} }
edje_object_part_text_set(page->image, "progress_text", buf); edje_object_part_text_set(page->image, "progress_text", buf);
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 1); burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible); burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
} }

View File

@ -140,6 +140,10 @@ ecdb_print_drive_info(void)
printf("Write HDDVD-R: %d, Write HDDVD-RW: %d\n", printf("Write HDDVD-R: %d, Write HDDVD-RW: %d\n",
drive->write_hddvdr, drive->write_hddvdr,
drive->write_hddvdrw); drive->write_hddvdrw);
printf("Status: %d, Type: %s, Capacity: %llu\n",
drive->status,
drive->type,
drive->capacity);
j = drive->write_speeds[0]; j = drive->write_speeds[0];
@ -151,27 +155,40 @@ ecdb_print_drive_info(void)
} }
int int
ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx) ecdb_aquire_drive(Ecdb_Project *proj)
{ {
Ecdb_Drive_Info *info;
char adr[BURN_DRIVE_ADR_LEN]; char adr[BURN_DRIVE_ADR_LEN];
info = eina_list_nth(em->drives, idx); if (burn_drive_convert_fs_adr(proj->drive->location, adr) <= 0)
if (burn_drive_convert_fs_adr(info->location, adr) <= 0)
{ {
EINA_ERROR_PWARN("Error: Address doesn't provide cd burner!\n"); EINA_ERROR_PWARN("Error: Address doesn't provide cd burner!\n");
return FALSE; return FALSE;
} }
if (burn_drive_scan_and_grab(&info->tangible, adr, 1) > 0) if (burn_drive_scan_and_grab(&proj->drive->tangible, adr, 1) > 0)
{ {
proj->drive = info;
return TRUE; return TRUE;
} }
else else
{ {
info->tangible = NULL; proj->drive->tangible = NULL;
return FALSE; return FALSE;
} }
} }
int
ecdb_set_project_drive(Ecdb_Project *proj, unsigned int idx)
{
Ecdb_Drive_Info *info;
info = eina_list_nth(em->drives, idx);
if (!info)
{
EINA_ERROR_PERR("Drive index does not exist!\n");
return FALSE;
}
proj->drive = info;
return TRUE;
}

View File

@ -7,7 +7,8 @@ int ecdb_aquire_drive_info(E_Hal_Device_Get_All_Properties_Return *ret,
int ecdb_update_drive_info(Ecdb_Drive_Info *drive, int ecdb_update_drive_info(Ecdb_Drive_Info *drive,
E_Hal_Device_Get_All_Properties_Return *ret); E_Hal_Device_Get_All_Properties_Return *ret);
void ecdb_print_drive_info(void); void ecdb_print_drive_info(void);
int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); int ecdb_aquire_drive(Ecdb_Project *proj);
int ecdb_set_project_drive(Ecdb_Project *proj, unsigned int idx);
void ecdb_drive_info_list_free(Eina_List *list); void ecdb_drive_info_list_free(Eina_List *list);
#endif #endif

View File

@ -71,11 +71,11 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__,
return; return;
} }
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), idx)) if (!ecdb_set_project_drive(ECDB_PROJECT(proj), idx))
{ {
EINA_ERROR_PDBG("Couldn't grab drive!\n"); EINA_ERROR_PWARN("Drive index doesn't exists!\n");
edje_object_part_text_set(page->erase, "progress_text", edje_object_part_text_set(page->erase, "progress_text",
"Couldn't grab the drive!"); "Drive doesn't exist!");
return; return;
} }
@ -84,8 +84,6 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__,
EINA_ERROR_PDBG("Insert a disc into the drive!\n"); EINA_ERROR_PDBG("Insert a disc into the drive!\n");
edje_object_part_text_set(page->erase, "progress_text", edje_object_part_text_set(page->erase, "progress_text",
"Insert a disc into the drive!"); "Insert a disc into the drive!");
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
return; return;
} }
@ -94,11 +92,16 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__,
EINA_ERROR_PDBG("Disc is already blank!\n"); EINA_ERROR_PDBG("Disc is already blank!\n");
edje_object_part_text_set(page->erase, "progress_text", edje_object_part_text_set(page->erase, "progress_text",
"Disc is already blank!"); "Disc is already blank!");
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
return; 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); proj->quick = ecdb_check_checked_get(proj->speed);
// TODO: Error Messages here // TODO: Error Messages here
if (!ecdb_erase_disc(proj, page)) if (!ecdb_erase_disc(proj, page))

View File

@ -307,7 +307,7 @@ ecdb_image_project(Ecdb_Burn_Project *bp)
data_src = burn_file_source_new(c->dst, NULL); data_src = burn_file_source_new(c->dst, NULL);
goto FIFO_CREATE; goto FIFO_CREATE;
} }
else if (ECDB_PROJECT(bp)->type == ECDB_IMAGE_PROJECT) else
{ {
EINA_ERROR_PWARN("Supplied file is not an image!\n"); EINA_ERROR_PWARN("Supplied file is not an image!\n");
efreet_mime_shutdown(); efreet_mime_shutdown();