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
00119 virtual ~KRun();
00120
00127 void abort();
00128
00134 bool hasError() const { return m_bFault; }
00135
00141 bool hasFinished() const { return m_bFinished; }
00142
00150 bool autoDelete() const { return m_bAutoDelete; }
00151
00160 void setAutoDelete(bool b) { m_bAutoDelete = b; }
00161
00170 void setPreferredService( const QString& desktopEntryName );
00171
00179 void setRunExecutables(bool b);
00180
00188 void setEnableExternalBrowser(bool b);
00189
00198 void setSuggestedFileName( const QString& fileName );
00199
00212 static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles = false );
00223
00224 static pid_t run( const KService& _service, const KURL::List& _urls, bool tempFiles );
00225 static pid_t run( const KService& _service, const KURL::List& _urls );
00228 static pid_t run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles, const QString& suggestedFileName );
00229
00243 static pid_t run( const QString& _exec, const KURL::List& _urls,
00244 const QString& _name = QString::null,
00245 const QString& _icon = QString::null,
00246 const QString& _obsolete1 = QString::null,
00247 const QString& _obsolete2 = QString::null );
00248
00264
00265
00266
00267 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
00268 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00269 static pid_t runURL( const KURL& _url, const QString& _mimetype );
00272 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables, const QString& suggestedFileName );
00273
00288 static pid_t runCommand( QString cmd );
00289
00301 static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
00302
00310
00311 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
00312 static bool displayOpenWithDialog( const KURL::List& lst );
00315 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles, const QString& suggestedFileName );
00316
00321 static void shellQuote( QString &_str );
00322
00337 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00338 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00341 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles, const QString& suggestedFileName);
00342
00351 static QString binaryName( const QString & execLine, bool removePath );
00352
00358 static bool isExecutable( const QString& serviceType );
00359
00373 static bool isExecutableFile( const KURL& url, const QString &mimetype );
00374
00379 static bool checkStartupNotify( const QString& binName, const KService* service, bool* silent_arg, QCString* wmclass_arg );
00380
00381 signals:
00386 void finished();
00391 void error();
00392
00393 protected slots:
00394 void slotTimeout();
00395 void slotScanFinished( KIO::Job * );
00396 void slotScanMimeType( KIO::Job *, const QString &type );
00397 virtual void slotStatResult( KIO::Job * );
00398
00399 protected:
00400 virtual void init();
00401
00402 virtual void scanFile();
00403
00409 virtual void foundMimeType( const QString& _type );
00410
00411 virtual void killJob();
00412
00413 KURL m_strURL;
00414 bool m_bFault;
00415 bool m_bAutoDelete;
00416 bool m_bProgressInfo;
00417 bool m_bFinished;
00418 KIO::Job * m_job;
00419 QTimer m_timer;
00420
00425 bool m_bScanFile;
00426 bool m_bIsDirectory;
00427
00432 bool m_bInit;
00433
00434 bool m_bIsLocalFile;
00435 mode_t m_mode;
00436
00437 protected:
00438 virtual void virtual_hook( int id, void* data );
00439
00440 private:
00441 void init (const KURL& url, QWidget* window, mode_t mode,
00442 bool isLocalFile, bool showProgressInfo);
00443 private:
00444 class KRunPrivate;
00445 KRunPrivate *d;
00446 };
00447
00448 #ifndef KDE_NO_COMPAT
00449
00455 class KIO_EXPORT_DEPRECATED KOpenWithHandler
00456 {
00457 public:
00458 KOpenWithHandler() {}
00459 static bool exists() { return true; }
00460 };
00461 #endif
00462
00469 class KIO_EXPORT KProcessRunner : public QObject
00470 {
00471 Q_OBJECT
00472
00473 public:
00474
00475 static pid_t run(KProcess *, const QString & binName);
00476 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00477 static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00478 #endif
00479
00480 virtual ~KProcessRunner();
00481
00482 pid_t pid() const;
00483
00484 protected slots:
00485
00486 void slotProcessExited(KProcess *);
00487
00488 private:
00489
00490 KProcessRunner(KProcess *, const QString & binName);
00491 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00492 KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00493 #endif
00494 KProcessRunner();
00495
00496 KProcess * process_;
00497 QString binName;
00498 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00499 KStartupInfoId id_;
00500 #endif
00501 };
00502
00503 #endif