krun.h
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 #include <kdemacros.h>
00032
00033 class KProcess;
00034 class KService;
00035 namespace KIO {
00036 class Job;
00037 class StatJob;
00038 }
00039
00058 class KRun : public QObject
00059 {
00060 Q_OBJECT
00061 public:
00085 KRun( const KURL& url, mode_t mode = 0,
00086 bool isLocalFile = false, bool showProgressInfo = true );
00087
00095 KRun( const KURL& url, QWidget* window, mode_t mode = 0,
00096 bool isLocalFile = false, bool showProgressInfo = true );
00097
00102 virtual ~KRun();
00103
00110 void abort();
00111
00117 bool hasError() const { return m_bFault; }
00118
00124 bool hasFinished() const { return m_bFinished; }
00125
00133 bool autoDelete() const { return m_bAutoDelete; }
00134
00143 void setAutoDelete(bool b) { m_bAutoDelete = b; }
00144
00153 void setPreferredService( const QString& desktopEntryName );
00154
00161 void setRunExecutables(bool b);
00162
00169 void setEnableExternalBrowser(bool b);
00170
00181 static pid_t run( const KService& _service, const KURL::List& _urls, bool tempFiles );
00182
00183 static pid_t run( const KService& _service, const KURL::List& _urls );
00184
00197 static pid_t run( const QString& _exec, const KURL::List& _urls,
00198 const QString& _name = QString::null,
00199 const QString& _icon = QString::null,
00200 const QString& _obsolete1 = QString::null,
00201 const QString& _obsolete2 = QString::null );
00202
00218 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
00219
00220 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00221
00222 static pid_t runURL( const KURL& _url, const QString& _mimetype );
00223
00238 static pid_t runCommand( QString cmd );
00239
00251 static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
00252
00260 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
00261
00262 static bool displayOpenWithDialog( const KURL::List& lst );
00263
00268 static void shellQuote( QString &_str );
00269
00284 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00285
00286 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00287
00296 static QString binaryName( const QString & execLine, bool removePath );
00297
00303 static bool isExecutable( const QString& serviceType );
00304
00318 static bool isExecutableFile( const KURL& url, const QString &mimetype );
00319
00320 signals:
00325 void finished();
00330 void error();
00331
00332 protected slots:
00333 void slotTimeout();
00334 void slotScanFinished( KIO::Job * );
00335 void slotScanMimeType( KIO::Job *, const QString &type );
00336 virtual void slotStatResult( KIO::Job * );
00337
00338 protected:
00339 virtual void init();
00340
00341 virtual void scanFile();
00342
00348 virtual void foundMimeType( const QString& _type );
00349
00350 virtual void killJob();
00351
00352 KURL m_strURL;
00353 bool m_bFault;
00354 bool m_bAutoDelete;
00355 bool m_bProgressInfo;
00356 bool m_bFinished;
00357 KIO::Job * m_job;
00358 QTimer m_timer;
00359
00364 bool m_bScanFile;
00365 bool m_bIsDirectory;
00366
00371 bool m_bInit;
00372
00373 bool m_bIsLocalFile;
00374 mode_t m_mode;
00375
00376 protected:
00377 virtual void virtual_hook( int id, void* data );
00378
00379 private:
00380 void init (const KURL& url, QWidget* window, mode_t mode,
00381 bool isLocalFile, bool showProgressInfo);
00382 private:
00383 class KRunPrivate;
00384 KRunPrivate *d;
00385 };
00386
00387 #ifndef KDE_NO_COMPAT
00388
00394 class KDE_DEPRECATED KOpenWithHandler
00395 {
00396 public:
00397 KOpenWithHandler() {}
00398 static bool exists() { return true; }
00399 };
00400 #endif
00401
00408 class KProcessRunner : public QObject
00409 {
00410 Q_OBJECT
00411
00412 public:
00413
00414 static pid_t run(KProcess *, const QString & binName);
00415 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00416 static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00417 #endif
00418
00419 virtual ~KProcessRunner();
00420
00421 pid_t pid() const;
00422
00423 protected slots:
00424
00425 void slotProcessExited(KProcess *);
00426
00427 private:
00428
00429 KProcessRunner(KProcess *, const QString & binName);
00430 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00431 KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00432 #endif
00433 KProcessRunner();
00434
00435 KProcess * process_;
00436 QString binName;
00437 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00438 KStartupInfoId id_;
00439 #endif
00440 };
00441
00442 #endif
This file is part of the documentation for kio Library Version 3.3.2.