libktorrent  2.2.0
movedatafilesjob.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTMOVEDATAFILESJOB_H
21 #define BTMOVEDATAFILESJOB_H
22 
23 #include <torrent/job.h>
24 #include <util/resourcemanager.h>
25 
26 namespace bt
27 {
28  class TorrentFileInterface;
29 
34  class MoveDataFilesJob : public Job, public Resource
35  {
36  Q_OBJECT
37  public:
38  MoveDataFilesJob();
39 
44  MoveDataFilesJob(const QMap<TorrentFileInterface*,QString> & fmap);
45  ~MoveDataFilesJob() override;
46 
52  void addMove(const QString & src,const QString & dst);
53 
54  void start() override;
55  void kill(bool quietly = true) override;
56 
58  const QMap<TorrentFileInterface*,QString> & fileMap() const {return file_map;}
59 
60  private Q_SLOTS:
61  void onJobDone(KJob* j);
62  void onRecoveryJobDone(KJob* j);
63  void onTransferred(KJob *job, KJob::Unit unit, qulonglong amount);
64  void onSpeed(KJob* job, unsigned long speed);
65 
66  private:
67  void recover(bool delete_active);
68  void startMoving();
69  void acquired() override;
70 
71  private:
72  bool err;
73  KIO::Job* active_job;
74  QString active_src,active_dst;
75  QMap<QString,QString> todo;
76  QMap<QString,QString> success;
77  int running_recovery_jobs;
78  QMap<TorrentFileInterface*,QString> file_map;
79 
80  bt::Uint64 bytes_moved;
81  bt::Uint64 total_bytes;
82  bt::Uint64 bytes_moved_current_file;
83  };
84 
85 }
86 
87 #endif
bt::MoveDataFilesJob::addMove
void addMove(const QString &src, const QString &dst)
bt::MoveDataFilesJob::fileMap
const QMap< TorrentFileInterface *, QString > & fileMap() const
Get the file map (could be empty)
Definition: movedatafilesjob.h:76