Fix classification of optical media

This resolves Bug 1612
pull/16/head
Timothy Pearson 11 years ago
parent 4a6abc0208
commit cbf8c414a1

@ -899,9 +899,35 @@ TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQ
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) == "1") {
disktype = disktype | TDEDiskDeviceType::CDROM;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_CD_R")) == "1") {
disktype = disktype | TDEDiskDeviceType::CDR;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_CD_RW")) == "1") {
disktype = disktype | TDEDiskDeviceType::CDRW;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
disktype = disktype & ~TDEDiskDeviceType::CDR;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_MRW")) == "1") {
disktype = disktype | TDEDiskDeviceType::CDMRRW;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
disktype = disktype & ~TDEDiskDeviceType::CDR;
disktype = disktype & ~TDEDiskDeviceType::CDRW;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_MRW_W")) == "1") {
disktype = disktype | TDEDiskDeviceType::CDMRRWW;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
disktype = disktype & ~TDEDiskDeviceType::CDR;
disktype = disktype & ~TDEDiskDeviceType::CDRW;
disktype = disktype & ~TDEDiskDeviceType::CDMRRW;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_MO")) == "1") {
disktype = disktype | TDEDiskDeviceType::CDMO;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
disktype = disktype & ~TDEDiskDeviceType::CDR;
disktype = disktype & ~TDEDiskDeviceType::CDRW;
disktype = disktype & ~TDEDiskDeviceType::CDMRRW;
disktype = disktype & ~TDEDiskDeviceType::CDMRRWW;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDROM;
@ -911,45 +937,95 @@ TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQ
disktype = disktype | TDEDiskDeviceType::DVDRAM;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
}
if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_R")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_R_DL")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_R")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R_DL")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_R_DL")) == "1")
) {
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_R")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_R_DL")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDPLUSR;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDRDL;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_R_DL")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDPLUSRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSR;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RW")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDRW;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSR;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSRDL;
}
if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RW")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RW_DL")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_RW")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW_DL")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_MINUS_RW_DL")) == "1")
) {
disktype = disktype | TDEDiskDeviceType::DVDRW; // FIXME
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_RW_DL")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDRWDL;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSR;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDRW;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDPLUSRW;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSR;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDRW;
disktype = disktype & ~TDEDiskDeviceType::DVDRWDL;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_DVD_PLUS_RW_DL")) == "1") {
disktype = disktype | TDEDiskDeviceType::DVDPLUSRWDL;
disktype = disktype & ~TDEDiskDeviceType::DVDROM;
disktype = disktype & ~TDEDiskDeviceType::DVDR;
disktype = disktype & ~TDEDiskDeviceType::DVDRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSR;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSRDL;
disktype = disktype & ~TDEDiskDeviceType::DVDRW;
disktype = disktype & ~TDEDiskDeviceType::DVDRWDL;
disktype = disktype & ~TDEDiskDeviceType::DVDPLUSRW;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD")) == "1") {
disktype = disktype | TDEDiskDeviceType::BDROM;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
}
if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_R")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_R_DL")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_PLUS_R")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_MINUS_R")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_R_DL")) == "1") // FIXME There is no official udev attribute for this type of disc (yet!)
) {
disktype = disktype | TDEDiskDeviceType::BDRW; // FIXME
disktype = disktype | TDEDiskDeviceType::BDR;
disktype = disktype & ~TDEDiskDeviceType::BDROM;
}
if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_RW")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_RW_DL")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_PLUS_RW")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_MINUS_RW")) == "1")
if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_RE")) == "1")
|| (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_BD_RE_DL")) == "1") // FIXME There is no official udev attribute for this type of disc (yet!)
) {
disktype = disktype | TDEDiskDeviceType::BDRW;
disktype = disktype & ~TDEDiskDeviceType::BDROM;
disktype = disktype & ~TDEDiskDeviceType::BDR;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_HDDVD")) == "1") {
disktype = disktype | TDEDiskDeviceType::HDDVDROM;
disktype = disktype & ~TDEDiskDeviceType::CDROM;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_HDDVD_R")) == "1") {
disktype = disktype | TDEDiskDeviceType::HDDVDR;
disktype = disktype & ~TDEDiskDeviceType::HDDVDROM;
}
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_HDDVD_RW")) == "1") {
disktype = disktype | TDEDiskDeviceType::HDDVDRW;
disktype = disktype & ~TDEDiskDeviceType::HDDVDROM;
disktype = disktype & ~TDEDiskDeviceType::HDDVDR;
}
if (!TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO")).isNull()) {
disktype = disktype | TDEDiskDeviceType::CDAudio;
@ -1153,24 +1229,69 @@ TDEDiskDeviceType::TDEDiskDeviceType readDiskDeviceSubtypeFromString(TQString qu
if (query == "CDROM") {
ret = ret | TDEDiskDeviceType::CDROM;
}
if (query == "CDR") {
ret = ret | TDEDiskDeviceType::CDR;
}
if (query == "CDRW") {
ret = ret | TDEDiskDeviceType::CDRW;
}
if (query == "CDMO") {
ret = ret | TDEDiskDeviceType::CDMO;
}
if (query == "CDMRRW") {
ret = ret | TDEDiskDeviceType::CDMRRW;
}
if (query == "CDMRRWW") {
ret = ret | TDEDiskDeviceType::CDMRRWW;
}
if (query == "DVDROM") {
ret = ret | TDEDiskDeviceType::DVDROM;
}
if (query == "DVDRAM") {
ret = ret | TDEDiskDeviceType::DVDRAM;
}
if (query == "DVDR") {
ret = ret | TDEDiskDeviceType::DVDR;
}
if (query == "DVDRW") {
ret = ret | TDEDiskDeviceType::DVDRW;
}
if (query == "DVDRDL") {
ret = ret | TDEDiskDeviceType::DVDRDL;
}
if (query == "DVDRWDL") {
ret = ret | TDEDiskDeviceType::DVDRWDL;
}
if (query == "DVDPLUSR") {
ret = ret | TDEDiskDeviceType::DVDPLUSR;
}
if (query == "DVDPLUSRW") {
ret = ret | TDEDiskDeviceType::DVDPLUSRW;
}
if (query == "DVDPLUSRDL") {
ret = ret | TDEDiskDeviceType::DVDPLUSRDL;
}
if (query == "DVDPLUSRWDL") {
ret = ret | TDEDiskDeviceType::DVDPLUSRWDL;
}
if (query == "BDROM") {
ret = ret | TDEDiskDeviceType::BDROM;
}
if (query == "BDR") {
ret = ret | TDEDiskDeviceType::BDR;
}
if (query == "BDRW") {
ret = ret | TDEDiskDeviceType::BDRW;
}
if (query == "HDDVDROM") {
ret = ret | TDEDiskDeviceType::HDDVDROM;
}
if (query == "HDDVDR") {
ret = ret | TDEDiskDeviceType::HDDVDR;
}
if (query == "HDDVDRW") {
ret = ret | TDEDiskDeviceType::HDDVDRW;
}
if (query == "Zip") {
ret = ret | TDEDiskDeviceType::Zip;
}
@ -2146,12 +2267,27 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
disktype = sdevice->diskType(); // The type can be overridden by an external rule
if ((disktype & TDEDiskDeviceType::CDROM)
|| (disktype & TDEDiskDeviceType::CDR)
|| (disktype & TDEDiskDeviceType::CDRW)
|| (disktype & TDEDiskDeviceType::CDMO)
|| (disktype & TDEDiskDeviceType::CDMRRW)
|| (disktype & TDEDiskDeviceType::CDMRRWW)
|| (disktype & TDEDiskDeviceType::DVDROM)
|| (disktype & TDEDiskDeviceType::DVDRAM)
|| (disktype & TDEDiskDeviceType::DVDR)
|| (disktype & TDEDiskDeviceType::DVDRW)
|| (disktype & TDEDiskDeviceType::DVDRDL)
|| (disktype & TDEDiskDeviceType::DVDRWDL)
|| (disktype & TDEDiskDeviceType::DVDPLUSR)
|| (disktype & TDEDiskDeviceType::DVDPLUSRW)
|| (disktype & TDEDiskDeviceType::DVDPLUSRDL)
|| (disktype & TDEDiskDeviceType::DVDPLUSRWDL)
|| (disktype & TDEDiskDeviceType::BDROM)
|| (disktype & TDEDiskDeviceType::BDR)
|| (disktype & TDEDiskDeviceType::BDRW)
|| (disktype & TDEDiskDeviceType::HDDVDROM)
|| (disktype & TDEDiskDeviceType::HDDVDR)
|| (disktype & TDEDiskDeviceType::HDDVDRW)
|| (disktype & TDEDiskDeviceType::CDAudio)
|| (disktype & TDEDiskDeviceType::CDVideo)
|| (disktype & TDEDiskDeviceType::DVDVideo)
@ -2297,11 +2433,27 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
// Clean up disk label
if ((sdevice->isDiskOfType(TDEDiskDeviceType::CDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDR))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDMO))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDMRRWW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRAM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDR))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRDL))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRWDL))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSR))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRDL))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDPLUSRWDL))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDR))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDR))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::HDDVDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo))

