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
|
||||
case Solid::DeviceInterface::OpticalDrive:
|
||||
return (property("ID_TYPE").toString() == "cd" || property("ID_CDROM_MEDIA_CD").toInt() == 1);
|
||||
case Solid::DeviceInterface::OpticalDisc:
|
||||
return false; // TODO:
|
||||
return (property("ID_TYPE").toString() == "cd" || property("ID_CDROM_MEDIA_CD").toInt() == 1);
|
||||
#endif
|
||||
|
||||
case Solid::DeviceInterface::Camera:
|
||||
|
|
|
@ -30,7 +30,7 @@ OpticalDisc::OpticalDisc(UDevDevice *device)
|
|||
: StorageVolume(device),
|
||||
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);
|
||||
if (!p_cdio) {
|
||||
qWarning() << "Could not open" << devicename;
|
||||
|
@ -81,10 +81,7 @@ Solid::OpticalDisc::DiscType OpticalDisc::discType() const
|
|||
return Solid::OpticalDisc::UnknownDiscType;
|
||||
}
|
||||
|
||||
/*
|
||||
libcdio does not support blue-ray, maybe it will some day
|
||||
BluRayRom, BluRayRecordable, BluRayRewritable
|
||||
*/
|
||||
// not supported by libcdio: BluRayRom, BluRayRecordable, BluRayRewritable
|
||||
/*
|
||||
TODO: not implemented by libcdio/needs rw query on CDIO_DISC_MODE_CD_*?
|
||||
CdRecordable, CdRewritable, HdDvdRewritable
|
||||
|
@ -147,13 +144,8 @@ Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const
|
|||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: not implemented by libcdio:
|
||||
VideoDvd, VideoBluRay
|
||||
*/
|
||||
/*
|
||||
TODO: analyze all tracks
|
||||
*/
|
||||
// not implemented by libcdio: VideoDvd, VideoBluRay
|
||||
// TODO: analyze all tracks
|
||||
cdio_iso_analysis_t analysis;
|
||||
::memset(&analysis, 0, sizeof(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),
|
||||
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);
|
||||
if (!p_cdio) {
|
||||
qWarning() << "Could not open" << devicename;
|
||||
|
@ -63,22 +63,44 @@ bool OpticalDrive::eject()
|
|||
const QByteArray devicename = m_device->deviceName().toLocal8Bit();
|
||||
const driver_return_code_t result = cdio_eject_media_drive(devicename.constData());
|
||||
if (result == DRIVER_OP_SUCCESS) {
|
||||
m_device->broadcastActionDone("setup", Solid::NoError, QString());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: check result and call broadcastActionDone with one of:
|
||||
UnauthorizedOperation
|
||||
DeviceBusy
|
||||
OperationFailed
|
||||
UserCanceled
|
||||
InvalidOption
|
||||
MissingDriver
|
||||
*/
|
||||
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||
m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, ejecterror);
|
||||
return false;
|
||||
// not supported by libcdio: UserCanceled
|
||||
switch(result) {
|
||||
case DRIVER_OP_SUCCESS: {
|
||||
m_device->broadcastActionDone("setup", Solid::NoError, QString());
|
||||
return true;
|
||||
}
|
||||
case DRIVER_OP_NOT_PERMITTED: {
|
||||
const QString ejecterror = QString::fromLatin1(cdio_driver_errmsg(result));;
|
||||
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
|
||||
|
@ -152,10 +174,7 @@ Solid::OpticalDrive::MediumTypes OpticalDrive::supportedMedia() const
|
|||
Q_UNUSED(reacap);
|
||||
Q_UNUSED(misccap);
|
||||
|
||||
/*
|
||||
TODO: not supported by libcdio:
|
||||
Dvdplusr, Dvdplusdl, Dvdplusdlrw, Bd, Bdr, Bdre, HdDvd, HdDvdr, HdDvdrw
|
||||
*/
|
||||
// not supported by libcdio: Dvdplusr, Dvdplusdl, Dvdplusdlrw, Bd, Bdr, Bdre, HdDvd, HdDvdr, HdDvdrw
|
||||
if (writecap == CDIO_DRIVE_CAP_ERROR) {
|
||||
qWarning() << "Could not obtain write capabilities";
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue