File indexing completed on 2024-02-25 05:07:06

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 2007 by Javier Goday <jgoday@gmail.com>
0004    Copyright (C) 2009 by Dario Massarin <nekkar@libero.it>
0005    Copyright (C) 2010 by 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 KUISERVERJOBS_H
0014 #define KUISERVERJOBS_H
0015 
0016 #include "kgetglobaljob.h"
0017 #include "transfer.h"
0018 
0019 #include <kio/filejob.h>
0020 #include <kio/job.h>
0021 
0022 #include <QList>
0023 #include <QObject>
0024 
0025 class KGetKJobAdapter;
0026 class TransferHandler;
0027 
0028 class KUiServerJobs : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     KUiServerJobs(QObject *parent = nullptr);
0033     ~KUiServerJobs() override;
0034 
0035     void settingsChanged();
0036 
0037 public Q_SLOTS:
0038     void slotTransfersAdded(QList<TransferHandler *> transfers);
0039     void slotTransfersAboutToBeRemoved(const QList<TransferHandler *> &transfer);
0040     void slotTransfersChanged(QMap<TransferHandler *, Transfer::ChangesFlags> transfers);
0041 
0042 private Q_SLOTS:
0043     void slotRequestStop(KJob *job, TransferHandler *transfer);
0044     void slotRequestSuspend(KJob *job, TransferHandler *transfer);
0045     void slotRequestResume(KJob *job, TransferHandler *transfer);
0046 
0047 private:
0048     void registerJob(KJob *job, TransferHandler *transfer);
0049     void registerJob(KGetKJobAdapter *job, TransferHandler *transfer);
0050     /**
0051      * Unregisters job and returns true if it worked
0052      */
0053     bool unregisterJob(KJob *job, TransferHandler *transfer);
0054     bool shouldBeShown(TransferHandler *transfer);
0055     bool existRunningTransfers();
0056     KGetGlobalJob *globalJob();
0057 
0058 private:
0059     QMap<TransferHandler *, KJob *> m_registeredJobs;
0060     QList<TransferHandler *> m_invalidTransfers;
0061     QList<TransferHandler *> m_suspendRequested;
0062     KGetGlobalJob *m_globalJob;
0063 };
0064 
0065 #endif