class KRun

Opens files with their associated applications in KDE. More...

Definition#include <krun.h>
InheritsQObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Signals

Public Static Methods

Protected Methods

Protected Slots

Protected Members


Detailed Description

To open files with their associated applications in KDE, use KRun.

It can execute any desktop entry, as well as any file, using the default application or another application "bound" to the file type.

In that example, the mimetype of the file is not known by the application, so a KRun instance must be created. It will determine the mimetype by itself. If the mimetype is known, or if you even know the service (application) to use for this file, use one of the static methods.

 KRun ( const KURL& url, mode_t mode = 0, bool isLocalFile = false, bool showProgressInfo = true )

KRun

Create a KRun object to run the preferred application for a file/URL. KRun will first determine the type of the file, and will then run the associated application.

Parameters:
urlthe URL of the file or directory to 'run'
modeThe st_mode field of struct stat. If you don't know this set it to 0.
isLocalFile If this parameter is set to false then url is examined to find out whether it is a local URL or not. This flag is just used to improve speed, since the function KURL::isLocalFile is a bit slow.
showProgressInfo Whether to show progress information when determining the type of the file (i.e. when using KIO::stat and KIO::mimetype) Before you set this to false to avoid a dialog box, think about a very slow FTP server... It is always better to provide progress info in such cases.

 ~KRun ()

~KRun

[virtual]

Destructor. Don't call it yourself, since a KRun object auto-deletes itself.

void  abort ()

abort

Abort this KRun. This kills any jobs launched by it, and leads to deletion if auto-deletion is on. This is much safer than deleting the KRun (in case it's currently showing an error dialog box, for instance)

bool  hasError ()

hasError

[const]

bool  hasFinished ()

hasFinished

[const]

bool  autoDelete ()

autoDelete

[const]

By default auto deletion is on.

void  setAutoDelete (bool b)

setAutoDelete

void  setPreferredService ( const QString& desktopEntryName )

setPreferredService

Set the preferred service for opening this URL, after its mimetype will have been found by KRun. IMPORTANT: the service is only used if its configuration says it can handle this mimetype. This is used for instance for the X-KDE-LastOpenedWith key, for the recent documents list.

Parameters:
desktopEntryNamethe desktopEntryName of the service, e.g. "kate".

pid_t  run ( const KService& _service, const KURL::List& _urls )

run

[static]

Open a list of URLs with a certain service.

Parameters:
_urlsthe list of URLs, can be empty (app launched without argument)

pid_t  run ( const QString& _exec, const KURL::List& _urls, const QString& _name = QString::null, const QString& _icon = QString::null, const QString& _obsolete1 = QString::null, const QString& _obsolete2 = QString::null )

run

[static]

Open a list of URLs with.

Parameters:
_execThe name of the executable, for example "/usr/bin/netscape".
_nameThe logical name of the application, for example "Netscape 4.06".
_iconThe icon which should be used by the application.
_obsolete1Do not use!
_obsolete2Do not use!

pid_t  runURL ( const KURL& _url, const QString& _mimetype )

runURL

[static]

Open the given URL.

This function is used after the mime type is found out. It will search for all services which can handle the mime type and call run() afterwards.

pid_t  runCommand ( QString cmd )

runCommand

[static]

Run the given shell command and notifies kicker of the starting of the application. If the program to be called doesn't exist, an error box will be displayed.

_cmd must be a shell command. You must not append "&" to it, since the function will do that for you.

Use only when you know the full command line. Otherwise use the other static methods, or KRun's constructor.

Returns: PID of running command, 0 if it could not be started, 0 - (PID of running command) if command was unsafe for map notification.

pid_t  runCommand ( const QString& cmd, const QString & execName, const QString & icon )

runCommand

[static]

Same as the other runCommand, but it also takes the name of the binary, to display an error message in case it couldn't find it.

Parameters:
iconicon for app starting notification

bool  displayOpenWithDialog ( const KURL::List& lst )

displayOpenWithDialog

[static]

Display the Open-With dialog for those URLs, and run the chosen application.

Returns: false if the dialog was canceled

void  shellQuote ( QString &_str )

shellQuote

[static]

Quotes a string for the shell

QStringList  processDesktopExec (const KService &_service, const KURL::List &_urls, bool has_shell)

processDesktopExec

[static]

Processes a Exec= line as found in .desktop files.

Parameters:
_servicethe service to extract information from.
_urlsThe urls the service should open.
has_shellIf true, the arguments are going to be fed into a shell e.g by using system(). If false, the arguments are going to be fed into a exec() kind call. If the arguments are intended for an exec() kind of call and the Exec line contains shell commands then "/bin/sh -c" is added.

Returns: a list of arguments suitable for either system() or exec().

void  finished ()

finished

[signal]

void  error ()

error

[signal]

void  slotTimeout ()

slotTimeout

[protected slots slot]

void  slotScanFinished ( KIO::Job * )

slotScanFinished

[protected slots slot]

void  slotScanMimeType ( KIO::Job *, const QString &type )

slotScanMimeType

[protected slots slot]

void  slotStatResult ( KIO::Job * )

slotStatResult

[protected slots virtual slot]

void  init ()

init

[protected virtual]

void  scanFile ()

scanFile

[protected virtual]

void  foundMimeType ( const QString& _type )

foundMimeType

[protected virtual]

Called if the mimetype has been detected. The function checks whether the document and appends the gzip protocol to the URL. Otherwise runURL is called to finish the job.

void  killJob ()

killJob

[protected virtual]

KURL m_strURL

m_strURL

[protected]

bool m_bFault

m_bFault

[protected]

bool m_bAutoDelete

m_bAutoDelete

[protected]

bool m_bProgressInfo

m_bProgressInfo

[protected]

bool m_bFinished

m_bFinished

[protected]

KIO::Job * m_job

m_job

[protected]

QTimer m_timer

m_timer

[protected]

bool m_bScanFile

m_bScanFile

[protected]

bool m_bIsDirectory

m_bIsDirectory

[protected]

bool m_bInit

m_bInit

[protected]

bool m_bIsLocalFile

m_bIsLocalFile

[protected]

mode_t m_mode

m_mode

[protected]

void  virtual_hook ( int id, void* data )

virtual_hook

[protected virtual]

USed to indicate that the next action is to initialize. This action is invoked from slotTimeout


Generated by: dfaure on faure on Tue Apr 16 08:49:48 2002, using kdoc 2.0a53.