| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 | */ |
| 6 | |
| 7 | #ifndef SOLID_STORAGEDRIVE_H |
| 8 | #define SOLID_STORAGEDRIVE_H |
| 9 | |
| 10 | #include <solid/solid_export.h> |
| 11 | |
| 12 | #include <solid/deviceinterface.h> |
| 13 | |
| 14 | namespace Solid |
| 15 | { |
| 16 | class StorageDrivePrivate; |
| 17 | class Device; |
| 18 | |
| 19 | /*! |
| 20 | * \class Solid::StorageDrive |
| 21 | * \inheaderfile Solid/StorageDrive |
| 22 | * |
| 23 | * \brief This device interface is available on storage devices. |
| 24 | * |
| 25 | * A storage is anything that can contain a set of volumes (card reader, |
| 26 | * hard disk, cdrom drive...). It's a particular kind of block device. |
| 27 | */ |
| 28 | class SOLID_EXPORT StorageDrive : public DeviceInterface |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | |
| 32 | /*! |
| 33 | * \property Solid::StorageDrive::bus |
| 34 | */ |
| 35 | Q_PROPERTY(Bus bus READ bus) |
| 36 | |
| 37 | /*! |
| 38 | * \property Solid::StorageDrive::driveType |
| 39 | */ |
| 40 | Q_PROPERTY(DriveType driveType READ driveType) |
| 41 | |
| 42 | /*! |
| 43 | * \property Solid::StorageDrive::removable |
| 44 | */ |
| 45 | Q_PROPERTY(bool removable READ isRemovable) |
| 46 | |
| 47 | /*! |
| 48 | * \property Solid::StorageDrive::hotpluggable |
| 49 | */ |
| 50 | Q_PROPERTY(bool hotpluggable READ isHotpluggable) |
| 51 | |
| 52 | /*! |
| 53 | * \property Solid::StorageDrive::inUse |
| 54 | */ |
| 55 | Q_PROPERTY(bool inUse READ isInUse) |
| 56 | |
| 57 | /*! |
| 58 | * \property Solid::StorageDrive::size |
| 59 | */ |
| 60 | Q_PROPERTY(qulonglong size READ size) |
| 61 | |
| 62 | /*! |
| 63 | * \property Solid::StorageDrive::timeDetected |
| 64 | */ |
| 65 | Q_PROPERTY(QDateTime timeDetected READ timeDetected CONSTANT) |
| 66 | |
| 67 | /*! |
| 68 | * \property Solid::StorageDrive::timeMediaDetected |
| 69 | */ |
| 70 | Q_PROPERTY(QDateTime timeMediaDetected READ timeDetected) |
| 71 | |
| 72 | Q_DECLARE_PRIVATE(StorageDrive) |
| 73 | friend class Device; |
| 74 | |
| 75 | public: |
| 76 | /*! |
| 77 | * This enum type defines the type of bus a storage device is attached to. |
| 78 | * |
| 79 | * \value Ide An Integrated Drive Electronics (IDE) bus, also known as ATA |
| 80 | * \value Usb An Universal Serial Bus (USB) |
| 81 | * \value Ieee1394 An Ieee1394 bus, also known as Firewire |
| 82 | * \value Scsi A Small Computer System Interface bus |
| 83 | * \value Sata A Serial Advanced Technology Attachment (SATA) bus |
| 84 | * \value Platform A legacy bus that is part of the underlying platform |
| 85 | */ |
| 86 | enum Bus { Ide, Usb, Ieee1394, Scsi, Sata, Platform }; |
| 87 | Q_ENUM(Bus) |
| 88 | |
| 89 | /*! |
| 90 | * This enum type defines the type of drive a storage device can be. |
| 91 | * |
| 92 | * \value HardDisk A hard disk |
| 93 | * \value CdromDrive An optical drive |
| 94 | * \value Floppy A floppy disk drive |
| 95 | * \value Tape A tape drive |
| 96 | * \value CompactFlash A Compact Flash card reader |
| 97 | * \value MemoryStick A Memory Stick card reader |
| 98 | * \value SmartMedia A Smart Media card reader |
| 99 | * \value SdMmc A SecureDigital/MultiMediaCard card reader |
| 100 | * \value Xd A xD card reader |
| 101 | */ |
| 102 | enum DriveType { HardDisk, CdromDrive, Floppy, Tape, CompactFlash, MemoryStick, SmartMedia, SdMmc, Xd }; |
| 103 | Q_ENUM(DriveType) |
| 104 | |
| 105 | private: |
| 106 | /*! |
| 107 | * \internal |
| 108 | * Creates a new StorageDrive object. |
| 109 | * You generally won't need this. It's created when necessary using |
| 110 | * Device::as(). |
| 111 | * |
| 112 | * \a backendObject the device interface object provided by the backend |
| 113 | * \sa Solid::Device::as() |
| 114 | */ |
| 115 | SOLID_NO_EXPORT explicit StorageDrive(QObject *backendObject); |
| 116 | |
| 117 | public: |
| 118 | ~StorageDrive() override; |
| 119 | |
| 120 | /*! |
| 121 | * Get the Solid::DeviceInterface::Type of the StorageDrive device interface. |
| 122 | * |
| 123 | * Returns the StorageDrive device interface type |
| 124 | * \sa Solid::DeviceInterface::Type |
| 125 | */ |
| 126 | static Type deviceInterfaceType() |
| 127 | { |
| 128 | return DeviceInterface::StorageDrive; |
| 129 | } |
| 130 | |
| 131 | /*! |
| 132 | * Retrieves the type of physical interface this storage device is |
| 133 | * connected to. |
| 134 | * |
| 135 | * Returns the bus type |
| 136 | * \sa Solid::StorageDrive::Bus |
| 137 | */ |
| 138 | Bus bus() const; |
| 139 | |
| 140 | /*! |
| 141 | * Retrieves the type of this storage drive. |
| 142 | * |
| 143 | * Returns the drive type |
| 144 | * \sa Solid::StorageDrive::DriveType |
| 145 | */ |
| 146 | DriveType driveType() const; |
| 147 | |
| 148 | /*! |
| 149 | * Indicates if the media contained by this drive can be removed. |
| 150 | * |
| 151 | * For example memory card can be removed from the drive by the user, |
| 152 | * while partitions can't be removed from hard disks. |
| 153 | * |
| 154 | * Returns true if media can be removed, false otherwise. |
| 155 | */ |
| 156 | bool isRemovable() const; |
| 157 | |
| 158 | /*! |
| 159 | * Indicates if this storage device can be plugged or unplugged while |
| 160 | * the computer is running. |
| 161 | * |
| 162 | * Returns true if this storage supports hotplug, false otherwise |
| 163 | */ |
| 164 | bool isHotpluggable() const; |
| 165 | |
| 166 | /*! |
| 167 | * Retrieves this drives size in bytes. |
| 168 | * |
| 169 | * Returns the size of this drive |
| 170 | */ |
| 171 | qulonglong size() const; |
| 172 | |
| 173 | /*! |
| 174 | * Indicates if the storage device is currently in use |
| 175 | * i.e. if at least one child storage access is |
| 176 | * mounted |
| 177 | * |
| 178 | * Returns true if at least one child storage access is mounted |
| 179 | */ |
| 180 | bool isInUse() const; |
| 181 | |
| 182 | /*! |
| 183 | * Returns the time the drive was deteced. |
| 184 | * Typically this means the time a drive was plugged in, or the computer rebooted |
| 185 | * |
| 186 | * An invalid datetime may be returned if the underlying information is not available |
| 187 | * \since 6.0 |
| 188 | */ |
| 189 | QDateTime timeDetected() const; |
| 190 | |
| 191 | /*! |
| 192 | * Returns the time media in the drive was deteced. |
| 193 | * Typically this means the time a card was inserted into a reader, or the computer rebooted |
| 194 | * |
| 195 | * An invalid datetime may be returned if the underlying information is not available |
| 196 | * \since 6.0 |
| 197 | */ |
| 198 | QDateTime timeMediaDetected() const; |
| 199 | |
| 200 | protected: |
| 201 | SOLID_NO_EXPORT StorageDrive(StorageDrivePrivate &dd, QObject *backendObject); |
| 202 | }; |
| 203 | } |
| 204 | |
| 205 | #endif // SOLID_STORAGEDRIVE_H |
| 206 | |