• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kio
 

kio/kio

  • kio
  • kio
scheduler.h
1 // -*- c++ -*-
2 /* This file is part of the KDE libraries
3  Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
4  Waldo Bastian <bastian@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef _kio_scheduler_h
23 #define _kio_scheduler_h
24 
25 #include "kio/job.h"
26 #include "kio/jobclasses.h"
27 #include <tqtimer.h>
28 #include <tqptrdict.h>
29 #include <tqmap.h>
30 
31 #include <dcopobject.h>
32 
33 namespace KIO {
34 
35  class Slave;
36  class SlaveList;
37  class SlaveConfig;
38  class SessionData;
39 
111  class KIO_EXPORT Scheduler : public TQObject, virtual public DCOPObject {
112  Q_OBJECT
113 
114  public:
115  typedef TQPtrList<SimpleJob> JobList;
116 
117  // InfoDict needs Info, so we can't declare it private
118  class ProtocolInfo;
119  class JobData;
120 
121  ~Scheduler();
122 
129  static void doJob(SimpleJob *job)
130  { self()->_doJob(job); }
131 
138  static void scheduleJob(SimpleJob *job)
139  { self()->_scheduleJob(job); }
140 
145  static void cancelJob(SimpleJob *job)
146  { self()->_cancelJob(job); }
147 
153  static void jobFinished(KIO::SimpleJob *job, KIO::Slave *slave)
154  { self()->_jobFinished(job, slave); }
155 
167  static void putSlaveOnHold(KIO::SimpleJob *job, const KURL &url)
168  { self()->_putSlaveOnHold(job, url); }
169 
174  static void removeSlaveOnHold()
175  { self()->_removeSlaveOnHold(); }
176 
182  static void publishSlaveOnHold()
183  { self()->_publishSlaveOnHold(); }
184 
196  static KIO::Slave *getConnectedSlave(const KURL &url, const KIO::MetaData &config = MetaData() )
197  { return self()->_getConnectedSlave(url, config); }
198 
199  /*
200  * Uses @p slave to do @p job.
201  * This function should be called immediately after creating a Job.
202  *
203  * @param slave The slave to use. The slave must have been obtained
204  * with a call to getConnectedSlave and must not
205  * be currently assigned to any other job.
206  * @param job The job to do.
207  *
208  * @return true is successful, false otherwise.
209  *
210  * @see getConnectedSlave()
211  * @see disconnectSlave()
212  * @see slaveConnected()
213  * @see slaveError()
214  */
215  static bool assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job)
216  { return self()->_assignJobToSlave(slave, job); }
217 
218  /*
219  * Disconnects @p slave.
220  *
221  * @param slave The slave to disconnect. The slave must have been
222  * obtained with a call to getConnectedSlave
223  * and must not be assigned to any job.
224  *
225  * @return true is successful, false otherwise.
226  *
227  * @see getConnectedSlave
228  * @see assignJobToSlave
229  */
230  static bool disconnectSlave(KIO::Slave *slave)
231  { return self()->_disconnectSlave(slave); }
232 
243  static void registerWindow(TQWidget *wid)
244  { self()->_registerWindow(wid); }
245 
250  static void unregisterWindow(TQObject *wid)
251  { self()->slotUnregisterWindow(wid); }
252 
259  static bool connect( const char *signal, const TQObject *receiver,
260  const char *member)
261  { return TQObject::connect(self(), signal, receiver, member); }
262 
263  static bool connect( const TQObject* sender, const char* signal,
264  const TQObject* receiver, const char* member )
265  { return TQObject::connect(sender, signal, receiver, member); }
266 
267  static bool disconnect( const TQObject* sender, const char* signal,
268  const TQObject* receiver, const char* member )
269  { return TQObject::disconnect(sender, signal, receiver, member); }
270 
271  bool connect( const TQObject *sender, const char *signal,
272  const char *member )
273  { return TQObject::connect(sender, signal, member); }
274 
280  static void checkSlaveOnHold(bool b) { self()->_checkSlaveOnHold(b); }
281 
282  void debug_info();
283 
284  virtual bool process(const TQCString &fun, const TQByteArray &data,
285  TQCString& replyType, TQByteArray &replyData);
286 
287  virtual QCStringList functions();
288 
289  public slots:
290  void slotSlaveDied(KIO::Slave *slave);
291  void slotSlaveStatus(pid_t pid, const TQCString &protocol,
292  const TQString &host, bool connected);
293  signals:
294  void slaveConnected(KIO::Slave *slave);
295  void slaveError(KIO::Slave *slave, int error, const TQString &errorMsg);
296 
297  protected:
298  void setupSlave(KIO::Slave *slave, const KURL &url, const TQString &protocol, const TQString &proxy , bool newSlave, const KIO::MetaData *config=0);
299  bool startJobScheduled(ProtocolInfo *protInfo);
300  bool startJobDirect();
301  Scheduler();
302 
303  protected slots:
304  void startStep();
305  void slotCleanIdleSlaves();
306  void slotSlaveConnected();
307  void slotSlaveError(int error, const TQString &errorMsg);
308  void slotScheduleCoSlave();
310  void slotUnregisterWindow(TQObject *);
311 
312  private:
313  class ProtocolInfoDict;
314  class ExtraJobData;
315 
316  Scheduler(const Scheduler&);
317  static Scheduler *self();
318  static Scheduler *instance;
319  void _doJob(SimpleJob *job);
320  void _scheduleJob(SimpleJob *job);
321  void _cancelJob(SimpleJob *job);
322  void _jobFinished(KIO::SimpleJob *job, KIO::Slave *slave);
323  void _scheduleCleanup();
324  void _putSlaveOnHold(KIO::SimpleJob *job, const KURL &url);
325  void _removeSlaveOnHold();
326  Slave *_getConnectedSlave(const KURL &url, const KIO::MetaData &metaData );
327  bool _assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job);
328  bool _disconnectSlave(KIO::Slave *slave);
329  void _checkSlaveOnHold(bool b);
330  void _publishSlaveOnHold();
331  void _registerWindow(TQWidget *wid);
332 
333  Slave *findIdleSlave(ProtocolInfo *protInfo, SimpleJob *job, bool &exact);
334  Slave *createSlave(ProtocolInfo *protInfo, SimpleJob *job, const KURL &url);
335 
336 
337  TQTimer slaveTimer;
338  TQTimer coSlaveTimer;
339  TQTimer cleanupTimer;
340  bool busy;
341 
342  SlaveList *slaveList;
343  SlaveList *idleSlaves;
344  SlaveList *coIdleSlaves;
345 
346  ProtocolInfoDict *protInfoDict;
347  Slave *slaveOnHold;
348  KURL urlOnHold;
349  JobList newJobs;
350 
351  TQPtrDict<JobList> coSlaves;
352  ExtraJobData *extraJobData;
353  SlaveConfig *slaveConfig;
354  SessionData *sessionData;
355  bool checkOnHold;
356  TQMap<TQObject *,WId> m_windowList;
357  protected:
358  virtual void virtual_hook( int id, void* data );
359  private:
360  class SchedulerPrivate* d;
361 };
362 
363 }
364 #endif
KIO
A namespace for KIO globals.
Definition: authinfo.h:29
KIO::Scheduler::checkSlaveOnHold
static void checkSlaveOnHold(bool b)
When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job...
Definition: scheduler.h:280
KIO::Scheduler::scheduleJob
static void scheduleJob(SimpleJob *job)
Calling ths function makes that job gets scheduled for later execution, if multiple jobs are register...
Definition: scheduler.h:138
KIO::Scheduler::connect
static bool connect(const char *signal, const TQObject *receiver, const char *member)
Function to connect signals emitted by the scheduler.
Definition: scheduler.h:259
KIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:514
KIO::Slave
Attention developers: If you change the implementation of KIO::Slave, do not use connection() or slav...
Definition: slave.h:44
KIO::Scheduler::doJob
static void doJob(SimpleJob *job)
Register job with the scheduler.
Definition: scheduler.h:129
KIO::Scheduler::getConnectedSlave
static KIO::Slave * getConnectedSlave(const KURL &url, const KIO::MetaData &config=MetaData())
Requests a slave for use in connection-oriented mode.
Definition: scheduler.h:196
KIO::Scheduler::removeSlaveOnHold
static void removeSlaveOnHold()
Removes any slave that might have been put on hold.
Definition: scheduler.h:174
KIO::Scheduler
The KIO::Scheduler manages io-slaves for the application.
Definition: scheduler.h:111
KIO::Scheduler::cancelJob
static void cancelJob(SimpleJob *job)
Stop the execution of a job.
Definition: scheduler.h:145
KIO::SlaveConfig
SlaveConfig.
Definition: slaveconfig.h:47
KIO::Scheduler::publishSlaveOnHold
static void publishSlaveOnHold()
Send the slave that was put on hold back to KLauncher.
Definition: scheduler.h:182
KIO::Scheduler::putSlaveOnHold
static void putSlaveOnHold(KIO::SimpleJob *job, const KURL &url)
Puts a slave on notice.
Definition: scheduler.h:167
KIO::Scheduler::registerWindow
static void registerWindow(TQWidget *wid)
Send the slave that was put on hold back to KLauncher.
Definition: scheduler.h:243
KIO::Scheduler::jobFinished
static void jobFinished(KIO::SimpleJob *job, KIO::Slave *slave)
Called when a job is done.
Definition: scheduler.h:153
KIO::SimpleJob
A simple job (one url and one command).
Definition: jobclasses.h:528

kio/kio

Skip menu "kio/kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kio/kio

Skip menu "kio/kio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kio by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |