• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KIO

  • KIO
  • Scheduler
Signals | Public Member Functions | Static Public Member Functions

KIO::Scheduler Class Reference

The KIO::Scheduler manages io-slaves for the application. More...

#include <scheduler.h>

Inheritance diagram for KIO::Scheduler:
Inheritance graph
[legend]

List of all members.

Signals

Q_SCRIPTABLE void reparseSlaveConfiguration (const QString &)
void slaveConnected (KIO::Slave *slave)
void slaveError (KIO::Slave *slave, int error, const QString &errorMsg)

Public Member Functions

bool connect (const QObject *sender, const char *signal, const char *member)

Static Public Member Functions

static bool assignJobToSlave (KIO::Slave *slave, KIO::SimpleJob *job)
static void cancelJob (SimpleJob *job)
static void checkSlaveOnHold (bool b)
static bool connect (const char *signal, const QObject *receiver, const char *member)
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static bool disconnectSlave (KIO::Slave *slave)
static void doJob (SimpleJob *job)
static void emitReparseSlaveConfiguration ()
static KIO::Slave * getConnectedSlave (const KUrl &url, const KIO::MetaData &config=MetaData())
static void jobFinished (KIO::SimpleJob *job, KIO::Slave *slave)
static void publishSlaveOnHold ()
static void putSlaveOnHold (KIO::SimpleJob *job, const KUrl &url)
static void registerWindow (QWidget *wid)
static void removeSlaveOnHold ()
static void scheduleJob (SimpleJob *job)
static void setJobPriority (SimpleJob *job, int priority)
static void unregisterWindow (QObject *wid)

Detailed Description

The KIO::Scheduler manages io-slaves for the application.

It also queues jobs and assigns the job to a slave when one becomes available.

There are 3 possible ways for a job to get a slave:

1. Direct

This is the default. When you create a job the KIO::Scheduler will be notified and will find either an existing slave that is idle or it will create a new slave for the job.

Example:

    TransferJob *job = KIO::get(KUrl("http://www.kde.org"));

2. Scheduled

If you create a lot of jobs, you might want not want to have a slave for each job. If you schedule a job, a maximum number of slaves will be created. When more jobs arrive, they will be queued. When a slave is finished with a job, it will be assigned a job from the queue.

Example:

    TransferJob *job = KIO::get(KUrl("http://www.kde.org"));
    KIO::Scheduler::scheduleJob(job);

3. Connection Oriented

For some operations it is important that multiple jobs use the same connection. This can only be ensured if all these jobs use the same slave.

You can ask the scheduler to open a slave for connection oriented operations. You can then use the scheduler to assign jobs to this slave. The jobs will be queued and the slave will handle these jobs one after the other.

Example:

    Slave *slave = KIO::Scheduler::getConnectedSlave(
            KUrl("pop3://bastian:password@mail.kde.org"));
    TransferJob *job1 = KIO::get(
            KUrl("pop3://bastian:password@mail.kde.org/msg1"));
    KIO::Scheduler::assignJobToSlave(slave, job1);
    TransferJob *job2 = KIO::get(
            KUrl("pop3://bastian:password@mail.kde.org/msg2"));
    KIO::Scheduler::assignJobToSlave(slave, job2);
    TransferJob *job3 = KIO::get(
            KUrl("pop3://bastian:password@mail.kde.org/msg3"));
    KIO::Scheduler::assignJobToSlave(slave, job3);

    // ... Wait for jobs to finish...

    KIO::Scheduler::disconnectSlave(slave);

Note that you need to explicitly disconnect the slave when the connection goes down, so your error handler should contain:

    if (error == KIO::ERR_CONNECTION_BROKEN)
        KIO::Scheduler::disconnectSlave(slave);
See also:
KIO::Slave
KIO::Job

Definition at line 110 of file scheduler.h.


Member Function Documentation

bool Scheduler::assignJobToSlave ( KIO::Slave *  slave,
KIO::SimpleJob *  job 
) [static]

Uses slave to do job.

This function should be called immediately after creating a Job.

Parameters:
slaveThe slave to use. The slave must have been obtained with a call to getConnectedSlave and must not be currently assigned to any other job.
jobThe job to do.
Returns:
true is successful, false otherwise.
See also:
getConnectedSlave()
disconnectSlave()
slaveConnected()
slaveError()

Definition at line 820 of file scheduler.cpp.

void Scheduler::cancelJob ( SimpleJob *  job) [static]

Stop the execution of a job.

Parameters:
jobthe job to cancel

Definition at line 789 of file scheduler.cpp.

void Scheduler::checkSlaveOnHold ( bool  b) [static]

When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job.

Parameters:
btrue when KLauncher has a job on hold

Definition at line 864 of file scheduler.cpp.

