| 1 | /* |
| 2 | SPDX-FileCopyrightText: 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_IFACES_STORAGEACCESS_H |
| 8 | #define SOLID_IFACES_STORAGEACCESS_H |
| 9 | |
| 10 | #include <solid/devices/ifaces/deviceinterface.h> |
| 11 | #include <solid/storageaccess.h> |
| 12 | |
| 13 | namespace Solid |
| 14 | { |
| 15 | namespace Ifaces |
| 16 | { |
| 17 | /** |
| 18 | * This device interface is available on volume devices. |
| 19 | * |
| 20 | * A volume is anything that can contain data (partition, optical disc, |
| 21 | * memory card). It's a particular kind of block device. |
| 22 | */ |
| 23 | class StorageAccess : virtual public DeviceInterface |
| 24 | { |
| 25 | public: |
| 26 | /** |
| 27 | * Destroys a StorageVolume object. |
| 28 | */ |
| 29 | ~StorageAccess() override; |
| 30 | |
| 31 | /** |
| 32 | * Indicates if this volume is mounted. |
| 33 | * |
| 34 | * @return true if the volume is mounted |
| 35 | */ |
| 36 | virtual bool isAccessible() const = 0; |
| 37 | |
| 38 | /** |
| 39 | * Retrieves the absolute path of this volume mountpoint. |
| 40 | * |
| 41 | * @return the absolute path to the mount point if the volume is |
| 42 | * mounted, QString() otherwise |
| 43 | */ |
| 44 | virtual QString filePath() const = 0; |
| 45 | |
| 46 | /** |
| 47 | * Indicates if this volume should be ignored by applications. |
| 48 | * |
| 49 | * If it should be ignored, it generally means that it should be |
| 50 | * invisible to the user. It's useful for firmware partitions or |
| 51 | * OS reinstall partitions on some systems. |
| 52 | * |
| 53 | * @return true if the volume should be ignored |
| 54 | */ |
| 55 | virtual bool isIgnored() const = 0; |
| 56 | |
| 57 | /** |
| 58 | * Checks if source of the storage is encrypted. |
| 59 | * |
| 60 | * @return true if storage is encrypted one |
| 61 | */ |
| 62 | virtual bool isEncrypted() const = 0; |
| 63 | |
| 64 | /** |
| 65 | * Mounts the volume. |
| 66 | * |
| 67 | * @return the job handling the operation |
| 68 | */ |
| 69 | virtual bool setup() = 0; |
| 70 | |
| 71 | /** |
| 72 | * Unmounts the volume. |
| 73 | * |
| 74 | * @return the job handling the operation |
| 75 | */ |
| 76 | virtual bool teardown() = 0; |
| 77 | |
| 78 | /** |
| 79 | * Indicates if this volume can check for filesystem errors. |
| 80 | * |
| 81 | * @return true if the volume is can be checked |
| 82 | */ |
| 83 | virtual bool canCheck() const; |
| 84 | |
| 85 | /** |
| 86 | * Checks the filesystem for consistency avoiding any modifications or repairs. |
| 87 | * |
| 88 | * Mounted or unsupported filesystems will result in an error. |
| 89 | * |
| 90 | * @return Whether the filesystem is undamaged. |
| 91 | */ |
| 92 | virtual bool check(); |
| 93 | |
| 94 | /** |
| 95 | * Indicates if this volume can repair filesystem errors. |
| 96 | * |
| 97 | * @return true if the volume is can be repaired |
| 98 | */ |
| 99 | virtual bool canRepair() const; |
| 100 | |
| 101 | /** |
| 102 | * Tries to repair the filesystem. |
| 103 | * |
| 104 | * Mounted or unsupported filesystems will result in an error. |
| 105 | * |
| 106 | * @return Whether the filesystem could be successfully repaired |
| 107 | */ |
| 108 | virtual bool repair(); |
| 109 | |
| 110 | protected: |
| 111 | // Q_SIGNALS: |
| 112 | /** |
| 113 | * This signal is emitted when the mount state of this device |
| 114 | * has changed. |
| 115 | * |
| 116 | * @param newState true if the volume is mounted, false otherwise |
| 117 | * @param udi the UDI of the volume |
| 118 | */ |
| 119 | virtual void accessibilityChanged(bool accessible, const QString &udi) = 0; |
| 120 | |
| 121 | /** |
| 122 | * This signal is emitted when the mount state of this device |
| 123 | * has changed. |
| 124 | * |
| 125 | * @param newState true if the volume is mounted, false otherwise |
| 126 | * @param udi the UDI of the volume |
| 127 | */ |
| 128 | virtual void setupDone(Solid::ErrorType error, QVariant resultData, const QString &udi) = 0; |
| 129 | |
| 130 | /** |
| 131 | * This signal is emitted when the mount state of this device |
| 132 | * has changed. |
| 133 | * |
| 134 | * @param newState true if the volume is mounted, false otherwise |
| 135 | * @param udi the UDI of the volume |
| 136 | */ |
| 137 | virtual void teardownDone(Solid::ErrorType error, QVariant resultData, const QString &udi) = 0; |
| 138 | |
| 139 | /** |
| 140 | * This signal is emitted when a setup of this device is requested. |
| 141 | * The signal might be spontaneous i.e. it can be triggered by |
| 142 | * another process. |
| 143 | * |
| 144 | * @param udi the UDI of the volume |
| 145 | */ |
| 146 | virtual void setupRequested(const QString &udi) = 0; |
| 147 | |
| 148 | /** |
| 149 | * This signal is emitted when a teardown of this device is requested. |
| 150 | * The signal might be spontaneous i.e. it can be triggered by |
| 151 | * another process |
| 152 | * |
| 153 | * @param udi the UDI of the volume |
| 154 | */ |
| 155 | virtual void teardownRequested(const QString &udi) = 0; |
| 156 | |
| 157 | /** |
| 158 | * This signal is emitted when a check of this device is requested. |
| 159 | * The signal might be spontaneous i.e. it can be triggered by |
| 160 | * another process. |
| 161 | * |
| 162 | * @param udi the UDI of the volume |
| 163 | */ |
| 164 | virtual void checkRequested(const QString &udi); |
| 165 | |
| 166 | /** |
| 167 | * This signal is emitted when the attempted checked of this |
| 168 | * device is completed. |
| 169 | * |
| 170 | * @param error type of error that occurred, if any |
| 171 | * @param errorData more information about the error, if any |
| 172 | * @param udi the UDI of the volume |
| 173 | */ |
| 174 | virtual void checkDone(Solid::ErrorType error, QVariant resultData, const QString &udi); |
| 175 | |
| 176 | /** |
| 177 | * This signal is emitted when a repair of this device is requested. |
| 178 | * The signal might be spontaneous i.e. it can be triggered by |
| 179 | * another process. |
| 180 | * |
| 181 | * @param udi the UDI of the volume |
| 182 | */ |
| 183 | virtual void repairRequested(const QString &udi); |
| 184 | |
| 185 | /** |
| 186 | * This signal is emitted when the attempted repaired of this |
| 187 | * device is completed. |
| 188 | * |
| 189 | * @param error type of error that occurred, if any |
| 190 | * @param errorData more information about the error, if any |
| 191 | * @param udi the UDI of the volume |
| 192 | */ |
| 193 | virtual void repairDone(Solid::ErrorType error, QVariant resultData, const QString &udi); |
| 194 | }; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | Q_DECLARE_INTERFACE(Solid::Ifaces::StorageAccess, "org.kde.Solid.Ifaces.StorageAccess/0.1" ) |
| 199 | |
| 200 | #endif |
| 201 | |