1 /*
2  * kdiskfreespace.h
3  *
4  * Copyright 2007 David Faure <faure@kde.org>
5  * Copyright 2008 Dirk Mueller <mueller@kde.org>
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Library General Public
9  *  License version 2 as published by the Free Software Foundation.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Library General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Library General Public License
17  *  along with this library; see the file COPYING.LIB.  If not, write to
18  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef KDISKFREESP_H
23 #define KDISKFREESP_H
24 
25 #include <QObject>
26 #include <QString>
27 
28 #include <kdelibs4support_export.h>
29 
30 /**
31  * \deprecated Use KDiskFreeSpaceInfo
32  */
33 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KDiskFreeSpace : public QObject
34 {
35     Q_OBJECT
36 
37 public:
38 
39     /**
40      * Constructor
41      */
42     KDELIBS4SUPPORT_DEPRECATED explicit KDiskFreeSpace(QObject *parent = nullptr);
43 
44     /**
45      * Destructor - this object autodeletes itself when it's done
46      */
47     ~KDiskFreeSpace() override;
48 
49     /**
50      * Call this to fire a search on the disk usage information
51      * for @p mountPoint.
52      * The foundMountPoint() signal will be emitted
53      * if this mount point is found, with the info requested.
54      * The done() signal is emitted in any case.
55      *
56      * @return true if the request could be handled, false if another
57      * request is happening already. readDF() can only be called once
58      * on a given instance of KDiskFreeSpace, given that it handles only
59      * the request for one mount point and then auto-deletes itself.
60      * Suicidal objects are not reusable...
61      */
62     bool readDF(const QString &mountPoint);
63 
64     /**
65      * Call this to fire a search on the disk usage information
66      * for the mount point containing @p path.
67      * The foundMountPoint() signal will be emitted
68      * if this mount point is found, with the info requested.
69      * The done() signal is emitted in any case.
70      */
71     static KDiskFreeSpace *findUsageInfo(const QString &path);
72 
73 Q_SIGNALS:
74     /**
75      * Emitted when the information about the requested mount point was found.
76      * @param mountPoint the requested mount point
77      * @param kibSize the total size of the partition in KiB
78      * @param kibUsed the amount of KiB being used on the partition
79      * @param kibAvail the available space on the partition in KiB
80      */
81     void foundMountPoint(const QString &mountPoint, quint64 kibSize, quint64 kibUsed, quint64 kibAvail);
82 
83     /**
84      * Emitted when the request made via readDF is over, whether foundMountPoint was emitted or not.
85      */
86     void done();
87 
88 private:
89     class Private;
90     Private *const d;
91 
92     Q_PRIVATE_SLOT(d, bool _k_calculateFreeSpace())
93 };
94 
95 #endif
96