libktorrent  2.2.0
waitjob.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 BTWAITJOB_H
21 #define BTWAITJOB_H
22 
23 #include <kio/job.h>
24 #include <qlist.h>
25 #include <interfaces/exitoperation.h>
26 #include "constants.h"
27 #include <ktorrent_export.h>
28 
29 namespace bt
30 {
31 
38  class KTORRENT_EXPORT WaitJob : public KIO::Job
39  {
40  Q_OBJECT
41  public:
42  WaitJob(Uint32 millis);
43  ~WaitJob() override;
44 
45  virtual void kill(bool quietly=true);
46 
51  void addExitOperation(ExitOperation* op);
52 
57  void addExitOperation(KIO::Job* job);
58 
59 
64  static void execute(WaitJob* job);
65 
67  bool needToWait() const {return exit_ops.count() > 0;}
68 
69  private Q_SLOTS:
70  void timerDone();
71  void operationFinished(ExitOperation* op);
72 
73  private:
74  QList<ExitOperation*> exit_ops;
75  };
76 
77  KTORRENT_EXPORT void SynchronousWait(Uint32 millis);
78 
79 
80 
81 }
82 
83 #endif