1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2004 David Faure <faure@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KIO_TRASH_H
9#define KIO_TRASH_H
10
11#include "trashimpl.h"
12#include <kio/workerbase.h>
13
14namespace KIO
15{
16class Job;
17}
18
19typedef TrashImpl::TrashedFileInfo TrashedFileInfo;
20typedef TrashImpl::TrashedFileInfoList TrashedFileInfoList;
21
22class TrashProtocol : public QObject, public KIO::WorkerBase
23{
24 Q_OBJECT
25public:
26 TrashProtocol(const QByteArray &protocol, const QByteArray &pool, const QByteArray &app);
27 ~TrashProtocol() override;
28 KIO::WorkerResult stat(const QUrl &url) override;
29 KIO::WorkerResult listDir(const QUrl &url) override;
30 KIO::WorkerResult get(const QUrl &url) override;
31 KIO::WorkerResult put(const QUrl &url, int, KIO::JobFlags flags) override;
32 KIO::WorkerResult rename(const QUrl &src, const QUrl &dest, KIO::JobFlags) override;
33 KIO::WorkerResult copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) override;
34 // TODO (maybe) chmod( const QUrl& url, int permissions );
35 KIO::WorkerResult del(const QUrl &url, bool isfile) override;
36 /**
37 * Special actions: (first int in the byte array)
38 * 1 : empty trash
39 * 2 : migrate old (pre-kde-3.4) trash contents
40 * 3 : restore a file to its original location. Args: QUrl trashURL.
41 */
42 KIO::WorkerResult special(const QByteArray &data) override;
43 KIO::WorkerResult fileSystemFreeSpace(const QUrl &url) override;
44
45Q_SIGNALS:
46 void leaveModality(int errid, const QString &text);
47
48private Q_SLOTS:
49 void slotData(KIO::Job *, const QByteArray &);
50 void slotMimetype(KIO::Job *, const QString &);
51 void jobFinished(KJob *job);
52
53private:
54 KIO::WorkerResult initImpl();
55 typedef enum { Copy, Move } CopyOrMove;
56 KIO::WorkerResult copyOrMoveFromTrash(const QUrl &src, const QUrl &dest, bool overwrite, CopyOrMove action);
57 KIO::WorkerResult copyOrMoveToTrash(const QUrl &src, const QUrl &dest, CopyOrMove action);
58 void createTopLevelDirEntry(KIO::UDSEntry &entry);
59 bool createUDSEntry(const QString &physicalPath,
60 const QString &displayFileName,
61 const QString &internalFileName,
62 KIO::UDSEntry &entry,
63 const TrashedFileInfo &info);
64 KIO::WorkerResult listRoot();
65 KIO::WorkerResult restore(const QUrl &trashURL);
66 KIO::WorkerResult enterLoop();
67 KIO::StatDetails getStatDetails();
68
69 TrashImpl impl;
70 QString m_userName;
71 QString m_groupName;
72 uid_t m_userId;
73 gid_t m_groupId;
74};
75
76#endif
77

source code of kio/src/kioworkers/trash/kio_trash.h