@ -24,54 +24,73 @@
// Keep readDiskDeviceSubtypeFromString() in tdehardwaredevices.cpp in sync with this enum
namespace TDEDiskDeviceType {
#if __cplusplus >= 201103L
enum TDEDiskDeviceType : unsigned long long {
#else
enum TDEDiskDeviceType {
Null = 0x00000000,
MediaDevice = 0x00000001,
Floppy = 0x00000002,
CDROM = 0x00000004,
CDRW = 0x00000008,
DVDROM = 0x00000010,
DVDRAM = 0x00000020,
DVDRW = 0x00000040,
BDROM = 0x00000080,
BDRW = 0x00000100,
Zip = 0x00000200,
Jaz = 0x00000400,
Camera = 0x00000800,
LUKS = 0x00001000,
OtherCrypted = 0x00002000,
CDAudio = 0x00004000,
CDVideo = 0x00008000,
DVDVideo = 0x00010000,
BDVideo = 0x00020000,
Flash = 0x00040000,
USB = 0x00080000,
Tape = 0x00100000,
HDD = 0x00200000,
Optical = 0x00400000,
RAM = 0x00800000,
Loop = 0x01000000,
CompactFlash = 0x02000000,
MemoryStick = 0x04000000,
SmartMedia = 0x08000000,
SDMMC = 0x10000000,
UnlockedCrypt = 0x20000000,
Other = 0x80000000
#endif
Null = 0x0000000000000000ULL,
MediaDevice = 0x0000000000000001ULL,
Floppy = 0x0000000000000002ULL,
CDROM = 0x0000000000000004ULL,
CDR = 0x0000000000000008ULL,
CDRW = 0x0000000000000010ULL,
CDMO = 0x0000000000000020ULL,
CDMRRW = 0x0000000000000040ULL,
CDMRRWW = 0x0000000000000080ULL,
DVDROM = 0x0000000000000100ULL,
DVDRAM = 0x0000000000000200ULL,
DVDR = 0x0000000000000400ULL,
DVDRW = 0x0000000000000800ULL,
DVDRDL = 0x0000000000001000ULL,
DVDRWDL = 0x0000000000002000ULL,
DVDPLUSR = 0x0000000000004000ULL,
DVDPLUSRW = 0x0000000000008000ULL,
DVDPLUSRDL = 0x0000000000010000ULL,
DVDPLUSRWDL = 0x0000000000020000ULL,
BDROM = 0x0000000000040000ULL,
BDR = 0x0000000000080000ULL,
BDRW = 0x0000000000100000ULL,
HDDVDROM = 0x0000000000200000ULL,
HDDVDR = 0x0000000000400000ULL,
HDDVDRW = 0x0000000000800000ULL,
Zip = 0x0000000001000000ULL,
Jaz = 0x0000000002000000ULL,
Camera = 0x0000000004000000ULL,
LUKS = 0x0000000008000000ULL,
OtherCrypted = 0x0000000010000000ULL,
CDAudio = 0x0000000020000000ULL,
CDVideo = 0x0000000040000000ULL,
DVDVideo = 0x0000000080000000ULL,
BDVideo = 0x0000000100000000ULL,
Flash = 0x0000000200000000ULL,
USB = 0x0000000400000000ULL,
Tape = 0x0000000800000000ULL,
HDD = 0x0000001000000000ULL,
Optical = 0x0000002000000000ULL,
RAM = 0x0000004000000000ULL,
Loop = 0x0000008000000000ULL,
CompactFlash = 0x0000010000000000ULL,
MemoryStick = 0x0000020000000000ULL,
SmartMedia = 0x0000040000000000ULL,
SDMMC = 0x0000080000000000ULL,
UnlockedCrypt = 0x0000100000000000ULL,
Other = 0x8000000000000000ULL
};
inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
{
return static_cast<TDEDiskDeviceType>(static_cast<int>(a) | static_cast<int>(b));
return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) | static_cast<unsigned long long>(b));
}
inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
{
return static_cast<TDEDiskDeviceType>(static_cast<int>(a) & static_cast<int>(b));
return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) & static_cast<unsigned long long>(b));
}
inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
{
return static_cast<TDEDiskDeviceType>(~static_cast<int>(a));
return static_cast<TDEDiskDeviceType>(~static_cast<unsigned long long>(a));
}
};

Loading…
Cancel
Save