File indexing completed on 2025-01-05 04:37:29
0001 /* 0002 SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com> 0003 SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #ifndef BTCOMPRESSFILEJOB_H 0008 #define BTCOMPRESSFILEJOB_H 0009 0010 #include <KIO/Job> 0011 #include <QThread> 0012 #include <ktorrent_export.h> 0013 0014 namespace bt 0015 { 0016 class KTORRENT_EXPORT CompressThread : public QThread 0017 { 0018 public: 0019 CompressThread(const QString &file); 0020 ~CompressThread() override; 0021 0022 /// Run the compression thread 0023 void run() override; 0024 0025 /// Cancel the thread, things should be cleaned up properly 0026 void cancel(); 0027 0028 /// Get the error which happened (0 means no error) 0029 int error() const 0030 { 0031 return err; 0032 } 0033 0034 private: 0035 QString file; 0036 bool canceled; 0037 int err; 0038 }; 0039 0040 /** 0041 Compress a file using gzip and remove it when completed successfully. 0042 */ 0043 class KTORRENT_EXPORT CompressFileJob : public KIO::Job 0044 { 0045 public: 0046 CompressFileJob(const QString &file); 0047 ~CompressFileJob() override; 0048 0049 void start() override; 0050 virtual void kill(bool quietly = true); 0051 0052 private: 0053 void compressThreadFinished(); 0054 0055 private: 0056 QString file; 0057 CompressThread *compress_thread; 0058 }; 0059 0060 } 0061 0062 #endif