KIO::UntrustedProgramHandlerInterface Class
class KIO::UntrustedProgramHandlerInterfaceThe UntrustedProgramHandlerInterface class allows ApplicationLauncherJob to prompt the user about an untrusted executable or desktop file. More...
Header: | #include <KIO/UntrustedProgramHandlerInterface> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
Since: | 5.70 |
Inherits: | QObject |
Public Functions
bool | makeServiceFileExecutable(const QString &fileName, QString &errorString) |
bool | setExecuteBit(const QString &fileName, QString &errorString) |
virtual void | showUntrustedProgramWarning(KJob *job, const QString &programName) |
Signals
void | result(bool confirmed) |
Protected Functions
UntrustedProgramHandlerInterface(QObject *parent = nullptr) |
Detailed Description
This extension mechanism for jobs is similar to KIO::JobUiDelegateExtension.
The class also provides helper methods to set the execute bit so that the program can be started.
Member Function Documentation
[explicit protected]
UntrustedProgramHandlerInterface::UntrustedProgramHandlerInterface(QObject *parent = nullptr)
Constructor
bool UntrustedProgramHandlerInterface::makeServiceFileExecutable(const QString &fileName, QString &errorString)
Helper function that attempts to make a desktop file executable. In addition to the execute bit, this includes fixing its first line to ensure that it says #!/usr/bin/env xdg-open.
fileName the full path to the file
errorString output parameter so the method can return an error message
Returns true
on success, false
on error
[signal]
void UntrustedProgramHandlerInterface::result(bool confirmed)
Implementations of this interface must emit result in showUntrustedProgramWarning.
confirmed true
if the user confirms running this program, false
on cancel
bool UntrustedProgramHandlerInterface::setExecuteBit(const QString &fileName, QString &errorString)
Helper function that attempts to set execute bit for given file.
fileName the full path to the file
errorString output parameter so the method can return an error message
Returns true
on success, false
on error
[virtual]
void UntrustedProgramHandlerInterface::showUntrustedProgramWarning(KJob *job, const QString &programName)
Show a warning to the user about the program not being trusted for execution. This could be an executable which is not a script and without the execute bit. Or it could be a desktop file outside the standard locations, without the execute bit.
job the job calling this. Useful to get the associated window.
programName the full path to the executable or desktop file
If this function emits result(true), the caller should then call either setExecuteBit or makeServiceFileExecutable; those helper methods are provided by this class.
The default implementation in this base class simply emits result(false). Any application using KIO::JobUiDelegate (KIOWidgets) will benefit from an automatically registered subclass which implements this method using QtWidgets.