File indexing completed on 2024-05-12 04:01:52
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "storagedrive.h" 0008 #include "storagedrive_p.h" 0009 0010 #include "device.h" 0011 #include "device_p.h" 0012 #include "predicate.h" 0013 #include "soliddefs_p.h" 0014 #include "storageaccess.h" 0015 #include <solid/devices/ifaces/storagedrive.h> 0016 0017 Solid::StorageDrive::StorageDrive(QObject *backendObject) 0018 : DeviceInterface(*new StorageDrivePrivate(), backendObject) 0019 { 0020 } 0021 0022 Solid::StorageDrive::StorageDrive(StorageDrivePrivate &dd, QObject *backendObject) 0023 : DeviceInterface(dd, backendObject) 0024 { 0025 } 0026 0027 Solid::StorageDrive::~StorageDrive() 0028 { 0029 } 0030 0031 Solid::StorageDrive::Bus Solid::StorageDrive::bus() const 0032 { 0033 Q_D(const StorageDrive); 0034 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), Platform, bus()); 0035 } 0036 0037 Solid::StorageDrive::DriveType Solid::StorageDrive::driveType() const 0038 { 0039 Q_D(const StorageDrive); 0040 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), HardDisk, driveType()); 0041 } 0042 0043 bool Solid::StorageDrive::isRemovable() const 0044 { 0045 Q_D(const StorageDrive); 0046 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isRemovable()); 0047 } 0048 0049 bool Solid::StorageDrive::isHotpluggable() const 0050 { 0051 Q_D(const StorageDrive); 0052 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isHotpluggable()); 0053 } 0054 0055 qulonglong Solid::StorageDrive::size() const 0056 { 0057 Q_D(const StorageDrive); 0058 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, size()); 0059 } 0060 0061 bool Solid::StorageDrive::isInUse() const 0062 { 0063 Q_D(const StorageDrive); 0064 Predicate p(DeviceInterface::StorageAccess); 0065 const QList<Device> devices = Device::listFromQuery(p, d->devicePrivate()->udi()); 0066 0067 bool inUse = false; 0068 for (const Device &dev : devices) { 0069 if (dev.is<Solid::StorageAccess>()) { 0070 const Solid::StorageAccess *access = dev.as<Solid::StorageAccess>(); 0071 inUse |= (access->isAccessible()); 0072 } 0073 } 0074 return inUse; 0075 } 0076 0077 QDateTime Solid::StorageDrive::timeDetected() const 0078 { 0079 Q_D(const StorageDrive); 0080 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), QDateTime(), timeDetected()); 0081 } 0082 0083 QDateTime Solid::StorageDrive::timeMediaDetected() const 0084 { 0085 Q_D(const StorageDrive); 0086 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), QDateTime(), timeMediaDetected()); 0087 } 0088 0089 #include "moc_storagedrive.cpp"