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
00216 static pid_t run( const QString& _exec, const KURL::List& _urls,
00217 const QString& _name = QString::null,
00218 const QString& _icon = QString::null,
00219 const QString& _obsolete1 = QString::null,
00220 const QString& _obsolete2 = QString::null );
00221
00237
00238
00239
00240 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
00241 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00242 static pid_t runURL( const KURL& _url, const QString& _mimetype );
00243
00258 static pid_t runCommand( QString cmd );
00259
00271 static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
00272
00280
00281 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
00282 static bool displayOpenWithDialog( const KURL::List& lst );
00283
00288 static void shellQuote( QString &_str );
00289
00304
00305 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00306 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00307
00316 static QString binaryName( const QString & execLine, bool removePath );
00317
00323 static bool isExecutable( const QString& serviceType );
00324
00338 static bool isExecutableFile( const KURL& url, const QString &mimetype );
00339
00344 static bool checkStartupNotify( const QString& binName, const KService* service, bool* silent_arg, QCString* wmclass_arg );
00345
00346 signals:
00351 void finished();
00356 void error();
00357
00358 protected slots:
00359 void slotTimeout();
00360 void slotScanFinished( KIO::Job * );
00361 void slotScanMimeType( KIO::Job *, const QString &type );
00362 virtual void slotStatResult( KIO::Job * );
00363
00364 protected:
00365 virtual void init();
00366
00367 virtual void scanFile();
00368
00374 virtual void foundMimeType( const QString& _type );
00375
00376 virtual void killJob();
00377
00378 KURL m_strURL;
00379 bool m_bFault;
00380 bool m_bAutoDelete;
00381 bool m_bProgressInfo;
00382 bool m_bFinished;
00383 KIO::Job * m_job;
00384 QTimer m_timer;
00385
00390 bool m_bScanFile;
00391 bool m_bIsDirectory;
00392
00397 bool m_bInit;
00398
00399 bool m_bIsLocalFile;
00400 mode_t m_mode;
00401
00402 protected:
00403 virtual void virtual_hook( int id, void* data );
00404
00405 private:
00406 void init (const KURL& url, QWidget* window, mode_t mode,
00407 bool isLocalFile, bool showProgressInfo);
00408 private:
00409 class KRunPrivate;
00410 KRunPrivate *d;
00411 };
00412
00413 #ifndef KDE_NO_COMPAT
00414
00420 class KIO_EXPORT_DEPRECATED KOpenWithHandler
00421 {
00422 public:
00423 KOpenWithHandler() {}
00424 static bool exists() { return true; }
00425 };
00426 #endif
00427
00434 class KIO_EXPORT KProcessRunner : public QObject
00435 {
00436 Q_OBJECT
00437
00438 public:
00439
00440 static pid_t run(KProcess *, const QString & binName);
00441 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00442 static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00443 #endif
00444
00445 virtual ~KProcessRunner();
00446
00447 pid_t pid() const;
00448
00449 protected slots:
00450
00451 void slotProcessExited(KProcess *);
00452
00453 private:
00454
00455 KProcessRunner(KProcess *, const QString & binName);
00456 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00457 KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00458 #endif
00459 KProcessRunner();
00460
00461 KProcess * process_;
00462 QString binName;
00463 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00464 KStartupInfoId id_;
00465 #endif
00466 };
00467
00468 #endif