7#include "iokitstorage.h"
9#include <CoreFoundation/CoreFoundation.h>
10#include <DiskArbitration/DiskArbitration.h>
12using namespace Solid::Backends::IOKit;
14IOKitStorage::IOKitStorage(IOKitDevice *device)
16 , daDict(new DADictionary(device))
20IOKitStorage::IOKitStorage(
const IOKitDevice *device)
22 , daDict(new DADictionary(device))
26IOKitStorage::~IOKitStorage()
33 const QString udi = m_device->udi();
35 if (udi.
contains(QStringLiteral(
"/SATA@"))) {
36 return Solid::StorageDrive::Sata;
38 if (udi.
contains(QStringLiteral(
"/SDXC@"))) {
41 return Solid::StorageDrive::Usb;
43 if (udi.
contains(QStringLiteral(
"/IOUSBInterface@"))) {
44 return Solid::StorageDrive::Usb;
46 if (daDict->stringForKey(kDADiskDescriptionDeviceProtocolKey) == QStringLiteral(
"USB")) {
47 return Solid::StorageDrive::Usb;
49 return Solid::StorageDrive::Platform;
54 const QString udi = m_device->udi();
57 if (type == QStringLiteral(
"IOCDMedia")
58 || type == QStringLiteral(
"IOBDMedia")
59 || type == QStringLiteral(
"IODVDMedia")) {
60 return Solid::StorageDrive::CdromDrive;
62 if (udi.
contains(QStringLiteral(
"/SDXC@"))) {
63 return Solid::StorageDrive::SdMmc;
65 if (daDict->stringForKey(kDADiskDescriptionDeviceModelKey) == QStringLiteral(
"Compact Flash")) {
66 return Solid::StorageDrive::CompactFlash;
68 return Solid::StorageDrive::HardDisk;
71bool IOKitStorage::isRemovable()
const
73 bool isInternal =
false;
74 daDict->boolForKey(kDADiskDescriptionDeviceInternalKey, isInternal);
78bool IOKitStorage::isHotpluggable()
const
81 return bus() == Solid::StorageDrive::Usb
82 ||
type == Solid::StorageDrive::CdromDrive
83 ||
type == Solid::StorageDrive::SdMmc;
86qulonglong IOKitStorage::size()
const
91QString IOKitStorage::vendor()
const
93 return daDict->stringForKey(kDADiskDescriptionDeviceVendorKey);
96QString IOKitStorage::product()
const
98 return daDict->stringForKey(kDADiskDescriptionDeviceModelKey);
101QString IOKitStorage::description()
const
103 return daDict->stringForKey(kDADiskDescriptionMediaNameKey);
106#include "moc_iokitstorage.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.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool toBool() const const
QString toString() const const
qulonglong toULongLong(bool *ok) const const