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 #ifndef SOLID_STORAGEDRIVE_H 0008 #define SOLID_STORAGEDRIVE_H 0009 0010 #include <solid/solid_export.h> 0011 0012 #include <solid/deviceinterface.h> 0013 0014 namespace Solid 0015 { 0016 class StorageDrivePrivate; 0017 class Device; 0018 0019 /** 0020 * @class Solid::StorageDrive storagedrive.h <Solid/StorageDrive> 0021 * 0022 * This device interface is available on storage devices. 0023 * 0024 * A storage is anything that can contain a set of volumes (card reader, 0025 * hard disk, cdrom drive...). It's a particular kind of block device. 0026 */ 0027 class SOLID_EXPORT StorageDrive : public DeviceInterface 0028 { 0029 Q_OBJECT 0030 Q_PROPERTY(Bus bus READ bus) 0031 Q_PROPERTY(DriveType driveType READ driveType) 0032 Q_PROPERTY(bool removable READ isRemovable) 0033 Q_PROPERTY(bool hotpluggable READ isHotpluggable) 0034 Q_PROPERTY(bool inUse READ isInUse) 0035 Q_PROPERTY(qulonglong size READ size) 0036 Q_PROPERTY(QDateTime timeDetected READ timeDetected CONSTANT) 0037 Q_PROPERTY(QDateTime timeMediaDetected READ timeDetected) 0038 0039 Q_DECLARE_PRIVATE(StorageDrive) 0040 friend class Device; 0041 0042 public: 0043 /** 0044 * This enum type defines the type of bus a storage device is attached to. 0045 * 0046 * - Ide : An Integrated Drive Electronics (IDE) bus, also known as ATA 0047 * - Usb : An Universal Serial Bus (USB) 0048 * - Ieee1394 : An Ieee1394 bus, also known as Firewire 0049 * - Scsi : A Small Computer System Interface bus 0050 * - Sata : A Serial Advanced Technology Attachment (SATA) bus 0051 * - Platform : A legacy bus that is part of the underlying platform 0052 */ 0053 enum Bus { Ide, Usb, Ieee1394, Scsi, Sata, Platform }; 0054 Q_ENUM(Bus) 0055 0056 /** 0057 * This enum type defines the type of drive a storage device can be. 0058 * 0059 * - HardDisk : A hard disk 0060 * - CdromDrive : An optical drive 0061 * - Floppy : A floppy disk drive 0062 * - Tape : A tape drive 0063 * - CompactFlash : A Compact Flash card reader 0064 * - MemoryStick : A Memory Stick card reader 0065 * - SmartMedia : A Smart Media card reader 0066 * - SdMmc : A SecureDigital/MultiMediaCard card reader 0067 * - Xd : A xD card reader 0068 */ 0069 enum DriveType { HardDisk, CdromDrive, Floppy, Tape, CompactFlash, MemoryStick, SmartMedia, SdMmc, Xd }; 0070 Q_ENUM(DriveType) 0071 0072 private: 0073 /** 0074 * Creates a new StorageDrive object. 0075 * You generally won't need this. It's created when necessary using 0076 * Device::as(). 0077 * 0078 * @param backendObject the device interface object provided by the backend 0079 * @see Solid::Device::as() 0080 */ 0081 SOLID_NO_EXPORT explicit StorageDrive(QObject *backendObject); 0082 0083 public: 0084 /** 0085 * Destroys a StorageDrive object. 0086 */ 0087 ~StorageDrive() override; 0088 0089 /** 0090 * Get the Solid::DeviceInterface::Type of the StorageDrive device interface. 0091 * 0092 * @return the StorageDrive device interface type 0093 * @see Solid::DeviceInterface::Type 0094 */ 0095 static Type deviceInterfaceType() 0096 { 0097 return DeviceInterface::StorageDrive; 0098 } 0099 0100 /** 0101 * Retrieves the type of physical interface this storage device is 0102 * connected to. 0103 * 0104 * @return the bus type 0105 * @see Solid::StorageDrive::Bus 0106 */ 0107 Bus bus() const; 0108 0109 /** 0110 * Retrieves the type of this storage drive. 0111 * 0112 * @return the drive type 0113 * @see Solid::StorageDrive::DriveType 0114 */ 0115 DriveType driveType() const; 0116 0117 /** 0118 * Indicates if the media contained by this drive can be removed. 0119 * 0120 * For example memory card can be removed from the drive by the user, 0121 * while partitions can't be removed from hard disks. 0122 * 0123 * @return true if media can be removed, false otherwise. 0124 */ 0125 bool isRemovable() const; 0126 0127 /** 0128 * Indicates if this storage device can be plugged or unplugged while 0129 * the computer is running. 0130 * 0131 * @return true if this storage supports hotplug, false otherwise 0132 */ 0133 bool isHotpluggable() const; 0134 0135 /** 0136 * Retrieves this drives size in bytes. 0137 * 0138 * @return the size of this drive 0139 */ 0140 qulonglong size() const; 0141 0142 /** 0143 * Indicates if the storage device is currently in use 0144 * i.e. if at least one child storage access is 0145 * mounted 0146 * 0147 * @return true if at least one child storage access is mounted 0148 */ 0149 bool isInUse() const; 0150 0151 /** 0152 * Returns the time the drive was deteced. 0153 * Typically this means the time a drive was plugged in, or the computer rebooted 0154 * 0155 * An invalid datetime may be returned if the underlying information is not available 0156 * @since 6.0 0157 */ 0158 QDateTime timeDetected() const; 0159 0160 /** 0161 * Returns the time media in the drive was deteced. 0162 * Typically this means the time a card was inserted into a reader, or the computer rebooted 0163 * 0164 * An invalid datetime may be returned if the underlying information is not available 0165 * @since 6.0 0166 */ 0167 QDateTime timeMediaDetected() const; 0168 0169 protected: 0170 /** 0171 * @internal 0172 */ 0173 SOLID_NO_EXPORT StorageDrive(StorageDrivePrivate &dd, QObject *backendObject); 0174 }; 0175 } 0176 0177 #endif // SOLID_STORAGEDRIVE_H