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"
|
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
void
|
|
|
|
_ecdb_drive_set_capabilities(Ecdb_Drive_Info *drive,
|
|
|
|
E_Hal_Device_Get_All_Properties_Return *ret)
|
2008-04-01 21:30:41 +00:00
|
|
|
{
|
2009-04-18 23:18:17 +00:00
|
|
|
Eina_List *write_speeds, *l;
|
|
|
|
char *val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Write speeds */
|
|
|
|
write_speeds = e_hal_property_strlist_get(ret, "storage.cdrom.write_speeds",
|
|
|
|
NULL);
|
|
|
|
drive->write_speeds = calloc(eina_list_count(write_speeds) + 1, sizeof(int));
|
|
|
|
drive->write_speeds[0] = eina_list_count(write_speeds) + 1;
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
EINA_LIST_FOREACH(write_speeds, l, val)
|
2008-12-09 05:47:59 +00:00
|
|
|
{
|
2009-04-18 23:18:17 +00:00
|
|
|
drive->write_speeds[i] = atoi(val);
|
|
|
|
i++;
|
2008-12-09 05:47:59 +00:00
|
|
|
}
|
2009-04-18 23:18:17 +00:00
|
|
|
}
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
int
|
|
|
|
ecdb_update_drive_info(Ecdb_Drive_Info *drive,
|
|
|
|
E_Hal_Device_Get_All_Properties_Return *ret,
|
|
|
|
char *udi)
|
|
|
|
{
|
|
|
|
/* Assume that nothing about the physical hardware has changed */
|
|
|
|
drive->udi = udi;
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
/* Update the drive directories */
|
|
|
|
FREE(drive->write_speeds);
|
|
|
|
_ecdb_drive_set_capabilities(drive, ret);
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
int
|
|
|
|
ecdb_aquire_drive_info(E_Hal_Device_Get_All_Properties_Return *ret,
|
|
|
|
char *mnt, char *udi)
|
|
|
|
{
|
|
|
|
Ecdb_Drive_Info *drive;
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
drive = calloc(1, sizeof(Ecdb_Drive_Info));
|
|
|
|
if (!drive)
|
|
|
|
{
|
|
|
|
return FALSE;
|
2008-12-09 05:47:59 +00:00
|
|
|
}
|
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
/* General Info */
|
|
|
|
drive->vendor = e_hal_property_string_get(ret, "storage.vendor", NULL);
|
|
|
|
drive->product = e_hal_property_string_get(ret, "storage.model", NULL);
|
|
|
|
drive->revision = e_hal_property_string_get(ret,
|
|
|
|
"storage.firmware_revision", NULL);
|
|
|
|
drive->location = mnt;
|
|
|
|
drive->udi = udi;
|
|
|
|
|
2009-04-19 01:54:14 +00:00
|
|
|
/* Drive Capabilities */
|
|
|
|
drive->write_cdr = e_hal_property_bool_get(ret, "storage.cdrom.cdr", NULL);
|
|
|
|
drive->write_cdrw = e_hal_property_bool_get(ret, "storage.cdrom.cdrw", NULL);
|
|
|
|
drive->write_dvdr = e_hal_property_bool_get(ret, "storage.cdrom.dvdr", NULL);
|
|
|
|
drive->write_dvdrw = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.dvdrw", NULL);
|
|
|
|
drive->write_dvdram = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.dvdram", NULL);
|
|
|
|
drive->write_dvdplusrw = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.dvdplusrw", NULL);
|
|
|
|
drive->write_dvdplusrwdl = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.dvdplusrwdl", NULL);
|
|
|
|
drive->write_dvdplusrdl = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.dvdplusrdl", NULL);
|
|
|
|
drive->write_bdr = e_hal_property_bool_get(ret, "storage.cdrom.bdr", NULL);
|
|
|
|
drive->write_bdre = e_hal_property_bool_get(ret, "storage.cdrom.bdre", NULL);
|
|
|
|
drive->write_hddvdr = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.hddvdr", NULL);
|
|
|
|
drive->write_hddvdrw = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.hddvdrw", NULL);
|
|
|
|
drive->support_multisession = e_hal_property_bool_get(ret,
|
|
|
|
"storage.cdrom.support_multisession",
|
|
|
|
NULL);
|
|
|
|
/* Update generic write speeds */
|
2009-04-18 23:18:17 +00:00
|
|
|
_ecdb_drive_set_capabilities(drive, ret);
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-18 23:18:17 +00:00
|
|
|
em->drives = eina_list_append(em->drives, drive);
|
|
|
|
|
2008-12-09 05:47:59 +00:00
|
|
|
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;
|
|
|
|
|
2009-03-18 01:26:39 +00:00
|
|
|
EINA_LIST_FREE(list, info)
|
2008-12-18 18:54:50 +00:00
|
|
|
{
|
2009-04-18 23:18:17 +00:00
|
|
|
if (!info)
|
|
|
|
continue;
|
|
|
|
|
2008-12-18 18:54:50 +00:00
|
|
|
FREE(info->write_speeds);
|
2009-04-18 23:18:17 +00:00
|
|
|
FREE(info->vendor);
|
|
|
|
FREE(info->product);
|
|
|
|
FREE(info->revision);
|
2008-12-18 18:54:50 +00:00
|
|
|
FREE(info->location);
|
2009-04-18 23:18:17 +00:00
|
|
|
FREE(info->udi);
|
2009-04-19 01:54:14 +00:00
|
|
|
FREE(info->type);
|
2009-04-18 23:18:17 +00:00
|
|
|
free(info);
|
2008-12-18 18:54:50 +00:00
|
|
|
}
|
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;
|
2009-04-18 23:18:17 +00:00
|
|
|
int j, i;
|
2008-12-09 05:47:59 +00:00
|
|
|
|
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
|
|
|
{
|
2009-02-26 03:30:21 +00:00
|
|
|
/* Leave these as printfs, they shouldn't go the stderr */
|
|
|
|
printf("Vendor: %s, Product: %s, Revision: %s, "
|
2008-12-09 05:47:59 +00:00
|
|
|
"Location: %s\n",
|
|
|
|
drive->vendor, drive->product,
|
|
|
|
drive->revision, drive->location);
|
2009-04-18 23:18:17 +00:00
|
|
|
printf("Write CD-R: %d, Write CD-RW: %d\n",
|
2008-12-09 05:47:59 +00:00
|
|
|
drive->write_cdr,
|
2009-04-18 23:18:17 +00:00
|
|
|
drive->write_cdrw);
|
|
|
|
printf("Write DVD-R: %d, Write DVD-RW: %d, Write DVD-RAM: %d\n",
|
|
|
|
drive->write_dvdr,
|
|
|
|
drive->write_dvdrw,
|
|
|
|
drive->write_dvdram);
|
|
|
|
printf("Write DVD+R: %d, Write DVD+RW: %d, Write DVD+RWDL: %d\n",
|
|
|
|
drive->write_dvdplusr,
|
|
|
|
drive->write_dvdplusrw,
|
|
|
|
drive->write_dvdplusrwdl);
|
|
|
|
printf("Write DVD+DL: %d\n",
|
|
|
|
drive->write_dvdplusrdl);
|
|
|
|
printf("Write BR-R: %d, Write BR-RW: %d\n",
|
|
|
|
drive->write_bdr,
|
|
|
|
drive->write_bdre);
|
|
|
|
printf("Write HDDVD-R: %d, Write HDDVD-RW: %d\n",
|
|
|
|
drive->write_hddvdr,
|
|
|
|
drive->write_hddvdrw);
|
|
|
|
|
|
|
|
j = drive->write_speeds[0];
|
2008-12-09 05:47:59 +00:00
|
|
|
|
|
|
|
for (i = 1; i < j; i ++)
|
|
|
|
{
|
2009-04-18 23:18:17 +00:00
|
|
|
printf("Write: %d\n", drive->write_speeds[i]);
|
2008-12-09 05:47:59 +00:00
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
2009-02-23 01:22:02 +00:00
|
|
|
EINA_ERROR_PWARN("Error: Address doesn't provide cd burner!\n");
|
2008-12-09 05:47:59 +00:00
|
|
|
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
|
|
|
|