KIO::OpenUrlJob

Search for usage in LXR

#include <KIO/OpenUrlJob>

Inheritance diagram for KIO::OpenUrlJob:

Signals

void mimeTypeFound (const QString &mimeType)
 
- Signals inherited from KJob
void description (KJob *job, const QString &title, const QPair< QString, QString > &field1=QPair< QString, QString >(), const QPair< QString, QString > &field2=QPair< QString, QString >())
 
void finished (KJob *job)
 
void infoMessage (KJob *job, const QString &message)
 
void percentChanged (KJob *job, unsigned long percent)
 
void processedAmountChanged (KJob *job, KJob::Unit unit, qulonglong amount)
 
void processedSize (KJob *job, qulonglong size)
 
void result (KJob *job)
 
void resumed (KJob *job)
 
void speed (KJob *job, unsigned long speed)
 
void suspended (KJob *job)
 
void totalAmountChanged (KJob *job, KJob::Unit unit, qulonglong amount)
 
void totalSize (KJob *job, qulonglong size)
 
void warning (KJob *job, const QString &message)
 

Public Member Functions

 OpenUrlJob (const QUrl &url, const QString &mimeType, QObject *parent=nullptr)
 
 OpenUrlJob (const QUrl &url, QObject *parent=nullptr)
 
 ~OpenUrlJob () override
 
void setDeleteTemporaryFile (bool b)
 
void setEnableExternalBrowser (bool b)
 
void setFollowRedirections (bool b)
 
void setRunExecutables (bool allow)
 
void setShowOpenOrExecuteDialog (bool b)
 
void setStartupId (const QByteArray &startupId)
 
void setSuggestedFileName (const QString &suggestedFileName)
 
void start () override
 
- Public Member Functions inherited from KCompositeJob
 KCompositeJob (QObject *parent=nullptr)
 
- Public Member Functions inherited from KJob
 KJob (QObject *parent=nullptr)
 
Capabilities capabilities () const
 
qint64 elapsedTime () const
 
int error () const
 
virtual QString errorString () const
 
QString errorText () const
 
bool exec ()
 
bool isAutoDelete () const
 
bool isFinishedNotificationHidden () const
 
bool isStartedWithExec () const
 
bool isSuspended () const
 
unsigned long percent () const
 
Q_SCRIPTABLE qulonglong processedAmount (Unit unit) const
 
void setAutoDelete (bool autodelete)
 
void setFinishedNotificationHidden (bool hide=true)
 
void setUiDelegate (KJobUiDelegate *delegate)
 
Q_SCRIPTABLE qulonglong totalAmount (Unit unit) const
 
KJobUiDelegateuiDelegate () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static bool isExecutableFile (const QUrl &url, const QString &mimetypeName)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

bool doKill () override
 
- Protected Member Functions inherited from KCompositeJob
virtual bool addSubjob (KJob *job)
 
void clearSubjobs ()
 
bool hasSubjobs () const
 
virtual bool removeSubjob (KJob *job)
 
const QList< KJob * > & subjobs () const
 
- Protected Member Functions inherited from KJob
virtual bool doResume ()
 
virtual bool doSuspend ()
 
void emitPercent (qulonglong processedAmount, qulonglong totalAmount)
 
void emitResult ()
 
void emitSpeed (unsigned long speed)
 
bool isFinished () const
 
void setCapabilities (Capabilities capabilities)
 
void setError (int errorCode)
 
void setErrorText (const QString &errorText)
 
void setPercent (unsigned long percentage)
 
void setProcessedAmount (Unit unit, qulonglong amount)
 
void setProgressUnit (Unit unit)
 
void setTotalAmount (Unit unit, qulonglong amount)
 
void startElapsedTimer ()
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from KJob
typedef QFlags< CapabilityCapabilities
 
enum  Capability
 
enum  Unit
 
- Public Types inherited from QObject
typedef  QObjectList
 
- Properties inherited from QObject
 objectName
 
- Public Slots inherited from KJob
bool kill (KJob::KillVerbosity verbosity=KJob::Quietly)
 
bool resume ()
 
bool suspend ()
 
- Public Attributes inherited from KJob
 Bytes
 
 Directories
 
 Files
 
 Items
 
 Killable
 
 NoCapabilities
 
 Suspendable
 
 UnitsCount
 
- Protected Slots inherited from KCompositeJob
virtual void slotInfoMessage (KJob *job, const QString &message)
 

Detailed Description

OpenUrlJob finds out the right way to "open" a URL.

This includes finding out its MIME type, and then the associated application, or running desktop files, executables, etc. It also honours the "use this webbrowser for all http(s) URLs" setting.

For the "Open With" dialog functionality to work, make sure to set KIO::JobUiDelegate as the delegate for this job (in widgets applications).

// Since 5.98 use:
// For older releases use:
A UI delegate tuned to be used with KIO Jobs.
KIOCORE_EXPORT KJobUiDelegate * createDefaultJobUiDelegate()
Convenience method: use default factory, if there's one, to create a delegate and return it.
Since
5.71

Definition at line 41 of file openurljob.h.

Constructor & Destructor Documentation

◆ OpenUrlJob() [1/2]

KIO::OpenUrlJob::OpenUrlJob ( const QUrl & url,
QObject * parent = nullptr )
explicit

Creates an OpenUrlJob in order to open a URL.

