diff --git a/src/core/batchrenamejob.cpp b/src/core/batchrenamejob.cpp --- a/src/core/batchrenamejob.cpp +++ b/src/core/batchrenamejob.cpp @@ -113,6 +113,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Rename; + } return job; } @@ -175,6 +179,7 @@ m_newUrl.setPath(m_newUrl.path() + KIO::encodeFileName(newName)); KIO::Job * job = KIO::moveAs(oldUrl, m_newUrl, KIO::HideProgressInfo); + job->setParentJob(q); q->addSubjob(job); q->setProcessedAmount(KJob::Files, q->processedAmount(KJob::Files) + 1); } else { diff --git a/src/core/chmodjob.cpp b/src/core/chmodjob.cpp --- a/src/core/chmodjob.cpp +++ b/src/core/chmodjob.cpp @@ -88,6 +88,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = ChangeAttr; + } return job; } }; @@ -232,6 +236,7 @@ /*qDebug() << "chmod'ing" << info.url << "to" << QString::number(info.permissions,8);*/ KIO::SimpleJob *job = KIO::chmod(info.url, info.permissions); + job->setParentJob(q); // copy the metadata for acl and default acl const QString aclString = q->queryMetaData(QStringLiteral("ACL_STRING")); const QString defaultAclString = q->queryMetaData(QStringLiteral("DEFAULT_ACL_STRING")); diff --git a/src/core/copyjob.cpp b/src/core/copyjob.cpp --- a/src/core/copyjob.cpp +++ b/src/core/copyjob.cpp @@ -274,6 +274,22 @@ job->d_func()->m_bOverwriteAllDirs = true; job->d_func()->m_bOverwriteAllFiles = true; } + if (!(flags & KIO::NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + FileOperationType copyType; + switch (mode) { + case CopyJob::Copy: + copyType = Copy; + break; + case CopyJob::Move: + copyType = Move; + break; + case CopyJob::Link: + copyType = Symlink; + break; + } + job->d_func()->m_operationType = copyType; + } return job; } }; @@ -919,6 +935,7 @@ KIO_ARGS << m_currentSrcURL << dest << (qint8) false /*no overwrite*/; SimpleJob *newJob = SimpleJobPrivate::newJobNoUi(slave_url, CMD_RENAME, packedArgs); + newJob->setParentJob(q); Scheduler::setJobPriority(newJob, 1); q->addSubjob(newJob); if (m_currentSrcURL.adjusted(QUrl::RemoveFilename) != dest.adjusted(QUrl::RemoveFilename)) { // For the user, moving isn't renaming. Only renaming is. @@ -1222,6 +1239,7 @@ // Create the directory - with default permissions so that we can put files into it // TODO : change permissions once all is finished; but for stuff coming from CDROM it sucks... KIO::SimpleJob *newjob = KIO::mkdir(udir, -1); + newjob->setParentJob(q); Scheduler::setJobPriority(newjob, 1); if (shouldOverwriteFile(udir.path())) { // if we are overwriting an existing file or symlink newjob->addMetaData(QStringLiteral("overwrite"), QStringLiteral("true")); @@ -1324,6 +1342,7 @@ // The only problem with this trick is that the error handling for this del operation // is not going to be right... see 'Very special case' above. KIO::Job *newjob = KIO::del((*it).uSource, HideProgressInfo); + newjob->setParentJob(q); q->addSubjob(newjob); return; // Don't move to next file yet ! } @@ -1500,6 +1519,7 @@ (uSource.password() == uDest.password())) { // This is the case of creating a real symlink KIO::SimpleJob *newJob = KIO::symlink(uSource.path(), uDest, flags | HideProgressInfo /*no GUI*/); + newJob->setParentJob(q_func()); Scheduler::setJobPriority(newJob, 1); qCDebug(KIO_COPYJOB_DEBUG) << "Linking target=" << uSource.path() << "link=" << uDest; //emit linking( this, uSource.path(), uDest ); @@ -1627,6 +1647,7 @@ // Copying a symlink - only on the same protocol/host/etc. (#5601, downloading an FTP file through its link), { KIO::SimpleJob *newJob = KIO::symlink((*it).linkDest, uDest, flags | HideProgressInfo /*no GUI*/); + newJob->setParentJob(q); Scheduler::setJobPriority(newJob, 1); newjob = newJob; qCDebug(KIO_COPYJOB_DEBUG) << "Linking target=" << (*it).linkDest << "link=" << uDest; @@ -1639,6 +1660,7 @@ // NOTE: if we are moving stuff, the deletion of the source will be done in slotResultCopyingFiles } else if (m_mode == CopyJob::Move) { // Moving a file KIO::FileCopyJob *moveJob = KIO::file_move(uSource, uDest, permissions, flags | HideProgressInfo/*no GUI*/); + moveJob->setParentJob(q); moveJob->setSourceSize((*it).size); moveJob->setModificationTime((*it).mtime); // #55804 newjob = moveJob; @@ -1680,6 +1702,7 @@ // Take first dir to delete out of list - last ones first ! QList::Iterator it = --dirsToRemove.end(); SimpleJob *job = KIO::rmdir(*it); + job->setParentJob(q); Scheduler::setJobPriority(job, 1); dirsToRemove.erase(it); q->addSubjob(job); @@ -1704,6 +1727,7 @@ ++m_directoriesCopiedIterator; KIO::SimpleJob *job = KIO::setModificationTime(url, dt); + job->setParentJob(q); Scheduler::setJobPriority(job, 1); q->addSubjob(job); diff --git a/src/core/deletejob.cpp b/src/core/deletejob.cpp --- a/src/core/deletejob.cpp +++ b/src/core/deletejob.cpp @@ -111,6 +111,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Delete; + } return job; } }; @@ -306,6 +310,7 @@ job = KIO::http_delete(*it, KIO::HideProgressInfo); } else { job = KIO::file_delete(*it, KIO::HideProgressInfo); + job->setParentJob(q); } Scheduler::setJobPriority(job, 1); m_currentURL = (*it); @@ -344,6 +349,7 @@ // Call rmdir - works for kioslaves with canDeleteRecursive too, // CMD_DEL will trigger the recursive deletion in the slave. SimpleJob *job = KIO::rmdir(*it); + job->setParentJob(q); job->addMetaData(QStringLiteral("recurse"), QStringLiteral("true")); Scheduler::setJobPriority(job, 1); dirs.erase(it); diff --git a/src/core/filecopyjob.cpp b/src/core/filecopyjob.cpp --- a/src/core/filecopyjob.cpp +++ b/src/core/filecopyjob.cpp @@ -111,6 +111,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = move ? Move : Copy; + } return job; } }; @@ -217,6 +221,7 @@ //qDebug(); KIO_ARGS << m_src << m_dest << m_permissions << (qint8)(m_flags & Overwrite); m_copyJob = new DirectCopyJob(slave_url, packedArgs); + m_copyJob->setParentJob(q); if (m_modificationTime.isValid()) { m_copyJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 } @@ -232,6 +237,7 @@ m_mustChmod = true; // CMD_RENAME by itself doesn't change permissions KIO_ARGS << m_src << m_dest << (qint8)(m_flags & Overwrite); m_moveJob = SimpleJobPrivate::newJobNoUi(slave_url, CMD_RENAME, packedArgs); + m_moveJob->setParentJob(q); if (m_modificationTime.isValid()) { m_moveJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 } @@ -332,6 +338,7 @@ m_resumeAnswerSent = false; m_getJob = nullptr; // for now m_putJob = put(m_dest, m_permissions, (m_flags | HideProgressInfo) /* no GUI */); + m_putJob->setParentJob(q); //qDebug() << "m_putJob=" << m_putJob << "m_dest=" << m_dest; if (m_modificationTime.isValid()) { m_putJob->setModificationTime(m_modificationTime); @@ -388,6 +395,7 @@ if (job == m_putJob) { m_getJob = KIO::get(m_src, NoReload, HideProgressInfo /* no GUI */); + m_getJob->setParentJob(q); //qDebug() << "m_getJob=" << m_getJob << m_src; m_getJob->addMetaData(QStringLiteral("errorPage"), QStringLiteral("false")); m_getJob->addMetaData(QStringLiteral("AllowCompressedPage"), QStringLiteral("false")); diff --git a/src/core/job_p.h b/src/core/job_p.h --- a/src/core/job_p.h +++ b/src/core/job_p.h @@ -249,6 +249,23 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + // Only delete, rename and symlink operation accept JobFlags. + FileOperationType opType; + switch (command) { + case CMD_DEL: + opType = Delete; + break; + case CMD_RENAME: + opType = Rename; + break; + case CMD_SYMLINK: + opType = Symlink; + break; + } + job->d_func()->m_operationType = opType; + } return job; } }; @@ -325,6 +342,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } @@ -338,6 +359,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } }; diff --git a/src/core/mkpathjob.cpp b/src/core/mkpathjob.cpp --- a/src/core/mkpathjob.cpp +++ b/src/core/mkpathjob.cpp @@ -96,6 +96,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = MkDir; + } return job; } @@ -122,6 +126,7 @@ if (m_pathIterator != m_pathComponents.constEnd()) { m_url.setPath(concatPaths(m_url.path(), *m_pathIterator)); KIO::Job* job = KIO::mkdir(m_url); + job->setParentJob(q); q->addSubjob(job); q->setProcessedAmount(KJob::Directories, q->processedAmount(KJob::Directories) + 1); } else { diff --git a/src/core/simplejob.cpp b/src/core/simplejob.cpp --- a/src/core/simplejob.cpp +++ b/src/core/simplejob.cpp @@ -377,7 +377,7 @@ { //qDebug() << "rename " << src << " " << dest; KIO_ARGS << src << dest << (qint8)(flags & Overwrite); - return SimpleJobPrivate::newJob(src, CMD_RENAME, packedArgs); + return SimpleJobPrivate::newJob(src, CMD_RENAME, packedArgs, flags); } SimpleJob *KIO::symlink(const QString &target, const QUrl &dest, JobFlags flags) diff --git a/src/core/storedtransferjob.cpp b/src/core/storedtransferjob.cpp --- a/src/core/storedtransferjob.cpp +++ b/src/core/storedtransferjob.cpp @@ -61,6 +61,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } @@ -74,6 +78,10 @@ if (!(flags & HideProgressInfo)) { KIO::getJobTracker()->registerJob(job); } + if (!(flags & NoPrivilegeExecution)) { + job->d_func()->m_privilegeExecutionEnabled = true; + job->d_func()->m_operationType = Transfer; + } return job; } };