Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/krun.cpp
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | 317 | if (!file.setPermissions(QFile::ExeUser | file.permissions())) { | |||
---|---|---|---|---|---|
318 | errorString = file.errorString(); | 318 | errorString = file.errorString(); | ||
319 | qCWarning(KIO_WIDGETS) << "Unable to change permissions for" << fileName << errorString; | 319 | qCWarning(KIO_WIDGETS) << "Unable to change permissions for" << fileName << errorString; | ||
320 | return false; | 320 | return false; | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | return true; | 323 | return true; | ||
324 | } | 324 | } | ||
325 | 325 | | |||
326 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
327 | bool KRun::runUrl(const QUrl &url, const QString &mimetype, QWidget *window, bool tempFile, bool runExecutables, const QString &suggestedFileName, const QByteArray &asn) | 326 | bool KRun::runUrl(const QUrl &url, const QString &mimetype, QWidget *window, bool tempFile, bool runExecutables, const QString &suggestedFileName, const QByteArray &asn) | ||
328 | { | 327 | { | ||
329 | RunFlags flags = tempFile ? KRun::DeleteTemporaryFiles : RunFlags(); | 328 | RunFlags flags = tempFile ? KRun::DeleteTemporaryFiles : RunFlags(); | ||
330 | if (runExecutables) { | 329 | if (runExecutables) { | ||
331 | flags |= KRun::RunExecutables; | 330 | flags |= KRun::RunExecutables; | ||
332 | } | 331 | } | ||
333 | 332 | | |||
334 | return runUrl(url, mimetype, window, flags, suggestedFileName, asn); | 333 | return runUrl(url, mimetype, window, flags, suggestedFileName, asn); | ||
335 | } | 334 | } | ||
336 | #endif | | |||
337 | 335 | | |||
338 | // This is called by foundMimeType, since it knows the mimetype of the URL | 336 | // This is called by foundMimeType, since it knows the mimetype of the URL | ||
339 | bool KRun::runUrl(const QUrl &u, const QString &_mimetype, QWidget *window, RunFlags flags, const QString &suggestedFileName, const QByteArray &asn) | 337 | bool KRun::runUrl(const QUrl &u, const QString &_mimetype, QWidget *window, RunFlags flags, const QString &suggestedFileName, const QByteArray &asn) | ||
340 | { | 338 | { | ||
341 | const QMimeDatabase db; | 339 | const QMimeDatabase db; | ||
342 | const bool runExecutables = flags.testFlag(KRun::RunExecutables); | 340 | const bool runExecutables = flags.testFlag(KRun::RunExecutables); | ||
343 | const bool tempFile = flags.testFlag(KRun::DeleteTemporaryFiles); | 341 | const bool tempFile = flags.testFlag(KRun::DeleteTemporaryFiles); | ||
344 | bool noRun = false; | 342 | bool noRun = false; | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 459 | if (!service) { | |||
463 | service = KService::Ptr(new KService(QString() /*name*/, dialog.text(), QString() /*icon*/)); | 461 | service = KService::Ptr(new KService(QString() /*name*/, dialog.text(), QString() /*icon*/)); | ||
464 | } | 462 | } | ||
465 | const RunFlags flags = tempFiles ? KRun::DeleteTemporaryFiles : RunFlags(); | 463 | const RunFlags flags = tempFiles ? KRun::DeleteTemporaryFiles : RunFlags(); | ||
466 | return KRun::runApplication(*service, lst, window, flags, suggestedFileName, asn); | 464 | return KRun::runApplication(*service, lst, window, flags, suggestedFileName, asn); | ||
467 | } | 465 | } | ||
468 | return false; | 466 | return false; | ||
469 | } | 467 | } | ||
470 | 468 | | |||
471 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
472 | void KRun::shellQuote(QString &_str) | 469 | void KRun::shellQuote(QString &_str) | ||
473 | { | 470 | { | ||
474 | // Credits to Walter, says Bernd G. :) | 471 | // Credits to Walter, says Bernd G. :) | ||
475 | if (_str.isEmpty()) { // Don't create an explicit empty parameter | 472 | if (_str.isEmpty()) { // Don't create an explicit empty parameter | ||
476 | return; | 473 | return; | ||
477 | } | 474 | } | ||
478 | const QChar q = QLatin1Char('\''); | 475 | const QChar q = QLatin1Char('\''); | ||
479 | _str.replace(q, QLatin1String("'\\''")).prepend(q).append(q); | 476 | _str.replace(q, QLatin1String("'\\''")).prepend(q).append(q); | ||
480 | } | 477 | } | ||
481 | #endif | | |||
482 | 478 | | |||
483 | QStringList KRun::processDesktopExec(const KService &_service, const QList<QUrl> &_urls, bool tempFiles, const QString &suggestedFileName) | 479 | QStringList KRun::processDesktopExec(const KService &_service, const QList<QUrl> &_urls, bool tempFiles, const QString &suggestedFileName) | ||
484 | { | 480 | { | ||
485 | KIO::DesktopExecParser parser(_service, _urls); | 481 | KIO::DesktopExecParser parser(_service, _urls); | ||
486 | parser.setUrlsAreTempFiles(tempFiles); | 482 | parser.setUrlsAreTempFiles(tempFiles); | ||
487 | parser.setSuggestedFileName(suggestedFileName); | 483 | parser.setSuggestedFileName(suggestedFileName); | ||
488 | return parser.resultingArguments(); | 484 | return parser.resultingArguments(); | ||
489 | } | 485 | } | ||
490 | 486 | | |||
491 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
492 | QString KRun::binaryName(const QString &execLine, bool removePath) | 487 | QString KRun::binaryName(const QString &execLine, bool removePath) | ||
493 | { | 488 | { | ||
494 | return removePath ? KIO::DesktopExecParser::executableName(execLine) : KIO::DesktopExecParser::executablePath(execLine); | 489 | return removePath ? KIO::DesktopExecParser::executableName(execLine) : KIO::DesktopExecParser::executablePath(execLine); | ||
495 | } | 490 | } | ||
496 | #endif | | |||
497 | 491 | | |||
498 | // This code is also used in klauncher. | 492 | // This code is also used in klauncher. | ||
499 | // TODO: move this to KProcessRunner | 493 | // TODO: move this to KProcessRunner | ||
500 | bool KRun::checkStartupNotify(const QString & /*binName*/, const KService *service, bool *silent_arg, QByteArray *wmclass_arg) | 494 | bool KRun::checkStartupNotify(const QString & /*binName*/, const KService *service, bool *silent_arg, QByteArray *wmclass_arg) | ||
501 | { | 495 | { | ||
502 | bool silent = false; | 496 | bool silent = false; | ||
503 | QByteArray wmclass; | 497 | QByteArray wmclass; | ||
504 | if (service && service->property(QStringLiteral("StartupNotify")).isValid()) { | 498 | if (service && service->property(QStringLiteral("StartupNotify")).isValid()) { | ||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | 696 | if (!::makeServiceFileExecutable(service.entryPath(), errorString)) { | |||
712 | ); | 706 | ); | ||
713 | 707 | | |||
714 | return false; | 708 | return false; | ||
715 | } | 709 | } | ||
716 | 710 | | |||
717 | return true; | 711 | return true; | ||
718 | } | 712 | } | ||
719 | 713 | | |||
720 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
721 | bool KRun::run(const KService &_service, const QList<QUrl> &_urls, QWidget *window, | 714 | bool KRun::run(const KService &_service, const QList<QUrl> &_urls, QWidget *window, | ||
722 | bool tempFiles, const QString &suggestedFileName, const QByteArray &asn) | 715 | bool tempFiles, const QString &suggestedFileName, const QByteArray &asn) | ||
723 | { | 716 | { | ||
724 | const RunFlags flags = tempFiles ? KRun::DeleteTemporaryFiles : RunFlags(); | 717 | const RunFlags flags = tempFiles ? KRun::DeleteTemporaryFiles : RunFlags(); | ||
725 | return runApplication(_service, _urls, window, flags, suggestedFileName, asn) != 0; | 718 | return runApplication(_service, _urls, window, flags, suggestedFileName, asn) != 0; | ||
726 | } | 719 | } | ||
727 | #endif | | |||
728 | 720 | | |||
729 | qint64 KRun::runApplication(const KService &service, const QList<QUrl> &urls, QWidget *window, | 721 | qint64 KRun::runApplication(const KService &service, const QList<QUrl> &urls, QWidget *window, | ||
730 | RunFlags flags, const QString &suggestedFileName, | 722 | RunFlags flags, const QString &suggestedFileName, | ||
731 | const QByteArray &asn) | 723 | const QByteArray &asn) | ||
732 | { | 724 | { | ||
733 | if (!service.entryPath().isEmpty() && | 725 | if (!service.entryPath().isEmpty() && | ||
734 | !KDesktopFile::isAuthorizedDesktopFile(service.entryPath()) && | 726 | !KDesktopFile::isAuthorizedDesktopFile(service.entryPath()) && | ||
735 | !::makeServiceExecutable(service, window)) { | 727 | !::makeServiceExecutable(service, window)) { | ||
▲ Show 20 Lines • Show All 784 Lines • ▼ Show 20 Line(s) | 1511 | { | |||
1520 | d->m_job = job; | 1512 | d->m_job = job; | ||
1521 | } | 1513 | } | ||
1522 | 1514 | | |||
1523 | KIO::Job *KRun::job() | 1515 | KIO::Job *KRun::job() | ||
1524 | { | 1516 | { | ||
1525 | return d->m_job; | 1517 | return d->m_job; | ||
1526 | } | 1518 | } | ||
1527 | 1519 | | |||
1528 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
1529 | QTimer &KRun::timer() | 1520 | QTimer &KRun::timer() | ||
1530 | { | 1521 | { | ||
1531 | return *d->m_timer; | 1522 | return *d->m_timer; | ||
1532 | } | 1523 | } | ||
1533 | #endif | | |||
1534 | 1524 | | |||
1535 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
1536 | void KRun::setDoScanFile(bool scanFile) | 1525 | void KRun::setDoScanFile(bool scanFile) | ||
1537 | { | 1526 | { | ||
1538 | d->m_bScanFile = scanFile; | 1527 | d->m_bScanFile = scanFile; | ||
1539 | } | 1528 | } | ||
1540 | #endif | | |||
1541 | 1529 | | |||
1542 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
1543 | bool KRun::doScanFile() const | 1530 | bool KRun::doScanFile() const | ||
1544 | { | 1531 | { | ||
1545 | return d->m_bScanFile; | 1532 | return d->m_bScanFile; | ||
1546 | } | 1533 | } | ||
1547 | #endif | | |||
1548 | 1534 | | |||
1549 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
1550 | void KRun::setIsDirecory(bool isDirectory) | 1535 | void KRun::setIsDirecory(bool isDirectory) | ||
1551 | { | 1536 | { | ||
1552 | d->m_bIsDirectory = isDirectory; | 1537 | d->m_bIsDirectory = isDirectory; | ||
1553 | } | 1538 | } | ||
1554 | #endif | | |||
1555 | 1539 | | |||
1556 | bool KRun::isDirectory() const | 1540 | bool KRun::isDirectory() const | ||
1557 | { | 1541 | { | ||
1558 | return d->m_bIsDirectory; | 1542 | return d->m_bIsDirectory; | ||
1559 | } | 1543 | } | ||
1560 | 1544 | | |||
1561 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
1562 | void KRun::setInitializeNextAction(bool initialize) | 1545 | void KRun::setInitializeNextAction(bool initialize) | ||
1563 | { | 1546 | { | ||
1564 | d->m_bInit = initialize; | 1547 | d->m_bInit = initialize; | ||
1565 | } | 1548 | } | ||
1566 | #endif | | |||
1567 | 1549 | | |||
1568 | #ifndef KIOWIDGETS_NO_DEPRECATED | | |||
1569 | bool KRun::initializeNextAction() const | 1550 | bool KRun::initializeNextAction() const | ||
1570 | { | 1551 | { | ||
1571 | return d->m_bInit; | 1552 | return d->m_bInit; | ||
1572 | } | 1553 | } | ||
1573 | #endif | | |||
1574 | 1554 | | |||
1575 | bool KRun::isLocalFile() const | 1555 | bool KRun::isLocalFile() const | ||
1576 | { | 1556 | { | ||
1577 | return d->m_strURL.isLocalFile(); | 1557 | return d->m_strURL.isLocalFile(); | ||
1578 | } | 1558 | } | ||
1579 | 1559 | | |||
1580 | /****************/ | 1560 | /****************/ | ||
1581 | 1561 | | |||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |