36#include <QtCore/QHash>
37#include <QtGui/QWidget>
38#include <QtDBus/QtDBus>
66 const QStringList &proxyList,
bool newSlave,
const KIO::MetaData *config = 0);
74 Q_ASSERT(newPriority >= -10 && newPriority <= 10);
75 newPriority = qBound(-10, newPriority, 10);
76 int unbiasedSerial = oldSerial % m_jobsPerPriority;
77 return unbiasedSerial + newPriority * m_jobsPerPriority;
83 m_grimTimer.setSingleShot(
true);
84 connect (&m_grimTimer, SIGNAL(
timeout()), SLOT(grimReaper()));
91 m_idleSlaves.insert(slave->
host(), slave);
104 QMultiHash<QString, Slave *>::Iterator it = m_idleSlaves.find(url.host());
105 if (it == m_idleSlaves.end()) {
106 it = m_idleSlaves.begin();
108 if (it == m_idleSlaves.end()) {
112 m_idleSlaves.erase(it);
119 QMultiHash<QString, Slave *>::Iterator it = m_idleSlaves.begin();
120 for (; it != m_idleSlaves.end(); ++it) {
121 if (it.value() == slave) {
122 m_idleSlaves.erase(it);
131 return m_idleSlaves.values();
134void SlaveKeeper::scheduleGrimReaper()
136 if (!m_grimTimer.isActive()) {
142void SlaveKeeper::grimReaper()
144 QMultiHash<QString, Slave *>::Iterator it = m_idleSlaves.begin();
145 while (it != m_idleSlaves.end()) {
146 Slave *slave = it.value();
148 it = m_idleSlaves.erase(it);
150 kDebug (7006) <<
"Idle slave" << slave <<
"still has job" << slave->
job();
159 if (!m_idleSlaves.isEmpty()) {
160 scheduleGrimReaper();
168 if (first != m_queuedJobs.constEnd()) {
177 Q_ASSERT(serial != 0);
178 Q_ASSERT(!m_queuedJobs.contains(serial));
179 Q_ASSERT(!m_runningJobs.contains(job));
180 m_queuedJobs.insert(serial, job);
185 Q_ASSERT(!m_queuedJobs.isEmpty());
188 m_queuedJobs.erase(first);
189 m_runningJobs.insert(job);
196 if (m_runningJobs.remove(job)) {
197 Q_ASSERT(!m_queuedJobs.contains(serial));
200 if (m_queuedJobs.remove(serial)) {
209 Q_FOREACH (
SimpleJob *job, m_runningJobs) {
221 m_startJobsTimer.setSingleShot(
true);
222 connect (&m_startJobsTimer, SIGNAL(
timeout()), SLOT(startRunnableJobs()));
228 if (it == m_connectedSlaves.end()) {
237 m_runnableSlaves.insert(slave);
238 m_startJobsTimer.start();
248 if (it == m_connectedSlaves.end()) {
255 Q_ASSERT(!m_runnableSlaves.contains(slave));
258 const bool removedRunning = jobs.
runningJob == job;
259 const bool removedWaiting = jobs.
waitingList.removeAll(job) != 0;
260 if (removedRunning) {
262 Q_ASSERT(!removedWaiting);
264 const bool removedTheJob = removedRunning || removedWaiting;
268 return removedTheJob;
272 m_runnableSlaves.insert(slave);
273 m_startJobsTimer.start();
275 if (removedWaiting && jobs.
waitingList.isEmpty()) {
276 m_runnableSlaves.remove(slave);
278 return removedTheJob;
284 if (!m_connectedSlaves.contains(slave)) {
292 if (it == m_connectedSlaves.end()) {
303 m_connectedSlaves.erase(it);
304 m_runnableSlaves.remove(slave);
314 if (it == m_connectedSlaves.end()) {
317 return it.value().runningJob == 0;
322void ConnectedSlaveQueue::startRunnableJobs()
325 while (it != m_runnableSlaves.end()) {
329 m_startJobsTimer.start();
333 it = m_runnableSlaves.erase(it);
341 const int port = url.port() == -1 ? 0 : url.port();
343 if (slave->
host() ==
"<reset>") {
351 Q_ASSERT(slave->
host() == url.host());
352 Q_ASSERT(slave->
port() == port);
360 Q_UNUSED(queuesBySerial);
361#ifdef SCHEDULER_DEBUG
364 Q_FOREACH (
HostQueue *hq, *queuesBySerial) {
365 Q_ASSERT(!seen.contains(hq));
374 Q_UNUSED(runningJobsCount);
375#ifdef SCHEDULER_DEBUG
376 int realRunningJobsCount = 0;
377 Q_FOREACH (
const HostQueue &hq, *queues) {
380 Q_ASSERT(realRunningJobsCount == runningJobsCount);
384 Q_FOREACH (
const HostQueue &hq, *queues) {
385 Q_FOREACH (
SimpleJob *job, hq.runningJobs()) {
386 Q_ASSERT(!seenJobs.contains(job));
387 seenJobs.insert(job);
395 : m_schedPrivate(sp),
396 m_maxConnectionsPerHost(maxSlavesPerHost ? maxSlavesPerHost : maxSlaves),
397 m_maxConnectionsTotal(qMax(maxSlaves, maxSlavesPerHost)),
398 m_runningJobsCount(0)
401 kDebug(7006) <<
"m_maxConnectionsTotal:" << m_maxConnectionsTotal
402 <<
"m_maxConnectionsPerHost:" << m_maxConnectionsPerHost;
403 Q_ASSERT(m_maxConnectionsPerHost >= 1);
404 Q_ASSERT(maxSlaves >= maxSlavesPerHost);
405 m_startJobTimer.setSingleShot(
true);
406 connect (&m_startJobTimer, SIGNAL(
timeout()), SLOT(startAJob()));
421 HostQueue &hq = m_queuesByHostname[hostname];
437 if (m_queuesBySerial.remove(prevLowestSerial) == 0) {
438 Q_UNUSED(wasQueueEmpty);
439 Q_ASSERT(wasQueueEmpty);
443#ifdef SCHEDULER_DEBUG
447 Q_ASSERT(!m_queuesBySerial.contains(prevLowestSerial));
452 m_startJobTimer.start();
461 if (it == m_queuesByHostname.end()) {
471 const bool needReinsert = hq.
lowestSerial() != prevLowestSerial;
474 if (needReinsert && m_queuesBySerial.remove(prevLowestSerial)) {
494 if (m_queuesBySerial.remove(prevLowestSerial) == 0) {
502 m_runningJobsCount--;
503 Q_ASSERT(m_runningJobsCount >= 0);
513 m_queuesByHostname.remove(jobPriv->
m_url.host());
520 m_startJobTimer.start();
541 scheduler()->
connect(slave, SIGNAL(slaveStatus(pid_t,QByteArray,QString,
bool)),
542 SLOT(slotSlaveStatus(pid_t,QByteArray,QString,
bool)));
544 kError() <<
"couldn't create slave:" << errortext;
555 const bool removedUnconnected = m_slaveKeeper.
removeSlave(slave);
556 Q_ASSERT(!(removedConnected && removedUnconnected));
557 return removedConnected || removedUnconnected;
563 Q_FOREACH (
const HostQueue &hq, m_queuesByHostname) {
571void ProtoQueue::startAJob()
576#ifdef SCHEDULER_DEBUG
577 kDebug(7006) <<
"m_runningJobsCount:" << m_runningJobsCount;
578 Q_FOREACH (
const HostQueue &hq, m_queuesByHostname) {
579 Q_FOREACH (
SimpleJob *job, hq.runningJobs()) {
584 if (m_runningJobsCount >= m_maxConnectionsTotal) {
585#ifdef SCHEDULER_DEBUG
586 kDebug(7006) <<
"not starting any jobs because maxConnectionsTotal has been reached.";
592 if (first != m_queuesBySerial.end()) {
595 const int prevLowestSerial = first.key();
596 Q_UNUSED(prevLowestSerial);
605 m_queuesBySerial.erase(first);
617 m_runningJobsCount++;
619 bool isNewSlave =
false;
642#ifdef SCHEDULER_DEBUG
643 kDebug(7006) <<
"not starting any jobs because there is no queued job.";
647 if (!m_queuesBySerial.isEmpty()) {
648 m_startJobTimer.start();
654class KIO::SchedulerPrivate
661 m_ignoreConfigReparse(false)
678 Slave *m_slaveOnHold;
681 bool m_ignoreConfigReparse;
687#ifndef KDE_NO_DEPRECATED
690 void setJobPriority(
SimpleJob *job,
int priority);
694 void removeSlaveOnHold();
698 void checkSlaveOnHold(
bool b);
699 void publishSlaveOnHold();
701 bool isSlaveOnHoldFor(
const KUrl& url);
702 void registerWindow(
QWidget *wid);
703 void updateInternalMetaData(
SimpleJob* job);
705 MetaData metaDataFor(
const QString &protocol,
const QStringList &proxyList,
const KUrl &url);
707 const QStringList &proxyList,
bool newSlave,
const KIO::MetaData *config = 0);
710 void slotSlaveStatus(pid_t pid,
const QByteArray &protocol,
711 const QString &host,
bool connected);
713 void slotReparseSlaveConfiguration(
const QString &,
const QDBusMessage&);
714 void slotSlaveOnHoldListChanged();
716 void slotSlaveConnected();
717 void slotSlaveError(
int error,
const QString &errorMsg);
718 void slotUnregisterWindow(
QObject *);
720 ProtoQueue *protoQ(
const QString& protocol,
const QString& host)
722 ProtoQueue *pq = m_protocols.value(protocol, 0);
724 kDebug(7006) <<
"creating ProtoQueue instance for" << protocol;
727 int maxSlavesPerHost = -1;
728 if (!host.isEmpty()) {
732 maxSlavesPerHost = value;
734 if (maxSlavesPerHost == -1) {
738 pq =
new ProtoQueue(
this, maxSlaves, qMin(maxSlaves, maxSlavesPerHost));
739 m_protocols.insert(protocol, pq);
752 return schedulerPrivate->q;
755SchedulerPrivate *Scheduler::d_func()
757 return schedulerPrivate;
763 return schedulerPrivate->q;
769 return schedulerPrivate->heldSlaveForJob(job);
773Scheduler::Scheduler()
776 setObjectName(
"scheduler" );
778 const QString dbusPath =
"/KIO/Scheduler";
779 const QString dbusInterface =
"org.kde.KIO.Scheduler";
780 QDBusConnection dbus = QDBusConnection::sessionBus();
781 dbus.registerObject(
"/KIO/Scheduler",
this, QDBusConnection::ExportScriptableSlots |
782 QDBusConnection::ExportScriptableSignals );
783 dbus.connect(QString(), dbusPath, dbusInterface,
"reparseSlaveConfiguration",
784 this, SLOT(slotReparseSlaveConfiguration(QString,QDBusMessage)));
785 dbus.connect(QString(), dbusPath, dbusInterface,
"slaveOnHoldListChanged",
786 this, SLOT(slotSlaveOnHoldListChanged()));
789Scheduler::~Scheduler()
795 schedulerPrivate->doJob(job);
798#ifndef KDE_NO_DEPRECATED
801 schedulerPrivate->scheduleJob(job);
807 schedulerPrivate->setJobPriority(job, priority);
812 schedulerPrivate->cancelJob(job);
817 schedulerPrivate->jobFinished(job, slave);
822 schedulerPrivate->putSlaveOnHold(job, url);
827 schedulerPrivate->removeSlaveOnHold();
832 schedulerPrivate->publishSlaveOnHold();
837 return schedulerPrivate->isSlaveOnHoldFor(url);
842 schedulerPrivate->updateInternalMetaData(job);
848 return schedulerPrivate->getConnectedSlave(url,
config);
853 return schedulerPrivate->assignJobToSlave(slave, job);
858 return schedulerPrivate->disconnectSlave(slave);
863 schedulerPrivate->registerWindow(wid);
868 schedulerPrivate->slotUnregisterWindow(wid);
874 return QObject::connect(self(), signal, receiver, member);
878 const QObject* receiver,
const char* member )
880 return QObject::connect(sender, signal, receiver, member);
884 const QObject* receiver,
const char* member )
886 return QObject::disconnect(sender, signal, receiver, member);
892 return QObject::connect(sender, signal, member);
897 schedulerPrivate->checkSlaveOnHold(b);
904 schedulerPrivate->slotReparseSlaveConfiguration(QString(), QDBusMessage());
906 schedulerPrivate->m_ignoreConfigReparse =
true;
911void SchedulerPrivate::slotReparseSlaveConfiguration(
const QString &proto,
const QDBusMessage&)
913 if (m_ignoreConfigReparse) {
914 kDebug(7006) <<
"Ignoring signal sent by myself";
915 m_ignoreConfigReparse =
false;
919 kDebug(7006) <<
"proto=" << proto;
926 m_protocols.constFind(proto);
928 if (it == m_protocols.constEnd()) {
933 for (; it != endIt; ++it) {
934 Q_FOREACH(
Slave *slave, (*it)->allSlaves()) {
941void SchedulerPrivate::slotSlaveOnHoldListChanged()
943 m_checkOnHold =
true;
954 if (cmd ==
CMD_SPECIAL && protocol.startsWith(QLatin1String(
"http"), Qt::CaseInsensitive))
960void SchedulerPrivate::doJob(
SimpleJob *job)
963 if (QThread::currentThread() != QCoreApplication::instance()->thread()) {
964 kWarning(7006) <<
"KIO is not thread-safe.";
973 m_checkOnHold =
false;
980#ifndef KDE_NO_DEPRECATED
981void SchedulerPrivate::scheduleJob(
SimpleJob *job)
984 setJobPriority(job, 1);
988void SchedulerPrivate::setJobPriority(
SimpleJob *job,
int priority)
990 kDebug(7006) << job << priority;
995void SchedulerPrivate::cancelJob(
SimpleJob *job)
1004 kDebug(7006) << job << slave;
1009 jobFinished(job, slave);
1014 kDebug(7006) << job << slave;
1015 if (QThread::currentThread() != QCoreApplication::instance()->thread()) {
1016 kWarning(7006) <<
"KIO is not thread-safe.";
1033 kDebug(7006) <<
"Updating ioslaves with new internal metadata information";
1036 QListIterator<Slave*> it (queue->
allSlaves());
1037 while (it.hasNext()) {
1038 Slave* runningSlave = it.next();
1039 if (slave->
host() == runningSlave->
host()) {
1042 <<
"ioslave, pid=" << slave->
slave_pid();
1048 slave->disconnect(job);
1059 const QStringList &proxyList ,
bool newSlave,
const KIO::MetaData *config)
1061 schedulerPrivate->setupSlave(slave, url, protocol, proxyList, newSlave,
config);
1064MetaData SchedulerPrivate::metaDataFor(
const QString &protocol,
const QStringList &proxyList,
const KUrl &url)
1066 const QString host = url.host();
1069 if (proxyList.isEmpty()) {
1070 configData.remove(QLatin1String(
"UseProxy"));
1071 configData.remove(QLatin1String(
"ProxyUrls"));
1073 configData[QLatin1String(
"UseProxy")] = proxyList.first();
1074 configData[QLatin1String(
"ProxyUrls")] = proxyList.join(QLatin1String(
","));
1077 if ( configData.contains(
"EnableAutoLogin") &&
1078 configData.value(
"EnableAutoLogin").compare(
"true", Qt::CaseInsensitive) == 0 )
1082 bool usern = (protocol ==
"ftp");
1085 configData[
"autoLoginUser"] = l.
login;
1086 configData[
"autoLoginPass"] = l.
password;
1091 for ( ; it != l.
macdef.constEnd(); ++it )
1092 macdef += it.key() +
'\\' + it.value().join(
"\\" ) +
'\n';
1093 configData[
"autoLoginMacro"] = macdef;
1101void SchedulerPrivate::setupSlave(
KIO::Slave *slave,
const KUrl &url,
const QString &protocol,
1102 const QStringList &proxyList,
bool newSlave,
const KIO::MetaData *config)
1104 int port = url.port();
1107 const QString host = url.host();
1108 const QString user = url.
user();
1109 const QString passwd = url.
pass();
1111 if (newSlave || slave->
host() != host || slave->
port() != port ||
1112 slave->
user() != user || slave->
passwd() != passwd) {
1114 MetaData configData = metaDataFor(protocol, proxyList, url);
1120 slave->
setHost(host, port, user, passwd);
1125void SchedulerPrivate::slotSlaveStatus(pid_t,
const QByteArray&,
const QString &,
bool)
1130void SchedulerPrivate::slotSlaveDied(
KIO::Slave *slave)
1143 if (slave == m_slaveOnHold) {
1145 m_urlOnHold.clear();
1153 kDebug(7006) << job << url << slave;
1154 slave->disconnect(job);
1160 if (m_slaveOnHold) {
1161 m_slaveOnHold->
kill();
1163 m_slaveOnHold = slave;
1168void SchedulerPrivate::publishSlaveOnHold()
1170 kDebug(7006) << m_slaveOnHold;
1174 m_slaveOnHold->
hold(m_urlOnHold);
1178bool SchedulerPrivate::isSlaveOnHoldFor(
const KUrl& url)
1180 if (url.isValid() && m_urlOnHold.isValid() && url == m_urlOnHold)
1195 if (!slave && m_slaveOnHold) {
1201 canJobReuse = ( canJobReuse || cmd ==
CMD_SPECIAL );
1204 const QString resume = outgoing.value(
"resume");
1205 kDebug(7006) <<
"Resume metadata is" << resume;
1206 canJobReuse = (resume.isEmpty() || resume ==
"0");
1210 if (job->
url() == m_urlOnHold) {
1212 kDebug(7006) <<
"HOLD: Reusing held slave (" << m_slaveOnHold <<
")";
1213 slave = m_slaveOnHold;
1215 kDebug(7006) <<
"HOLD: Discarding held slave (" << m_slaveOnHold <<
")";
1216 m_slaveOnHold->
kill();
1219 m_urlOnHold.clear();
1222 kDebug(7006) <<
"HOLD: Reusing klauncher held slave (" << slave <<
")";
1228void SchedulerPrivate::removeSlaveOnHold()
1230 kDebug(7006) << m_slaveOnHold;
1231 if (m_slaveOnHold) {
1232 m_slaveOnHold->
kill();
1235 m_urlOnHold.clear();
1240 QStringList proxyList;
1242 ProtoQueue *pq = protoQ(protocol, url.host());
1246 setupSlave(slave, url, protocol, proxyList,
true, &config);
1250 q->
connect(slave, SIGNAL(connected()),
1251 SLOT(slotSlaveConnected()));
1252 q->
connect(slave, SIGNAL(error(
int,QString)),
1253 SLOT(slotSlaveError(
int,QString)));
1255 kDebug(7006) << url << slave;
1260void SchedulerPrivate::slotSlaveConnected()
1263 Slave *slave =
static_cast<Slave *
>(q->sender());
1265 q->
disconnect(slave, SIGNAL(connected()), q, SLOT(slotSlaveConnected()));
1269void SchedulerPrivate::slotSlaveError(
int errorNr,
const QString &errorMsg)
1271 Slave *slave =
static_cast<Slave *
>(q->sender());
1272 kDebug(7006) << slave << errorNr << errorMsg;
1277 emit q->
slaveError(slave, errorNr, errorMsg);
1283 kDebug(7006) << slave << job;
1293bool SchedulerPrivate::disconnectSlave(
KIO::Slave *slave)
1300void SchedulerPrivate::checkSlaveOnHold(
bool b)
1322 while (w && w->parentWidget()) {
1323 w = w->parentWidget();
1325 return (w ? w->window() : 0);
1328void SchedulerPrivate::registerWindow(
QWidget *wid)
1336 if (!m_windowList.contains(obj))
1341 WId windowId = window->winId();
1342 m_windowList.insert(obj, windowId);
1344 SLOT(slotUnregisterWindow(
QObject*)));
1345 QDBusInterface(
"org.kde.kded",
"/kded",
"org.kde.kded").
1346 call(QDBus::NoBlock,
"registerWindowId", qlonglong(windowId));
1350void SchedulerPrivate::slotUnregisterWindow(
QObject *obj)
1356 if (it == m_windowList.end())
1358 WId windowId = it.value();
1360 q, SLOT(slotUnregisterWindow(
QObject*)));
1361 m_windowList.erase( it );
1362 QDBusInterface(
"org.kde.kded",
"/kded",
"org.kde.kded").
1363 call(QDBus::NoBlock,
"unregisterWindowId", qlonglong(windowId));
1366void SchedulerPrivate::updateInternalMetaData(
SimpleJob* job)
1371 const KUrl jobUrl = job->
url();
1374 while (it.hasNext()) {
1376 if (it.key().startsWith(QLatin1String(
"{internal~currenthost}"), Qt::CaseInsensitive)) {
1378 }
else if (it.key().startsWith(QLatin1String(
"{internal~allhosts}"), Qt::CaseInsensitive)) {
1385#include "scheduler.moc"
1386#include "scheduler_p.moc"
bool removeSlave(KIO::Slave *slave)
void addSlave(KIO::Slave *slave)
QList< KIO::Slave * > allSlaves() const
bool queueJob(KIO::SimpleJob *job, KIO::Slave *slave)
bool removeJob(KIO::SimpleJob *job)
bool isIdle(KIO::Slave *slave)
int runningJobsCount() const
bool removeJob(KIO::SimpleJob *job)
bool isJobRunning(KIO::SimpleJob *job) const
bool isQueueEmpty() const
void queueJob(KIO::SimpleJob *job)
KIO::SimpleJob * takeFirstInQueue()
QList< KIO::Slave * > allSlaves() const
MetaData m_internalMetaData
bool lookup(const KUrl &url, AutoLogin &login, bool userealnetrc=false, const QString &type=QString(), LookUpMode mode=LookUpMode(exactOnly)|defaultOnly)
Looks up the login information for the given url.
static NetRC * self()
A reference to the instance of the class.
void reload()
Reloads the auto login information.
void changeJobPriority(KIO::SimpleJob *job, int newPriority)
bool removeSlave(KIO::Slave *slave)
ProtoQueue(KIO::SchedulerPrivate *sp, int maxSlaves, int maxSlavesPerHost)
QList< KIO::Slave * > allSlaves() const
void queueJob(KIO::SimpleJob *job)
ConnectedSlaveQueue m_connectedSlaveQueue
void removeJob(KIO::SimpleJob *job)
KIO::Slave * createSlave(const QString &protocol, KIO::SimpleJob *job, const KUrl &url)
The KIO::Scheduler manages io-slaves for the application.
static void putSlaveOnHold(KIO::SimpleJob *job, const KUrl &url)
Puts a slave on notice.
static KIO::Slave * getConnectedSlave(const KUrl &url, const KIO::MetaData &config=MetaData())
Requests a slave for use in connection-oriented mode.
static void setJobPriority(SimpleJob *job, int priority)
Changes the priority of job; jobs of the same priority run in the order in which they were created.
static void scheduleJob(SimpleJob *job)
Schedules job scheduled for later execution.
Q_SCRIPTABLE void slaveOnHoldListChanged()
static bool isSlaveOnHoldFor(const KUrl &url)
Returns true if there is a slave on hold for url.
static void removeSlaveOnHold()
Removes any slave that might have been put on hold.
void slaveConnected(KIO::Slave *slave)
static bool assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job)
Uses slave to do job.
void slaveError(KIO::Slave *slave, int error, const QString &errorMsg)
static void doJob(SimpleJob *job)
Register job with the scheduler.
static void emitReparseSlaveConfiguration()
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static void jobFinished(KIO::SimpleJob *job, KIO::Slave *slave)
Called when a job is done.
static bool connect(const char *signal, const QObject *receiver, const char *member)
Function to connect signals emitted by the scheduler.
static bool disconnectSlave(KIO::Slave *slave)
Disconnects slave.
static void registerWindow(QWidget *wid)
Register the mainwindow wid with the KIO subsystem Do not call this, it is called automatically from ...
Q_SCRIPTABLE void reparseSlaveConfiguration(const QString &)
static void cancelJob(SimpleJob *job)
Stop the execution of a job.
static void publishSlaveOnHold()
Send the slave that was put on hold back to KLauncher.
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...
static void updateInternalMetaData(SimpleJob *job)
Updates the internal metadata from job.
static void unregisterWindow(QObject *wid)
int changedPrioritySerial(int oldSerial, int newPriority) const
static const int maxSerial
virtual void configDataFor(KIO::MetaData &configData, const QString &proto, const QString &host)
static SimpleJobPrivate * get(KIO::SimpleJob *job)
virtual void start(KIO::Slave *slave)
A simple job (one url and one command).
void slotError(int, const QString &)
const KUrl & url() const
Returns the SimpleJob's URL.
MetaData configData(const QString &protocol, const QString &host)
Query slave configuration for slaves of type protocol when dealing with host.
void setConfigData(const QString &protocol, const QString &host, const QString &key, const QString &value)
Configure slaves of type protocol by setting key to value.
static SlaveConfig * self()
void reset()
Undo any changes made by calls to setConfigData.
void returnSlave(KIO::Slave *slave)
KIO::Slave * takeSlaveForJob(KIO::SimpleJob *job)
bool removeSlave(KIO::Slave *slave)
QList< KIO::Slave * > allSlaves() const
static Slave * holdSlave(const QString &protocol, const KUrl &url)
Requests a slave on hold for ths url, from klauncher, if there is such a job.
KIO::SimpleJob * job() const
virtual void send(int cmd, const QByteArray &arr=QByteArray())
Sends the given command to the kioslave.
virtual void hold(const KUrl &url)
Puts the kioslave associated with url at halt, and return it to klauncher, in order to let another ap...
virtual void setHost(const QString &host, quint16 port, const QString &user, const QString &passwd)
Set host for url.
void setJob(KIO::SimpleJob *job)
virtual void suspend()
Suspends the operation of the attached kioslave.
static bool checkForHeldSlave(const KUrl &url)
Returns true if klauncher is holding a slave for url.
static Slave * createSlave(const QString &protocol, const KUrl &url, int &error, QString &error_text)
Creates a new slave.
void kill()
Force termination.
void setConnected(bool c)
QString protocol()
The protocol this slave handles.
void setIdle()
Marks this slave as idle.
void setProtocol(const QString &protocol)
void resetHost()
Clear host info.
virtual void setConfig(const MetaData &config)
Configure slave.
The transfer job pumps data into and/or out of a Slave.
bool kill(KillVerbosity verbosity=Quietly)
static int maxSlavesPerHost(const QString &protocol)
static int maxSlaves(const QString &protocol)
static QString slaveProtocol(const KUrl &url, QString &proxy)
Return the protocol to use in order to handle the given url It's usually the same,...
static void reparseConfiguration()
Force a reload of the general config file of io-slaves ( kioslaverc).
#define K_GLOBAL_STATIC(TYPE, NAME)
static Slave * jobSlave(SimpleJob *job)
KSharedConfigPtr config()
A namespace for KIO globals.
@ CMD_REPARSECONFIGURATION
static bool mayReturnContent(int cmd, const QString &protocol)
static Slave * jobSlave(SimpleJob *job)
static QWidget * topLevelWindow(QWidget *widget)
static void verifyRunningJobsCount(QHash< QString, HostQueue > *queues, int runningJobsCount)
static Scheduler * scheduler()
static int jobCommand(SimpleJob *job)
static void ensureNoDuplicates(QMap< int, HostQueue * > *queuesBySerial)
static void startJob(SimpleJob *job, Slave *slave)
static Slave * heldSlaveForJob(SimpleJob *job)
static const int s_idleSlaveLifetime
static void setupSlave(KIO::Slave *slave, const KUrl &url, const QString &protocol, const QStringList &proxyList, bool newSlave, const KIO::MetaData *config=0)
Contains auto login information.
QMap< QString, QStringList > macdef
QList< SimpleJob * > waitingList