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
00173 static pid_t run( const KService& _service, const KURL::List& _urls, bool tempFiles );
00174
00175 static pid_t run( const KService& _service, const KURL::List& _urls );
00176
00189 static pid_t run( const QString& _exec, const KURL::List& _urls,
00190 const QString& _name = QString::null,
00191 const QString& _icon = QString::null,
00192 const QString& _obsolete1 = QString::null,
00193 const QString& _obsolete2 = QString::null );
00194
00210 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
00211
00212 static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00213
00214 static pid_t runURL( const KURL& _url, const QString& _mimetype );
00215
00230 static pid_t runCommand( QString cmd );
00231
00243 static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
00244
00252 static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
00253
00254 static bool displayOpenWithDialog( const KURL::List& lst );
00255
00260 static void shellQuote( QString &_str );
00261
00276 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00277
00278 static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00279
00288 static QString binaryName( const QString & execLine, bool removePath );
00289
00295 static bool isExecutable( const QString& serviceType );
00296
00310 static bool isExecutableFile( const KURL& url, const QString &mimetype );
00311
00312 signals:
00317 void finished();
00322 void error();
00323
00324 protected slots:
00325 void slotTimeout();
00326 void slotScanFinished( KIO::Job * );
00327 void slotScanMimeType( KIO::Job *, const QString &type );
00328 virtual void slotStatResult( KIO::Job * );
00329
00330 protected:
00331 virtual void init();
00332
00333 virtual void scanFile();
00334
00340 virtual void foundMimeType( const QString& _type );
00341
00342 virtual void killJob();
00343
00344 KURL m_strURL;
00345 bool m_bFault;
00346 bool m_bAutoDelete;
00347 bool m_bProgressInfo;
00348 bool m_bFinished;
00349 KIO::Job * m_job;
00350 QTimer m_timer;
00351
00356 bool m_bScanFile;
00357 bool m_bIsDirectory;
00358
00363 bool m_bInit;
00364
00365 bool m_bIsLocalFile;
00366 mode_t m_mode;
00367
00368 protected:
00369 virtual void virtual_hook( int id, void* data );
00370
00371 private:
00372 void init (const KURL& url, QWidget* window, mode_t mode,
00373 bool isLocalFile, bool showProgressInfo);
00374 private:
00375 class KRunPrivate;
00376 KRunPrivate *d;
00377 };
00378
00379 #ifndef KDE_NO_COMPAT
00380
00386 class KDE_DEPRECATED KOpenWithHandler
00387 {
00388 public:
00389 KOpenWithHandler() {}
00390 static bool exists() { return true; }
00391 };
00392 #endif
00393
00400 class KProcessRunner : public QObject
00401 {
00402 Q_OBJECT
00403
00404 public:
00405
00406 static pid_t run(KProcess *, const QString & binName);
00407 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00408 static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00409 #endif
00410
00411 virtual ~KProcessRunner();
00412
00413 pid_t pid() const;
00414
00415 protected slots:
00416
00417 void slotProcessExited(KProcess *);
00418
00419 private:
00420
00421 KProcessRunner(KProcess *, const QString & binName);
00422 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00423 KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00424 #endif
00425 KProcessRunner();
00426
00427 KProcess * process_;
00428 QString binName;
00429 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00430 KStartupInfoId id_;
00431 #endif
00432 };
00433
00434 #endif
This file is part of the documentation for kio Library Version 3.3.0.