2008-12-09 19:46:00 +00:00
|
|
|
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
2008-04-01 21:30:41 +00:00
|
|
|
#include "ecdb.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_aquire_drive_info(void)
|
|
|
|
{
|
2008-12-23 02:37:34 +00:00
|
|
|
int ret, i;
|
2008-12-09 05:47:59 +00:00
|
|
|
unsigned int drive_num;
|
|
|
|
struct burn_drive_info *drives_current;
|
|
|
|
struct burn_speed_descriptor *speeds;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
if (em->drives)
|
|
|
|
{
|
2008-12-18 18:54:50 +00:00
|
|
|
ecdb_drive_info_list_free(em->drives);
|
2008-12-09 05:47:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (!ret)
|
|
|
|
{
|
|
|
|
ret = burn_drive_scan(&drives_current, &drive_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < drive_num; i++)
|
|
|
|
{
|
|
|
|
Ecdb_Drive_Info *drive;
|
|
|
|
|
|
|
|
drive = calloc(1, sizeof(Ecdb_Drive_Info));
|
|
|
|
|
|
|
|
if (!drive)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-20 21:08:50 +00:00
|
|
|
drive->product = eina_stringshare_add(drives_current[i].product);
|
|
|
|
drive->vendor = eina_stringshare_add(drives_current[i].vendor);
|
|
|
|
drive->revision = eina_stringshare_add(drives_current[i].revision);
|
2008-12-09 05:47:59 +00:00
|
|
|
drive->location = strdup(drives_current[i].location);
|
|
|
|
drive->read_dvdram = drives_current[i].read_dvdram;
|
|
|
|
drive->read_dvdr = drives_current[i].read_dvdr;
|
|
|
|
drive->read_dvdrom = drives_current[i].read_dvdrom;
|
|
|
|
drive->read_cdr = drives_current[i].read_cdr;
|
|
|
|
drive->read_cdrw = drives_current[i].read_cdrw;
|
|
|
|
drive->write_dvdram = drives_current[i].write_dvdram;
|
|
|
|
drive->write_dvdr = drives_current[i].write_dvdr;
|
|
|
|
drive->write_cdr = drives_current[i].write_cdr;
|
|
|
|
drive->write_simulate = drives_current[i].write_simulate;
|
|
|
|
|
|
|
|
burn_drive_get_speedlist(drives_current[i].drive, &speeds);
|
|
|
|
|
2008-12-20 21:08:50 +00:00
|
|
|
drive->profile_name = eina_stringshare_add(speeds->profile_name);
|
2008-12-09 05:47:59 +00:00
|
|
|
drive->profile_loaded = speeds->profile_loaded;
|
2008-12-27 17:54:40 +00:00
|
|
|
|
|
|
|
if (burn_drive_grab(drives_current[i].drive, 1))
|
|
|
|
{
|
|
|
|
drive->capacity = burn_disc_available_space(drives_current[i].drive,
|
|
|
|
NULL);
|
|
|
|
burn_drive_release(drives_current[i].drive, 0);
|
|
|
|
}
|
2008-12-09 05:47:59 +00:00
|
|
|
|
|
|
|
while (speeds->next)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
speeds = speeds->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
drive->read_speeds = calloc(i + 2, sizeof(int));
|
|
|
|
drive->write_speeds = calloc(i + 2, sizeof(int));
|
|
|
|
|
|
|
|
drive->read_speeds[0] = i + 1;
|
|
|
|
drive->write_speeds[0] = i + 1;
|
|
|
|
|
|
|
|
for (ret = 1; ret <= i; ret++)
|
|
|
|
{
|
2008-12-23 02:37:34 +00:00
|
|
|
drive->write_speeds[ret] = speeds->write_speed;
|
|
|
|
drive->read_speeds[ret] = speeds->read_speed;
|
2008-12-09 05:47:59 +00:00
|
|
|
speeds = speeds->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
burn_drive_free_speedlist(&speeds);
|
2008-12-18 18:54:50 +00:00
|
|
|
em->drives = eina_list_append(em->drives, drive);
|
2008-12-09 05:47:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
burn_drive_info_free(drives_current);
|
|
|
|
|
|
|
|
return TRUE;
|
2008-04-01 21:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-12-18 18:54:50 +00:00
|
|
|
ecdb_drive_info_list_free(Eina_List *list)
|
2008-04-01 21:30:41 +00:00
|
|
|
{
|
2008-12-09 05:47:59 +00:00
|
|
|
Ecdb_Drive_Info *info;
|
2008-12-18 18:54:50 +00:00
|
|
|
Eina_List *l;
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2008-12-18 18:54:50 +00:00
|
|
|
EINA_LIST_FOREACH(list, l, info)
|
|
|
|
{
|
|
|
|
FREE(info->read_speeds);
|
|
|
|
FREE(info->write_speeds);
|
|
|
|
FREE(info->location);
|
2008-12-20 21:08:50 +00:00
|
|
|
eina_stringshare_del(info->vendor);
|
|
|
|
eina_stringshare_del(info->product);
|
|
|
|
eina_stringshare_del(info->revision);
|
|
|
|
eina_stringshare_del(info->profile_name);
|
2008-12-18 18:54:50 +00:00
|
|
|
FREE(info);
|
|
|
|
}
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2008-12-18 18:54:50 +00:00
|
|
|
list = eina_list_free(list);
|
2008-04-01 21:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ecdb_print_drive_info(void)
|
|
|
|
{
|
2008-12-18 18:54:50 +00:00
|
|
|
Eina_List *l;
|
2008-12-09 05:47:59 +00:00
|
|
|
Ecdb_Drive_Info *drive;
|
|
|
|
int j, i, h;
|
|
|
|
|
2008-12-18 18:54:50 +00:00
|
|
|
em->drives = eina_list_nth_list(em->drives, 0);
|
|
|
|
EINA_LIST_FOREACH(em->drives, l, drive)
|
2008-12-09 05:47:59 +00:00
|
|
|
{
|
|
|
|
printf("Vendor: %s, Product: %s, Revision: %s, "
|
|
|
|
"Location: %s\n",
|
|
|
|
drive->vendor, drive->product,
|
|
|
|
drive->revision, drive->location);
|
|
|
|
printf("Profile name: %s, Loaded: %d\n",
|
|
|
|
drive->profile_name,
|
|
|
|
drive->profile_loaded);
|
|
|
|
printf("Read DVDRAM: %d, Read DVDR: %d, Read DVDROM: %d, "
|
|
|
|
"Read CDR: %d, Read CDRW: %d\n",
|
|
|
|
drive->read_dvdram,
|
|
|
|
drive->read_dvdr,
|
|
|
|
drive->read_dvdrom,
|
|
|
|
drive->read_cdr,
|
|
|
|
drive->read_cdrw);
|
|
|
|
printf("Write DVDRAM: %d, Write DVDR: %d, Write CDR: %d, "
|
|
|
|
"Write Simulate: %d\n",
|
|
|
|
drive->write_dvdram,
|
|
|
|
drive->write_dvdr,
|
|
|
|
drive->write_cdr,
|
|
|
|
drive->write_simulate);
|
|
|
|
|
|
|
|
j = drive->read_speeds[0];
|
|
|
|
|
|
|
|
for (i = 1; i < j; i ++)
|
|
|
|
{
|
|
|
|
if ((h = drive->write_speeds[i]))
|
|
|
|
{
|
|
|
|
printf("Write: %d\n", h);
|
|
|
|
}
|
|
|
|
if ((h = drive->read_speeds[i]))
|
|
|
|
{
|
|
|
|
printf("Read: %d\n", h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-01 21:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx)
|
|
|
|
{
|
2008-12-09 05:47:59 +00:00
|
|
|
Ecdb_Drive_Info *info;
|
|
|
|
char adr[BURN_DRIVE_ADR_LEN];
|
|
|
|
|
2008-12-18 18:54:50 +00:00
|
|
|
info = eina_list_nth(em->drives, idx);
|
2008-12-09 05:47:59 +00:00
|
|
|
if (burn_drive_convert_fs_adr(info->location, adr) <= 0)
|
|
|
|
{
|
|
|
|
printf("Error: Address doesn't provide cd burner!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (burn_drive_scan_and_grab(&info->tangible, adr, 1) > 0)
|
|
|
|
{
|
|
|
|
proj->drive = info;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
info->tangible = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-04-01 21:30:41 +00:00
|
|
|
}
|
2008-12-09 05:47:59 +00:00
|
|
|
|