Relicense all GPLv2 only code to GPLv2+.
[kdenetwork.git] / kget / core / speedlimiter.h
blob946bd5aedded842191ac61ac6fe5912d209594dd
1 /* This file is part of the KDE project
3 Copyright (C) 2007 Manolo Valdes <nolis71cu@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9 */
11 #ifndef SPEEDLIMITER_H
12 #define SPEEDLIMITER_H
14 #include <kio/job.h>
16 #include <QtCore/QTime>
18 class KJobSpeedLimiter;
20 /**
21 * The KSpeedLimiter is designed to throtle the speed in kio jobs
24 class KSpeedLimiter
27 public:
28 KSpeedLimiter(unsigned long speed);
29 ~KSpeedLimiter();
31 void setSpeedLimit(unsigned long speed);
32 unsigned long speedLimit();
34 void addJob(KJob *job);
36 private:
37 unsigned long m_speedLimit;
38 QList<KJobSpeedLimiter *> m_JobSpeedLimiters;
42 class KJobSpeedLimiter : public QObject
44 Q_OBJECT
46 public:
47 KJobSpeedLimiter(KJob *job, unsigned long speedLimit);
48 ~KJobSpeedLimiter();
50 private Q_SLOTS:
51 void slotOnTimer();
52 void slotOffTimer();
53 void slotResult(KJob *job);
55 private:
56 bool isSuspended();
57 void suspend();
58 void resume();
60 private:
61 unsigned long m_speedLimit;
62 unsigned long m_channelSpeed;
63 KJob *m_job;
64 qulonglong m_bytes;
65 QTime m_time;
66 bool m_isSuspended;
67 int m_OnTime;
68 int m_OffTime;
71 #endif