2 KNode, the KDE newsreader
3 Copyright (c) 1999-2005 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #ifndef KNODE_SCHEDULER_H
16 #define KNODE_SCHEDULER_H
30 /** The job scheduler.
31 * This class manages three diffrent queues of all created jobs:
32 * - a queue for all NNTP jobs
33 * - a queue for all SMTP jobs
34 * - a queue for jobs that are waiting for KWallet
35 * At most two jobs (one NNTP, one SMTP job) are executed at once.
37 * @todo Add per-account queues and execute one job per account.
39 * @see KNGlobals::scheduler()
41 class Scheduler
: public QObject
{
47 /** Create a new Scheduler object
48 * @param parent The parent QObject.
50 explicit Scheduler( QObject
*parent
= 0 );
53 /** Adds a new job to the scheduler queue.
54 * @param job The new job.
56 void addJob(KNJobData
*job
);
58 QMutex
& nntpMutex() { return nntp_Mutex
; }
60 /** Cancel the selected jobs.
61 * @param type Cancel all jobs of the given type, 0 means all.
62 * @param item Cancel the job associated with this progress item.
63 * If item is 0, only the job type is evaluated.
65 void cancelJobs( int type
= 0, KPIM::ProgressItem
* item
= 0 );
68 /// the currently active NNTP job
69 KNJobData
*currentNntpJob
;
70 /// the currently active SMTP job
71 KNJobData
*currentSmtpJob
;
75 /** Indicates whether there are currently active jobs, useful to e.g. enable
81 /** Checks if there is a free slot available for a waiting job and executes
86 /** Starts the given job.
87 * @param job The job to start.
89 void startJob( KNJobData
*job
);
91 /** Update activitiy status, i.e. emit netActive signal. */
95 /** Connected to the finished() signal of all active jobs.
96 * @param job The job that has been finished.
98 void slotJobFinished( KNJobData
*job
);
100 /** Connected to the cancel signal of the progress item of each job.
101 * @param item The progress item which has been canceled.
103 void slotCancelJob( KPIM::ProgressItem
*item
);
105 void slotPasswordsChanged();
108 /// queue for NNTP jobs
109 QList
<KNJobData
*> nntpJobQueue
;
111 QList
<KNJobData
*> smtpJobs
;
112 /// jobs waiting for async wallet loading
113 QList
<KNJobData
*> mWalletQueue
;