• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • core
scheduler.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2005 Dario Massarin <nekkar@libero.it>
4  Coypright (C) 2010 Matthias Fuchs <mat69@gmx.net>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 */
11 
12 #ifndef SCHEDULER_H
13 #define SCHEDULER_H
14 
15 #include <QObject>
16 #include <QMap>
17 #include <QTimerEvent>
18 
19 #include "core/job.h"
20 #include "core/jobqueue.h"
21 #include "../kget_export.h"
22 
32 class KGET_EXPORT Scheduler : public QObject
33 {
34  Q_OBJECT
35 
36  friend class SchedulerTest;
37 
38  public:
39 
40  enum FailureStatus {
41  None = 0,
42  AboutToStall = 1,
43  Stall = 2,
44  StallTimeout = 3,
45  Abort = 4,
46  AbortTimeout = 5,
47  Error = 6
48  };
49 
50  class JobFailure {
51  public:
52  JobFailure()
53  : status(None), time(-1), count(0)
54  {}
55 
56  bool isValid() {return ((status != None) && (time != -1));}
57 
58  FailureStatus status;
59  int time;
60  int count;
61 
62  bool operator==(JobFailure f) const {return ((status == f.status) && (time == f.time));}
63  bool operator!=(JobFailure f) const {return ((status != f.status) || (time != f.time));}
64  };
65 
66  Scheduler(QObject * parent = 0);
67  ~Scheduler();
68 
74  void start();
75 
81  void stop();
82 
92  void setIsSuspended(bool isSuspended);
93 
99  void setHasNetworkConnection(bool hasConnection);
100 
106  void addQueue(JobQueue * queue);
107 
115  void delQueue(JobQueue * queue);
116 
120  bool hasRunningJobs() const;
121 
125  int countRunningJobs() const;
126 
131  void settingsChanged();
132 
133  //JobQueue notifications
134  virtual void jobQueueChangedEvent(JobQueue * queue, JobQueue::Status status);
135  virtual void jobQueueMovedJobEvent(JobQueue * queue, Job * job);
136  virtual void jobQueueAddedJobEvent(JobQueue * queue, Job * job);
137  virtual void jobQueueAddedJobsEvent(JobQueue *queue, const QList<Job*> jobs);
138  virtual void jobQueueRemovedJobEvent(JobQueue * queue, Job * job);
139  virtual void jobQueueRemovedJobsEvent(JobQueue *queue, const QList<Job*> jobs);
140 
141  //Job notifications
142  virtual void jobChangedEvent(Job * job, Job::Status status);
143  virtual void jobChangedEvent(Job * job, Job::Policy status);
144  virtual void jobChangedEvent(Job * job, JobFailure failure);
145 
146  protected:
153  void updateQueue( JobQueue * queue );
154 
161  bool shouldBeRunning( Job * job );
162 
163  private:
164  //Virtual QObject method
165  void timerEvent(QTimerEvent * event);
166 
171  void updateAllQueues();
172 
173  bool shouldUpdate() const;
174 
175  private:
176  QList<JobQueue *> m_queues;
177  QMap<Job *, JobFailure> m_failedJobs;
178 
179  int m_failureCheckTimer;
180 
181  const int m_stallTime;
182  int m_stallTimeout;
183  int m_abortTimeout;
184  bool m_isSuspended;
185  bool m_hasConnection;
186 };
187 
188 inline bool Scheduler::shouldUpdate() const
189 {
190  return !m_isSuspended && m_hasConnection;
191 }
192 #endif
Scheduler
Scheduler class: what handle all the jobs in kget.
Definition: scheduler.h:32
Job::Status
Status
The status property describes the current job status.
Definition: job.h:42
Scheduler::JobFailure
Definition: scheduler.h:50
Job
Definition: job.h:35
Scheduler::JobFailure::time
int time
Definition: scheduler.h:59
QObject
JobQueue::Status
Status
Definition: jobqueue.h:36
Scheduler::JobFailure::count
int count
Definition: scheduler.h:60
Scheduler::JobFailure::operator!=
bool operator!=(JobFailure f) const
Definition: scheduler.h:63
jobqueue.h
Scheduler::JobFailure::status
FailureStatus status
Definition: scheduler.h:58
Job::Policy
Policy
The policy property describes how the scheduler should manage this job.
Definition: job.h:57
Scheduler::JobFailure::JobFailure
JobFailure()
Definition: scheduler.h:52
Scheduler::JobFailure::operator==
bool operator==(JobFailure f) const
Definition: scheduler.h:62
job.h
JobQueue
Definition: jobqueue.h:32
KGET_EXPORT
#define KGET_EXPORT
Definition: kget_export.h:24
Scheduler::JobFailure::isValid
bool isValid()
Definition: scheduler.h:56
Scheduler::FailureStatus
FailureStatus
Definition: scheduler.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal