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/slavebase.h> 13 14 namespace KIO 15 { 16 class Job; 17 } 18 19 typedef TrashImpl::TrashedFileInfo TrashedFileInfo; 20 typedef TrashImpl::TrashedFileInfoList TrashedFileInfoList; 21 22 class TrashProtocol : public QObject, public KIO::SlaveBase 23 { 24 Q_OBJECT 25 public: 26 TrashProtocol(const QByteArray &protocol, const QByteArray &pool, const QByteArray &app); 27 ~TrashProtocol() override; 28 void stat(const QUrl &url) override; 29 void listDir(const QUrl &url) override; 30 void get(const QUrl &url) override; 31 void put(const QUrl &url, int, KIO::JobFlags flags) override; 32 void rename(const QUrl &src, const QUrl &dest, KIO::JobFlags) override; 33 void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) override; 34 // TODO (maybe) chmod( const QUrl& url, int permissions ); 35 void 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 void special(const QByteArray &data) override; 43 44 Q_SIGNALS: 45 void leaveModality(); 46 47 protected: 48 void virtual_hook(int id, void *data) override; 49 50 private Q_SLOTS: 51 void slotData(KIO::Job *, const QByteArray &); 52 void slotMimetype(KIO::Job *, const QString &); 53 void jobFinished(KJob *job); 54 55 private: 56 bool initImpl(); 57 typedef enum { Copy, Move } CopyOrMove; 58 void copyOrMoveFromTrash(const QUrl &src, const QUrl &dest, bool overwrite, CopyOrMove action); 59 void copyOrMoveToTrash(const QUrl &src, const QUrl &dest, CopyOrMove action); 60 void createTopLevelDirEntry(KIO::UDSEntry &entry); 61 bool createUDSEntry(const QString &physicalPath, 62 const QString &displayFileName, 63 const QString &internalFileName, 64 KIO::UDSEntry &entry, 65 const TrashedFileInfo &info); 66 void listRoot(); 67 void restore(const QUrl &trashURL); 68 void enterLoop(); 69 void fileSystemFreeSpace(const QUrl &url); 70 KIO::StatDetails getStatDetails(); 71 72 TrashImpl impl; 73 QString m_userName; 74 QString m_groupName; 75 }; 76 77 #endif 78