File indexing completed on 2024-05-19 04:59:55

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 2008 Javier Goday <jgoday @ gmail.com>
0004    Idea by Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de>
0005    Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net>
0006 
0007    This program is free software; you can redistribute it and/or
0008    modify it under the terms of the GNU General Public
0009    License as published by the Free Software Foundation; either
0010    version 2 of the License, or (at your option) any later version.
0011 */
0012 
0013 #ifndef KGETKJOBADAPTER_H
0014 #define KGETKJOBADAPTER_H
0015 
0016 #include "transferhandler.h"
0017 
0018 #include <KIO/Job>
0019 
0020 /**
0021  * Allows kget to register all transfers in kuiserver as kjobs
0022  */
0023 class KGetKJobAdapter : public KJob
0024 {
0025     Q_OBJECT
0026 public:
0027     KGetKJobAdapter(QObject *parent, TransferHandler *transfer);
0028     ~KGetKJobAdapter() override;
0029 
0030     void start() override
0031     {
0032     }
0033 
0034     qulonglong processedAmount(Unit unit) const;
0035     qulonglong totalAmount(Unit unit) const;
0036     unsigned long percent() const;
0037 
0038 public Q_SLOTS:
0039     void slotUpdateDescription();
0040 
0041 Q_SIGNALS:
0042     /**
0043      * Emitted when doKill is called, e.g. when the gui is closed.
0044      * Not handling this signal might lead to a crash if something tries to
0045      * access the then non-existing gui.
0046      */
0047     void requestStop(KJob *job, TransferHandler *handler);
0048     void requestSuspend(KJob *job, TransferHandler *handler);
0049     void requestResume(KJob *job, TransferHandler *handler);
0050 
0051 protected:
0052     bool doKill() override;
0053     bool doSuspend() override;
0054     bool doResume() override;
0055 
0056 private:
0057     TransferHandler *m_transferHandler;
0058 };
0059 #endif