00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __k_run_h__
00022 #define __k_run_h__
00023
00024 #include <sys/stat.h>
00025 #include <sys/types.h>
00026
00027 #include <qobject.h>
00028 #include <qtimer.h>
00029 #include <qstring.h>
00030 #include <kurl.h>
00031 #include <kstartupinfo.h>
00032
00033 class KProcess;
00034 class KService;
00035 namespace KIO {
00036 class Job;
00037 class StatJob;
00038 }
00039
00058 class KIO_EXPORT 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
00112 KRun( const KURL& url, QWidget* window, mode_t mode = 0,
00113 bool isLocalFile = false, bool showProgressInfo = true );
00114 KRun( const KURL& url, QWidget* window, const QCString& asn, mode_t mode = 0,
00115 bool isLocalFile = false, bool showProgressInfo = true );
00116
00121 virtual ~KRun();
00122
00129 void abort();
00130
00136 bool hasError() const { return m_bFault; }
00137
00143 bool hasFinished() const { return m_bFinished; }
00144
00152 bool autoDelete() const { return m_bAutoDelete; }
00153
00162 void setAutoDelete(bool b) { m_bAutoDelete = b; }
00163
00172 void setPreferredService( const QString& desktopEntryName );
00173
00181 void setRunExecutables(bool b);
00182
00190 void setEnableExternalBrowser(bool b);
00191
00200 void setSuggestedFileName( const QString& fileName );
00201
00214 static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles = false );
00215 static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window,
00216 const QCString& asn, bool tempFiles = false );
00227
00228 static pid_t run( const KService& _service, const KURL::List& _urls, bool tempFiles );
00229 static pid_t run( const KService& _service, const KURL::List& _urls );
00232 static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles, const QString& suggestedFileName );
00233 static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window,
00234 const QCString& asn, bool tempFiles, const QString& suggestedFileName );
00235
00249 static pid_t run( const QString& _exec, const KURL::List& _urls,
00250 const QString& _name = QString::null,
00251 const QString& _icon = QString::null,
00252 const QString& _obsolete1 = QString::null,
00253 const QString& _obsolete2 = QString::null );
00254
00270
00271
00272
00273 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
00274 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00275 static pid_t runURL( const KURL& _url, const QString& _mimetype );
00278 static pid_t runURL( const KURL& _url, const QString& _mimetype, QWidget* window, const QCString& asn, bool tempFile, bool runExecutables, const QString& suggestedFileName );
00279 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables, const QString& suggestedFileName );
00280
00295 static pid_t runCommand( QString cmd );
00296
00308 static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
00309 static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon,
00310 QWidget* window, const QCString& asn );
00311
00319
00320 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
00321 static bool displayOpenWithDialog( const KURL::List& lst );
00324 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles, const QString& suggestedFileName );
00325
00330 static void shellQuote( QString &_str );
00331
00346 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00347 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00350 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles, const QString& suggestedFileName);
00351
00360 static QString binaryName( const QString & execLine, bool removePath );
00361
00367 static bool isExecutable( const QString& serviceType );
00368
00382 static bool isExecutableFile( const KURL& url, const QString &mimetype );
00383
00388 static bool checkStartupNotify( const QString& binName, const KService* service, bool* silent_arg, QCString* wmclass_arg );
00389
00390 signals:
00395 void finished();
00400 void error();
00401
00402 protected slots:
00403 void slotTimeout();
00404 void slotScanFinished( KIO::Job * );
00405 void slotScanMimeType( KIO::Job *, const QString &type );
00406 virtual void slotStatResult( KIO::Job * );
00407
00408 protected:
00409 virtual void init();
00410
00411 virtual void scanFile();
00412
00418 virtual void foundMimeType( const QString& _type );
00419
00420 virtual void killJob();
00421
00422 KURL m_strURL;
00423 bool m_bFault;
00424 bool m_bAutoDelete;
00425 bool m_bProgressInfo;
00426 bool m_bFinished;
00427 KIO::Job * m_job;
00428 QTimer m_timer;
00429
00434 bool m_bScanFile;
00435 bool m_bIsDirectory;
00436
00441 bool m_bInit;
00442
00443 bool m_bIsLocalFile;
00444 mode_t m_mode;
00445
00446 protected:
00447 virtual void virtual_hook( int id, void* data );
00448
00449 private:
00450 void init (const KURL& url, QWidget* window, const QCString& asn, mode_t mode,
00451 bool isLocalFile, bool showProgressInfo);
00452 private:
00453 class KRunPrivate;
00454 KRunPrivate *d;
00455 };
00456
00457 #ifndef KDE_NO_COMPAT
00458
00464 class KIO_EXPORT_DEPRECATED KOpenWithHandler
00465 {
00466 public:
00467 KOpenWithHandler() {}
00468 static bool exists() { return true; }
00469 };
00470 #endif
00471
00478 class KIO_EXPORT KProcessRunner : public QObject
00479 {
00480 Q_OBJECT
00481
00482 public:
00483
00484 static pid_t run(KProcess *, const QString & binName);
00485 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00486 static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00487 #endif
00488
00489 virtual ~KProcessRunner();
00490
00491 pid_t pid() const;
00492
00493 protected slots:
00494
00495 void slotProcessExited(KProcess *);
00496
00497 private:
00498
00499 KProcessRunner(KProcess *, const QString & binName);
00500 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00501 KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00502 #endif
00503 KProcessRunner();
00504
00505 KProcess * process_;
00506 QString binName;
00507 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00508 KStartupInfoId id_;
00509 #endif
00510 };
00511
00512 #endif