1 /* This file is part of the KDE project
3 Copyright (C) 2005 Dario Massarin <nekkar@libero.it>
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; version 2
17 * We want to abstract this common interface in order to simplify the
18 * Scheduler code. A Job can be either a Transfer or a search through the net.
19 * It is basically something you execute in background and that the scheduler
20 * can decide to start, stop or cancel. In this way we don't expose the complex
21 * API of a Transfer (or a Search), to the scheduler.
22 * By definition a job must always belong to a JobQueue (see jobqueue.h).
25 #include "kget_export.h"
36 * The status property describes the current job status
39 Running
, ///< The job is being executed
40 Delayed
, ///< The job is delayed. This means that the scheduler should
41 /// not start it until it exits from the delayed state
42 Stopped
, ///< The job is stopped
43 Aborted
, ///< The job is stopped, but this also indicates that it
44 /// stopped because an error occurred
45 Finished
///< The job exited from its Running state successfully
49 * The policy property describes how the scheduler should manage this job.
51 enum Policy
{Start
, ///< The scheduler should start this job even if its queue
52 /// isn't in a Running status
53 Stop
, ///< The scheduler shouldn't never start this job, even if
54 /// if its queue is in a Running status
55 None
///< The scheduler should start this job depending on its
59 Job(JobQueue
* parent
, Scheduler
* scheduler
);
63 virtual void start()=0;
64 virtual void stop()=0;
66 virtual void setDelay(int seconds
)=0;
67 virtual void delayTimerEvent()=0;
69 JobQueue
* jobQueue() {return m_jobQueue
;}
72 void setStatus(Status jobStatus
);
73 void setPolicy(Policy jobPolicy
);
75 Status
status() const {return m_status
;}
76 Policy
policy() const {return m_policy
;}
78 virtual int elapsedTime() const =0;
79 virtual int remainingTime() const =0;
82 virtual bool isResumable() const =0;
85 Scheduler
* scheduler() const {return m_scheduler
;}
87 void read(QDomNode
* n
);
88 void write(QDomNode
* n
);
91 * This one posts a job event to the scheduler
93 void postJobEvent(Status
); //do we need a JobEvent instead of JobStatus?
95 JobQueue
* m_jobQueue
;
96 Scheduler
* m_scheduler
;