kio Library API Documentation

krun.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
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   // BIC merge with method above, using tempFiles=false
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   // BIC merge with method above, using runExecutables=true
00212   static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00213   // BIC merge with method above, using tempFiles=false
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   // BIC merge with method above, using tempFiles=false
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   // BIC merge with method above, using tempFiles=false
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 
00297 signals:
00302   void finished();
00307   void error();
00308 
00309 protected slots:
00310   void slotTimeout();
00311   void slotScanFinished( KIO::Job * );
00312   void slotScanMimeType( KIO::Job *, const QString &type );
00313   virtual void slotStatResult( KIO::Job * );
00314 
00315 protected:
00316   virtual void init();
00317 
00318   virtual void scanFile();
00319 
00325   virtual void foundMimeType( const QString& _type );
00326 
00327   virtual void killJob();
00328 
00329   KURL m_strURL;
00330   bool m_bFault;
00331   bool m_bAutoDelete;
00332   bool m_bProgressInfo;
00333   bool m_bFinished;
00334   KIO::Job * m_job;
00335   QTimer m_timer;
00336 
00341   bool m_bScanFile;
00342   bool m_bIsDirectory;
00343 
00348   bool m_bInit;
00349 
00350   bool m_bIsLocalFile;
00351   mode_t m_mode;
00352 
00353 protected:
00354   virtual void virtual_hook( int id, void* data );
00355 
00356 private:
00357   void init (const KURL& url, QWidget* window, mode_t mode,
00358              bool isLocalFile, bool showProgressInfo);
00359 private:
00360   class KRunPrivate;
00361   KRunPrivate *d;
00362 };
00363 
00364 #ifndef KDE_NO_COMPAT
00365 
00371 class KDE_DEPRECATED KOpenWithHandler
00372 {
00373 public:
00374   KOpenWithHandler() {}
00375   static bool exists() { return true; }
00376 };
00377 #endif
00378 
00385 class KProcessRunner : public QObject
00386 {
00387   Q_OBJECT
00388 
00389   public:
00390 
00391     static pid_t run(KProcess *, const QString & binName);
00392 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00393     static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00394 #endif
00395 
00396     virtual ~KProcessRunner();
00397 
00398     pid_t pid() const;
00399 
00400   protected slots:
00401 
00402     void slotProcessExited(KProcess *);
00403 
00404   private:
00405 
00406     KProcessRunner(KProcess *, const QString & binName);
00407 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00408     KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00409 #endif
00410     KProcessRunner();
00411 
00412     KProcess * process_;
00413     QString binName;
00414 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00415     KStartupInfoId id_;
00416 #endif
00417 };
00418 
00419 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Apr 21 18:43:47 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003