| 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_STORAGEVOLUME_H |
| 8 | #define SOLID_STORAGEVOLUME_H |
| 9 | |
| 10 | #include <solid/solid_export.h> |
| 11 | |
| 12 | #include <solid/deviceinterface.h> |
| 13 | |
| 14 | namespace Solid |
| 15 | { |
| 16 | class StorageVolumePrivate; |
| 17 | class Device; |
| 18 | |
| 19 | /*! |
| 20 | * \class Solid::StorageVolume |
| 21 | * \inheaderfile Solid/StorageVolume |
| 22 | * \inmodule Solid |
| 23 | * |
| 24 | * \brief This device interface is available on volume devices. |
| 25 | * |
| 26 | * A volume is anything that can contain data (partition, optical disc, |
| 27 | * memory card). It's a particular kind of block device. |
| 28 | */ |
| 29 | class SOLID_EXPORT StorageVolume : public DeviceInterface |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | |
| 33 | /*! |
| 34 | * \property Solid::StorageVolume::ignored |
| 35 | */ |
| 36 | Q_PROPERTY(bool ignored READ isIgnored) |
| 37 | |
| 38 | /*! |
| 39 | * \property Solid::StorageVolume::usage |
| 40 | */ |
| 41 | Q_PROPERTY(UsageType usage READ usage) |
| 42 | |
| 43 | /*! |
| 44 | * \property Solid::StorageVolume::fsType |
| 45 | */ |
| 46 | Q_PROPERTY(QString fsType READ fsType) |
| 47 | |
| 48 | /*! |
| 49 | * \property Solid::StorageVolume::label |
| 50 | */ |
| 51 | Q_PROPERTY(QString label READ label) |
| 52 | |
| 53 | /*! |
| 54 | * \property Solid::StorageVolume::uuid |
| 55 | */ |
| 56 | Q_PROPERTY(QString uuid READ uuid) |
| 57 | |
| 58 | /*! |
| 59 | * \property Solid::StorageVolume::size |
| 60 | */ |
| 61 | Q_PROPERTY(qulonglong size READ size) |
| 62 | |
| 63 | Q_DECLARE_PRIVATE(StorageVolume) |
| 64 | friend class Device; |
| 65 | |
| 66 | public: |
| 67 | /*! |
| 68 | * This enum type defines the how a volume is used. |
| 69 | * |
| 70 | * \value FileSystem A mountable filesystem volume |
| 71 | * \value PartitionTable A volume containing a partition table |
| 72 | * \value Raid A volume member of a raid set (not mountable) |
| 73 | * \value Other A not mountable volume (like a swap partition) |
| 74 | * \value Unused An unused or free volume |
| 75 | * \value Encrypted |
| 76 | */ |
| 77 | enum UsageType { Other = 0, Unused = 1, FileSystem = 2, PartitionTable = 3, Raid = 4, Encrypted = 5 }; |
| 78 | Q_ENUM(UsageType) |
| 79 | |
| 80 | private: |
| 81 | /*! |
| 82 | * \internal |
| 83 | * Creates a new StorageVolume object. |
| 84 | * You generally won't need this. It's created when necessary using |
| 85 | * Device::as(). |
| 86 | * |
| 87 | * \a backendObject the device interface object provided by the backend |
| 88 | * \sa Solid::Device::as() |
| 89 | */ |
| 90 | SOLID_NO_EXPORT explicit StorageVolume(QObject *backendObject); |
| 91 | |
| 92 | public: |
| 93 | ~StorageVolume() override; |
| 94 | |
| 95 | /*! |
| 96 | * Get the Solid::DeviceInterface::Type of the StorageVolume device interface. |
| 97 | * |
| 98 | * Returns the StorageVolume device interface type |
| 99 | * \sa Solid::DeviceInterface::Type |
| 100 | */ |
| 101 | static Type deviceInterfaceType() |
| 102 | { |
| 103 | return DeviceInterface::StorageVolume; |
| 104 | } |
| 105 | |
| 106 | /*! |
| 107 | * Indicates if this volume should be ignored by applications. |
| 108 | * |
| 109 | * If it should be ignored, it generally means that it should be |
| 110 | * invisible to the user. It's useful for firmware partitions or |
| 111 | * OS reinstall partitions on some systems. |
| 112 | * |
| 113 | * Returns true if the volume should be ignored |
| 114 | */ |
| 115 | bool isIgnored() const; |
| 116 | |
| 117 | /*! |
| 118 | * Retrieves the type of use for this volume (for example filesystem). |
| 119 | * |
| 120 | * Returns the usage type |
| 121 | * \sa Solid::StorageVolume::UsageType |
| 122 | */ |
| 123 | UsageType usage() const; |
| 124 | |
| 125 | /*! |
| 126 | * Retrieves the filesystem type of this volume. |
| 127 | * |
| 128 | * FIXME: It's a platform dependent string, maybe we should switch to |
| 129 | * an enum? |
| 130 | * |
| 131 | * Returns the filesystem type if applicable, QString() otherwise |
| 132 | */ |
| 133 | QString fsType() const; |
| 134 | |
| 135 | /*! |
| 136 | * Retrieves this volume label. |
| 137 | * |
| 138 | * Returns the volume label if available, QString() otherwise |
| 139 | */ |
| 140 | QString label() const; |
| 141 | |
| 142 | /*! |
| 143 | * Retrieves this volume Universal Unique IDentifier (UUID). |
| 144 | * |
| 145 | * You can generally assume that this identifier is unique with reasonable |
| 146 | * confidence. Except if the volume UUID has been forged to intentionally |
| 147 | * provoke a collision, the probability to have two volumes having the same |
| 148 | * UUID is low. |
| 149 | * |
| 150 | * Returns the Universal Unique IDentifier if available, QString() otherwise |
| 151 | */ |
| 152 | QString uuid() const; |
| 153 | |
| 154 | /*! |
| 155 | * Retrieves this volume size in bytes. |
| 156 | * |
| 157 | * Returns the size of this volume |
| 158 | */ |
| 159 | qulonglong size() const; |
| 160 | |
| 161 | /*! |
| 162 | * Retrieves the crypto container of this volume. |
| 163 | * |
| 164 | * Returns the encrypted volume containing the current volume if applicable, |
| 165 | * an invalid device otherwise |
| 166 | */ |
| 167 | Device encryptedContainer() const; |
| 168 | |
| 169 | protected: |
| 170 | SOLID_NO_EXPORT StorageVolume(StorageVolumePrivate &dd, QObject *backendObject); |
| 171 | }; |
| 172 | } |
| 173 | |
| 174 | #endif // SOLID_STORAGEVOLUME_H |
| 175 | |