Parameters
urlthe URL of the file/directory to open

Definition at line 88 of file openurljob.cpp.

◆ OpenUrlJob() [2/2]

KIO::OpenUrlJob::OpenUrlJob ( const QUrl & url,
const QString & mimeType,
QObject * parent = nullptr )
explicit

Creates an OpenUrlJob for the case where the MIME type is already known.

Parameters
urlthe URL of the file/directory to open
mimeTypethe type of file/directory. See QMimeType.

Definition at line 94 of file openurljob.cpp.

◆ ~OpenUrlJob()

KIO::OpenUrlJob::~OpenUrlJob ( )
override

Destructor.

Note that by default jobs auto-delete themselves after emitting result.

Definition at line 101 of file openurljob.cpp.

Member Function Documentation

◆ doKill()

bool KIO::OpenUrlJob::doKill ( )
overrideprotectedvirtual

Reimplemented from KJob.

Definition at line 216 of file openurljob.cpp.

◆ isExecutableFile()

bool KIO::OpenUrlJob::isExecutableFile ( const QUrl & url,
const QString & mimetypeName )
static

Returns whether the url of mimetype is executable.

To be executable the file must pass the following rules:

  1. Must reside on the local filesystem.
  2. Must be marked as executable for the user by the filesystem.
  3. The MIME type must inherit application/x-executable, application/x-executable-script

Definition at line 350 of file openurljob.cpp.

◆ mimeTypeFound

void KIO::OpenUrlJob::mimeTypeFound ( const QString & mimeType)
signal

Emitted when the MIME type is determined.

This can be used for special cases like webbrowsers who want to embed the URL in some cases, rather than starting a different application. In that case they can kill the job.

◆ setDeleteTemporaryFile()

void KIO::OpenUrlJob::setDeleteTemporaryFile ( bool b)

Specifies that the URL passed to the application will be deleted when it exits (if the URL is a local file)

Definition at line 105 of file openurljob.cpp.

◆ setEnableExternalBrowser()

void KIO::OpenUrlJob::setEnableExternalBrowser ( bool b)

Sets whether the external webbrowser setting should be honoured.

This is enabled by default. This should only be disabled in webbrowser applications.

Parameters
bwhether to let the external browser handle the URL or not

Definition at line 130 of file openurljob.cpp.

◆ setFollowRedirections()

void KIO::OpenUrlJob::setFollowRedirections ( bool b)

Sets whether the job should follow URL redirections.

This is enabled by default.

Parameters
bwhether to follow redirections or not.

Definition at line 135 of file openurljob.cpp.

◆ setRunExecutables()

void KIO::OpenUrlJob::setRunExecutables ( bool allow)

Set this to true if this class should allow the user to run executables.

Unlike KF5's KRun, this setting is OFF by default here for security reasons. File managers can enable this, but e.g. web browsers, mail clients etc. shouldn't.

Definition at line 120 of file openurljob.cpp.

◆ setShowOpenOrExecuteDialog()

void KIO::OpenUrlJob::setShowOpenOrExecuteDialog ( bool b)

Set this to true if this class should show a dialog to ask the user about how to handle various types of executable files; note that executing/running remote files is disallowed as that is not secure (in the case of remote shell scripts and .desktop files, they are always opened as text in the default application):

  • For native binaries: whether to execute or cancel
  • For .exe files: whether to execute or cancel, ("execute" on Linux in this context means running the file with the default application (e.g. WINE))
  • For executable shell scripts: whether to execute the file or open it as text in the default application; note that if the file doesn't have the execute bit, it'll always be opened as text
  • For .desktop files: whether to run the file or open it as text in the default application; note that if the .desktop file is located in a non-standard location (on Linux standard locations are /usr/share/applications or ~/.local/share/applications) and does not have the execute bit, another dialog (see UntrustedProgramHandlerInterface) will be launched to ask the user whether they trust running the application (the one the .desktop file launches based on the Exec line)

Note that the dialog, ExecutableFileOpenDialog (from KIOWidgets), provides an option to remember the last value used and not ask again, if that is set, then the dialog will not be shown.

When set to true this will take precedence over setRunExecutables (the latter can be used to allow running executables without first asking the user for confirmation).

Since
5.73

Definition at line 125 of file openurljob.cpp.

◆ setStartupId()

void KIO::OpenUrlJob::setStartupId ( const QByteArray & startupId)

Sets the platform-specific startup id of the application launch.

Parameters
startupIdstartup id, if any (otherwise ""). For X11, this would be the id for the Startup Notification protocol. For Wayland, this would be the token for the XDG Activation protocol.

Definition at line 115 of file openurljob.cpp.

◆ setSuggestedFileName()

void KIO::OpenUrlJob::setSuggestedFileName ( const QString & suggestedFileName)

Sets the file name to use in the case of downloading the file to a tempfile, in order to give it to a non-URL-aware application.

Some apps rely on the extension to determine the MIME type of the file. Usually the file name comes from the URL, but in the case of the HTTP Content-Disposition header, we need to override the file name.

Parameters
suggestedFileNamethe file name

Definition at line 110 of file openurljob.cpp.

◆ start()

void KIO::OpenUrlJob::start ( )
overridevirtual

Starts the job.

You must call this, after having called all the needed setters. This is a GUI job, never use exec(), it would block user interaction.

Implements KJob.

Definition at line 140 of file openurljob.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:09:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.