File indexing completed on 2024-04-28 15:27:20

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef KAUTOMOUNT_H
0009 #define KAUTOMOUNT_H
0010 
0011 #include <QObject>
0012 #include <QString>
0013 
0014 #include <QtGlobal>
0015 
0016 #include "kiowidgets_export.h"
0017 
0018 #include <memory>
0019 
0020 #ifdef Q_OS_UNIX
0021 
0022 class KJob;
0023 namespace KIO
0024 {
0025 class Job;
0026 }
0027 
0028 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 88)
0029 
0030 class KAutoMountPrivate;
0031 /**
0032  * @class KAutoMount kautomount.h <KAutoMount>
0033  *
0034  * This class implements synchronous mounting of devices,
0035  * as well as showing a file-manager window after mounting a device, optionally.
0036  * It is a wrapper around the asynchronous KIO::special() call for mount,
0037  * used by KDesktopFileActions.
0038  *
0039  * @short This class implements synchronous mounting of devices.
0040  *
0041  * @deprecated Since 5.88. There's no direct replacement, Solid::StorageAccess::setup may help
0042  */
0043 class KIOWIDGETS_EXPORT KAutoMount : public QObject
0044 {
0045     Q_OBJECT
0046 public:
0047     /**
0048      * Mounts a device.
0049      * @param readonly if true, the device is mounted read-only
0050      * @param format the file system (e.g. vfat, ext2...) [optional, fstab is used otherwise]
0051      * @param device the path to the device (e.g. /dev/fd0)
0052      * @param mountpoint the directory where to mount the device [optional, fstab is used otherwise]
0053      * @param desktopFile the file the user clicked on - to notify KDirWatch of the fact that
0054      * it should emit fileDirty for it (to have the icon change)
0055      * @param show_filemanager_window if true, a file-manager window for that mountpoint is shown after
0056      * the mount, if successful.
0057      */
0058     KIOWIDGETS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
0059     KAutoMount(bool readonly,
0060                const QByteArray &format,
0061                const QString &device,
0062                const QString &mountpoint,
0063                const QString &desktopFile,
0064                bool show_filemanager_window = true);
0065 
0066 Q_SIGNALS:
0067     /** Emitted when the directory has been mounted */
0068     void finished();
0069     /** Emitted in case the directory could not been mounted */
0070     void error();
0071 
0072 private:
0073     /** KAutoMount deletes itself. Don't delete it manually. */
0074     ~KAutoMount() override;
0075     Q_PRIVATE_SLOT(d, void slotResult(KJob *))
0076     friend class KAutoMountPrivate;
0077     std::unique_ptr<KAutoMountPrivate> const d;
0078 };
0079 
0080 class KAutoUnmountPrivate;
0081 /**
0082  * This class implements synchronous unmounting of devices,
0083  * It is a wrapper around the asynchronous KIO::special() call for unmount,
0084  * used by KDesktopFileActions.
0085  *
0086  * @short This class implements synchronous unmounting of devices,
0087  *
0088  * @deprecated Since 5.88. There's no direct replacement, Solid::StorageAccess::teardown may help
0089  */
0090 class KIOWIDGETS_EXPORT KAutoUnmount : public QObject
0091 {
0092     Q_OBJECT
0093 public:
0094     /**
0095      * Unmounts a device.
0096      * @param mountpoint the mount point - KAutoUnmount finds the device from that
0097      * @param desktopFile the file the user clicked on - to notify KDirWatch of the fact that
0098      * it should emit fileDirty for it (to have the icon change)
0099      */
0100     KIOWIDGETS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
0101     KAutoUnmount(const QString &mountpoint, const QString &desktopFile);
0102 
0103 Q_SIGNALS:
0104     /** Emitted when the directory has been unmounted */
0105     void finished();
0106     /** Emitted in case the directory could not been unmounted */
0107     void error();
0108 
0109 private:
0110     /** KAutoUnmount deletes itself. Don't delete it manually. */
0111     ~KAutoUnmount() override;
0112     Q_PRIVATE_SLOT(d, void slotResult(KJob *))
0113     friend class KAutoUnmountPrivate;
0114     std::unique_ptr<KAutoUnmountPrivate> const d;
0115 };
0116 #endif
0117 
0118 #endif // Q_OS_UNIX
0119 
0120 #endif