Solid

frontend/storageaccess.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_STORAGEACCESS_H
8#define SOLID_STORAGEACCESS_H
9
10#include <solid/solid_export.h>
11
12#include <QVariant>
13#include <solid/deviceinterface.h>
14#include <solid/solidnamespace.h>
15
16namespace Solid
17{
18class StorageAccessPrivate;
19class Device;
20
21/**
22 * @class Solid::StorageAccess storageaccess.h <Solid/StorageAccess>
23 *
24 * This device interface is available on volume devices to access them
25 * (i.e. mount or unmount them).
26 *
27 * A volume is anything that can contain data (partition, optical disc,
28 * memory card). It's a particular kind of block device.
29 */
30class SOLID_EXPORT StorageAccess : public DeviceInterface
31{
32 Q_OBJECT
33 Q_PROPERTY(bool accessible READ isAccessible)
34 Q_PROPERTY(QString filePath READ filePath)
35 Q_PROPERTY(bool ignored READ isIgnored)
36 Q_PROPERTY(bool encrypted READ isEncrypted)
37 Q_DECLARE_PRIVATE(StorageAccess)
38 friend class Device;
39
40private:
41 /**
42 * Creates a new StorageAccess object.
43 * You generally won't need this. It's created when necessary using
44 * Device::as().
45 *
46 * @param backendObject the device interface object provided by the backend
47 * @see Solid::Device::as()
48 */
49 SOLID_NO_EXPORT explicit StorageAccess(QObject *backendObject);
50
51public:
52 /**
53 * Destroys a StorageAccess object.
54 */
55 ~StorageAccess() override;
56
57 /**
58 * Get the Solid::DeviceInterface::Type of the StorageAccess device interface.
59 *
60 * @return the StorageVolume device interface type
61 * @see Solid::Ifaces::Enums::DeviceInterface::Type
62 */
64 {
65 return DeviceInterface::StorageAccess;
66 }
67
68 /**
69 * Indicates if this volume is mounted.
70 *
71 * @return true if the volume is mounted
72 */
73 bool isAccessible() const;
74
75 /**
76 * Retrieves the absolute path of this volume mountpoint.
77 *
78 * @return the absolute path to the mount point if the volume is
79 * mounted, QString() otherwise
80 */
81 QString filePath() const;
82
83 /**
84 * Indicates if this volume should be ignored by applications.
85 *
86 * If it should be ignored, it generally means that it should be
87 * invisible to the user. It's useful for firmware partitions or
88 * OS reinstall partitions on some systems.
89 *
90 * @return true if the volume should be ignored
91 */
92 bool isIgnored() const;
93
94 /**
95 * Checks if source of the storage is encrypted.
96 *
97 * @return true if storage is encrypted one
98 *
99 * @since 5.80
100 */
101 bool isEncrypted() const;
102
103 /**
104 * Mounts the volume.
105 *
106 * @return false if the operation is not supported, true if the
107 * operation is attempted
108 */
109 bool setup();
110
111 /**
112 * Unmounts the volume.
113 *
114 * @return false if the operation is not supported, true if the
115 * operation is attempted
116 */
117 bool teardown();
118
119 /**
120 * Indicates if this volume can check for filesystem errors.
121 *
122 * @return true if the volume is can be checked
123 */
124 bool canCheck() const;
125
126 /**
127 * Checks the filesystem for consistency avoiding any modifications or repairs.
128 *
129 * Mounted or unsupported filesystems will result in an error.
130 *
131 * @return Whether the filesystem is undamaged.
132 */
133 bool check();
134
135 /**
136 * Indicates if the filesystem of this volume supports repair
137 * attempts. It does not indicate if such an attempt will succeed.
138 *
139 * @return true if the volume is can be repaired
140 */
141 bool canRepair() const;
142
143 /**
144 * Tries to repair the filesystem.
145 *
146 * Mounted or unsupported filesystems will result in an error.
147 *
148 * @return Whether the filesystem could be successfully repaired
149 */
150 bool repair();
151
152Q_SIGNALS:
153 /**
154 * This signal is emitted when the accessiblity of this device
155 * has changed.
156 *
157 * @param accessible true if the volume is accessible, false otherwise
158 * @param udi the UDI of the volume
159 */
160 void accessibilityChanged(bool accessible, const QString &udi);
161
162 /**
163 * This signal is emitted when the attempted setting up of this
164 * device is completed. The signal might be spontaneous i.e.
165 * it can be triggered by another process.
166 *
167 * @param error type of error that occurred, if any
168 * @param errorData more information about the error, if any
169 * @param udi the UDI of the volume
170 */
171 void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
172
173 /**
174 * This signal is emitted when the attempted tearing down of this
175 * device is completed. The signal might be spontaneous i.e.
176 * it can be triggered by another process.
177 *
178 * @param error type of error that occurred, if any
179 * @param errorData more information about the error, if any
180 * @param udi the UDI of the volume
181 */
182 void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
183
184 /**
185 * This signal is emitted when a setup of this device is requested.
186 * The signal might be spontaneous i.e. it can be triggered by
187 * another process.
188 *
189 * @param udi the UDI of the volume
190 */
191 void setupRequested(const QString &udi);
192
193 /**
194 * This signal is emitted when a teardown of this device is requested.
195 * The signal might be spontaneous i.e. it can be triggered by
196 * another process
197 *
198 * @param udi the UDI of the volume
199 */
200 void teardownRequested(const QString &udi);
201
202 /**
203 * This signal is emitted when a repair of this device is requested.
204 * The signal might be spontaneous i.e. it can be triggered by
205 * another process.
206 *
207 * @param udi the UDI of the volume
208 */
209 void repairRequested(const QString &udi);
210
211 /**
212 * This signal is emitted when the attempted repaired of this
213 * device is completed. The signal might be spontaneous i.e.
214 * it can be triggered by another process.
215 *
216 * @param error type of error that occurred, if any
217 * @param errorData more information about the error, if any
218 * @param udi the UDI of the volume
219 */
220 void repairDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
221
222protected:
223 /**
224 * @internal
225 */
226 SOLID_NO_EXPORT StorageAccess(StorageAccessPrivate &dd, QObject *backendObject);
227};
228}
229
230#endif
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 volume devices to access them (i.e.
void repairDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
This signal is emitted when the attempted repaired of this device is completed.
void setupRequested(const QString &udi)
This signal is emitted when a setup of this device is requested.
static Type deviceInterfaceType()
Get the Solid::DeviceInterface::Type of the StorageAccess device interface.
void accessibilityChanged(bool accessible, const QString &udi)
This signal is emitted when the accessiblity of this device has changed.
void teardownRequested(const QString &udi)
This signal is emitted when a teardown of this device is requested.
void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
This signal is emitted when the attempted tearing down of this device is completed.
void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi)
This signal is emitted when the attempted setting up of this device is completed.
void repairRequested(const QString &udi)
This signal is emitted when a repair of this device is requested.
The single responsibility of this class is to create arguments valid for logind Inhibit call.
Definition fakebattery.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:56:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.