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
30 return m_device->prop(QStringLiteral(
"Size")).
toULongLong();
33bool StorageDrive::isHotpluggable()
const
38 return _bus == Solid::StorageDrive::Usb
39 || _bus == Solid::StorageDrive::Ieee1394
40 || (m_udevDevice.deviceProperty(QStringLiteral(
"UDISKS_SYSTEM")).
isValid()
41 && !m_udevDevice.deviceProperty(QStringLiteral(
"UDISKS_SYSTEM")).toBool());
43#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
44 return m_device->prop(QStringLiteral(
"bsdisks_IsHotpluggable")).
toBool();
46#error Implement this or stub this out for your platform
50bool StorageDrive::isRemovable()
const
52 return m_device->prop(QStringLiteral(
"MediaRemovable")).
toBool() || m_device->prop(QStringLiteral(
"Removable")).
toBool();
59 if (m_device->isOpticalDrive()) {
60 return Solid::StorageDrive::CdromDrive;
61 }
else if (mediaTypes.
contains(QStringLiteral(
"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(QStringLiteral(
"flash_cf"))) {
74 return Solid::StorageDrive::CompactFlash;
75 }
else if (mediaTypes.
contains(QStringLiteral(
"flash_ms"))) {
76 return Solid::StorageDrive::MemoryStick;
77 }
else if (mediaTypes.
contains(QStringLiteral(
"flash_sm"))) {
78 return Solid::StorageDrive::SmartMedia;
79 }
else if (mediaTypes.
contains(QStringLiteral(
"flash_sd"))
80 || mediaTypes.
contains(QStringLiteral(
"flash_sdhc"))
81 || mediaTypes.
contains(QStringLiteral(
"flash_mmc"))
82 || mediaTypes.
contains(QStringLiteral(
"flash_sdxc"))) {
83 return Solid::StorageDrive::SdMmc;
87 return Solid::StorageDrive::HardDisk;
93 const QString bus = m_device->prop(QStringLiteral(
"ConnectionBus")).
toString();
96 m_udevDevice.deviceProperty(QStringLiteral(
"ID_BUS")).toString();
97#elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
98 m_device->prop(QStringLiteral(
"bsdisks_ConnectionBus")).
toString();
100#error Implement this or stub this out for your platform
107 if (m_udevDevice.deviceProperty(QStringLiteral(
"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)
114 return Solid::StorageDrive::Sata;
116 return Solid::StorageDrive::Ide;
119#error Implement this or stub this out for your platform
122 return Solid::StorageDrive::Usb;
124 return Solid::StorageDrive::Ieee1394;
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(QStringLiteral(
"TimeDetected")).
toULongLong(&conversionValid);
144 if (!conversionValid) {
150QDateTime StorageDrive::timeMediaDetected()
const
152 bool conversionValid;
153 const qulonglong microSecondsSinceEpoch = m_device->prop(QStringLiteral(
"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.
char * toString(const EngineQuery &query)
bool isValid(QStringView ifopt)
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