krun.h
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
Copyright (C) 2006 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __k_run_h__
#define __k_run_h__
#include <sys/stat.h>
#include <sys/types.h>
#include <qobject.h>
#include <qtimer.h>
#include <qstring.h>
#include <kurl.h>
#include <kstartupinfo.h>
class KProcess;
class KService;
namespace KIO {
class Job;
class StatJob;
}
class KIO_EXPORT KRun : public QObject
{
Q_OBJECT
public:
KRun( const KURL& url, mode_t mode = 0,
bool isLocalFile = false, bool showProgressInfo = true );
KRun( const KURL& url, QWidget* window, mode_t mode = 0,
bool isLocalFile = false, bool showProgressInfo = true );
virtual ~KRun();
void abort();
bool hasError() const { return m_bFault; }
bool hasFinished() const { return m_bFinished; }
bool autoDelete() const { return m_bAutoDelete; }
void setAutoDelete(bool b) { m_bAutoDelete = b; }
void setPreferredService( const QString& desktopEntryName );
void setRunExecutables(bool b);
void setEnableExternalBrowser(bool b);
void setSuggestedFileName( const QString& fileName );
static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles = false );
// BIC merge second overload with first one, using tempFiles=false
static pid_t run( const KService& _service, const KURL::List& _urls, bool tempFiles );
static pid_t run( const KService& _service, const KURL::List& _urls );
static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles, const QString& suggestedFileName );
static 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 );
// BIC Merge second overload with first one using runExecutables=true, and
// merge third overload with first one as well using tempFiles=false and
// runExecutables=true
static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
static pid_t runURL( const KURL& _url, const QString& _mimetype );
static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables, const QString& suggestedFileName );
static pid_t runCommand( QString cmd );
static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
// BIC merge second overload with first one, using tempFiles=false
static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
static bool displayOpenWithDialog( const KURL::List& lst );
static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles, const QString& suggestedFileName );
static void shellQuote( QString &_str );
static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles, const QString& suggestedFileName);
static QString binaryName( const QString & execLine, bool removePath );
static bool isExecutable( const QString& serviceType );
static bool isExecutableFile( const KURL& url, const QString &mimetype );
static bool checkStartupNotify( const QString& binName, const KService* service, bool* silent_arg, QCString* wmclass_arg );
signals:
void finished();
void error();
protected slots:
void slotTimeout();
void slotScanFinished( KIO::Job * );
void slotScanMimeType( KIO::Job *, const QString &type );
virtual void slotStatResult( KIO::Job * );
protected:
virtual void init();
virtual void scanFile();
virtual void foundMimeType( const QString& _type );
virtual void killJob();
KURL m_strURL;
bool m_bFault;
bool m_bAutoDelete;
bool m_bProgressInfo;
bool m_bFinished;
KIO::Job * m_job;
QTimer m_timer;
bool m_bScanFile;
bool m_bIsDirectory;
bool m_bInit;
bool m_bIsLocalFile;
mode_t m_mode;
protected:
virtual void virtual_hook( int id, void* data );
private:
void init (const KURL& url, QWidget* window, mode_t mode,
bool isLocalFile, bool showProgressInfo);
private:
class KRunPrivate;
KRunPrivate *d;
};
#ifndef KDE_NO_COMPAT
class KIO_EXPORT_DEPRECATED KOpenWithHandler
{
public:
KOpenWithHandler() {}
static bool exists() { return true; }
};
#endif
class KIO_EXPORT KProcessRunner : public QObject
{
Q_OBJECT
public:
static pid_t run(KProcess *, const QString & binName);
#ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
#endif
virtual ~KProcessRunner();
pid_t pid() const;
protected slots:
void slotProcessExited(KProcess *);
private:
KProcessRunner(KProcess *, const QString & binName);
#ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
#endif
KProcessRunner();
KProcess * process_;
QString binName;
#ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
KStartupInfoId id_;
#endif
};
#endif
KService
Represent a service, i.e.
Definition: kservice.h:48
KRun::hasError
bool hasError() const
Returns true if the KRun instance has an error.
Definition: krun.h:134
KRun
To open files with their associated applications in KDE, use KRun.
Definition: krun.h:58
KRun::autoDelete
bool autoDelete() const
Checks whether auto delete is activated.
Definition: krun.h:150
KRun::setAutoDelete
void setAutoDelete(bool b)
Enables or disabled auto deletion.
Definition: krun.h:160
KRun::m_bScanFile
bool m_bScanFile
Used to indicate that the next action is to scan the file.
Definition: krun.h:425
KIO::Job
The base class for all jobs.
Definition: jobclasses.h:68
KRun::m_bInit
bool m_bInit
USed to indicate that the next action is to initialize.
Definition: krun.h:432
KOpenWithHandler
Definition: krun.h:455
KRun::hasFinished
bool hasFinished() const
Returns true if the KRun instance has finished.
Definition: krun.h:141

KDE Home | KDE Accessibility Home | Description of Access Keys