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,
|
2009-04-19 03:34:54 +00:00
|
|
|
E_Hal_Device_Get_All_Properties_Return *ret)
|
2009-04-18 23:18:17 +00:00
|
|
|
{
|
2009-04-19 03:34:54 +00:00
|
|
|
/* Assume that the physical hardware hasn't changed */
|
2009-04-18 23:18:17 +00:00
|
|
|
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);
|
2009-04-19 23:24:53 +00:00
|
|
|
printf("Status: %d, Type: %s, Capacity: %llu\n",
|
|
|
|
drive->status,
|
|
|
|
drive->type,
|
|
|
|
drive->capacity);
|
2009-04-18 23:18:17 +00:00
|
|
|
|
|
|
|
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
|
2009-04-19 23:24:53 +00:00
|
|
|
ecdb_aquire_drive(Ecdb_Project *proj)
|
2008-04-01 21:30:41 +00:00
|
|
|
{
|
2008-12-09 05:47:59 +00:00
|
|
|
char adr[BURN_DRIVE_ADR_LEN];
|
|
|
|
|
2009-04-19 23:24:53 +00:00
|
|
|
if (burn_drive_convert_fs_adr(proj->drive->location, adr) <= 0)
|
2008-12-09 05:47:59 +00:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2009-04-19 23:24:53 +00:00
|
|
|
if (burn_drive_scan_and_grab(&proj->drive->tangible, adr, 1) > 0)
|
2008-12-09 05:47:59 +00:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-19 23:24:53 +00:00
|
|
|
proj->drive->tangible = NULL;
|
2008-12-09 05:47:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-04-01 21:30:41 +00:00
|
|
|
}
|
2009-04-19 23:24:53 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_set_project_drive(Ecdb_Project *proj, unsigned int idx)
|
|
|
|
{
|
|
|
|
Ecdb_Drive_Info *info;
|
2008-12-09 05:47:59 +00:00
|
|
|
|
2009-04-19 23:24:53 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|