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.
52 Start
, /// The scheduler should start this job even if its queue
53 /// isn't in a Running status
54 Stop
, /// The scheduler shouldn't never start this job, even if
55 /// if its queue is in a Running status
56 None
/// The scheduler should start this job depending on its
60 Job(JobQueue
* parent
, Scheduler
* scheduler
);
64 virtual void start()=0;
65 virtual void stop()=0;
67 virtual void setDelay(int seconds
)=0;
68 virtual void delayTimerEvent()=0;
70 JobQueue
* jobQueue() {return m_jobQueue
;}
73 void setStatus(Status jobStatus
);
74 void setPolicy(Policy jobPolicy
);
76 Status
status() const {return m_status
;}
77 Policy
policy() const {return m_policy
;}
79 virtual int elapsedTime() const =0;
80 virtual int remainingTime() const =0;
83 virtual bool isResumable() const =0;
86 Scheduler
* scheduler() const {return m_scheduler
;}
88 void read(QDomNode
* n
);
89 void write(QDomNode
* n
);
92 * This one posts a job event to the scheduler
94 void postJobEvent(Status
); //do we need a JobEvent instead of JobStatus?
96 JobQueue
* m_jobQueue
;
97 Scheduler
* m_scheduler
;