Solid

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

KDE's Doxygen guidelines are available online.