# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | 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
    00099     class Scheduler : public QObject, virtual public DCOPObject {
    00100         Q_OBJECT
    00101
    00102     public:
    00103         typedef QPtrList<SimpleJob> JobList;
    00104
    00105         // InfoDict needs Info, so we can't declare it private
    00106         class ProtocolInfo;
    00107         class JobData;
    00108
    00109         ~Scheduler();
    00110
    00116         static void doJob(SimpleJob *job)
    00117         { self()->_doJob(job); }
    00118
    00124         static void scheduleJob(SimpleJob *job)
    00125         { self()->_scheduleJob(job); }
    00126
    00130         static void cancelJob(SimpleJob *job)
    00131         { self()->_cancelJob(job); }
    00132
    00136         static void jobFinished(KIO::SimpleJob *job, KIO::Slave *slave)
    00137         { self()->_jobFinished(job, slave); }
    00138
    00148         static void putSlaveOnHold(KIO::SimpleJob *job, const KURL &url)
    00149         { self()->_putSlaveOnHold(job, url); }
    00150
    00155         static void removeSlaveOnHold()
    00156         { self()->_removeSlaveOnHold(); }
    00157
    00163         static void publishSlaveOnHold()
    00164         { self()->_publishSlaveOnHold(); }
    00165
    00177         static KIO::Slave *getConnectedSlave(const KURL &url, const KIO::MetaData &config = MetaData() )
    00178         { return self()->_getConnectedSlave(url, config); }
    00179
    00180         /*
    00181          * Uses @p slave to do @p job.
    00182          *
    00183          * @param slave The slave to use. The slave must have been obtained
    00184          *              with a call to @ref getConnectedSlave and must not
    00185          *              be currently assigned to any other job.
    00186          * @param job The job to do.
    00187          *
    00188          * @return true is successfull, false otherwise.
    00189          *
    00190          * This function should be called immediately after creating a Job.
    00191          *
    00192          * @see getConnectedSlave
    00193          * @see disconnectSlave
    00194          * @see slaveConnected
    00195          * @see slaveError
    00196          */
    00197         static bool assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job)
    00198         { return self()->_assignJobToSlave(slave, job); }
    00199
    00200         /*
    00201          * Disconnects @p slave.
    00202          *
    00203          * @param slave The slave to disconnect. The slave must have been
    00204          *              obtained with a call to @ref getConnectedSlave
    00205          *              and must not be assigned to any job.
    00206          *
    00207          * @return true is successfull, false otherwise.
    00208          *
    00209          * @see getConnectedSlave
    00210          * @see assignJobToSlave
    00211          */
    00212         static bool disconnectSlave(KIO::Slave *slave)
    00213         { return self()->_disconnectSlave(slave); }
    00214
    00221         static void registerWindow(QWidget *wid)
    00222         { self()->_registerWindow(wid); }
    00223
    00231         static bool connect( const char *signal, const QObject *receiver,
    00232                              const char *member)
    00233         { return QObject::connect(self(), signal, receiver, member); }
    00234
    00235         static bool connect( const QObject* sender, const char* signal,
    00236                              const QObject* receiver, const char* member )
    00237         { return QObject::connect(sender, signal, receiver, member); }
    00238
    00239         static bool disconnect( const QObject* sender, const char* signal,
    00240                                 const QObject* receiver, const char* member )
    00241         { return QObject::disconnect(sender, signal, receiver, member); }
    00242
    00243         bool connect( const QObject *sender, const char *signal,
    00244                       const char *member )
    00245         { return QObject::connect(sender, signal, member); }
    00246
    00251         static void checkSlaveOnHold(bool b) { self()->_checkSlaveOnHold(b); }
    00252
    00253         void debug_info();
    00254
    00255         virtual bool process(const QCString &fun, const QByteArray &data,
    00256                              QCString& replyType, QByteArray &replyData);
    00257
    00258         virtual QCStringList functions();
    00259
    00260     public slots:
    00261         void slotSlaveDied(KIO::Slave *slave);
    00262         void slotSlaveStatus(pid_t pid, const QCString &protocol,
    00263                              const QString &host, bool connected);
    00264     signals:
    00265         void slaveConnected(KIO::Slave *slave);
    00266         void slaveError(KIO::Slave *slave, int error, const QString &errorMsg);
    00267
    00268     protected:
    00269         void setupSlave(KIO::Slave *slave, const KURL &url, const QString &protocol, const QString &proxy , bool newSlave, const KIO::MetaData *config=0);
    00270         bool startJobScheduled(ProtocolInfo *protInfo);
    00271         bool startJobDirect();
    00272         Scheduler();
    00273
    00274     protected slots:
    00275         void startStep();
    00276         void slotCleanIdleSlaves();
    00277         void slotSlaveConnected();
    00278         void slotSlaveError(int error, const QString &errorMsg);
    00279         void slotScheduleCoSlave();
    00281         void slotUnregisterWindow(QObject *);
    00282
    00283     private:
    00284         class ProtocolInfoDict;
    00285         class ExtraJobData;
    00286
    00287         Scheduler(const Scheduler&);
    00288         static Scheduler *self();
    00289         static Scheduler *instance;
    00290         void _doJob(SimpleJob *job);
    00291         void _scheduleJob(SimpleJob *job);
    00292         void _cancelJob(SimpleJob *job);
    00293         void _jobFinished(KIO::SimpleJob *job, KIO::Slave *slave);
    00294         void _scheduleCleanup();
    00295         void _putSlaveOnHold(KIO::SimpleJob *job, const KURL &url);
    00296         void _removeSlaveOnHold();
    00297         Slave *_getConnectedSlave(const KURL &url, const KIO::MetaData &metaData );
    00298         bool _assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job);
    00299         bool _disconnectSlave(KIO::Slave *slave);
    00300         void _checkSlaveOnHold(bool b);
    00301         void _publishSlaveOnHold();
    00302         void _registerWindow(QWidget *wid);
    00303
    00304         Slave *findIdleSlave(ProtocolInfo *protInfo, SimpleJob *job, bool &exact);
    00305         Slave *createSlave(ProtocolInfo *protInfo, SimpleJob *job, const KURL &url);
    00306
    00307
    00308         QTimer slaveTimer;
    00309         QTimer coSlaveTimer;
    00310         QTimer cleanupTimer;
    00311         bool busy;
    00312
    00313         SlaveList *slaveList;
    00314         SlaveList *idleSlaves;
    00315         SlaveList *coIdleSlaves;
    00316
    00317         ProtocolInfoDict *protInfoDict;
    00318         Slave *slaveOnHold;
    00319         KURL urlOnHold;
    00320         JobList newJobs;
    00321
    00322         QPtrDict<JobList> coSlaves;
    00323         ExtraJobData *extraJobData;
    00324         SlaveConfig *slaveConfig;
    00325         SessionData *sessionData;
    00326         bool checkOnHold;
    00327         QMap<QObject *,long> m_windowList;
    00328     protected:
    00329         virtual void virtual_hook( int id, void* data );
    00330     private:
    00331         class SchedulerPrivate* d;
    00332 };
    00333
    00334 }
    00335 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:14:38 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001