Show invite menu in wlm chat window immediately
[kdenetwork.git] / kget / core / job.h
blob97e4b7bdbb68ee27a100e76ba9e15ccaffc35080
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; either
8 version 2 of the License, or (at your option) any later version.
9 */
11 #ifndef JOB_H
12 #define JOB_H
14 /**
15 * @brief Job class
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).
23 **/
25 #include "kget_export.h"
27 class QDomNode;
29 class Scheduler;
30 class JobQueue;
32 class KGET_EXPORT Job
34 public:
35 /**
36 * The status property describes the current job status
38 enum 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
48 /**
49 * The policy property describes how the scheduler should manage this job.
51 enum Policy {
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
57 /// queue status
60 Job(JobQueue * parent, Scheduler * scheduler);
61 virtual ~Job();
63 //Job commands
64 virtual void start()=0;
65 virtual void stop()=0;
67 virtual void setDelay(int seconds)=0;
68 virtual void delayTimerEvent()=0;
70 virtual void postDeleteEvent() {}
72 JobQueue * jobQueue() {return m_jobQueue;}
74 //Job properties
75 void setStatus(Status jobStatus);
76 void setPolicy(Policy jobPolicy);
78 Status status() const {return m_status;}
79 Policy policy() const {return m_policy;}
81 virtual int elapsedTime() const =0;
82 virtual int remainingTime() const =0;
84 //Job capabilities
85 virtual bool isResumable() const =0;
87 protected:
88 Scheduler * scheduler() const {return m_scheduler;}
90 void read(QDomNode * n);
91 void write(QDomNode * n);
93 /**
94 * This one posts a job event to the scheduler
96 void postJobEvent(Status); //do we need a JobEvent instead of JobStatus?
98 JobQueue * m_jobQueue;
99 Scheduler * m_scheduler;
101 private:
102 Status m_status;
103 Policy m_policy;
106 #endif