From d0ad461ee292518484f821169929f28d8de85683 Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Mon, 5 Nov 2012 19:41:33 +0000 Subject: [PATCH] Remove CDROM/OpticalDisc handling - as this is not used by Cantata. --- devices/mediadevicecache.cpp | 9 +- solid-lite/CMakeLists.txt | 18 -- solid-lite/README | 4 +- solid-lite/backends/hal/halcdrom.cpp | 218 --------------- solid-lite/backends/hal/halcdrom.h | 77 ------ solid-lite/backends/hal/haldevice.cpp | 40 +-- solid-lite/backends/hal/halopticaldisc.cpp | 158 ----------- solid-lite/backends/hal/halopticaldisc.h | 53 ---- solid-lite/backends/udisks/udisksdevice.cpp | 44 +-- .../backends/udisks/udisksopticaldisc.cpp | 260 ------------------ .../backends/udisks/udisksopticaldisc.h | 63 ----- .../backends/udisks/udisksopticaldrive.cpp | 197 ------------- .../backends/udisks/udisksopticaldrive.h | 81 ------ solid-lite/backends/wmi/wmicdrom.cpp | 157 ----------- solid-lite/backends/wmi/wmicdrom.h | 69 ----- solid-lite/backends/wmi/wmiopticaldisc.cpp | 113 -------- solid-lite/backends/wmi/wmiopticaldisc.h | 57 ---- solid-lite/device.cpp | 20 +- solid-lite/ifaces/opticaldisc.cpp | 26 -- solid-lite/ifaces/opticaldisc.h | 96 ------- solid-lite/ifaces/opticaldrive.cpp | 26 -- solid-lite/ifaces/opticaldrive.h | 101 ------- solid-lite/opticaldisc.cpp | 73 ----- solid-lite/opticaldisc.h | 186 ------------- solid-lite/opticaldisc_p.h | 36 --- solid-lite/opticaldrive.cpp | 73 ----- solid-lite/opticaldrive.h | 186 ------------- solid-lite/opticaldrive_p.h | 36 --- 28 files changed, 56 insertions(+), 2421 deletions(-) delete mode 100644 solid-lite/backends/hal/halcdrom.cpp delete mode 100644 solid-lite/backends/hal/halcdrom.h delete mode 100644 solid-lite/backends/hal/halopticaldisc.cpp delete mode 100644 solid-lite/backends/hal/halopticaldisc.h delete mode 100644 solid-lite/backends/udisks/udisksopticaldisc.cpp delete mode 100644 solid-lite/backends/udisks/udisksopticaldisc.h delete mode 100644 solid-lite/backends/udisks/udisksopticaldrive.cpp delete mode 100644 solid-lite/backends/udisks/udisksopticaldrive.h delete mode 100644 solid-lite/backends/wmi/wmicdrom.cpp delete mode 100644 solid-lite/backends/wmi/wmicdrom.h delete mode 100644 solid-lite/backends/wmi/wmiopticaldisc.cpp delete mode 100644 solid-lite/backends/wmi/wmiopticaldisc.h delete mode 100644 solid-lite/ifaces/opticaldisc.cpp delete mode 100644 solid-lite/ifaces/opticaldisc.h delete mode 100644 solid-lite/ifaces/opticaldrive.cpp delete mode 100644 solid-lite/ifaces/opticaldrive.h delete mode 100644 solid-lite/opticaldisc.cpp delete mode 100644 solid-lite/opticaldisc.h delete mode 100644 solid-lite/opticaldisc_p.h delete mode 100644 solid-lite/opticaldrive.cpp delete mode 100644 solid-lite/opticaldrive.h delete mode 100644 solid-lite/opticaldrive_p.h diff --git a/devices/mediadevicecache.cpp b/devices/mediadevicecache.cpp index 6e0bdb13f..2d385d612 100644 --- a/devices/mediadevicecache.cpp +++ b/devices/mediadevicecache.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,6 @@ #include "solid-lite/deviceinterface.h" #include "solid-lite/devicenotifier.h" #include "solid-lite/genericinterface.h" -#include "solid-lite/opticaldisc.h" #include "solid-lite/portablemediaplayer.h" #include "solid-lite/storageaccess.h" #include "solid-lite/storagedrive.h" @@ -190,13 +188,8 @@ void MediaDeviceCache::slotAddDevice(const QString &udi) debug() << "Found new Solid device with udi = " << device.udi(); debug() << "Device name is = " << device.product() << " and was made by " << device.vendor(); Solid::StorageAccess *ssa = device.as(); - Solid::OpticalDisc * opt = device.as(); - if (opt && opt->availableContent() & Solid::OpticalDisc::Audio) { - debug() << "device is an Audio CD"; - m_type[udi] = MediaDeviceCache::AudioCdType; - m_name[udi] = device.vendor() + " - " + device.product(); - } else if (ssa) { + if (ssa) { debug() << "volume is generic storage"; if (!m_volumes.contains(device.udi())) { connect(ssa, SIGNAL(accessibilityChanged(bool, const QString&)), diff --git a/solid-lite/CMakeLists.txt b/solid-lite/CMakeLists.txt index 16457fde7..2d0ab737b 100644 --- a/solid-lite/CMakeLists.txt +++ b/solid-lite/CMakeLists.txt @@ -19,9 +19,7 @@ set(solidlite_LIB_SRCS genericinterface.cpp block.cpp storagedrive.cpp - opticaldrive.cpp storagevolume.cpp - opticaldisc.cpp storageaccess.cpp portablemediaplayer.cpp predicate.cpp @@ -31,12 +29,10 @@ set(solidlite_LIB_SRCS xdgbasedirs.cpp ifaces/block.cpp - ifaces/opticaldrive.cpp ifaces/device.cpp ifaces/deviceinterface.cpp ifaces/devicemanager.cpp ifaces/genericinterface.cpp - ifaces/opticaldisc.cpp ifaces/portablemediaplayer.cpp ifaces/storagedrive.cpp ifaces/storagevolume.cpp @@ -52,8 +48,6 @@ set(solidlite_LIB_MOC_HDRS devicenotifier.h device_p.h genericinterface.h - opticaldisc.h - opticaldrive.h portablemediaplayer.h storageaccess.h storagedrive.h @@ -119,13 +113,11 @@ set(solidlite_LIB_MOC_HDRS message(STATUS "Building Solid HAL backend." ) set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS} backends/hal/halblock.cpp - backends/hal/halcdrom.cpp backends/hal/haldeviceinterface.cpp backends/hal/halfstabhandling.cpp backends/hal/halgenericinterface.cpp backends/hal/haldevice.cpp backends/hal/halmanager.cpp - backends/hal/halopticaldisc.cpp backends/hal/halportablemediaplayer.cpp backends/hal/halstorageaccess.cpp backends/hal/halstorage.cpp @@ -133,12 +125,10 @@ set(solidlite_LIB_MOC_HDRS ) set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS} backends/hal/halblock.h - backends/hal/halcdrom.h backends/hal/haldevice.h backends/hal/haldeviceinterface.h backends/hal/halgenericinterface.h backends/hal/halmanager.h - backends/hal/halopticaldisc.h backends/hal/halportablemediaplayer.h backends/hal/halstorageaccess.h backends/hal/halstorage.h @@ -154,8 +144,6 @@ set(solidlite_LIB_MOC_HDRS backends/udisks/udisksblock.cpp backends/udisks/udisksstoragevolume.cpp backends/udisks/udisksdeviceinterface.cpp - backends/udisks/udisksopticaldisc.cpp - backends/udisks/udisksopticaldrive.cpp backends/udisks/udisksstoragedrive.cpp backends/udisks/udisksstorageaccess.cpp backends/udisks/udisksgenericinterface.cpp @@ -166,8 +154,6 @@ set(solidlite_LIB_MOC_HDRS backends/udisks/udisksdeviceinterface.h backends/udisks/udisksgenericinterface.h backends/udisks/udisksmanager.h - backends/udisks/udisksopticaldisc.h - backends/udisks/udisksopticaldrive.h backends/udisks/udisksstorageaccess.h backends/udisks/udisksstoragedrive.h backends/udisks/udisksstoragevolume.h @@ -209,12 +195,10 @@ if(WIN32) set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS} backends/wmi/wmiblock.cpp - backends/wmi/wmicdrom.cpp backends/wmi/wmideviceinterface.cpp backends/wmi/wmigenericinterface.cpp backends/wmi/wmidevice.cpp backends/wmi/wmimanager.cpp - backends/wmi/wmiopticaldisc.cpp backends/wmi/wmiportablemediaplayer.cpp backends/wmi/wmiquery.cpp backends/wmi/wmistorageaccess.cpp @@ -224,12 +208,10 @@ if(WIN32) ) set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS} backends/wmi/wmiblock.h - backends/wmi/wmicdrom.h backends/wmi/wmidevice.h backends/wmi/wmideviceinterface.h backends/wmi/wmigenericinterface.h backends/wmi/wmimanager.h - backends/wmi/wmiopticaldisc.h backends/wmi/wmiportablemediaplayer.h backends/wmi/wmistorageaccess.h backends/wmi/wmistorage.h diff --git a/solid-lite/README b/solid-lite/README index 26a872b53..dea862489 100644 --- a/solid-lite/README +++ b/solid-lite/README @@ -1,3 +1,3 @@ -This is a (cut down) copy of Solid for KDE4.9.1 +This is a (cut down) copy of Solid from KDE4.9.1 -Only disk/medisplayer detection is remaining - as this is all Cantata needs. +Only disk/mediaplayer detection is remaining - as this is all Cantata needs. diff --git a/solid-lite/backends/hal/halcdrom.cpp b/solid-lite/backends/hal/halcdrom.cpp deleted file mode 100644 index 1216641db..000000000 --- a/solid-lite/backends/hal/halcdrom.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halcdrom.h" - -#include -#include -#include -#include -#include - -#include "halfstabhandling.h" - -using namespace Solid::Backends::Hal; - -Cdrom::Cdrom(HalDevice *device) - : Storage(device), m_ejectInProgress(false) -{ - connect(device, SIGNAL(conditionRaised(QString,QString)), - this, SLOT(slotCondition(QString,QString))); - m_device->registerAction("eject", this, - SLOT(slotEjectRequested()), - SLOT(slotEjectDone(int,QString))); -} - -Cdrom::~Cdrom() -{ - -} - - -Solid::OpticalDrive::MediumTypes Cdrom::supportedMedia() const -{ - Solid::OpticalDrive::MediumTypes supported; - - QMap map; - map[Solid::OpticalDrive::Cdr] = "storage.cdrom.cdr"; - map[Solid::OpticalDrive::Cdrw] = "storage.cdrom.cdrw"; - map[Solid::OpticalDrive::Dvd] = "storage.cdrom.dvd"; - map[Solid::OpticalDrive::Dvdr] = "storage.cdrom.dvdr"; - map[Solid::OpticalDrive::Dvdrw] ="storage.cdrom.dvdrw"; - map[Solid::OpticalDrive::Dvdram] ="storage.cdrom.dvdram"; - map[Solid::OpticalDrive::Dvdplusr] ="storage.cdrom.dvdplusr"; - map[Solid::OpticalDrive::Dvdplusrw] ="storage.cdrom.dvdplusrw"; - map[Solid::OpticalDrive::Dvdplusdl] ="storage.cdrom.dvdplusrdl"; - map[Solid::OpticalDrive::Dvdplusdlrw] ="storage.cdrom.dvdplusrwdl"; - map[Solid::OpticalDrive::Bd] ="storage.cdrom.bd"; - map[Solid::OpticalDrive::Bdr] ="storage.cdrom.bdr"; - map[Solid::OpticalDrive::Bdre] ="storage.cdrom.bdre"; - map[Solid::OpticalDrive::HdDvd] ="storage.cdrom.hddvd"; - map[Solid::OpticalDrive::HdDvdr] ="storage.cdrom.hddvdr"; - map[Solid::OpticalDrive::HdDvdrw] ="storage.cdrom.hddvdrw"; - - foreach (const Solid::OpticalDrive::MediumType type, map.keys()) - { - if (m_device->prop(map[type]).toBool()) - { - supported|= type; - } - } - - return supported; -} - -int Cdrom::readSpeed() const -{ - return m_device->prop("storage.cdrom.read_speed").toInt(); -} - -int Cdrom::writeSpeed() const -{ - return m_device->prop("storage.cdrom.write_speed").toInt(); -} - -QList Cdrom::writeSpeeds() const -{ - QList speeds; - QStringList speed_strlist = m_device->prop("storage.cdrom.write_speeds").toStringList(); - - foreach (const QString &speed_str, speed_strlist) - { - speeds << speed_str.toInt(); - } - - return speeds; -} - -void Cdrom::slotCondition(const QString &name, const QString &/*reason */) -{ - if (name == "EjectPressed") - { - emit ejectPressed(m_device->udi()); - } -} - -bool Cdrom::eject() -{ - if (m_ejectInProgress) { - return false; - } - m_ejectInProgress = true; - m_device->broadcastActionRequested("eject"); - - if (FstabHandling::isInFstab(m_device->prop("block.device").toString())) { - return callSystemEject(); - } else { - return callHalDriveEject(); - } -} - -void Cdrom::slotEjectRequested() -{ - m_ejectInProgress = true; - emit ejectRequested(m_device->udi()); -} - -bool Cdrom::callHalDriveEject() -{ - QString udi = m_device->udi(); - QString interface = "org.freedesktop.Hal.Device.Storage"; - - // HACK: Eject doesn't work on cdrom drives when there's a mounted disc, - // let's try to workaround this by calling a child volume... - if (m_device->prop("storage.removable.media_available").toBool()) { - QDBusInterface manager("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - QDBusConnection::systemBus()); - - QDBusReply reply = manager.call("FindDeviceStringMatch", "info.parent", udi); - - if (reply.isValid()) - { - const QStringList udis = reply; - if (!udis.isEmpty()) { - udi = udis[0]; - interface = "org.freedesktop.Hal.Device.Volume"; - } - } - } - - QDBusConnection c = QDBusConnection::systemBus(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - interface, "Eject"); - - msg << QStringList(); - - - return c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -bool Solid::Backends::Hal::Cdrom::callSystemEject() -{ - const QString device = m_device->prop("block.device").toString(); - m_process = FstabHandling::callSystemCommand("eject", device, - this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); - - return m_process!=0; -} - -void Cdrom::slotDBusReply(const QDBusMessage &/*reply*/) -{ - m_ejectInProgress = false; - m_device->broadcastActionDone("eject"); -} - -void Cdrom::slotDBusError(const QDBusError &error) -{ - m_ejectInProgress = false; - - // TODO: Better error reporting here - m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, - QString(error.name()+": "+error.message())); -} - -void Solid::Backends::Hal::Cdrom::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitStatus); - if (m_ejectInProgress) { - m_ejectInProgress = false; - - if (exitCode==0) { - m_device->broadcastActionDone("eject"); - } else { - m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, - m_process->readAllStandardError()); - } - } - - delete m_process; -} - -void Cdrom::slotEjectDone(int error, const QString &errorString) -{ - m_ejectInProgress = false; - emit ejectDone(static_cast(error), errorString, m_device->udi()); -} - -//#include "backends/hal/halcdrom.moc" diff --git a/solid-lite/backends/hal/halcdrom.h b/solid-lite/backends/hal/halcdrom.h deleted file mode 100644 index 7f0d3e771..000000000 --- a/solid-lite/backends/hal/halcdrom.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_CDROM_H -#define SOLID_BACKENDS_HAL_CDROM_H - -#include -#include "halstorage.h" - -#include -#include -#include -#include - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Cdrom : public Storage, virtual public Solid::Ifaces::OpticalDrive -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDrive) - -public: - Cdrom(HalDevice *device); - virtual ~Cdrom(); - - virtual Solid::OpticalDrive::MediumTypes supportedMedia() const; - virtual int readSpeed() const; - virtual int writeSpeed() const; - virtual QList writeSpeeds() const; - virtual bool eject(); - -Q_SIGNALS: - void ejectPressed(const QString &udi); - void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void ejectRequested(const QString &udi); - -private Q_SLOTS: - void slotCondition(const QString &name, const QString &reason); - void slotDBusReply(const QDBusMessage &reply); - void slotDBusError(const QDBusError &error); - void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - void slotEjectRequested(); - void slotEjectDone(int error, const QString &errorString); - -private: - bool callHalDriveEject(); - bool callSystemEject(); - - bool m_ejectInProgress; - QProcess *m_process; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_CDROM_H diff --git a/solid-lite/backends/hal/haldevice.cpp b/solid-lite/backends/hal/haldevice.cpp index d66a28201..731cddf52 100644 --- a/solid-lite/backends/hal/haldevice.cpp +++ b/solid-lite/backends/hal/haldevice.cpp @@ -36,9 +36,9 @@ #include "halblock.h" #include "halstorageaccess.h" #include "halstorage.h" -#include "halcdrom.h" -//#include "halvolume.h" -#include "halopticaldisc.h" +//#include "halcdrom.h" +#include "halvolume.h" +//#include "halopticaldisc.h" //#include "halcamera.h" #include "halportablemediaplayer.h" //#include "halnetworkinterface.h" @@ -203,9 +203,9 @@ QString HalDevice::icon() const if (prop("storage.drive_type").toString()=="floppy") { return "media-floppy"; - } else if (prop("storage.drive_type").toString()=="cdrom") { + } /*else if (prop("storage.drive_type").toString()=="cdrom") { return "drive-optical"; - } else if (prop("storage.drive_type").toString()=="sd_mmc") { + } */ else if (prop("storage.drive_type").toString()=="sd_mmc") { return "media-flash-sd-mmc"; } else if (prop("storage.hotpluggable").toBool()) { if (prop("storage.bus").toString()=="usb") { @@ -235,13 +235,13 @@ QString HalDevice::icon() const || prop("volume.disc.is_appendable").toBool() || prop("volume.disc.is_rewritable").toBool(); - if (has_video) { + /*if (has_video) { return "media-optical-video"; } else if (has_audio) { return "media-optical-audio"; } else if (recordable) { return "media-optical-recordable"; - } else { + } else*/ { return "media-optical"; } @@ -469,15 +469,15 @@ QObject *HalDevice::createDeviceInterface(const Solid::DeviceInterface::Type &ty case Solid::DeviceInterface::StorageDrive: iface = new Storage(this); break; - case Solid::DeviceInterface::OpticalDrive: - iface = new Cdrom(this); - break; + //case Solid::DeviceInterface::OpticalDrive: + // iface = new Cdrom(this); + // break; case Solid::DeviceInterface::StorageVolume: iface = new Volume(this); break; - case Solid::DeviceInterface::OpticalDisc: - iface = new OpticalDisc(this); - break; + //case Solid::DeviceInterface::OpticalDisc: + // iface = new OpticalDisc(this); + // break; //case Solid::DeviceInterface::Camera: // iface = new Camera(this); // break; @@ -568,7 +568,7 @@ QString HalDevice::storageDescription() const Solid::StorageDrive::DriveType drive_type = storageDrive.driveType(); bool drive_is_hotpluggable = storageDrive.isHotpluggable(); - if (drive_type == Solid::StorageDrive::CdromDrive) { + /*if (drive_type == Solid::StorageDrive::CdromDrive) { const Cdrom opticalDrive(const_cast(this)); Solid::OpticalDrive::MediumTypes mediumTypes = opticalDrive.supportedMedia(); QString first; @@ -624,16 +624,16 @@ QString HalDevice::storageDescription() const } return description; - } + }*/ - if (drive_type == Solid::StorageDrive::Floppy) { + /*if (drive_type == Solid::StorageDrive::Floppy) { if (drive_is_hotpluggable) description = QObject::tr("External Floppy Drive"); else description = QObject::tr("Floppy Drive"); return description; - } + }*/ bool drive_is_removable = storageDrive.isRemovable(); @@ -693,7 +693,7 @@ QString HalDevice::volumeDescription() const Solid::StorageDrive::DriveType drive_type = storageDrive.driveType(); /* Handle media in optical drives */ - if (drive_type == Solid::StorageDrive::CdromDrive) { + /*if (drive_type == Solid::StorageDrive::CdromDrive) { const OpticalDisc disc(const_cast(this)); switch (disc.discType()) { case Solid::OpticalDisc::UnknownDiscType: @@ -805,13 +805,13 @@ QString HalDevice::volumeDescription() const break; } - /* Special case for pure audio disc */ + / * Special case for pure audio disc * / if (disc.availableContent() == Solid::OpticalDisc::Audio) { description = QObject::tr("Audio CD"); } return description; - } + }*/ bool drive_is_removable = storageDrive.isRemovable(); bool drive_is_hotpluggable = storageDrive.isHotpluggable(); diff --git a/solid-lite/backends/hal/halopticaldisc.cpp b/solid-lite/backends/hal/halopticaldisc.cpp deleted file mode 100644 index b6c378e6d..000000000 --- a/solid-lite/backends/hal/halopticaldisc.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halopticaldisc.h" - -using namespace Solid::Backends::Hal; - -OpticalDisc::OpticalDisc(HalDevice *device) - : Volume(device) -{ - -} - -OpticalDisc::~OpticalDisc() -{ - -} - - -Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const -{ - Solid::OpticalDisc::ContentTypes content; - - QMap map; - map[Solid::OpticalDisc::Audio] = "volume.disc.has_audio"; - map[Solid::OpticalDisc::Data] = "volume.disc.has_data"; - map[Solid::OpticalDisc::VideoCd] = "volume.disc.is_vcd"; - map[Solid::OpticalDisc::SuperVideoCd] = "volume.disc.is_svcd"; - map[Solid::OpticalDisc::VideoDvd] ="volume.disc.is_videodvd"; - map[Solid::OpticalDisc::VideoBluRay] ="volume.disc.is_blurayvideo"; - - foreach (const Solid::OpticalDisc::ContentType type, map.keys()) - { - if (m_device->prop(map[type]).toBool()) - { - content|= type; - } - } - - return content; -} - -Solid::OpticalDisc::DiscType OpticalDisc::discType() const -{ - QString type = m_device->prop("volume.disc.type").toString(); - - if (type == "cd_rom") - { - return Solid::OpticalDisc::CdRom; - } - else if (type == "cd_r") - { - return Solid::OpticalDisc::CdRecordable; - } - else if (type == "cd_rw") - { - return Solid::OpticalDisc::CdRewritable; - } - else if (type == "dvd_rom") - { - return Solid::OpticalDisc::DvdRom; - } - else if (type == "dvd_ram") - { - return Solid::OpticalDisc::DvdRam; - } - else if (type == "dvd_r") - { - return Solid::OpticalDisc::DvdRecordable; - } - else if (type == "dvd_rw") - { - return Solid::OpticalDisc::DvdRewritable; - } - else if (type == "dvd_plus_r") - { - return Solid::OpticalDisc::DvdPlusRecordable; - } - else if (type == "dvd_plus_rw") - { - return Solid::OpticalDisc::DvdPlusRewritable; - } - else if (type == "dvd_plus_r_dl") - { - return Solid::OpticalDisc::DvdPlusRecordableDuallayer; - } - else if (type == "dvd_plus_rw_dl") - { - return Solid::OpticalDisc::DvdPlusRewritableDuallayer; - } - else if (type == "bd_rom") - { - return Solid::OpticalDisc::BluRayRom; - } - else if (type == "bd_r") - { - return Solid::OpticalDisc::BluRayRecordable; - } - else if (type == "bd_re") - { - return Solid::OpticalDisc::BluRayRewritable; - } - else if (type == "hddvd_rom") - { - return Solid::OpticalDisc::HdDvdRom; - } - else if (type == "hddvd_r") - { - return Solid::OpticalDisc::HdDvdRecordable; - } - else if (type == "hddvd_rw") - { - return Solid::OpticalDisc::HdDvdRewritable; - } - else - { - return Solid::OpticalDisc::UnknownDiscType; - } -} - -bool OpticalDisc::isAppendable() const -{ - return m_device->prop("volume.disc.is_appendable").toBool(); -} - -bool OpticalDisc::isBlank() const -{ - return m_device->prop("volume.disc.is_blank").toBool(); -} - -bool OpticalDisc::isRewritable() const -{ - return m_device->prop("volume.disc.is_rewritable").toBool(); -} - -qulonglong OpticalDisc::capacity() const -{ - return m_device->prop("volume.disc.capacity").toULongLong(); -} - -//#include "backends/hal/halopticaldisc.moc" diff --git a/solid-lite/backends/hal/halopticaldisc.h b/solid-lite/backends/hal/halopticaldisc.h deleted file mode 100644 index da9d90716..000000000 --- a/solid-lite/backends/hal/halopticaldisc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_OPTICALDISC_H -#define SOLID_BACKENDS_HAL_OPTICALDISC_H - -#include -#include "halvolume.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class OpticalDisc : public Volume, virtual public Solid::Ifaces::OpticalDisc -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDisc) - -public: - OpticalDisc(HalDevice *device); - virtual ~OpticalDisc(); - - virtual Solid::OpticalDisc::ContentTypes availableContent() const; - virtual Solid::OpticalDisc::DiscType discType() const; - virtual bool isAppendable() const; - virtual bool isBlank() const; - virtual bool isRewritable() const; - virtual qulonglong capacity() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_OPTICALDISC_H diff --git a/solid-lite/backends/udisks/udisksdevice.cpp b/solid-lite/backends/udisks/udisksdevice.cpp index bbe8a8849..10b4698e8 100644 --- a/solid-lite/backends/udisks/udisksdevice.cpp +++ b/solid-lite/backends/udisks/udisksdevice.cpp @@ -23,8 +23,9 @@ #include "udisksdevice.h" #include "udisksdeviceinterface.h" #include "udisksstoragevolume.h" -#include "udisksopticaldisc.h" -#include "udisksopticaldrive.h" +#include "udisksstoragedrive.h" +//#include "udisksopticaldisc.h" +//#include "udisksopticaldrive.h" #include "udisksstorageaccess.h" #include "udisksgenericinterface.h" @@ -129,15 +130,15 @@ QObject* UDisksDevice::createDeviceInterface(const Solid::DeviceInterface::Type& case Solid::DeviceInterface::StorageDrive: iface = new UDisksStorageDrive(this); break; - case Solid::DeviceInterface::OpticalDrive: - iface = new UDisksOpticalDrive(this); - break; + //case Solid::DeviceInterface::OpticalDrive: + // iface = new UDisksOpticalDrive(this); + // break; case Solid::DeviceInterface::StorageVolume: iface = new UDisksStorageVolume(this); break; - case Solid::DeviceInterface::OpticalDisc: - iface = new OpticalDisc(this); - break; + //case Solid::DeviceInterface::OpticalDisc: + // iface = new OpticalDisc(this); + // break; default: break; } @@ -172,12 +173,12 @@ bool UDisksDevice::queryDeviceInterface(const Solid::DeviceInterface::Type& type case Solid::DeviceInterface::StorageDrive: return !m_udi.endsWith(":media") && prop("DeviceIsDrive").toBool(); - case Solid::DeviceInterface::OpticalDrive: - return !m_udi.endsWith(":media") - && prop( "DeviceIsDrive" ).toBool() - && !prop( "DriveMediaCompatibility" ).toStringList().filter( "optical_" ).isEmpty(); - case Solid::DeviceInterface::OpticalDisc: - return m_udi.endsWith(":media") && prop("DeviceIsOpticalDisc").toBool(); + //case Solid::DeviceInterface::OpticalDrive: + // return !m_udi.endsWith(":media") + // && prop( "DeviceIsDrive" ).toBool() + // && !prop( "DriveMediaCompatibility" ).toStringList().filter( "optical_" ).isEmpty(); + //case Solid::DeviceInterface::OpticalDisc: + // return m_udi.endsWith(":media") && prop("DeviceIsOpticalDisc").toBool(); default: return false; } @@ -235,7 +236,7 @@ QString UDisksDevice::storageDescription() const bool drive_is_hotpluggable = storageDrive.isHotpluggable(); const UDisks::UDisksStorageVolume storageVolume(const_cast(this)); - if (drive_type == Solid::StorageDrive::CdromDrive) + /*if (drive_type == Solid::StorageDrive::CdromDrive) { const UDisks::UDisksOpticalDrive opticalDrive(const_cast(this)); Solid::OpticalDrive::MediumTypes mediumTypes = opticalDrive.supportedMedia(); @@ -303,7 +304,7 @@ QString UDisksDevice::storageDescription() const description = QObject::tr("Floppy Drive"); return description; - } + }*/ bool drive_is_removable = storageDrive.isRemovable(); @@ -375,7 +376,7 @@ QString UDisksDevice::volumeDescription() const Solid::StorageDrive::DriveType drive_type = storageDrive.driveType(); // Handle media in optical drives - if (drive_type == Solid::StorageDrive::CdromDrive) + /*if (drive_type == Solid::StorageDrive::CdromDrive) { const UDisks::OpticalDisc disc(const_cast(this)); switch (disc.discType()) @@ -494,7 +495,7 @@ QString UDisksDevice::volumeDescription() const description = QObject::tr("Audio CD"); return description; - } + }*/ bool drive_is_removable = storageDrive.isRemovable(); bool drive_is_hotpluggable = storageDrive.isHotpluggable(); @@ -578,6 +579,7 @@ QString UDisksDevice::icon() const if ( !media.isEmpty() ) { +#if 0 if ( isOptical ) // optical stuff { bool isWritable = prop( "OpticalDiscIsBlank" ).toBool() || prop("OpticalDiscIsAppendable").toBool(); @@ -608,7 +610,7 @@ QString UDisksDevice::icon() const // fallback for every other optical disc return "media-optical"; } - +#endif if ( media == "flash_ms" ) // Flash & Co. return "media-flash-memory-stick"; else if ( media == "flash_sd" || media == "flash_sdhc" || media == "flash_mmc" ) @@ -626,9 +628,9 @@ QString UDisksDevice::icon() const bool isRemovable = prop( "DeviceIsRemovable" ).toBool(); const QString conn = prop( "DriveConnectionInterface" ).toString(); - if ( queryDeviceInterface(Solid::DeviceInterface::OpticalDrive) ) + /*if ( queryDeviceInterface(Solid::DeviceInterface::OpticalDrive) ) return "drive-optical"; - else if ( isRemovable && !isOptical ) + else*/ if ( isRemovable && !isOptical ) { if ( conn == "usb" ) return "drive-removable-media-usb"; diff --git a/solid-lite/backends/udisks/udisksopticaldisc.cpp b/solid-lite/backends/udisks/udisksopticaldisc.cpp deleted file mode 100644 index 42272aad8..000000000 --- a/solid-lite/backends/udisks/udisksopticaldisc.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - Copyright 2010 Michael Zanetti - Copyright 2010, 2011 Lukas Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include -#include -#include -#include - -#include - -#include "udisksopticaldisc.h" - -// inspired by http://cgit.freedesktop.org/hal/tree/hald/linux/probing/probe-volume.c -static Solid::OpticalDisc::ContentType advancedDiscDetect(const QString & device_file) -{ - /* the discs block size */ - unsigned short bs; - /* the path table size */ - unsigned short ts; - /* the path table location (in blocks) */ - unsigned int tl; - /* length of the directory name in current path table entry */ - unsigned char len_di = 0; - /* the number of the parent directory's path table entry */ - unsigned int parent = 0; - /* filename for the current path table entry */ - char dirname[256]; - /* our position into the path table */ - int pos = 0; - /* the path table record we're on */ - int curr_record = 1; - - Solid::OpticalDisc::ContentType result = Solid::OpticalDisc::NoContent; - - int fd = open (QFile::encodeName(device_file), O_RDONLY); - - /* read the block size */ - lseek (fd, 0x8080, SEEK_CUR); - if (read (fd, &bs, 2) != 2) - { - qDebug("Advanced probing on %s failed while reading block size", qPrintable(device_file)); - goto out; - } - - /* read in size of path table */ - lseek (fd, 2, SEEK_CUR); - if (read (fd, &ts, 2) != 2) - { - qDebug("Advanced probing on %s failed while reading path table size", qPrintable(device_file)); - goto out; - } - - /* read in which block path table is in */ - lseek (fd, 6, SEEK_CUR); - if (read (fd, &tl, 4) != 4) - { - qDebug("Advanced probing on %s failed while reading path table block", qPrintable(device_file)); - goto out; - } - - /* seek to the path table */ - lseek (fd, bs * tl, SEEK_SET); - - /* loop through the path table entries */ - while (pos < ts) - { - /* get the length of the filename of the current entry */ - if (read (fd, &len_di, 1) != 1) - { - qDebug("Advanced probing on %s failed, cannot read more entries", qPrintable(device_file)); - break; - } - - /* get the record number of this entry's parent - i'm pretty sure that the 1st entry is always the top directory */ - lseek (fd, 5, SEEK_CUR); - if (read (fd, &parent, 2) != 2) - { - qDebug("Advanced probing on %s failed, couldn't read parent entry", qPrintable(device_file)); - break; - } - - /* read the name */ - if (read (fd, dirname, len_di) != len_di) - { - qDebug("Advanced probing on %s failed, couldn't read the entry name", qPrintable(device_file)); - break; - } - dirname[len_di] = 0; - - /* if we found a folder that has the root as a parent, and the directory name matches - one of the special directories then set the properties accordingly */ - if (parent == 1) - { - if (!strcasecmp (dirname, "VIDEO_TS")) - { - qDebug("Disc in %s is a Video DVD", qPrintable(device_file)); - result = Solid::OpticalDisc::VideoDvd; - break; - } - else if (!strcasecmp (dirname, "BDMV")) - { - qDebug("Disc in %s is a Blu-ray video disc", qPrintable(device_file)); - result = Solid::OpticalDisc::VideoBluRay; - break; - } - else if (!strcasecmp (dirname, "VCD")) - { - qDebug("Disc in %s is a Video CD", qPrintable(device_file)); - result = Solid::OpticalDisc::VideoCd; - break; - } - else if (!strcasecmp (dirname, "SVCD")) - { - qDebug("Disc in %s is a Super Video CD", qPrintable(device_file)); - result = Solid::OpticalDisc::SuperVideoCd; - break; - } - } - - /* all path table entries are padded to be even, - so if this is an odd-length table, seek a byte to fix it */ - if (len_di%2 == 1) - { - lseek (fd, 1, SEEK_CUR); - pos++; - } - - /* update our position */ - pos += 8 + len_di; - curr_record++; - } - - close(fd); - return result; - -out: - /* go back to the start of the file */ - lseek (fd, 0, SEEK_SET); - close(fd); - return result; -} - -using namespace Solid::Backends::UDisks; - -OpticalDisc::OpticalDisc(UDisksDevice *device) - : UDisksStorageVolume(device), m_needsReprobe(true), m_cachedContent(Solid::OpticalDisc::NoContent) -{ - connect(device, SIGNAL(changed()), this, SLOT(slotChanged())); -} - -OpticalDisc::~OpticalDisc() -{ - -} - -qulonglong OpticalDisc::capacity() const -{ - return m_device->prop("DeviceSize").toULongLong(); -} - -bool OpticalDisc::isRewritable() const -{ - // the hard way, udisks has no notion of a disc "rewritability" - const QString mediaType = m_device->prop("DriveMedia").toString(); - return mediaType == "optical_cd_rw" || mediaType == "optical_dvd_rw" || mediaType == "optical_dvd_ram" || - mediaType == "optical_dvd_plus_rw" || mediaType == "optical_dvd_plus_rw_dl" || - mediaType == "optical_bd_re" || mediaType == "optical_hddvd_rw"; // TODO check completeness -} - -bool OpticalDisc::isBlank() const -{ - return m_device->prop("OpticalDiscIsBlank").toBool(); -} - -bool OpticalDisc::isAppendable() const -{ - return m_device->prop("OpticalDiscIsAppendable").toBool(); -} - -Solid::OpticalDisc::DiscType OpticalDisc::discType() const -{ - const QString discType = m_device->prop("DriveMedia").toString(); - - QMap map; - map[Solid::OpticalDisc::CdRom] = "optical_cd"; - map[Solid::OpticalDisc::CdRecordable] = "optical_cd_r"; - map[Solid::OpticalDisc::CdRewritable] = "optical_cd_rw"; - map[Solid::OpticalDisc::DvdRom] = "optical_dvd"; - map[Solid::OpticalDisc::DvdRecordable] = "optical_dvd_r"; - map[Solid::OpticalDisc::DvdRewritable] ="optical_dvd_rw"; - map[Solid::OpticalDisc::DvdRam] ="optical_dvd_ram"; - map[Solid::OpticalDisc::DvdPlusRecordable] ="optical_dvd_plus_r"; - map[Solid::OpticalDisc::DvdPlusRewritable] ="optical_dvd_plus_rw"; - map[Solid::OpticalDisc::DvdPlusRecordableDuallayer] ="optical_dvd_plus_r_dl"; - map[Solid::OpticalDisc::DvdPlusRewritableDuallayer] ="optical_dvd_plus_rw_dl"; - map[Solid::OpticalDisc::BluRayRom] ="optical_bd"; - map[Solid::OpticalDisc::BluRayRecordable] ="optical_bd_r"; - map[Solid::OpticalDisc::BluRayRewritable] ="optical_bd_re"; - map[Solid::OpticalDisc::HdDvdRom] ="optical_hddvd"; - map[Solid::OpticalDisc::HdDvdRecordable] ="optical_hddvd_r"; - map[Solid::OpticalDisc::HdDvdRewritable] ="optical_hddvd_rw"; - // TODO add these to Solid - //map[Solid::OpticalDisc::MagnetoOptical] ="optical_mo"; - //map[Solid::OpticalDisc::MountRainer] ="optical_mrw"; - //map[Solid::OpticalDisc::MountRainerWritable] ="optical_mrw_w"; - - return map.key( discType, Solid::OpticalDisc::UnknownDiscType ); -} - -Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const -{ - if (isBlank()) { - m_needsReprobe = false; - return Solid::OpticalDisc::NoContent; - } - - if (m_needsReprobe) { - m_cachedContent = Solid::OpticalDisc::NoContent; - bool hasData = m_device->prop("OpticalDiscNumTracks").toInt() > 0 && - m_device->prop("OpticalDiscNumTracks").toInt() > m_device->prop("OpticalDiscNumAudioTracks").toInt(); - bool hasAudio = m_device->prop("OpticalDiscNumAudioTracks").toInt() > 0; - - if ( hasData ) { - m_cachedContent |= Solid::OpticalDisc::Data; - m_cachedContent |= advancedDiscDetect(m_device->prop("DeviceFile").toString()); - } - if ( hasAudio ) - m_cachedContent |= Solid::OpticalDisc::Audio; - - m_needsReprobe = false; - } - - return m_cachedContent; -} - -void OpticalDisc::slotChanged() -{ - m_needsReprobe = true; - m_cachedContent = Solid::OpticalDisc::NoContent; -} - diff --git a/solid-lite/backends/udisks/udisksopticaldisc.h b/solid-lite/backends/udisks/udisksopticaldisc.h deleted file mode 100644 index a0319764c..000000000 --- a/solid-lite/backends/udisks/udisksopticaldisc.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2010 Michael Zanetti - Copyright 2010, 2011 Lukas Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef OPTICALDISC_H -#define OPTICALDISC_H - -#include -#include "udisksstoragevolume.h" - -namespace Solid -{ -namespace Backends -{ -namespace UDisks -{ - -class OpticalDisc : public UDisksStorageVolume, virtual public Solid::Ifaces::OpticalDisc -{ - - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDisc) - -public: - OpticalDisc(UDisksDevice *device); - virtual ~OpticalDisc(); - - virtual qulonglong capacity() const; - virtual bool isRewritable() const; - virtual bool isBlank() const; - virtual bool isAppendable() const; - virtual Solid::OpticalDisc::DiscType discType() const; - virtual Solid::OpticalDisc::ContentTypes availableContent() const; - -private slots: - void slotChanged(); - -private: - mutable bool m_needsReprobe; - mutable Solid::OpticalDisc::ContentTypes m_cachedContent; -}; - -} -} -} -#endif // OPTICALDISC_H diff --git a/solid-lite/backends/udisks/udisksopticaldrive.cpp b/solid-lite/backends/udisks/udisksopticaldrive.cpp deleted file mode 100644 index 601c84237..000000000 --- a/solid-lite/backends/udisks/udisksopticaldrive.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - Copyright 2010 Michael Zanetti - Copyright 2010-2011 Lukas Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "udisksopticaldrive.h" -#include "udisks.h" -#include "udisksdevice.h" - -using namespace Solid::Backends::UDisks; - -UDisksOpticalDrive::UDisksOpticalDrive(UDisksDevice *device) - : UDisksStorageDrive(device), m_ejectInProgress(false), m_readSpeed(0), m_writeSpeed(0), m_speedsInit(false) -{ - m_device->registerAction("eject", this, - SLOT(slotEjectRequested()), - SLOT(slotEjectDone(int,QString))); - - connect(m_device, SIGNAL(changed()), this, SLOT(slotChanged())); -} - -UDisksOpticalDrive::~UDisksOpticalDrive() -{ - -} - -bool UDisksOpticalDrive::eject() -{ - if (m_ejectInProgress) - return false; - m_ejectInProgress = true; - m_device->broadcastActionRequested("eject"); - - QDBusConnection c = QDBusConnection::systemBus(); - - QString path = m_device->udi(); - - // check if the device is mounted and call umount if needed - if (m_device->prop("DeviceIsMounted").toBool()) - { - QDBusMessage msg = QDBusMessage::createMethodCall(UD_DBUS_SERVICE, path, UD_DBUS_INTERFACE_DISKS_DEVICE, "FilesystemUnmount"); - msg << QStringList(); // options, unused now - c.call(msg, QDBus::NoBlock); - } - - QDBusMessage msg = QDBusMessage::createMethodCall(UD_DBUS_SERVICE, path, UD_DBUS_INTERFACE_DISKS_DEVICE, "DriveEject"); - msg << QStringList(); - return c.callWithCallback(msg, this, SLOT(slotDBusReply(QDBusMessage)), SLOT(slotDBusError(QDBusError))); -} - -void UDisksOpticalDrive::slotDBusReply(const QDBusMessage &/*reply*/) -{ - m_ejectInProgress = false; - m_device->broadcastActionDone("eject"); -} - -void UDisksOpticalDrive::slotDBusError(const QDBusError &error) -{ - m_ejectInProgress = false; - m_device->broadcastActionDone("eject", m_device->errorToSolidError(error.name()), - m_device->errorToString(error.name()) + ": " +error.message()); -} - -void UDisksOpticalDrive::slotEjectRequested() -{ - m_ejectInProgress = true; - emit ejectRequested(m_device->udi()); -} - -void UDisksOpticalDrive::slotEjectDone(int error, const QString &errorString) -{ - m_ejectInProgress = false; - emit ejectDone(static_cast(error), errorString, m_device->udi()); -} - -void UDisksOpticalDrive::initReadWriteSpeeds() const -{ -#if 0 - int read_speed, write_speed; - char *write_speeds = 0; - QByteArray device_file = QFile::encodeName(m_device->property("DeviceFile").toString()); - - //qDebug("Doing open (\"%s\", O_RDONLY | O_NONBLOCK)", device_file.constData()); - int fd = open(device_file, O_RDONLY | O_NONBLOCK); - if (fd < 0) { - qWarning("Cannot open %s: %s", device_file.constData(), strerror (errno)); - return; - } - - if (get_read_write_speed(fd, &read_speed, &write_speed, &write_speeds) >= 0) { - m_readSpeed = read_speed; - m_writeSpeed = write_speed; - - QStringList list = QString::fromLatin1(write_speeds).split(',', QString::SkipEmptyParts); - foreach (const QString & speed, list) - m_writeSpeeds.append(speed.toInt()); - - free(write_speeds); - - m_speedsInit = true; - } - - close(fd); -#endif -} - -QList UDisksOpticalDrive::writeSpeeds() const -{ - if (!m_speedsInit) - initReadWriteSpeeds(); - //qDebug() << "solid write speeds:" << m_writeSpeeds; - return m_writeSpeeds; -} - -int UDisksOpticalDrive::writeSpeed() const -{ - if (!m_speedsInit) - initReadWriteSpeeds(); - return m_writeSpeed; -} - -int UDisksOpticalDrive::readSpeed() const -{ - if (!m_speedsInit) - initReadWriteSpeeds(); - return m_readSpeed; -} - -Solid::OpticalDrive::MediumTypes UDisksOpticalDrive::supportedMedia() const -{ - const QStringList mediaTypes = m_device->prop("DriveMediaCompatibility").toStringList(); - Solid::OpticalDrive::MediumTypes supported; - - QMap map; - map[Solid::OpticalDrive::Cdr] = "optical_cd_r"; - map[Solid::OpticalDrive::Cdrw] = "optical_cd_rw"; - map[Solid::OpticalDrive::Dvd] = "optical_dvd"; - map[Solid::OpticalDrive::Dvdr] = "optical_dvd_r"; - map[Solid::OpticalDrive::Dvdrw] ="optical_dvd_rw"; - map[Solid::OpticalDrive::Dvdram] ="optical_dvd_ram"; - map[Solid::OpticalDrive::Dvdplusr] ="optical_dvd_plus_r"; - map[Solid::OpticalDrive::Dvdplusrw] ="optical_dvd_plus_rw"; - map[Solid::OpticalDrive::Dvdplusdl] ="optical_dvd_plus_r_dl"; - map[Solid::OpticalDrive::Dvdplusdlrw] ="optical_dvd_plus_rw_dl"; - map[Solid::OpticalDrive::Bd] ="optical_bd"; - map[Solid::OpticalDrive::Bdr] ="optical_bd_r"; - map[Solid::OpticalDrive::Bdre] ="optical_bd_re"; - map[Solid::OpticalDrive::HdDvd] ="optical_hddvd"; - map[Solid::OpticalDrive::HdDvdr] ="optical_hddvd_r"; - map[Solid::OpticalDrive::HdDvdrw] ="optical_hddvd_rw"; - // TODO add these to Solid - //map[Solid::OpticalDrive::Mo] ="optical_mo"; - //map[Solid::OpticalDrive::Mr] ="optical_mrw"; - //map[Solid::OpticalDrive::Mrw] ="optical_mrw_w"; - - foreach ( const Solid::OpticalDrive::MediumType & type, map.keys() ) - { - if ( mediaTypes.contains( map[type] ) ) - { - supported |= type; - } - } - - return supported; -} - -void UDisksOpticalDrive::slotChanged() -{ - m_speedsInit = false; // reset the read/write speeds, changes eg. with an inserted media -} diff --git a/solid-lite/backends/udisks/udisksopticaldrive.h b/solid-lite/backends/udisks/udisksopticaldrive.h deleted file mode 100644 index 1e5d634f7..000000000 --- a/solid-lite/backends/udisks/udisksopticaldrive.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright 2010 Michael Zanetti - Copyright 2010 Lukas Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef UDISKSOPTICALDRIVE_H -#define UDISKSOPTICALDRIVE_H - -#include -#include "udisksstoragedrive.h" - -namespace Solid -{ -namespace Backends -{ -namespace UDisks -{ - -class UDisksOpticalDrive: public UDisksStorageDrive, virtual public Solid::Ifaces::OpticalDrive -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDrive) - -public: - UDisksOpticalDrive(UDisksDevice *device); - virtual ~UDisksOpticalDrive(); - -Q_SIGNALS: - void ejectPressed(const QString &udi); - void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void ejectRequested(const QString &udi); - -public: - virtual bool eject(); - virtual QList writeSpeeds() const; - virtual int writeSpeed() const; - virtual int readSpeed() const; - virtual Solid::OpticalDrive::MediumTypes supportedMedia() const; - -private Q_SLOTS: - void slotDBusReply(const QDBusMessage &reply); - void slotDBusError(const QDBusError &error); - - void slotEjectRequested(); - void slotEjectDone(int error, const QString &errorString); - - void slotChanged(); - -private: - void initReadWriteSpeeds() const; - - bool m_ejectInProgress; - - // read/write speeds - mutable int m_readSpeed; - mutable int m_writeSpeed; - mutable QList m_writeSpeeds; - mutable bool m_speedsInit; -}; - -} -} -} - -#endif // UDISKSOPTICALDRIVE_H diff --git a/solid-lite/backends/wmi/wmicdrom.cpp b/solid-lite/backends/wmi/wmicdrom.cpp deleted file mode 100644 index 6e0cc8566..000000000 --- a/solid-lite/backends/wmi/wmicdrom.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - Copyright 2012 Patrick von Reth - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "wmicdrom.h" - -#include - - -using namespace Solid::Backends::Wmi; - -Cdrom::Cdrom(WmiDevice *device) - : Storage(device), m_ejectInProgress(false) -{ - connect(device, SIGNAL(conditionRaised(QString,QString)), - this, SLOT(slotCondition(QString,QString))); -} - -Cdrom::~Cdrom() -{ - -} - - -Solid::OpticalDrive::MediumTypes Cdrom::supportedMedia() const -{ - Solid::OpticalDrive::MediumTypes supported; - - QString type = m_device->property("MediaType").toString(); - if (type == "CdRomOnly" || type == "CD-ROM") - { - supported |= Solid::OpticalDrive::Cdr; - } - else if (type == "CdRomWrite") - { - supported |= Solid::OpticalDrive::Cdr|Solid::OpticalDrive::Cdrw; - } - else if (type == "DVDRomOnly") - { - supported |= Solid::OpticalDrive::Dvd; - } - else if (type == "DVDRomWrite" || type == "DVD Writer") - { - supported |= Solid::OpticalDrive::Dvd|Solid::OpticalDrive::Dvdr|Solid::OpticalDrive::Dvdrw; - } - - return supported; -} - -int Cdrom::readSpeed() const -{ - return m_device->property("TransferRate").toInt(); -} - -int Cdrom::writeSpeed() const -{ - return m_device->property("TransferRate").toInt(); -} - -QList Cdrom::writeSpeeds() const -{ - QList speeds; - return speeds; -} - -void Cdrom::slotCondition(const QString &name, const QString &/*reason */) -{ - if (name == "EjectPressed") - { - emit ejectPressed(m_device->udi()); - } -} - -bool Cdrom::eject() -{ - if (m_ejectInProgress) { - return false; - } - m_ejectInProgress = true; - - return callWmiDriveEject(); -} - -bool Cdrom::callWmiDriveEject() -{ -// QString udi = m_device->udi(); -// QString interface = "org.freedesktop.Wmi.Device.Storage"; - - // HACK: Eject doesn't work on cdrom drives when there's a mounted disc, - // let's try to workaround this by calling a child volume... - // if (m_device->property("storage.removable.media_available").toBool()) { - // QDBusInterface manager("org.freedesktop.Wmi", - // "/org/freedesktop/Wmi/Manager", - // "org.freedesktop.Wmi.Manager", - // QDBusConnection::systemBus()); - - // QDBusReply reply = manager.call("FindDeviceStringMatch", "info.parent", udi); - - // if (reply.isValid()) - // { - // QStringList udis = reply; - // if (!udis.isEmpty()) { - // udi = udis[0]; - // interface = "org.freedesktop.Wmi.Device.Volume"; - // } - // } - // } - - // QDBusConnection c = QDBusConnection::systemBus(); - // QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Wmi", udi, - // interface, "Eject"); - - // msg << QStringList(); - - - // return c.callWithCallback(msg, this, - // SLOT(slotDBusReply(QDBusMessage)), - // SLOT(slotDBusError(QDBusError))); - return false; -} - -void Solid::Backends::Wmi::Cdrom::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitStatus); - if (m_ejectInProgress) { - m_ejectInProgress = false; - - if (exitCode==0) { - emit ejectDone(Solid::NoError, QVariant(), m_device->udi()); - } else { - emit ejectDone(Solid::UnauthorizedOperation, - m_process->readAllStandardError(), - m_device->udi()); - } - } - - delete m_process; -} - -//#include "backends/wmi/wmicdrom.moc" diff --git a/solid-lite/backends/wmi/wmicdrom.h b/solid-lite/backends/wmi/wmicdrom.h deleted file mode 100644 index 6c7fda6a3..000000000 --- a/solid-lite/backends/wmi/wmicdrom.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright 2012 Patrick von Reth - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_WMI_CDROM_H -#define SOLID_BACKENDS_WMI_CDROM_H - -#include -#include "wmistorage.h" - -#include - -namespace Solid -{ -namespace Backends -{ -namespace Wmi -{ -class Cdrom : public Storage, virtual public Solid::Ifaces::OpticalDrive -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDrive) - -public: - Cdrom(WmiDevice *device); - virtual ~Cdrom(); - - virtual Solid::OpticalDrive::MediumTypes supportedMedia() const; - virtual int readSpeed() const; - virtual int writeSpeed() const; - virtual QList writeSpeeds() const; - virtual bool eject(); - -Q_SIGNALS: - void ejectPressed(const QString &udi); - void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - -private Q_SLOTS: - void slotCondition(const QString &name, const QString &reason); - void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - -private: - bool callWmiDriveEject(); - - bool m_ejectInProgress; - QProcess *m_process; -}; -} -} -} - -#endif // SOLID_BACKENDS_WMI_CDROM_H diff --git a/solid-lite/backends/wmi/wmiopticaldisc.cpp b/solid-lite/backends/wmi/wmiopticaldisc.cpp deleted file mode 100644 index 05ba8084e..000000000 --- a/solid-lite/backends/wmi/wmiopticaldisc.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - Copyright 2012 Patrick von Reth - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "wmiopticaldisc.h" - - -#include - -using namespace Solid::Backends::Wmi; - -OpticalDisc::OpticalDisc(WmiDevice *device) - : Volume(device) -{ - m_logicalDisk = WmiDevice::win32LogicalDiskByDriveLetter(m_device->property("Drive").toString()); -} - -OpticalDisc::~OpticalDisc() -{ - -} - - -Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const -{ - Solid::OpticalDisc::ContentTypes content; - - QDir dir(m_device->property("Drive").toString()); - QStringList files = dir.entryList(); - if(files.length()>0) - if(files[0].endsWith(".cda")) - content |= Solid::OpticalDisc::Audio; - - return content; -} - -Solid::OpticalDisc::DiscType OpticalDisc::discType() const -{ - QString type = m_logicalDisk.getProperty("FileSystem").toString(); - - if (type == "CDFS") - { - return Solid::OpticalDisc::CdRom; - } -// else if (type == "CdRomWrite") -// { -// return Solid::OpticalDisc::CdRecordable; -// } - else if (type == "UDF") - { - return Solid::OpticalDisc::DvdRom; - } -// else if (type == "DVDRomWrite") -// { -// return Solid::OpticalDisc::DvdRecordable; -// } - else - { - qDebug()<<"Solid::OpticalDisc::DiscType OpticalDisc::discType(): Unknown Type"<property("FileSystemFlagsEx").toUInt(); - if(val == 0) - return true; - return false; -} - -bool OpticalDisc::isRewritable() const -{ - //TODO: - return capacity()>0 && isWriteable(); -} - -qulonglong OpticalDisc::capacity() const -{ - return m_device->property("Size").toULongLong(); -} - -bool OpticalDisc::isWriteable() const -{ - ushort val = m_device->property("FileSystemFlagsEx").toUInt(); - if(val == 0) - return true; - return !val & 0x80001;//read only -} - -//#include "backends/wmi/wmiopticaldisc.moc" diff --git a/solid-lite/backends/wmi/wmiopticaldisc.h b/solid-lite/backends/wmi/wmiopticaldisc.h deleted file mode 100644 index a2bbf3bbf..000000000 --- a/solid-lite/backends/wmi/wmiopticaldisc.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2012 Patrick von Reth - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_WMI_OPTICALDISC_H -#define SOLID_BACKENDS_WMI_OPTICALDISC_H - -#include -#include "wmivolume.h" - -namespace Solid -{ -namespace Backends -{ -namespace Wmi -{ -class OpticalDisc : public Volume, virtual public Solid::Ifaces::OpticalDisc -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDisc) - -public: - OpticalDisc(WmiDevice *device); - virtual ~OpticalDisc(); - - virtual Solid::OpticalDisc::ContentTypes availableContent() const; - virtual Solid::OpticalDisc::DiscType discType() const; - virtual bool isAppendable() const; - virtual bool isBlank() const; - virtual bool isRewritable() const; - virtual qulonglong capacity() const; -private: - bool isWriteable() const; - WmiQuery::Item m_logicalDisk; -}; -} -} -} - -#endif // SOLID_BACKENDS_WMI_OPTICALDISC_H diff --git a/solid-lite/device.cpp b/solid-lite/device.cpp index 814f1ebb4..263845030 100644 --- a/solid-lite/device.cpp +++ b/solid-lite/device.cpp @@ -38,12 +38,12 @@ #include #include #include -#include -#include +//#include +//#include #include #include -#include -#include +//#include +//#include //#include //#include #include @@ -195,15 +195,15 @@ const Solid::DeviceInterface *Solid::Device::asDeviceInterface(const DeviceInter case DeviceInterface::StorageDrive: iface = deviceinterface_cast(Ifaces::StorageDrive, StorageDrive, dev_iface); break; - case DeviceInterface::OpticalDrive: - iface = deviceinterface_cast(Ifaces::OpticalDrive, OpticalDrive, dev_iface); - break; + //case DeviceInterface::OpticalDrive: + // iface = deviceinterface_cast(Ifaces::OpticalDrive, OpticalDrive, dev_iface); + // break; case DeviceInterface::StorageVolume: iface = deviceinterface_cast(Ifaces::StorageVolume, StorageVolume, dev_iface); break; - case DeviceInterface::OpticalDisc: - iface = deviceinterface_cast(Ifaces::OpticalDisc, OpticalDisc, dev_iface); - break; + //case DeviceInterface::OpticalDisc: + // iface = deviceinterface_cast(Ifaces::OpticalDisc, OpticalDisc, dev_iface); + // break; //case DeviceInterface::Camera: // iface = deviceinterface_cast(Ifaces::Camera, Camera, dev_iface); // break; diff --git a/solid-lite/ifaces/opticaldisc.cpp b/solid-lite/ifaces/opticaldisc.cpp deleted file mode 100644 index 5047fa0c0..000000000 --- a/solid-lite/ifaces/opticaldisc.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "opticaldisc.h" - -Solid::Ifaces::OpticalDisc::~OpticalDisc() -{ -} - diff --git a/solid-lite/ifaces/opticaldisc.h b/solid-lite/ifaces/opticaldisc.h deleted file mode 100644 index 4ef41e969..000000000 --- a/solid-lite/ifaces/opticaldisc.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_IFACES_OPTICALDISC_H -#define SOLID_IFACES_OPTICALDISC_H - -#include -#include - -namespace Solid -{ -namespace Ifaces -{ - /** - * This device interface is available on optical discs. - * - * An optical disc is a volume that can be inserted in a cdrom drive. - */ - class OpticalDisc : virtual public StorageVolume - { - public: - /** - * Destroys an OpticalDisc object. - */ - virtual ~OpticalDisc(); - - - /** - * Retrieves the content types this disc contains (audio, video, - * data...). - * - * @return the flag set indicating the available contents - */ - virtual Solid::OpticalDisc::ContentTypes availableContent() const = 0; - - /** - * Retrieves the disc type (cdr, cdrw...). - * - * @return the disc type - */ - virtual Solid::OpticalDisc::DiscType discType() const = 0; - - /** - * Indicates if it's possible to write additional data to the disc. - * - * @return true if the disc is appendable, false otherwise - */ - virtual bool isAppendable() const = 0; - - /** - * Indicates if the disc is blank. - * - * @return true if the disc is blank, false otherwise - */ - virtual bool isBlank() const = 0; - - /** - * Indicates if the disc is rewritable. - * - * A disc is rewritable if you can write on it several times. - * - * @return true if the disc is rewritable, false otherwise - */ - virtual bool isRewritable() const = 0; - - /** - * Retrieves the disc capacity (that is the maximum size of a - * volume could have on this disc). - * - * @return the capacity of the disc in bytes - */ - virtual qulonglong capacity() const = 0; - }; -} -} - -Q_DECLARE_INTERFACE(Solid::Ifaces::OpticalDisc, "org.kde.Solid.Ifaces.OpticalDisc/0.1") - -#endif diff --git a/solid-lite/ifaces/opticaldrive.cpp b/solid-lite/ifaces/opticaldrive.cpp deleted file mode 100644 index 91679f1d3..000000000 --- a/solid-lite/ifaces/opticaldrive.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "opticaldrive.h" - -Solid::Ifaces::OpticalDrive::~OpticalDrive() -{ -} - diff --git a/solid-lite/ifaces/opticaldrive.h b/solid-lite/ifaces/opticaldrive.h deleted file mode 100644 index 3903a1980..000000000 --- a/solid-lite/ifaces/opticaldrive.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_IFACE_OPTICALDRIVE_H -#define SOLID_IFACE_OPTICALDRIVE_H - -#include - -#include -#include - -namespace Solid -{ -namespace Ifaces -{ - /** - * This device interface is available on CD-ROM drives. - * - * A Cdrom is a storage that can handle optical discs. - */ - class OpticalDrive : virtual public StorageDrive - { - public: - /** - * Destroys a Cdrom object. - */ - virtual ~OpticalDrive(); - - /** - * Retrieves the medium types this drive supports. - * - * @return the flag set indicating the supported medium types - */ - virtual Solid::OpticalDrive::MediumTypes supportedMedia() const = 0; - - /** - * Retrieves the maximum read speed of this drive in kilobytes. - * - * @return the maximum read speed - */ - virtual int readSpeed() const = 0; - - /** - * Retrieves the maximum write speed of this drive in kilobytes. - * - * @return the maximum write speed - */ - virtual int writeSpeed() const = 0; - - /** - * Retrieves the list of supported write speeds of this drive in - * kilobytes. - * - * @return the list of supported write speeds - */ - virtual QList writeSpeeds() const = 0; - - /** - * Ejects any disc that could be contained in this drive. - * If this drive is empty, but has a tray it'll be opened - * - * @return - */ - virtual bool eject() = 0; - - protected: - //Q_SIGNALS: - /** - * This signal is emitted when the eject button is pressed - * on the drive. - * - * Please note that some (broken) drives doesn't report this event. - * @param udi the UDI of the drive - */ - virtual void ejectPressed(const QString &udi) = 0; - - virtual void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi) = 0; - }; -} -} - -Q_DECLARE_INTERFACE(Solid::Ifaces::OpticalDrive, "org.kde.Solid.Ifaces.OpticalDrive/0.1") - -#endif // SOLID_IFACE_OPTICALDRIVE_H diff --git a/solid-lite/opticaldisc.cpp b/solid-lite/opticaldisc.cpp deleted file mode 100644 index 94bc3f583..000000000 --- a/solid-lite/opticaldisc.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright 2006-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "opticaldisc.h" -#include "opticaldisc_p.h" - -#include "soliddefs_p.h" -#include - -Solid::OpticalDisc::OpticalDisc(QObject *backendObject) - : StorageVolume(*new OpticalDiscPrivate(), backendObject) -{ -} - -Solid::OpticalDisc::~OpticalDisc() -{ - -} - -Solid::OpticalDisc::ContentTypes Solid::OpticalDisc::availableContent() const -{ - Q_D(const OpticalDisc); - return_SOLID_CALL(Ifaces::OpticalDisc *, d->backendObject(), ContentTypes(), availableContent()); -} - -Solid::OpticalDisc::DiscType Solid::OpticalDisc::discType() const -{ - Q_D(const OpticalDisc); - return_SOLID_CALL(Ifaces::OpticalDisc *, d->backendObject(), UnknownDiscType, discType()); -} - -bool Solid::OpticalDisc::isAppendable() const -{ - Q_D(const OpticalDisc); - return_SOLID_CALL(Ifaces::OpticalDisc *, d->backendObject(), false, isAppendable()); -} - -bool Solid::OpticalDisc::isBlank() const -{ - Q_D(const OpticalDisc); - return_SOLID_CALL(Ifaces::OpticalDisc *, d->backendObject(), false, isBlank()); -} - -bool Solid::OpticalDisc::isRewritable() const -{ - Q_D(const OpticalDisc); - return_SOLID_CALL(Ifaces::OpticalDisc *, d->backendObject(), false, isRewritable()); -} - -qulonglong Solid::OpticalDisc::capacity() const -{ - Q_D(const OpticalDisc); - return_SOLID_CALL(Ifaces::OpticalDisc *, d->backendObject(), 0, capacity()); -} - -//#include "opticaldisc.moc" diff --git a/solid-lite/opticaldisc.h b/solid-lite/opticaldisc.h deleted file mode 100644 index b6bf30c1d..000000000 --- a/solid-lite/opticaldisc.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - Copyright 2006-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_OPTICALDISC_H -#define SOLID_OPTICALDISC_H - -#include - -#include - -namespace Solid -{ - class OpticalDiscPrivate; - class Device; - - /** - * This device interface is available on optical discs. - * - * An optical disc is a volume that can be inserted in CD-R*,DVD*,Blu-Ray,HD-DVD drives. - */ - class SOLID_EXPORT OpticalDisc : public StorageVolume - { - Q_OBJECT - Q_ENUMS(ContentType DiscType) - Q_FLAGS(ContentTypes) - Q_PROPERTY(ContentTypes availableContent READ availableContent) - Q_PROPERTY(DiscType discType READ discType) - Q_PROPERTY(bool appendable READ isAppendable) - Q_PROPERTY(bool blank READ isBlank) - Q_PROPERTY(bool rewritable READ isRewritable) - Q_PROPERTY(qulonglong capacity READ capacity) - Q_DECLARE_PRIVATE(OpticalDisc) - friend class Device; - - public: - /** - * This enum type defines the type of content available in an optical disc. - * - * - Audio : A disc containing audio - * - Data : A disc containing data - * - VideoCd : A Video Compact Disc (VCD) - * - SuperVideoCd : A Super Video Compact Disc (SVCD) - * - VideoDvd : A Video Digital Versatile Disc (DVD-Video) - */ - enum ContentType { - NoContent = 0x00, - Audio = 0x01, - Data = 0x02, - VideoCd = 0x04, - SuperVideoCd = 0x08, - VideoDvd = 0x10, - VideoBluRay = 0x20 - }; - - /** - * This type stores an OR combination of ContentType values. - */ - Q_DECLARE_FLAGS(ContentTypes, ContentType) - - /** - * This enum type defines the type of optical disc it can be. - * - * - UnknownDiscType : An undetermined disc type - * - CdRom : A Compact Disc Read-Only Memory (CD-ROM) - * - CdRecordable : A Compact Disc Recordable (CD-R) - * - CdRewritable : A Compact Disc ReWritable (CD-RW) - * - DvdRom : A Digital Versatile Disc Read-Only Memory (DVD-ROM) - * - DvdRam : A Digital Versatile Disc Random Access Memory (DVD-RAM) - * - DvdRecordable : A Digital Versatile Disc Recordable (DVD-R) - * - DvdRewritable : A Digital Versatile Disc ReWritable (DVD-RW) - * - DvdPlusRecordable : A Digital Versatile Disc Recordable (DVD+R) - * - DvdPlusRewritable : A Digital Versatile Disc ReWritable (DVD+RW) - * - DvdPlusRecordableDuallayer : A Digital Versatile Disc Recordable Dual-Layer (DVD+R DL) - * - DvdPlusRewritableDuallayer : A Digital Versatile Disc ReWritable Dual-Layer (DVD+RW DL) - * - BluRayRom : A Blu-ray Disc (BD) - * - BluRayRecordable : A Blu-ray Disc Recordable (BD-R) - * - BluRayRewritable : A Blu-ray Disc (BD-RE) - * - HdDvdRom: A High Density Digital Versatile Disc (HD DVD) - * - HdDvdRecordable : A High Density Digital Versatile Disc Recordable (HD DVD-R) - * - HdDvdRewritable : A High Density Digital Versatile Disc ReWritable (HD DVD-RW) - */ - enum DiscType { UnknownDiscType = -1, - CdRom, CdRecordable, CdRewritable, DvdRom, DvdRam, - DvdRecordable, DvdRewritable, - DvdPlusRecordable, DvdPlusRewritable, - DvdPlusRecordableDuallayer, DvdPlusRewritableDuallayer, - BluRayRom, BluRayRecordable, BluRayRewritable, - HdDvdRom, HdDvdRecordable, HdDvdRewritable }; - - - private: - /** - * Creates a new OpticalDisc object. - * You generally won't need this. It's created when necessary using - * Device::as(). - * - * @param backendObject the device interface object provided by the backend - * @see Solid::Device::as() - */ - explicit OpticalDisc(QObject *backendObject); - - public: - /** - * Destroys an OpticalDisc object. - */ - virtual ~OpticalDisc(); - - - /** - * Get the Solid::DeviceInterface::Type of the OpticalDisc device interface. - * - * @return the OpticalDisc device interface type - * @see Solid::Ifaces::Enums::DeviceInterface::Type - */ - static Type deviceInterfaceType() { return DeviceInterface::OpticalDisc; } - - - /** - * Retrieves the content types this disc contains (audio, video, - * data...). - * - * @return the flag set indicating the available contents - * @see Solid::OpticalDisc::ContentType - */ - ContentTypes availableContent() const; - - /** - * Retrieves the disc type (cdr, cdrw...). - * - * @return the disc type - */ - DiscType discType() const; - - /** - * Indicates if it's possible to write additional data to the disc. - * - * @return true if the disc is appendable, false otherwise - */ - bool isAppendable() const; - - /** - * Indicates if the disc is blank. - * - * @return true if the disc is blank, false otherwise - */ - bool isBlank() const; - - /** - * Indicates if the disc is rewritable. - * - * A disc is rewritable if you can write on it several times. - * - * @return true if the disc is rewritable, false otherwise - */ - bool isRewritable() const; - - /** - * Retrieves the disc capacity (that is the maximum size of a - * volume could have on this disc). - * - * @return the capacity of the disc in bytes - */ - qulonglong capacity() const; - }; -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::OpticalDisc::ContentTypes) - -#endif diff --git a/solid-lite/opticaldisc_p.h b/solid-lite/opticaldisc_p.h deleted file mode 100644 index b5da48a56..000000000 --- a/solid-lite/opticaldisc_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2006-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_OPTICALDISC_P_H -#define SOLID_OPTICALDISC_P_H - -#include "storagevolume_p.h" - -namespace Solid -{ - class OpticalDiscPrivate : public StorageVolumePrivate - { - public: - OpticalDiscPrivate() - : StorageVolumePrivate() { } - }; -} - -#endif diff --git a/solid-lite/opticaldrive.cpp b/solid-lite/opticaldrive.cpp deleted file mode 100644 index 60967f2f2..000000000 --- a/solid-lite/opticaldrive.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright 2006-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "opticaldrive.h" -#include "opticaldrive_p.h" - -#include "soliddefs_p.h" -#include - -Solid::OpticalDrive::OpticalDrive(QObject *backendObject) - : StorageDrive(*new OpticalDrivePrivate(), backendObject) -{ - connect(backendObject, SIGNAL(ejectPressed(QString)), - this, SIGNAL(ejectPressed(QString))); - connect(backendObject, SIGNAL(ejectDone(Solid::ErrorType,QVariant,QString)), - this, SIGNAL(ejectDone(Solid::ErrorType,QVariant,QString))); - connect(backendObject, SIGNAL(ejectRequested(QString)), - this, SIGNAL(ejectRequested(QString))); -} - -Solid::OpticalDrive::~OpticalDrive() -{ - -} - -Solid::OpticalDrive::MediumTypes Solid::OpticalDrive::supportedMedia() const -{ - Q_D(const OpticalDrive); - return_SOLID_CALL(Ifaces::OpticalDrive *, d->backendObject(), MediumTypes(), supportedMedia()); -} - -int Solid::OpticalDrive::readSpeed() const -{ - Q_D(const OpticalDrive); - return_SOLID_CALL(Ifaces::OpticalDrive *, d->backendObject(), 0, readSpeed()); -} - -int Solid::OpticalDrive::writeSpeed() const -{ - Q_D(const OpticalDrive); - return_SOLID_CALL(Ifaces::OpticalDrive *, d->backendObject(), 0, writeSpeed()); -} - -QList Solid::OpticalDrive::writeSpeeds() const -{ - Q_D(const OpticalDrive); - return_SOLID_CALL(Ifaces::OpticalDrive *, d->backendObject(), QList(), writeSpeeds()); -} - -bool Solid::OpticalDrive::eject() -{ - Q_D(OpticalDrive); - return_SOLID_CALL(Ifaces::OpticalDrive *, d->backendObject(), false, eject()); -} - -//#include "opticaldrive.moc" diff --git a/solid-lite/opticaldrive.h b/solid-lite/opticaldrive.h deleted file mode 100644 index 26dd02741..000000000 --- a/solid-lite/opticaldrive.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - Copyright 2006-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_OPTICALDRIVE_H -#define SOLID_OPTICALDRIVE_H - -#include -#include - -#include -#include - -#include - -namespace Solid -{ - class OpticalDrivePrivate; - class Device; - - /** - * This device interface is available on CD-R*,DVD*,Blu-Ray,HD-DVD drives. - * - * An OpticalDrive is a storage that can handle optical discs. - */ - class SOLID_EXPORT OpticalDrive : public StorageDrive - { - Q_OBJECT - Q_ENUMS(MediumType) - Q_FLAGS(MediumTypes) - Q_PROPERTY(MediumTypes supportedMedia READ supportedMedia) - Q_PROPERTY(int readSpeed READ readSpeed) - Q_PROPERTY(int writeSpeed READ writeSpeed) - Q_PROPERTY(QList writeSpeeds READ writeSpeeds) - Q_DECLARE_PRIVATE(OpticalDrive) - friend class Device; - - public: - /** - * This enum type defines the type of medium an optical drive supports. - * - * - Cdr : A Recordable Compact Disc (CD-R) - * - Cdrw : A ReWritable Compact Disc (CD-RW) - * - Dvd : A Digital Versatile Disc (DVD) - * - Dvdr : A Recordable Digital Versatile Disc (DVD-R) - * - Dvdrw : A ReWritable Digital Versatile Disc (DVD-RW) - * - Dvdram : A Random Access Memory Digital Versatile Disc (DVD-RAM) - * - Dvdplusr : A Recordable Digital Versatile Disc (DVD+R) - * - Dvdplusrw : A ReWritable Digital Versatile Disc (DVD+RW) - * - Dvdplusdl : A Dual Layer Digital Versatile Disc (DVD+R DL) - * - Dvdplusdlrw : A Dual Layer Digital Versatile Disc (DVD+RW DL) - * - Bd : A Blu-ray Disc (BD) - * - Bdr : A Blu-ray Disc Recordable (BD-R) - * - Bdre : A Blu-ray Disc Recordable and Eraseable (BD-RE) - * - HdDvd : A High Density Digital Versatile Disc (HD DVD) - * - HdDvdr : A High Density Digital Versatile Disc Recordable (HD DVD-R) - * - HdDvdrw : A High Density Digital Versatile Disc ReWritable (HD DVD-RW) - */ - enum MediumType { Cdr=0x00001, Cdrw=0x00002, Dvd=0x00004, Dvdr=0x00008, - Dvdrw=0x00010, Dvdram=0x00020, Dvdplusr=0x00040, - Dvdplusrw=0x00080, Dvdplusdl=0x00100, Dvdplusdlrw=0x00200, - Bd=0x00400, Bdr=0x00800, Bdre=0x01000, - HdDvd=0x02000, HdDvdr=0x04000, HdDvdrw=0x08000 }; - - /** - * This type stores an OR combination of MediumType values. - */ - Q_DECLARE_FLAGS(MediumTypes, MediumType) - - - private: - /** - * Creates a new OpticalDrive object. - * You generally won't need this. It's created when necessary using - * Device::as(). - * - * @param backendObject the device interface object provided by the backend - * @see Solid::Device::as() - */ - explicit OpticalDrive(QObject *backendObject); - - public: - /** - * Destroys an OpticalDrive object. - */ - virtual ~OpticalDrive(); - - - /** - * Get the Solid::DeviceInterface::Type of the OpticalDrive device interface. - * - * @return the OpticalDrive device interface type - * @see Solid::Ifaces::Enums::DeviceInterface::Type - */ - static Type deviceInterfaceType() { return DeviceInterface::OpticalDrive; } - - - /** - * Retrieves the medium types this drive supports. - * - * @return the flag set indicating the supported medium types - */ - MediumTypes supportedMedia() const; - - /** - * Retrieves the maximum read speed of this drive in kilobytes per second. - * - * @return the maximum read speed - */ - int readSpeed() const; - - /** - * Retrieves the maximum write speed of this drive in kilobytes per second. - * - * @return the maximum write speed - */ - int writeSpeed() const; - - /** - * Retrieves the list of supported write speeds of this drive in - * kilobytes per second. - * - * @return the list of supported write speeds - */ - QList writeSpeeds() const; - - /** - * Ejects any disc that could be contained in this drive. - * If this drive is empty, but has a tray it'll be opened. - * - * @return the status of the eject operation - */ - bool eject(); - - Q_SIGNALS: - /** - * This signal is emitted when the eject button is pressed - * on the drive. - * - * Please note that some (broken) drives doesn't report this event. - * @param udi the UDI of the drive - */ - void ejectPressed(const QString &udi); - - /** - * This signal is emitted when the attempted eject process on this - * drive is completed. The signal might be spontaneous, i.e. - * it can be triggered by another process. - * - * @param error type of error that occurred, if any - * @param errorData more information about the error, if any - * @param udi the UDI of the volume - */ - void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - - /** - * This signal is emitted when eject on this drive is - * requested. The signal might be spontaneous, i.e. it - * can be triggered by another process. - * - * @param udi the UDI of the volume - */ - void ejectRequested(const QString &udi); - - }; -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::OpticalDrive::MediumTypes) - -#endif // SOLID_OPTICALDRIVE_H diff --git a/solid-lite/opticaldrive_p.h b/solid-lite/opticaldrive_p.h deleted file mode 100644 index 09a6d241d..000000000 --- a/solid-lite/opticaldrive_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2006-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_OPTICALDRIVE_P_H -#define SOLID_OPTICALDRIVE_P_H - -#include "storagedrive_p.h" - -namespace Solid -{ - class OpticalDrivePrivate : public StorageDrivePrivate - { - public: - OpticalDrivePrivate() - : StorageDrivePrivate() { } - }; -} - -#endif // SOLID_OPTICALDRIVE_P_H