1 /* This file is part of the KDE project
2 Copyright (C) 2004 David Faure <faure@kde.org>
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 as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library 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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #include <kio/slavebase.h>
24 #include "trashimpl.h"
25 namespace KIO
{ class Job
; }
27 typedef TrashImpl::TrashedFileInfo TrashedFileInfo
;
28 typedef TrashImpl::TrashedFileInfoList TrashedFileInfoList
;
30 class TrashProtocol
: public QObject
, public KIO::SlaveBase
34 TrashProtocol( const QByteArray
& protocol
, const QByteArray
&pool
, const QByteArray
&app
);
35 virtual ~TrashProtocol();
36 virtual void stat(const KUrl
& url
);
37 virtual void listDir(const KUrl
& url
);
38 virtual void get( const KUrl
& url
);
39 virtual void put( const KUrl
& url
, int , KIO::JobFlags flags
);
40 virtual void rename( const KUrl
&, const KUrl
&, KIO::JobFlags
);
41 virtual void copy( const KUrl
&src
, const KUrl
&dest
, int permissions
, KIO::JobFlags flags
);
42 // TODO (maybe) chmod( const KUrl& url, int permissions );
43 virtual void del( const KUrl
&url
, bool isfile
);
45 * Special actions: (first int in the byte array)
47 * 2 : migrate old (pre-kde-3.4) trash contents
48 * 3 : restore a file to its original location. Args: KUrl trashURL.
50 virtual void special( const QByteArray
& data
);
56 void slotData( KIO::Job
*, const QByteArray
& );
57 void slotMimetype( KIO::Job
*, const QString
& );
58 void jobFinished( KJob
* job
);
61 typedef enum { Copy
, Move
} CopyOrMove
;
62 void copyOrMove( const KUrl
& src
, const KUrl
& dest
, bool overwrite
, CopyOrMove action
);
63 void createTopLevelDirEntry(KIO::UDSEntry
& entry
);
64 bool createUDSEntry( const QString
& physicalPath
, const QString
& displayFileName
, const QString
& internalFileName
,
65 KIO::UDSEntry
& entry
, const TrashedFileInfo
& info
);
67 void restore( const KUrl
& trashURL
);