1 /* This file is part of the KDE project
2 
3    Copyright (C) 2008 Javier Goday <jgoday @ gmail.com>
4    Idea by Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de>
5    Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net>
6 
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public
9    License as published by the Free Software Foundation; either
10    version 2 of the License, or (at your option) any later version.
11 */
12 
13 #ifndef KGETKJOBADAPTER_H
14 #define KGETKJOBADAPTER_H
15 
16 #include "transferhandler.h"
17 
18 #include <KIO/Job>
19 
20 /**
21 * Allows kget to register all transfers in kuiserver as kjobs
22 */
23 class KGetKJobAdapter : public KJob
24 {
25     Q_OBJECT
26 public:
27     KGetKJobAdapter(QObject *parent, TransferHandler *transfer);
28     ~KGetKJobAdapter() override;
29 
start()30     void start() override {};
31 
32     qulonglong processedAmount(Unit unit) const;
33     qulonglong totalAmount(Unit unit) const;
34     unsigned long percent() const;
35 
36 public Q_SLOTS:
37     void slotUpdateDescription();
38 
39 Q_SIGNALS:
40     /**
41      * Emitted when doKill is called, e.g. when the gui is closed.
42      * Not handling this signal might lead to a crash if something tries to
43      * access the then non-existing gui.
44      */
45     void requestStop(KJob *job, TransferHandler *handler);
46     void requestSuspend(KJob *job, TransferHandler *handler);
47     void requestResume(KJob *job, TransferHandler *handler);
48 
49 protected:
50     bool doKill() override;
51     bool doSuspend() override;
52     bool doResume() override;
53 
54 private:
55     TransferHandler *m_transferHandler;
56 };
57 #endif
58