1 /**************************************************************************
2 *   Copyright (C) 2011 Matthias Fuchs <mat69@gmx.net>                     *
3 *                                                                         *
4 *   This program is free software; you can redistribute it and/or modify  *
5 *   it under the terms of the GNU General Public License as published by  *
6 *   the Free Software Foundation; either version 2 of the License, or     *
7 *   (at your option) any later version.                                   *
8 *                                                                         *
9 *   This program is distributed in the hope that it will be useful,       *
10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 *   GNU General Public License for more details.                          *
13 *                                                                         *
14 *   You should have received a copy of the GNU General Public License     *
15 *   along with this program; if not, write to the                         *
16 *   Free Software Foundation, Inc.,                                       *
17 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
18 ***************************************************************************/
19 
20 #ifndef KGET_FILE_DELETER_H
21 #define KGET_FILE_DELETER_H
22 
23 #include "kget_export.h"
24 
25 class KJob;
26 class QUrl;
27 class QObject;
28 
29 /**
30  * The FileDeleter is a wrapper around KIO ensuring that always
31  * just one job is started for deleting a file.
32  * Thus deleteFile can be called multiple times safely and all callees
33  * are informed once the file is actually deleted.
34  */
35 class KGET_EXPORT FileDeleter
36 {
37     public:
38         FileDeleter();
39         ~FileDeleter();
40 
41         /**
42          * Starts the deletion of dest and emits KJob::finished once done.
43          * You can safely call this method multiple times for the same destination.
44          * @param dest destination to delete
45          * @param receiver receiver of the finished signal
46          * @param method method the finished signal should be connected to, thus
47          *        informing you of the result
48          * @return the KJob that has been created
49          * @note only use the returned job to create connections yourself, not to modify it!
50          */
51         static KJob *deleteFile(const QUrl &dest, QObject *receiver = nullptr, const char *method = nullptr);
52 
53         /**
54          * @return true if dest is being deleted
55          */
56         static bool isFileBeingDeleted(const QUrl &dest);
57 
58     private:
59         class Private;
60         Private *d;
61 };
62 
63 #endif
64