legacy/experimental/ecdb/trunk/src/ecdb_drives.c

182 lines
5.5 KiB
C
Raw Normal View History

/* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h"
void
_ecdb_drive_set_capabilities(Ecdb_Drive_Info *drive,
E_Hal_Device_Get_All_Properties_Return *ret)
{
Eina_List *write_speeds, *l;
char *val;
int i;
/* 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);
/* 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
{
drive->write_speeds[i] = atoi(val);
i++;
2008-12-09 05:47:59 +00:00
}
}
2008-12-09 05:47:59 +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
/* Update the drive directories */
FREE(drive->write_speeds);
_ecdb_drive_set_capabilities(drive, ret);
2008-12-09 05:47:59 +00:00
return TRUE;
}
2008-12-09 05:47:59 +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
drive = calloc(1, sizeof(Ecdb_Drive_Info));
if (!drive)
{
return FALSE;
2008-12-09 05:47:59 +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;
/* Update current directories */
_ecdb_drive_set_capabilities(drive, ret);
2008-12-09 05:47:59 +00:00
em->drives = eina_list_append(em->drives, drive);
2008-12-09 05:47:59 +00:00
return TRUE;
}
void
2008-12-18 18:54:50 +00:00
ecdb_drive_info_list_free(Eina_List *list)
{
2008-12-09 05:47:59 +00:00
Ecdb_Drive_Info *info;
EINA_LIST_FREE(list, info)
2008-12-18 18:54:50 +00:00
{
if (!info)
continue;
2008-12-18 18:54:50 +00:00
FREE(info->write_speeds);
FREE(info->vendor);
FREE(info->product);
FREE(info->revision);
2008-12-18 18:54:50 +00:00
FREE(info->location);
FREE(info->udi);
free(info);
2008-12-18 18:54:50 +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;
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
{
/* 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);
printf("Write CD-R: %d, Write CD-RW: %d\n",
2008-12-09 05:47:59 +00:00
drive->write_cdr,
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 ++)
{
printf("Write: %d\n", drive->write_speeds[i]);
2008-12-09 05:47:59 +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)
{
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-12-09 05:47:59 +00:00