00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#ifndef __k_run_h__
00021
#define __k_run_h__
00022
00023
#include <sys/stat.h>
00024
#include <sys/types.h>
00025
00026
#include <qobject.h>
00027
#include <qtimer.h>
00028
#include <qstring.h>
00029
#include <kurl.h>
00030
#include <kstartupinfo.h>
00031
00032
class KProcess;
00033
class KService;
00034
namespace KIO {
00035
class Job;
00036
class StatJob;
00037 }
00038
00057 class KIO_EXPORT KRun :
public QObject
00058 {
00059 Q_OBJECT
00060
public:
00084 KRun(
const KURL& url, mode_t mode = 0,
00085
bool isLocalFile =
false,
bool showProgressInfo =
true );
00086
00111 KRun(
const KURL& url,
QWidget* window, mode_t mode = 0,
00112
bool isLocalFile =
false,
bool showProgressInfo =
true );
00113
00118
virtual ~KRun();
00119
00126
void abort();
00127
00133 bool hasError()
const {
return m_bFault; }
00134
00140 bool hasFinished()
const {
return m_bFinished; }
00141
00149 bool autoDelete()
const {
return m_bAutoDelete; }
00150
00159 void setAutoDelete(
bool b) { m_bAutoDelete = b; }
00160
00169
void setPreferredService(
const QString& desktopEntryName );
00170
00178
void setRunExecutables(
bool b);
00179
00187
void setEnableExternalBrowser(
bool b);
00188
00199
00200
static pid_t run(
const KService& _service,
const KURL::List& _urls,
bool tempFiles );
00201
static pid_t run(
const KService& _service,
const KURL::List& _urls );
00202
00215
static pid_t run(
const QString& _exec,
const KURL::List& _urls,
00216
const QString& _name = QString::null,
00217
const QString& _icon = QString::null,
00218
const QString& _obsolete1 = QString::null,
00219
const QString& _obsolete2 = QString::null );
00220
00236
00237
00238
00239
static pid_t runURL(
const KURL& _url,
const QString& _mimetype,
bool tempFile,
bool runExecutables);
00240
static pid_t runURL(
const KURL& _url,
const QString& _mimetype,
bool tempFile);
00241
static pid_t runURL(
const KURL& _url,
const QString& _mimetype );
00242
00257
static pid_t runCommand(
QString cmd );
00258
00270
static pid_t runCommand(
const QString& cmd,
const QString & execName,
const QString & icon );
00271
00279
00280
static bool displayOpenWithDialog(
const KURL::List& lst,
bool tempFiles );
00281
static bool displayOpenWithDialog(
const KURL::List& lst );
00282
00287
static void shellQuote(
QString &_str );
00288
00303
00304
static QStringList processDesktopExec(
const KService &_service,
const KURL::List &_urls,
bool has_shell,
bool tempFiles);
00305
static QStringList processDesktopExec(
const KService &_service,
const KURL::List &_urls,
bool has_shell);
00306
00315
static QString binaryName(
const QString & execLine,
bool removePath );
00316
00322
static bool isExecutable(
const QString& serviceType );
00323
00337
static bool isExecutableFile(
const KURL& url,
const QString &mimetype );
00338
00343
static bool checkStartupNotify(
const QString& binName,
const KService* service,
bool* silent_arg,
QCString* wmclass_arg );
00344
00345 signals:
00350
void finished();
00355
void error();
00356
00357
protected slots:
00358
void slotTimeout();
00359
void slotScanFinished(
KIO::Job * );
00360
void slotScanMimeType(
KIO::Job *,
const QString &type );
00361
virtual void slotStatResult(
KIO::Job * );
00362
00363
protected:
00364
virtual void init();
00365
00366
virtual void scanFile();
00367
00373
virtual void foundMimeType(
const QString& _type );
00374
00375
virtual void killJob();
00376
00377
KURL m_strURL;
00378
bool m_bFault;
00379
bool m_bAutoDelete;
00380
bool m_bProgressInfo;
00381
bool m_bFinished;
00382
KIO::Job * m_job;
00383
QTimer m_timer;
00384
00389 bool m_bScanFile;
00390
bool m_bIsDirectory;
00391
00396 bool m_bInit;
00397
00398
bool m_bIsLocalFile;
00399 mode_t m_mode;
00400
00401
protected:
00402
virtual void virtual_hook(
int id,
void* data );
00403
00404
private:
00405
void init (
const KURL& url,
QWidget* window, mode_t mode,
00406
bool isLocalFile,
bool showProgressInfo);
00407
private:
00408
class KRunPrivate;
00409 KRunPrivate *d;
00410 };
00411
00412
#ifndef KDE_NO_COMPAT
00413
00419 class KIO_EXPORT_DEPRECATED KOpenWithHandler
00420 {
00421
public:
00422 KOpenWithHandler() {}
00423
static bool exists() {
return true; }
00424 };
00425
#endif
00426
00433
class KIO_EXPORT KProcessRunner :
public QObject
00434 {
00435 Q_OBJECT
00436
00437
public:
00438
00439
static pid_t run(
KProcess *,
const QString & binName);
00440
#ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00441
static pid_t run(
KProcess *,
const QString & binName,
const KStartupInfoId&
id );
00442
#endif
00443
00444
virtual ~KProcessRunner();
00445
00446 pid_t pid() const;
00447
00448 protected slots:
00449
00450
void slotProcessExited(
KProcess *);
00451
00452 private:
00453
00454 KProcessRunner(KProcess *, const
QString & binName);
00455 #ifdef Q_WS_X11
00456 KProcessRunner(KProcess *, const
QString & binName, const
KStartupInfoId&
id );
00457 #endif
00458 KProcessRunner();
00459
00460 KProcess * process_;
00461
QString binName;
00462 #ifdef Q_WS_X11
00463
KStartupInfoId id_;
00464 #endif
00465 };
00466
00467 #endif