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