Changeset View
Changeset View
Standalone View
Standalone View
src/core/job.cpp
Show All 28 Lines | |||||
29 | #include <QLinkedList> | 29 | #include <QLinkedList> | ||
30 | 30 | | |||
31 | #include <klocalizedstring.h> | 31 | #include <klocalizedstring.h> | ||
32 | #include <kstringhandler.h> | 32 | #include <kstringhandler.h> | ||
33 | 33 | | |||
34 | #include <kio/jobuidelegateextension.h> | 34 | #include <kio/jobuidelegateextension.h> | ||
35 | #include "slave.h" | 35 | #include "slave.h" | ||
36 | #include "scheduler.h" | 36 | #include "scheduler.h" | ||
37 | #include "slavebase.h" | ||||
37 | 38 | | |||
38 | using namespace KIO; | 39 | using namespace KIO; | ||
39 | 40 | | |||
40 | Job::Job() : KCompositeJob(nullptr) | 41 | Job::Job() : KCompositeJob(nullptr) | ||
41 | , d_ptr(new JobPrivate) | 42 | , d_ptr(new JobPrivate) | ||
42 | { | 43 | { | ||
43 | d_ptr->q_ptr = this; | 44 | d_ptr->q_ptr = this; | ||
44 | setCapabilities(KJob::Killable | KJob::Suspendable); | 45 | setCapabilities(KJob::Killable | KJob::Suspendable); | ||
▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Line(s) | 255 | for (; it != values.end(); ++it) | |||
258 | } | 259 | } | ||
259 | } | 260 | } | ||
260 | 261 | | |||
261 | MetaData Job::outgoingMetaData() const | 262 | MetaData Job::outgoingMetaData() const | ||
262 | { | 263 | { | ||
263 | return d_func()->m_outgoingMetaData; | 264 | return d_func()->m_outgoingMetaData; | ||
264 | } | 265 | } | ||
265 | 266 | | |||
267 | bool JobPrivate::tryAskPrivilegeOpConfirmation() | ||||
268 | { | ||||
269 | if (m_confirmationAsked) { | ||||
270 | return true; | ||||
271 | } | ||||
272 | | ||||
273 | if (m_parentJob) { | ||||
274 | if (!m_parentJob->d_func()->m_privilegeExecutionEnabled) { | ||||
275 | // Whether or not sub-jobs have PrivilegeExecution flag set doesn't matter. | ||||
276 | // If it's not set in parent job then don't continue. | ||||
dfaure: its -> it's | |||||
277 | return false; | ||||
278 | } | ||||
279 | | ||||
280 | if (!m_parentJob->d_func()->m_confirmationAsked) { | ||||
281 | bool confirmed = m_parentJob->d_func()->tryAskPrivilegeOpConfirmation(); | ||||
282 | if (confirmed) { | ||||
283 | m_confirmationAsked = true; | ||||
284 | } | ||||
285 | return confirmed; | ||||
286 | } else { | ||||
287 | return true; | ||||
288 | } | ||||
289 | } else { | ||||
290 | // Some application trying to use SimpleJob directly. | ||||
291 | if (!m_privilegeExecutionEnabled) { | ||||
292 | return false; | ||||
293 | } | ||||
294 | } | ||||
295 | | ||||
296 | switch (m_operationType) { | ||||
297 | case ChangeAttr: | ||||
298 | m_caption = i18n("Change Attribute"); | ||||
299 | m_message = i18n("Root privileges are required to change file attributes. " | ||||
300 | "Do you want to continue?"); | ||||
301 | break; | ||||
302 | case Copy: | ||||
303 | m_caption = i18n("Copy Files"); | ||||
304 | m_message = i18n("Root privileges are required to complete the copy operation. " | ||||
305 | "Do you want to continue?"); | ||||
306 | break; | ||||
307 | case Delete: | ||||
308 | m_caption = i18n("Delete Files"); | ||||
309 | m_message = i18n("Root privileges are required to complete the delete operation." | ||||
310 | "However, doing so may damage your system. Do you want to continue?"); | ||||
311 | break; | ||||
312 | case MkDir: | ||||
313 | m_caption = i18n("Create Folder"); | ||||
314 | m_message = i18n("Root privileges are required to create this folder. " | ||||
315 | "Do you want to continue?"); | ||||
316 | break; | ||||
317 | case Move: | ||||
318 | m_caption = i18n("Move Items"); | ||||
319 | m_message = i18n("Root privileges are required to complete the move operation. " | ||||
320 | "Do you want to continue?"); | ||||
321 | break; | ||||
322 | case Rename: | ||||
323 | m_caption = i18n("Rename"); | ||||
324 | m_message = i18n("Root privileges are required to complete renaming. " | ||||
325 | "Do you want to continue?"); | ||||
326 | break; | ||||
327 | case Symlink: | ||||
328 | m_caption = i18n("Create Symlink"); | ||||
329 | m_message = i18n("Root privileges are required to create a symlink. " | ||||
330 | "Do you want to continue?"); | ||||
331 | break; | ||||
332 | case Transfer: | ||||
333 | m_caption = i18n("Transfer data"); | ||||
334 | m_message = i18n("Root privileges are required to complete transferring data. " | ||||
335 | "Do you want to continue?"); | ||||
336 | default: | ||||
337 | break; | ||||
338 | } | ||||
339 | | ||||
340 | if (m_outgoingMetaData.value(QStringLiteral("UnitTesting")) == QLatin1String("true")) { | ||||
341 | return true; | ||||
342 | } | ||||
343 | | ||||
344 | if (!m_uiDelegateExtension) { | ||||
345 | return false; | ||||
dfaure: This hardcoded 5 is awful, please use SlaveBase::Continue instead. | |||||
346 | } | ||||
347 | | ||||
348 | int status = m_uiDelegateExtension->requestMessageBox(JobUiDelegateExtension::WarningContinueCancel, | ||||
349 | m_message, m_caption, i18n("Continue"), i18n("Cancel")); | ||||
350 | m_confirmationAsked = true; | ||||
351 | return status == SlaveBase::Continue; | ||||
352 | } | ||||
353 | | ||||
266 | ////////////////////////// | 354 | ////////////////////////// | ||
267 | 355 | | |||
268 | class KIO::DirectCopyJobPrivate: public KIO::SimpleJobPrivate | 356 | class KIO::DirectCopyJobPrivate: public KIO::SimpleJobPrivate | ||
269 | { | 357 | { | ||
270 | public: | 358 | public: | ||
271 | DirectCopyJobPrivate(const QUrl &url, int command, const QByteArray &packedArgs) | 359 | DirectCopyJobPrivate(const QUrl &url, int command, const QByteArray &packedArgs) | ||
272 | : SimpleJobPrivate(url, command, packedArgs) | 360 | : SimpleJobPrivate(url, command, packedArgs) | ||
273 | {} | 361 | {} | ||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |
its -> it's