File indexing completed on 2024-05-19 04:03:20

0001 /*
0002     SPDX-FileCopyrightText: 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_IFACES_STORAGEACCESS_H
0008 #define SOLID_IFACES_STORAGEACCESS_H
0009 
0010 #include <solid/devices/ifaces/deviceinterface.h>
0011 #include <solid/storageaccess.h>
0012 
0013 namespace Solid
0014 {
0015 namespace Ifaces
0016 {
0017 /**
0018  * This device interface is available on volume devices.
0019  *
0020  * A volume is anything that can contain data (partition, optical disc,
0021  * memory card). It's a particular kind of block device.
0022  */
0023 class StorageAccess : virtual public DeviceInterface
0024 {
0025 public:
0026     /**
0027      * Destroys a StorageVolume object.
0028      */
0029     ~StorageAccess() override;
0030 
0031     /**
0032      * Indicates if this volume is mounted.
0033      *
0034      * @return true if the volume is mounted
0035      */
0036     virtual bool isAccessible() const = 0;
0037 
0038     /**
0039      * Retrieves the absolute path of this volume mountpoint.
0040      *
0041      * @return the absolute path to the mount point if the volume is
0042      * mounted, QString() otherwise
0043      */
0044     virtual QString filePath() const = 0;
0045 
0046     /**
0047      * Indicates if this volume should be ignored by applications.
0048      *
0049      * If it should be ignored, it generally means that it should be
0050      * invisible to the user. It's useful for firmware partitions or
0051      * OS reinstall partitions on some systems.
0052      *
0053      * @return true if the volume should be ignored
0054      */
0055     virtual bool isIgnored() const = 0;
0056 
0057     /**
0058      * Checks if source of the storage is encrypted.
0059      *
0060      * @return true if storage is encrypted one
0061      */
0062     virtual bool isEncrypted() const = 0;
0063 
0064     /**
0065      * Mounts the volume.
0066      *
0067      * @return the job handling the operation
0068      */
0069     virtual bool setup() = 0;
0070 
0071     /**
0072      * Unmounts the volume.
0073      *
0074      * @return the job handling the operation
0075      */
0076     virtual bool teardown() = 0;
0077 
0078 protected:
0079     // Q_SIGNALS:
0080     /**
0081      * This signal is emitted when the mount state of this device
0082      * has changed.
0083      *
0084      * @param newState true if the volume is mounted, false otherwise
0085      * @param udi the UDI of the volume
0086      */
0087     virtual void accessibilityChanged(bool accessible, const QString &udi) = 0;
0088 
0089     /**
0090      * This signal is emitted when the mount state of this device
0091      * has changed.
0092      *
0093      * @param newState true if the volume is mounted, false otherwise
0094      * @param udi the UDI of the volume
0095      */
0096     virtual void setupDone(Solid::ErrorType error, QVariant resultData, const QString &udi) = 0;
0097 
0098     /**
0099      * This signal is emitted when the mount state of this device
0100      * has changed.
0101      *
0102      * @param newState true if the volume is mounted, false otherwise
0103      * @param udi the UDI of the volume
0104      */
0105     virtual void teardownDone(Solid::ErrorType error, QVariant resultData, const QString &udi) = 0;
0106 
0107     /**
0108      * This signal is emitted when a setup of this device is requested.
0109      * The signal might be spontaneous i.e. it can be triggered by
0110      * another process.
0111      *
0112      * @param udi the UDI of the volume
0113      */
0114     virtual void setupRequested(const QString &udi) = 0;
0115 
0116     /**
0117      * This signal is emitted when a teardown of this device is requested.
0118      * The signal might be spontaneous i.e. it can be triggered by
0119      * another process
0120      *
0121      * @param udi the UDI of the volume
0122      */
0123     virtual void teardownRequested(const QString &udi) = 0;
0124 };
0125 }
0126 }
0127 
0128 Q_DECLARE_INTERFACE(Solid::Ifaces::StorageAccess, "org.kde.Solid.Ifaces.StorageAccess/0.1")
0129 
0130 #endif