bool Scheduler::connect ( const QObject *  sender,
const char *  signal,
const char *  member 
)

Definition at line 858 of file scheduler.cpp.

bool Scheduler::connect ( const char *  signal,
const QObject *  receiver,
const char *  member 
) [static]

Function to connect signals emitted by the scheduler.

See also:
slaveConnected()
slaveError()

Definition at line 840 of file scheduler.cpp.

bool Scheduler::connect ( const QObject *  sender,
const char *  signal,
const QObject *  receiver,
const char *  member 
) [static]

Definition at line 846 of file scheduler.cpp.

bool Scheduler::disconnect ( const QObject *  sender,
const char *  signal,
const QObject *  receiver,
const char *  member 
) [static]

Definition at line 852 of file scheduler.cpp.

bool Scheduler::disconnectSlave ( KIO::Slave *  slave) [static]

Disconnects slave.

Parameters:
slaveThe slave to disconnect. The slave must have been obtained with a call to getConnectedSlave and must not be assigned to any job.
Returns:
true is successful, false otherwise.
See also:
getConnectedSlave
assignJobToSlave

Definition at line 825 of file scheduler.cpp.

void Scheduler::doJob ( SimpleJob *  job) [static]

Register job with the scheduler.

The default is to create a new slave for the job if no slave is available. This can be changed by calling scheduleJob.

Parameters:
jobthe job to register

Definition at line 772 of file scheduler.cpp.

void Scheduler::emitReparseSlaveConfiguration ( ) [static]

Definition at line 869 of file scheduler.cpp.

KIO::Slave * Scheduler::getConnectedSlave ( const KUrl &  url,
const KIO::MetaData &  config = MetaData() 
) [static]

Requests a slave for use in connection-oriented mode.

Parameters:
urlThis defines the username,password,host & port to connect with.
configConfiguration data for the slave.
Returns:
A pointer to a connected slave or 0 if an error occurred.
See also:
assignJobToSlave()
disconnectSlave()

Definition at line 814 of file scheduler.cpp.

void Scheduler::jobFinished ( KIO::SimpleJob *  job,
KIO::Slave *  slave 
) [static]

Called when a job is done.

Parameters:
jobthe finished job
slavethe slave that executed the job

Definition at line 794 of file scheduler.cpp.

void Scheduler::publishSlaveOnHold ( ) [static]

Send the slave that was put on hold back to KLauncher.

This allows another process to take over the slave and resume the job that was started.

Definition at line 809 of file scheduler.cpp.

void Scheduler::putSlaveOnHold ( KIO::SimpleJob *  job,
const KUrl &  url 
) [static]

Puts a slave on notice.

A next job may reuse this slave if it requests the same URL.

A job can be put on hold after it has emit'ed its mimetype. Based on the mimetype, the program can give control to another component in the same process which can then resume the job by simply asking for the same URL again.

Parameters:
jobthe job that should be stopped
urlthe URL that is handled by the url

Definition at line 799 of file scheduler.cpp.

void Scheduler::registerWindow ( QWidget *  wid) [static]

Register the mainwindow wid with the KIO subsystem Do not call this, it is called automatically from void KIO::Job::setWindow(QWidget*).

Parameters:
widthe window to register

Definition at line 830 of file scheduler.cpp.

void Scheduler::removeSlaveOnHold ( ) [static]

Removes any slave that might have been put on hold.

If a slave was put on hold it will be killed.

Definition at line 804 of file scheduler.cpp.

Q_SCRIPTABLE void KIO::Scheduler::reparseSlaveConfiguration ( const QString &  ) [signal]
void Scheduler::scheduleJob ( SimpleJob *  job) [static]

Schedules job scheduled for later execution.

This just sets the job's priority to 1 now.

Parameters:
jobthe job to schedule

Definition at line 778 of file scheduler.cpp.

void Scheduler::setJobPriority ( SimpleJob *  job,
int  priority 
) [static]

Changes the priority of job; jobs of the same priority run in the order in which they were created.

Jobs of lower numeric priority always run before any waiting jobs of higher numeric priority. The range of priority is -10 to 10, the default priority of jobs is 0.

Parameters:
jobthe job to change
prioritynew priority of job, lower runs earlier

Definition at line 784 of file scheduler.cpp.

void KIO::Scheduler::slaveConnected ( KIO::Slave *  slave) [signal]
void KIO::Scheduler::slaveError ( KIO::Slave *  slave,
int  error,
const QString &  errorMsg 
) [signal]
void Scheduler::unregisterWindow ( QObject *  wid) [static]

Unregisters the window registered by registerWindow().

Definition at line 835 of file scheduler.cpp.


The documentation for this class was generated from the following files:
  • scheduler.h
  • scheduler.cpp

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal