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
119Q_SIGNALS:
120 /**
121 * This signal is emitted when the accessiblity of this device
122 * has changed.
123 *
124 * @param accessible true if the volume is accessible, false otherwise
125 * @param udi the UDI of the volume
126 */
127 void accessibilityChanged(bool accessible, const QString &udi);
128
129 /**
130 * This signal is emitted when the attempted setting up of this
131 * device is completed. The signal might be spontaneous i.e.
132 * it can be triggered by another process.
133 *
134 * @param error type of error that occurred, if any
135 * @param errorData more information about the error, if any
136 * @param udi the UDI of the volume
137 */
138 void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
139
140 /**
141 * This signal is emitted when the attempted tearing down of this
142 * device is completed. The signal might be spontaneous i.e.
143 * it can be triggered by another process.
144 *
145 * @param error type of error that occurred, if any
146 * @param errorData more information about the error, if any
147 * @param udi the UDI of the volume
148 */
149 void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
150
151 /**
152 * This signal is emitted when a setup of this device is requested.
153 * The signal might be spontaneous i.e. it can be triggered by
154 * another process.
155 *
156 * @param udi the UDI of the volume
157 */
158 void setupRequested(const QString &udi);
159
160 /**
161 * This signal is emitted when a teardown of this device is requested.
162 * The signal might be spontaneous i.e. it can be triggered by
163 * another process
164 *
165 * @param udi the UDI of the volume
166 */
167 void teardownRequested(const QString &udi);
168
169protected:
170 /**
171 * @internal
172 */
173 SOLID_NO_EXPORT StorageAccess(StorageAccessPrivate &dd, QObject *backendObject);
174};
175}
176
177#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 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.
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 Tue Mar 26 2024 11:17:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.