kio Library: scheduler.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# scheduler.h

    00001 // -*- c++ -*-
    00002 /* This file is part of the KDE libraries
    00003     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
    00004                        Waldo Bastian <bastian@kde.org>
    00005
    00006     This library is free software; you can redistribute it and/or
    00007     modify it under the terms of the GNU Library General Public
    00008     License as published by the Free Software Foundation; either
    00009     version 2 of the License, or (at your option) any later version.
    00010
    00011     This library is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014     Library General Public License for more details.
    00015
    00016     You should have received a copy of the GNU Library General Public License
    00017     along with this library; see the file COPYING.LIB.  If not, write to
    00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019     Boston, MA 02111-1307, USA.
    00020 */
    00021
    00022 #ifndef _kio_scheduler_h
    00023 #define _kio_scheduler_h
    00024
    00025 #include "kio/job.h"
    00026 #include "kio/jobclasses.h"
    00027 #include <qtimer.h>
    00028 #include <qptrdict.h>
    00029 #include <qmap.h>
    00030
    00031 #include <dcopobject.h>
    00032
    00033 namespace KIO {
    00034
    00035     class Slave;
    00036     class SlaveList;
    00037     class SlaveConfig;
    00038     class SessionData;
    00039
    00111     class KIO_EXPORT Scheduler : public QObject, virtual public DCOPObject {
    00112         Q_OBJECT
    00113
    00114     public:
    00115         typedef QPtrList<SimpleJob> JobList;
    00116
    00117         // InfoDict needs Info, so we can't declare it private
    00118         class ProtocolInfo;
    00119         class JobData;
    00120
    00121         ~Scheduler();
    00122
    00129         static void doJob(SimpleJob *job)
    00130         { self()->_doJob(job); }
    00131
    00138         static void scheduleJob(SimpleJob *job)
    00139         { self()->_scheduleJob(job); }
    00140
    00145         static void cancelJob(SimpleJob *job)
    00146         { self()->_cancelJob(job); }
    00147
    00153         static void jobFinished(KIO::SimpleJob *job, KIO::Slave *slave)
    00154         { self()->_jobFinished(job, slave); }
    00155
    00167         static void putSlaveOnHold(KIO::SimpleJob *job, const KURL &url)
    00168         { self()->_putSlaveOnHold(job, url); }
    00169
    00174         static void removeSlaveOnHold()
    00175         { self()->_removeSlaveOnHold(); }
    00176
    00182         static void publishSlaveOnHold()
    00183         { self()->_publishSlaveOnHold(); }
    00184
    00196         static KIO::Slave *getConnectedSlave(const KURL &url, const KIO::MetaData &config = MetaData() )
    00197         { return self()->_getConnectedSlave(url, config); }
    00198
    00199         /*
    00200          * Uses @p slave to do @p job.
    00201          * This function should be called immediately after creating a Job.
    00202          *
    00203          * @param slave The slave to use. The slave must have been obtained
    00204          *              with a call to getConnectedSlave and must not
    00205          *              be currently assigned to any other job.
    00206          * @param job The job to do.
    00207          *
    00208          * @return true is successful, false otherwise.
    00209          *
    00210          * @see getConnectedSlave()
    00211          * @see disconnectSlave()
    00212          * @see slaveConnected()
    00213          * @see slaveError()
    00214          */
    00215         static bool assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job)
    00216         { return self()->_assignJobToSlave(slave, job); }
    00217
    00218         /*
    00219          * Disconnects @p slave.
    00220          *
    00221          * @param slave The slave to disconnect. The slave must have been
    00222          *              obtained with a call to getConnectedSlave
    00223          *              and must not be assigned to any job.
    00224          *
    00225          * @return true is successful, false otherwise.
    00226          *
    00227          * @see getConnectedSlave
    00228          * @see assignJobToSlave
    00229          */
    00230         static bool disconnectSlave(KIO::Slave *slave)
    00231         { return self()->_disconnectSlave(slave); }
    00232
    00243         static void registerWindow(QWidget *wid)
    00244         { self()->_registerWindow(wid); }
    00245
    00250         static void unregisterWindow(QObject *wid)
    00251         { self()->slotUnregisterWindow(wid); }
    00252
    00259         static bool connect( const char *signal, const QObject *receiver,
    00260                              const char *member)
    00261         { return QObject::connect(self(), signal, receiver, member); }
    00262
    00263         static bool connect( const QObject* sender, const char* signal,
    00264                              const QObject* receiver, const char* member )
    00265         { return QObject::connect(sender, signal, receiver, member); }
    00266
    00267         static bool disconnect( const QObject* sender, const char* signal,
    00268                                 const QObject* receiver, const char* member )
    00269         { return QObject::disconnect(sender, signal, receiver, member); }
    00270
    00271         bool connect( const QObject *sender, const char *signal,
    00272                       const char *member )
    00273         { return QObject::connect(sender, signal, member); }
    00274
    00280         static void checkSlaveOnHold(bool b) { self()->_checkSlaveOnHold(b); }
    00281
    00282         void debug_info();
    00283
    00284         virtual bool process(const QCString &fun, const QByteArray &data,
    00285                              QCString& replyType, QByteArray &replyData);
    00286
    00287         virtual QCStringList functions();
    00288
    00289     public slots:
    00290         void slotSlaveDied(KIO::Slave *slave);
    00291         void slotSlaveStatus(pid_t pid, const QCString &protocol,
    00292                              const QString &host, bool connected);
    00293     signals:
    00294         void slaveConnected(KIO::Slave *slave);
    00295         void slaveError(KIO::Slave *slave, int error, const QString &errorMsg);
    00296
    00297     protected:
    00298         void setupSlave(KIO::Slave *slave, const KURL &url, const QString &protocol, const QString &proxy , bool newSlave, const KIO::MetaData *config=0);
    00299         bool startJobScheduled(ProtocolInfo *protInfo);
    00300         bool startJobDirect();
    00301         Scheduler();
    00302
    00303     protected slots:
    00304         void startStep();
    00305         void slotCleanIdleSlaves();
    00306         void slotSlaveConnected();
    00307         void slotSlaveError(int error, const QString &errorMsg);
    00308         void slotScheduleCoSlave();
    00310         void slotUnregisterWindow(QObject *);
    00311
    00312     private:
    00313         class ProtocolInfoDict;
    00314         class ExtraJobData;
    00315
    00316         Scheduler(const Scheduler&);
    00317         static Scheduler *self();
    00318         static Scheduler *instance;
    00319         void _doJob(SimpleJob *job);
    00320         void _scheduleJob(SimpleJob *job);
    00321         void _cancelJob(SimpleJob *job);
    00322         void _jobFinished(KIO::SimpleJob *job, KIO::Slave *slave);
    00323         void _scheduleCleanup();
    00324         void _putSlaveOnHold(KIO::SimpleJob *job, const KURL &url);
    00325         void _removeSlaveOnHold();
    00326         Slave *_getConnectedSlave(const KURL &url, const KIO::MetaData &metaData );
    00327         bool _assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job);
    00328         bool _disconnectSlave(KIO::Slave *slave);
    00329         void _checkSlaveOnHold(bool b);
    00330         void _publishSlaveOnHold();
    00331         void _registerWindow(QWidget *wid);
    00332
    00333         Slave *findIdleSlave(ProtocolInfo *protInfo, SimpleJob *job, bool &exact);
    00334         Slave *createSlave(ProtocolInfo *protInfo, SimpleJob *job, const KURL &url);
    00335
    00336
    00337         QTimer slaveTimer;
    00338         QTimer coSlaveTimer;
    00339         QTimer cleanupTimer;
    00340         bool busy;
    00341
    00342         SlaveList *slaveList;
    00343         SlaveList *idleSlaves;
    00344         SlaveList *coIdleSlaves;
    00345
    00346         ProtocolInfoDict *protInfoDict;
    00347         Slave *slaveOnHold;
    00348         KURL urlOnHold;
    00349         JobList newJobs;
    00350
    00351         QPtrDict<JobList> coSlaves;
    00352         ExtraJobData *extraJobData;
    00353         SlaveConfig *slaveConfig;
    00354         SessionData *sessionData;
    00355         bool checkOnHold;
    00356         QMap<QObject *,WId> m_windowList;
    00357     protected:
    00358     virtual void virtual_hook( int id, void* data );
    00359     private:
    00360     class SchedulerPrivate* d;
    00361 };
    00362
    00363 }
    00364 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:07 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003