Changeset View
Changeset View
Standalone View
Standalone View
src/core/filecopyjob.cpp
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 105 | { | |||
---|---|---|---|---|---|
106 | //qDebug() << src << "->" << dest; | 106 | //qDebug() << src << "->" << dest; | ||
107 | FileCopyJob *job = new FileCopyJob( | 107 | FileCopyJob *job = new FileCopyJob( | ||
108 | *new FileCopyJobPrivate(src, dest, permissions, move, flags)); | 108 | *new FileCopyJobPrivate(src, dest, permissions, move, flags)); | ||
109 | job->setProperty("destUrl", dest.toString()); | 109 | job->setProperty("destUrl", dest.toString()); | ||
110 | job->setUiDelegate(KIO::createDefaultJobUiDelegate()); | 110 | job->setUiDelegate(KIO::createDefaultJobUiDelegate()); | ||
111 | if (!(flags & HideProgressInfo)) { | 111 | if (!(flags & HideProgressInfo)) { | ||
112 | KIO::getJobTracker()->registerJob(job); | 112 | KIO::getJobTracker()->registerJob(job); | ||
113 | } | 113 | } | ||
114 | if (flags & PrivilegeExecution) { | ||||
115 | job->d_func()->m_privilegeExecutionEnabled = true; | ||||
116 | job->d_func()->m_operationType = move ? Move : Copy; | ||||
117 | } | ||||
114 | return job; | 118 | return job; | ||
115 | } | 119 | } | ||
116 | }; | 120 | }; | ||
117 | 121 | | |||
118 | /* | 122 | /* | ||
119 | * The FileCopyJob works according to the famous Bavarian | 123 | * The FileCopyJob works according to the famous Bavarian | ||
120 | * 'Alternating Bitburger Protocol': we either drink a beer or we | 124 | * 'Alternating Bitburger Protocol': we either drink a beer or we | ||
121 | * we order a beer, but never both at the same time. | 125 | * we order a beer, but never both at the same time. | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
212 | } | 216 | } | ||
213 | 217 | | |||
214 | void FileCopyJobPrivate::startCopyJob(const QUrl &slave_url) | 218 | void FileCopyJobPrivate::startCopyJob(const QUrl &slave_url) | ||
215 | { | 219 | { | ||
216 | Q_Q(FileCopyJob); | 220 | Q_Q(FileCopyJob); | ||
217 | //qDebug(); | 221 | //qDebug(); | ||
218 | KIO_ARGS << m_src << m_dest << m_permissions << (qint8)(m_flags & Overwrite); | 222 | KIO_ARGS << m_src << m_dest << m_permissions << (qint8)(m_flags & Overwrite); | ||
219 | m_copyJob = new DirectCopyJob(slave_url, packedArgs); | 223 | m_copyJob = new DirectCopyJob(slave_url, packedArgs); | ||
224 | m_copyJob->setParentJob(q); | ||||
220 | if (m_modificationTime.isValid()) { | 225 | if (m_modificationTime.isValid()) { | ||
221 | m_copyJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 | 226 | m_copyJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 | ||
222 | } | 227 | } | ||
223 | q->addSubjob(m_copyJob); | 228 | q->addSubjob(m_copyJob); | ||
224 | connectSubjob(m_copyJob); | 229 | connectSubjob(m_copyJob); | ||
225 | q->connect(m_copyJob, SIGNAL(canResume(KIO::Job*,KIO::filesize_t)), | 230 | q->connect(m_copyJob, SIGNAL(canResume(KIO::Job*,KIO::filesize_t)), | ||
226 | SLOT(slotCanResume(KIO::Job*,KIO::filesize_t))); | 231 | SLOT(slotCanResume(KIO::Job*,KIO::filesize_t))); | ||
227 | } | 232 | } | ||
228 | 233 | | |||
229 | void FileCopyJobPrivate::startRenameJob(const QUrl &slave_url) | 234 | void FileCopyJobPrivate::startRenameJob(const QUrl &slave_url) | ||
230 | { | 235 | { | ||
231 | Q_Q(FileCopyJob); | 236 | Q_Q(FileCopyJob); | ||
232 | m_mustChmod = true; // CMD_RENAME by itself doesn't change permissions | 237 | m_mustChmod = true; // CMD_RENAME by itself doesn't change permissions | ||
233 | KIO_ARGS << m_src << m_dest << (qint8)(m_flags & Overwrite); | 238 | KIO_ARGS << m_src << m_dest << (qint8)(m_flags & Overwrite); | ||
234 | m_moveJob = SimpleJobPrivate::newJobNoUi(slave_url, CMD_RENAME, packedArgs); | 239 | m_moveJob = SimpleJobPrivate::newJobNoUi(slave_url, CMD_RENAME, packedArgs); | ||
240 | m_moveJob->setParentJob(q); | ||||
235 | if (m_modificationTime.isValid()) { | 241 | if (m_modificationTime.isValid()) { | ||
236 | m_moveJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 | 242 | m_moveJob->addMetaData(QStringLiteral("modified"), m_modificationTime.toString(Qt::ISODate)); // #55804 | ||
237 | } | 243 | } | ||
238 | q->addSubjob(m_moveJob); | 244 | q->addSubjob(m_moveJob); | ||
239 | connectSubjob(m_moveJob); | 245 | connectSubjob(m_moveJob); | ||
240 | } | 246 | } | ||
241 | 247 | | |||
242 | void FileCopyJobPrivate::connectSubjob(SimpleJob *job) | 248 | void FileCopyJobPrivate::connectSubjob(SimpleJob *job) | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
327 | { | 333 | { | ||
328 | Q_Q(FileCopyJob); | 334 | Q_Q(FileCopyJob); | ||
329 | //qDebug(); | 335 | //qDebug(); | ||
330 | 336 | | |||
331 | m_canResume = false; | 337 | m_canResume = false; | ||
332 | m_resumeAnswerSent = false; | 338 | m_resumeAnswerSent = false; | ||
333 | m_getJob = nullptr; // for now | 339 | m_getJob = nullptr; // for now | ||
334 | m_putJob = put(m_dest, m_permissions, (m_flags | HideProgressInfo) /* no GUI */); | 340 | m_putJob = put(m_dest, m_permissions, (m_flags | HideProgressInfo) /* no GUI */); | ||
341 | m_putJob->setParentJob(q); | ||||
335 | //qDebug() << "m_putJob=" << m_putJob << "m_dest=" << m_dest; | 342 | //qDebug() << "m_putJob=" << m_putJob << "m_dest=" << m_dest; | ||
336 | if (m_modificationTime.isValid()) { | 343 | if (m_modificationTime.isValid()) { | ||
337 | m_putJob->setModificationTime(m_modificationTime); | 344 | m_putJob->setModificationTime(m_modificationTime); | ||
338 | } | 345 | } | ||
339 | 346 | | |||
340 | // The first thing the put job will tell us is whether we can | 347 | // The first thing the put job will tell us is whether we can | ||
341 | // resume or not (this is always emitted) | 348 | // resume or not (this is always emitted) | ||
342 | q->connect(m_putJob, SIGNAL(canResume(KIO::Job*,KIO::filesize_t)), | 349 | q->connect(m_putJob, SIGNAL(canResume(KIO::Job*,KIO::filesize_t)), | ||
Show All 40 Lines | 378 | } else if (res == R_CANCEL) { | |||
383 | return; | 390 | return; | ||
384 | } | 391 | } | ||
385 | } else { | 392 | } else { | ||
386 | m_resumeAnswerSent = true; // No need for an answer | 393 | m_resumeAnswerSent = true; // No need for an answer | ||
387 | } | 394 | } | ||
388 | 395 | | |||
389 | if (job == m_putJob) { | 396 | if (job == m_putJob) { | ||
390 | m_getJob = KIO::get(m_src, NoReload, HideProgressInfo /* no GUI */); | 397 | m_getJob = KIO::get(m_src, NoReload, HideProgressInfo /* no GUI */); | ||
398 | m_getJob->setParentJob(q); | ||||
391 | //qDebug() << "m_getJob=" << m_getJob << m_src; | 399 | //qDebug() << "m_getJob=" << m_getJob << m_src; | ||
392 | m_getJob->addMetaData(QStringLiteral("errorPage"), QStringLiteral("false")); | 400 | m_getJob->addMetaData(QStringLiteral("errorPage"), QStringLiteral("false")); | ||
393 | m_getJob->addMetaData(QStringLiteral("AllowCompressedPage"), QStringLiteral("false")); | 401 | m_getJob->addMetaData(QStringLiteral("AllowCompressedPage"), QStringLiteral("false")); | ||
394 | // Set size in subjob. This helps if the slave doesn't emit totalSize. | 402 | // Set size in subjob. This helps if the slave doesn't emit totalSize. | ||
395 | if (m_sourceSize != (KIO::filesize_t) - 1) { | 403 | if (m_sourceSize != (KIO::filesize_t) - 1) { | ||
396 | m_getJob->setTotalAmount(KJob::Bytes, m_sourceSize); | 404 | m_getJob->setTotalAmount(KJob::Bytes, m_sourceSize); | ||
397 | } | 405 | } | ||
398 | if (offset) { | 406 | if (offset) { | ||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |