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 <tqobject.h>
00028 #include <tqtimer.h>
00029 #include <tqstring.h>
00030 #include <kurl.h>
00031 #include <tdestartupinfo.h>
00032
00033 class TDEProcess;
00034 class KService;
00035 namespace TDEIO {
00036 class Job;
00037 class StatJob;
00038 }
00039
00058 class TDEIO_EXPORT KRun : public TQObject
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, TQWidget* window, mode_t mode = 0,
00113 bool isLocalFile = false, bool showProgressInfo = true );
00114 KRun( const KURL& url, TQWidget* window, const TQCString& 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 TQString& desktopEntryName );
00173
00181 void setRunExecutables(bool b);
00182
00190 void setEnableExternalBrowser(bool b);
00191
00200 void setSuggestedFileName( const TQString& fileName );
00201
00214 static pid_t run( const KService& _service, const KURL::List& _urls, TQWidget* window, bool tempFiles = false );
00215 static pid_t run( const KService& _service, const KURL::List& _urls, TQWidget* window,
00216 const TQCString& 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, TQWidget* window, bool tempFiles, const TQString& suggestedFileName );
00233 static pid_t run( const KService& _service, const KURL::List& _urls, TQWidget* window,
00234 const TQCString& asn, bool tempFiles, const TQString& suggestedFileName );
00235
00249 static pid_t run( const TQString& _exec, const KURL::List& _urls,
00250 const TQString& _name = TQString::null,
00251 const TQString& _icon = TQString::null,
00252 const TQString& _obsolete1 = TQString::null,
00253 const TQString& _obsolete2 = TQString::null );
00254
00270
00271
00272
00273 static pid_t runURL( const KURL& _url, const TQString& _mimetype, bool tempFile, bool runExecutables);
00274 static pid_t runURL( const KURL& _url, const TQString& _mimetype, bool tempFile);
00275 static pid_t runURL( const KURL& _url, const TQString& _mimetype );
00278 static pid_t runURL( const KURL& _url, const TQString& _mimetype, TQWidget* window, const TQCString& asn, bool tempFile, bool runExecutables, const TQString& suggestedFileName );
00279 static pid_t runURL( const KURL& _url, const TQString& _mimetype, bool tempFile, bool runExecutables, const TQString& suggestedFileName );
00280
00295 static pid_t runCommand( TQString cmd );
00296
00308 static pid_t runCommand( const TQString& cmd, const TQString & execName, const TQString & icon );
00309 static pid_t runCommand( const TQString& cmd, const TQString & execName, const TQString & icon,
00310 TQWidget* window, const TQCString& 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 TQString& suggestedFileName );
00325
00330 static void shellQuote( TQString &_str );
00331
00346 static TQStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00347 static TQStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00350 static TQStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles, const TQString& suggestedFileName);
00351
00360 static TQString binaryName( const TQString & execLine, bool removePath );
00361
00367 static bool isExecutable( const TQString& serviceType );
00368
00382 static bool isExecutableFile( const KURL& url, const TQString &mimetype );
00383
00388 static bool checkStartupNotify( const TQString& binName, const KService* service, bool* silent_arg, TQCString* wmclass_arg );
00389
00390 signals:
00395 void finished();
00400 void error();
00401
00402 protected slots:
00403 void slotTimeout();
00404 void slotScanFinished( TDEIO::Job * );
00405 void slotScanMimeType( TDEIO::Job *, const TQString &type );
00406 virtual void slotStatResult( TDEIO::Job * );
00407
00408 protected:
00409 virtual void init();
00410
00411 virtual void scanFile();
00412
00418 virtual void foundMimeType( const TQString& _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 TDEIO::Job * m_job;
00428 TQTimer 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, TQWidget* window, const TQCString& 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 TDEIO_EXPORT_DEPRECATED KOpenWithHandler
00465 {
00466 public:
00467 KOpenWithHandler() {}
00468 static bool exists() { return true; }
00469 };
00470 #endif
00471
00478 class TDEIO_EXPORT TDEProcessRunner : public TQObject
00479 {
00480 Q_OBJECT
00481
00482 public:
00483
00484 static pid_t run(TDEProcess *, const TQString & binName);
00485 #ifdef Q_WS_X11 // We don't have TDEStartupInfo in Qt/Embedded
00486 static pid_t run(TDEProcess *, const TQString & binName, const TDEStartupInfoId& id );
00487 #endif
00488
00489 virtual ~TDEProcessRunner();
00490
00491 pid_t pid() const;
00492
00493 protected slots:
00494
00495 void slotProcessExited(TDEProcess *);
00496
00497 private:
00498
00499 TDEProcessRunner(TDEProcess *, const TQString & binName);
00500 #ifdef Q_WS_X11 // We don't have TDEStartupInfo in Qt/Embedded
00501 TDEProcessRunner(TDEProcess *, const TQString & binName, const TDEStartupInfoId& id );
00502 #endif
00503 TDEProcessRunner();
00504
00505 TDEProcess * process_;
00506 TQString binName;
00507 #ifdef Q_WS_X11 // We don't have TDEStartupInfo in Qt/Embedded
00508 TDEStartupInfoId id_;
00509 #endif
00510 };
00511
00512 #endif