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

source code of solid/src/solid/devices/frontend/storagedrive.h