mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
solid: optical drive media types implementation
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1d740b7466
commit
2fda57ec54
2 changed files with 67 additions and 4 deletions
|
@ -18,17 +18,24 @@
|
|||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "udevopticaldrive.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include "udevopticaldrive.h"
|
||||
|
||||
using namespace Solid::Backends::UDev;
|
||||
|
||||
// TODO: Q_CONSTRUCTOR_FUNCTION() for cdio_init()? cdio_open() is supposed to call it
|
||||
|
||||
OpticalDrive::OpticalDrive(UDevDevice *device)
|
||||
: StorageDrive(device)
|
||||
: StorageDrive(device),
|
||||
p_cdio(Q_NULLPTR)
|
||||
{
|
||||
const QByteArray devicename = m_device->deviceName().toLocal8Bit();
|
||||
p_cdio = cdio_open(devicename.constData(), DRIVER_UNKNOWN);
|
||||
if (!p_cdio) {
|
||||
qWarning() << "Could not open" << devicename;
|
||||
}
|
||||
|
||||
m_device->registerAction("eject", this,
|
||||
SLOT(slotEjectRequested()),
|
||||
SLOT(slotEjectDone(int,QString)));
|
||||
|
@ -36,6 +43,9 @@ OpticalDrive::OpticalDrive(UDevDevice *device)
|
|||
|
||||
OpticalDrive::~OpticalDrive()
|
||||
{
|
||||
if (p_cdio) {
|
||||
cdio_destroy(p_cdio);
|
||||
}
|
||||
}
|
||||
|
||||
bool OpticalDrive::eject()
|
||||
|
@ -80,7 +90,54 @@ int OpticalDrive::readSpeed() const
|
|||
|
||||
Solid::OpticalDrive::MediumTypes OpticalDrive::supportedMedia() const
|
||||
{
|
||||
return 0; // TODO:
|
||||
Solid::OpticalDrive::MediumTypes result = 0;
|
||||
if (!p_cdio) {
|
||||
return result;
|
||||
}
|
||||
|
||||
cdio_drive_read_cap_t reacap;
|
||||
cdio_drive_write_cap_t writecap;
|
||||
cdio_drive_misc_cap_t misccap;
|
||||
cdio_get_drive_cap(p_cdio, &reacap, &writecap, &misccap);
|
||||
// ignoring read capabilities on purpose
|
||||
Q_UNUSED(reacap);
|
||||
Q_UNUSED(misccap);
|
||||
|
||||
/*
|
||||
TODO: 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 {
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_CD_R) {
|
||||
result |= Solid::OpticalDrive::Cdr;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_CD_RW) {
|
||||
result |= Solid::OpticalDrive::Cdrw;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_DVD_R) {
|
||||
result |= Solid::OpticalDrive::Dvd;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_DVD_PR) {
|
||||
result |= Solid::OpticalDrive::Dvdr;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_DVD_RW) {
|
||||
result |= Solid::OpticalDrive::Dvdrw;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_DVD_RAM) {
|
||||
result |= Solid::OpticalDrive::Dvdram;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_DVD_RPW) {
|
||||
result |= Solid::OpticalDrive::Dvdplusrw;
|
||||
}
|
||||
if (writecap & CDIO_DRIVE_CAP_WRITE_DVD_RPW) {
|
||||
result |= Solid::OpticalDrive::Dvdplusrw;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void OpticalDrive::slotEjectRequested()
|
||||
|
|
|
@ -22,8 +22,11 @@
|
|||
#define UDEVOPTICALDRIVE_H
|
||||
|
||||
#include <solid/ifaces/opticaldrive.h>
|
||||
|
||||
#include "udevstoragedrive.h"
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
|
||||
namespace Solid
|
||||
{
|
||||
namespace Backends
|
||||
|
@ -55,6 +58,9 @@ public:
|
|||
private Q_SLOTS:
|
||||
void slotEjectRequested();
|
||||
void slotEjectDone(int error, const QString &errorString);
|
||||
|
||||
private:
|
||||
CdIo_t *p_cdio;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue