File indexing completed on 2024-05-12 04:01:52
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef SOLID_STORAGEACCESS_H 0008 #define SOLID_STORAGEACCESS_H 0009 0010 #include <solid/solid_export.h> 0011 0012 #include <QVariant> 0013 #include <solid/deviceinterface.h> 0014 #include <solid/solidnamespace.h> 0015 0016 namespace Solid 0017 { 0018 class StorageAccessPrivate; 0019 class Device; 0020 0021 /** 0022 * @class Solid::StorageAccess storageaccess.h <Solid/StorageAccess> 0023 * 0024 * This device interface is available on volume devices to access them 0025 * (i.e. mount or unmount them). 0026 * 0027 * A volume is anything that can contain data (partition, optical disc, 0028 * memory card). It's a particular kind of block device. 0029 */ 0030 class SOLID_EXPORT StorageAccess : public DeviceInterface 0031 { 0032 Q_OBJECT 0033 Q_PROPERTY(bool accessible READ isAccessible) 0034 Q_PROPERTY(QString filePath READ filePath) 0035 Q_PROPERTY(bool ignored READ isIgnored) 0036 Q_PROPERTY(bool encrypted READ isEncrypted) 0037 Q_DECLARE_PRIVATE(StorageAccess) 0038 friend class Device; 0039 0040 private: 0041 /** 0042 * Creates a new StorageAccess object. 0043 * You generally won't need this. It's created when necessary using 0044 * Device::as(). 0045 * 0046 * @param backendObject the device interface object provided by the backend 0047 * @see Solid::Device::as() 0048 */ 0049 SOLID_NO_EXPORT explicit StorageAccess(QObject *backendObject); 0050 0051 public: 0052 /** 0053 * Destroys a StorageAccess object. 0054 */ 0055 ~StorageAccess() override; 0056 0057 /** 0058 * Get the Solid::DeviceInterface::Type of the StorageAccess device interface. 0059 * 0060 * @return the StorageVolume device interface type 0061 * @see Solid::Ifaces::Enums::DeviceInterface::Type 0062 */ 0063 static Type deviceInterfaceType() 0064 { 0065 return DeviceInterface::StorageAccess; 0066 } 0067 0068 /** 0069 * Indicates if this volume is mounted. 0070 * 0071 * @return true if the volume is mounted 0072 */ 0073 bool isAccessible() const; 0074 0075 /** 0076 * Retrieves the absolute path of this volume mountpoint. 0077 * 0078 * @return the absolute path to the mount point if the volume is 0079 * mounted, QString() otherwise 0080 */ 0081 QString filePath() const; 0082 0083 /** 0084 * Indicates if this volume should be ignored by applications. 0085 * 0086 * If it should be ignored, it generally means that it should be 0087 * invisible to the user. It's useful for firmware partitions or 0088 * OS reinstall partitions on some systems. 0089 * 0090 * @return true if the volume should be ignored 0091 */ 0092 bool isIgnored() const; 0093 0094 /** 0095 * Checks if source of the storage is encrypted. 0096 * 0097 * @return true if storage is encrypted one 0098 * 0099 * @since 5.80 0100 */ 0101 bool isEncrypted() const; 0102 0103 /** 0104 * Mounts the volume. 0105 * 0106 * @return false if the operation is not supported, true if the 0107 * operation is attempted 0108 */ 0109 bool setup(); 0110 0111 /** 0112 * Unmounts the volume. 0113 * 0114 * @return false if the operation is not supported, true if the 0115 * operation is attempted 0116 */ 0117 bool teardown(); 0118 0119 Q_SIGNALS: 0120 /** 0121 * This signal is emitted when the accessiblity of this device 0122 * has changed. 0123 * 0124 * @param accessible true if the volume is accessible, false otherwise 0125 * @param udi the UDI of the volume 0126 */ 0127 void accessibilityChanged(bool accessible, const QString &udi); 0128 0129 /** 0130 * This signal is emitted when the attempted setting up of this 0131 * device is completed. The signal might be spontaneous i.e. 0132 * it can be triggered by another process. 0133 * 0134 * @param error type of error that occurred, if any 0135 * @param errorData more information about the error, if any 0136 * @param udi the UDI of the volume 0137 */ 0138 void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi); 0139 0140 /** 0141 * This signal is emitted when the attempted tearing down of this 0142 * device is completed. The signal might be spontaneous i.e. 0143 * it can be triggered by another process. 0144 * 0145 * @param error type of error that occurred, if any 0146 * @param errorData more information about the error, if any 0147 * @param udi the UDI of the volume 0148 */ 0149 void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi); 0150 0151 /** 0152 * This signal is emitted when a setup of this device is requested. 0153 * The signal might be spontaneous i.e. it can be triggered by 0154 * another process. 0155 * 0156 * @param udi the UDI of the volume 0157 */ 0158 void setupRequested(const QString &udi); 0159 0160 /** 0161 * This signal is emitted when a teardown of this device is requested. 0162 * The signal might be spontaneous i.e. it can be triggered by 0163 * another process 0164 * 0165 * @param udi the UDI of the volume 0166 */ 0167 void teardownRequested(const QString &udi); 0168 0169 protected: 0170 /** 0171 * @internal 0172 */ 0173 SOLID_NO_EXPORT StorageAccess(StorageAccessPrivate &dd, QObject *backendObject); 0174 }; 0175 } 0176 0177 #endif