mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
solid: optical disc/drive support fixes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
45dc6bb0c4
commit
e948b64fb1
3 changed files with 43 additions and 33 deletions
|
@ -427,9 +427,8 @@ bool UDevDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type)
|
||||||
|
|
||||||
#ifdef UDEV_CDIO
|
#ifdef UDEV_CDIO
|
||||||
case Solid::DeviceInterface::OpticalDrive:
|
case Solid::DeviceInterface::OpticalDrive:
|
||||||
return (property("ID_TYPE").toString() == "cd" || property("ID_CDROM_MEDIA_CD").toInt() == 1);
|
|
||||||
case Solid::DeviceInterface::OpticalDisc:
|
case Solid::DeviceInterface::OpticalDisc:
|
||||||
return false; // TODO:
|
return (property("ID_TYPE").toString() == "cd" || property("ID_CDROM_MEDIA_CD").toInt() == 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case Solid::DeviceInterface::Camera:
|
case Solid::DeviceInterface::Camera:
|
||||||
|
|
|
@ -30,7 +30,7 @@ OpticalDisc::OpticalDisc(UDevDevice *device)
|
||||||
: StorageVolume(device),
|
: StorageVolume(device),
|
||||||
p_cdio(Q_NULLPTR)
|
p_cdio(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
const QByteArray devicename = m_device->deviceName().toLocal8Bit();
|
const QByteArray devicename = m_device->property("DEVNAME").toString().toLocal8Bit();
|
||||||
p_cdio = cdio_open(devicename.constData(), DRIVER_UNKNOWN);
|
p_cdio = cdio_open(devicename.constData(), DRIVER_UNKNOWN);
|
||||||
if (!p_cdio) {
|
if (!p_cdio) {
|
||||||
qWarning() << "Could not open" << devicename;
|
qWarning() << "Could not open" << devicename;
|
||||||
|
@ -81,10 +81,7 @@ Solid::OpticalDisc::DiscType OpticalDisc::discType() const
|
||||||
return Solid::OpticalDisc::UnknownDiscType;
|
return Solid::OpticalDisc::UnknownDiscType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// not supported by libcdio: BluRayRom, BluRayRecordable, BluRayRewritable
|
||||||
libcdio does not support blue-ray, maybe it will some day
|
|
||||||
BluRayRom, BluRayRecordable, BluRayRewritable
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
TODO: not implemented by libcdio/needs rw query on CDIO_DISC_MODE_CD_*?
|
TODO: not implemented by libcdio/needs rw query on CDIO_DISC_MODE_CD_*?
|
||||||
CdRecordable, CdRewritable, HdDvdRewritable
|
CdRecordable, CdRewritable, HdDvdRewritable
|
||||||
|
@ -147,13 +144,8 @@ Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// not implemented by libcdio: VideoDvd, VideoBluRay
|
||||||
TODO: not implemented by libcdio:
|
// TODO: analyze all tracks
|
||||||
VideoDvd, VideoBluRay
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
TODO: analyze all tracks
|
|
||||||
*/
|
|
||||||
cdio_iso_analysis_t analysis;
|
cdio_iso_analysis_t analysis;
|
||||||
::memset(&analysis, 0, sizeof(analysis));
|
::memset(&analysis, 0, sizeof(analysis));
|
||||||
const cdio_fs_anal_t guessresult = cdio_guess_cd_type(p_cdio, 0, 0, &analysis);
|
const cdio_fs_anal_t guessresult = cdio_guess_cd_type(p_cdio, 0, 0, &analysis);
|
||||||
|
|
|
@ -38,7 +38,7 @@ OpticalDrive::OpticalDrive(UDevDevice *device)
|
||||||
: StorageDrive(device),
|
: StorageDrive(device),
|
||||||
p_cdio(Q_NULLPTR)
|
p_cdio(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
const QByteArray devicename = m_device->deviceName().toLocal8Bit();
|
const QByteArray devicename = m_device->property("DEVNAME").toString().toLocal8Bit();
|
||||||
p_cdio = cdio_open(devicename.constData(), DRIVER_UNKNOWN);
|
p_cdio = cdio_open(devicename.constData(), DRIVER_UNKNOWN);
|
||||||
if (!p_cdio) {
|
if (!p_cdio) {
|
||||||
qWarning() << "Could not open" << devicename;
|
qWarning() << "Could not open" << devicename;
|
||||||
|
@ -63,22 +63,44 @@ bool OpticalDrive::eject()
|
||||||
const QByteArray devicename = m_device->deviceName().toLocal8Bit();
|
const QByteArray devicename = m_device->deviceName().toLocal8Bit();
|
||||||
const driver_return_code_t result = cdio_eject_media_drive(devicename.constData());
|
const driver_return_code_t result = cdio_eject_media_drive(devicename.constData());
|
||||||
if (result == DRIVER_OP_SUCCESS) {
|
if (result == DRIVER_OP_SUCCESS) {
|
||||||
m_device->broadcastActionDone("setup", Solid::NoError, QString());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// not supported by libcdio: UserCanceled
|
||||||
TODO: check result and call broadcastActionDone with one of:
|
switch(result) {
|
||||||
UnauthorizedOperation
|
case DRIVER_OP_SUCCESS: {
|
||||||
DeviceBusy
|
m_device->broadcastActionDone("setup", Solid::NoError, QString());
|
||||||
OperationFailed
|
return true;
|
||||||
UserCanceled
|
}
|
||||||
InvalidOption
|
case DRIVER_OP_NOT_PERMITTED: {
|
||||||
MissingDriver
|
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||||
*/
|
m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, ejecterror);
|
||||||
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
return false;
|
||||||
m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, ejecterror);
|
}
|
||||||
return false;
|
case DRIVER_OP_BAD_PARAMETER: // falltrough
|
||||||
|
case DRIVER_OP_BAD_POINTER: {
|
||||||
|
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||||
|
m_device->broadcastActionDone("eject", Solid::InvalidOption, ejecterror);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case DRIVER_OP_NO_DRIVER: {
|
||||||
|
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||||
|
m_device->broadcastActionDone("eject", Solid::MissingDriver, ejecterror);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case DRIVER_OP_UNINIT: {
|
||||||
|
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||||
|
m_device->broadcastActionDone("eject", Solid::DeviceBusy, ejecterror);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||||
|
m_device->broadcastActionDone("eject", Solid::OperationFailed, ejecterror);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> OpticalDrive::writeSpeeds() const
|
QList<int> OpticalDrive::writeSpeeds() const
|
||||||
|
@ -152,10 +174,7 @@ Solid::OpticalDrive::MediumTypes OpticalDrive::supportedMedia() const
|
||||||
Q_UNUSED(reacap);
|
Q_UNUSED(reacap);
|
||||||
Q_UNUSED(misccap);
|
Q_UNUSED(misccap);
|
||||||
|
|
||||||
/*
|
// not supported by libcdio: Dvdplusr, Dvdplusdl, Dvdplusdlrw, Bd, Bdr, Bdre, HdDvd, HdDvdr, HdDvdrw
|
||||||
TODO: not supported by libcdio:
|
|
||||||
Dvdplusr, Dvdplusdl, Dvdplusdlrw, Bd, Bdr, Bdre, HdDvd, HdDvdr, HdDvdrw
|
|
||||||
*/
|
|
||||||
if (writecap == CDIO_DRIVE_CAP_ERROR) {
|
if (writecap == CDIO_DRIVE_CAP_ERROR) {
|
||||||
qWarning() << "Could not obtain write capabilities";
|
qWarning() << "Could not obtain write capabilities";
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue