1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#ifndef KAUTOMOUNT_H
20#define KAUTOMOUNT_H
21
22#include <QtCore/QObject>
23#include <QtCore/QString>
24
25#include <QtGlobal>
26
27#include <kio/kio_export.h>
28
29#ifdef Q_OS_UNIX
30
31class KJob;
32namespace KIO {
33 class Job;
34}
35
36class KAutoMountPrivate;
37/**
38 * This class implements synchronous mounting of devices,
39 * as well as showing a file-manager window after mounting a device, optionally.
40 * It is a wrapper around the asychronous KIO::special() call for mount,
41 * used by KMimeType.
42 *
43 * @short This class implements synchronous mounting of devices.
44 */
45class KIO_EXPORT KAutoMount : public QObject
46{
47 Q_OBJECT
48public:
49 /**
50 * Mounts a device.
51 * @param readonly if true, the device is mounted read-only
52 * @param format the file system (e.g. vfat, ext2...) [optional, fstab is used otherwise]
53 * @param device the path to the device (e.g. /dev/fd0)
54 * @param mountpoint the directory where to mount the device [optional, fstab is used otherwise]
55 * @param desktopFile the file the user clicked on - to notify KDirWatch of the fact that
56 * it should emit fileDirty for it (to have the icon change)
57 * @param show_filemanager_window if true, a file-manager window for that mountpoint is shown after
58 * the mount, if successful.
59 */
60 KAutoMount( bool readonly, const QByteArray& format, const QString& device, const QString& mountpoint,
61 const QString & desktopFile, bool show_filemanager_window = true );
62
63Q_SIGNALS:
64 /** Emitted when the directory has been mounted */
65 void finished();
66 /** Emitted in case the directory could not been mounted */
67 void error();
68
69private:
70 /** KAutoMount deletes itself. Don't delete it manually. */
71 ~KAutoMount();
72 Q_PRIVATE_SLOT(d, void slotResult( KJob * ))
73 friend class KAutoMountPrivate;
74 KAutoMountPrivate* const d;
75};
76
77class KAutoUnmountPrivate;
78/**
79 * This class implements synchronous unmounting of devices,
80 * It is a wrapper around the asychronous KIO::special() call for unmount,
81 * used by KMimeType.
82 *
83 * @short This class implements synchronous unmounting of devices,
84 */
85class KIO_EXPORT KAutoUnmount : public QObject
86{
87 Q_OBJECT
88public:
89 /**
90 * Unmounts a device.
91 * @param mountpoint the mount point - KAutoUnmount finds the device from that
92 * @param desktopFile the file the user clicked on - to notify KDirWatch of the fact that
93 * it should emit fileDirty for it (to have the icon change)
94 */
95 KAutoUnmount( const QString & mountpoint, const QString & desktopFile );
96
97Q_SIGNALS:
98 /** Emitted when the directory has been unmounted */
99 void finished();
100 /** Emitted in case the directory could not been unmounted */
101 void error();
102
103private:
104 /** KAutoUnmount deletes itself. Don't delete it manually. */
105 ~KAutoUnmount();
106 Q_PRIVATE_SLOT(d, void slotResult( KJob * ))
107 friend class KAutoUnmountPrivate;
108 KAutoUnmountPrivate* const d;
109};
110
111#endif //Q_OS_UNIX
112
113#endif
114