8#include "udisksstoragedrive.h"
12using namespace Solid::Backends::UDisks2;
14StorageDrive::StorageDrive(Device *dev)
18 UdevQt::Client client(
this);
19 m_udevDevice = client.deviceByDeviceFile(device());
20 m_udevDevice.deviceProperties();
24StorageDrive::~StorageDrive()
28qulonglong StorageDrive::size()
const
33bool StorageDrive::isHotpluggable()
const
38 return _bus == Solid::StorageDrive::Usb
39 || _bus == Solid::StorageDrive::Ieee1394
40 || (m_udevDevice.deviceProperty(
"UDISKS_SYSTEM").isValid()
41 && !m_udevDevice.deviceProperty(
"UDISKS_SYSTEM").toBool());
43#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
44 return m_device->prop(
"bsdisks_IsHotpluggable").
toBool();
46#error Implement this or stub this out for your platform
50bool StorageDrive::isRemovable()
const
52 return m_device->prop(
"MediaRemovable").
toBool() || m_device->prop(
"Removable").
toBool();
59 if (m_device->isOpticalDrive()) {
60 return Solid::StorageDrive::CdromDrive;
61 }
else if (mediaTypes.
contains(
"floppy")) {
62 return Solid::StorageDrive::Floppy;
65 else if (mediaTypes.
contains(
"floppy_jaz")) {
66 return Solid::StorageDrive::Jaz;
67 }
else if (mediaTypes.
contains(
"floppy_zip")) {
68 return Solid::StorageDrive::Zip;
69 }
else if (mediaTypes.
contains(
"flash")) {
70 return Solid::StorageDrive::Flash;
73 else if (mediaTypes.
contains(
"flash_cf")) {
74 return Solid::StorageDrive::CompactFlash;
75 }
else if (mediaTypes.
contains(
"flash_ms")) {
76 return Solid::StorageDrive::MemoryStick;
77 }
else if (mediaTypes.
contains(
"flash_sm")) {
78 return Solid::StorageDrive::SmartMedia;
79 }
else if (mediaTypes.
contains(
"flash_sd")
82 || mediaTypes.
contains(
"flash_sdxc")) {
83 return Solid::StorageDrive::SdMmc;
87 return Solid::StorageDrive::HardDisk;
96 m_udevDevice.deviceProperty(
"ID_BUS").toString();
97#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
98 m_device->prop(
"bsdisks_ConnectionBus").
toString();
100#error Implement this or stub this out for your platform
105 if (udevBus ==
"ata") {
107 if (m_udevDevice.deviceProperty(
"ID_ATA_SATA").toInt() == 1) {
108 return Solid::StorageDrive::Sata;
110 return Solid::StorageDrive::Ide;
112#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
113 if (m_device->prop(
"bsdisks_AtaSata").
toString() ==
"sata") {
114 return Solid::StorageDrive::Sata;
116 return Solid::StorageDrive::Ide;
119#error Implement this or stub this out for your platform
121 }
else if (bus ==
"usb") {
122 return Solid::StorageDrive::Usb;
123 }
else if (bus ==
"ieee1394") {
124 return Solid::StorageDrive::Ieee1394;
125 }
else if (udevBus ==
"scsi") {
126 return Solid::StorageDrive::Scsi;
129 else if (bus ==
"sdio") {
130 return Solid::StorageDrive::SDIO;
131 }
else if (bus ==
"virtual") {
132 return Solid::StorageDrive::Virtual;
136 return Solid::StorageDrive::Platform;
140QDateTime StorageDrive::timeDetected()
const
142 bool conversionValid;
143 const qulonglong microSecondsSinceEpoch = m_device->prop(
"TimeDetected").
toULongLong(&conversionValid);
144 if (!conversionValid) {
150QDateTime StorageDrive::timeMediaDetected()
const
152 bool conversionValid;
153 const qulonglong microSecondsSinceEpoch = m_device->prop(
"TimeMediaDetected").
toULongLong(&conversionValid);
154 if (!conversionValid) {
160#include "moc_udisksstoragedrive.cpp"
DriveType
This enum type defines the type of drive a storage device can be.
Bus
This enum type defines the type of bus a storage device is attached to.
QDateTime fromMSecsSinceEpoch(qint64 msecs)
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool toBool() const const
QString toString() const const
QStringList toStringList() const const
qulonglong toULongLong(bool *ok) const const