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 
00032 class KProcess;
00033 class KService;
00034 namespace KIO {
00035    class Job;
00036    class StatJob;
00037 }
00038 
00057 class KIO_EXPORT KRun : public QObject
00058 {
00059   Q_OBJECT
00060 public:
00084   KRun( const KURL& url, mode_t mode = 0,
00085     bool isLocalFile = false, bool showProgressInfo = true );
00086 
00094   KRun( const KURL& url, QWidget* window, mode_t mode = 0,
00095     bool isLocalFile = false, bool showProgressInfo = true );
00096 
00101   virtual ~KRun();
00102 
00109   void abort();
00110 
00116   bool hasError() const { return m_bFault; }
00117 
00123   bool hasFinished() const { return m_bFinished; }
00124 
00132   bool autoDelete() const { return m_bAutoDelete; }
00133 
00142   void setAutoDelete(bool b) { m_bAutoDelete = b; }
00143 
00152   void setPreferredService( const QString& desktopEntryName );
00153 
00160   void setRunExecutables(bool b);
00161 
00168   void setEnableExternalBrowser(bool b);
00169 
00180   static pid_t run( const KService& _service, const KURL::List& _urls, bool tempFiles );
00181   // BIC merge with method above, using tempFiles=false
00182   static pid_t run( const KService& _service, const KURL::List& _urls );
00183 
00196   static pid_t run( const QString& _exec, const KURL::List& _urls,
00197            const QString& _name = QString::null,
00198            const QString& _icon = QString::null,
00199            const QString& _obsolete1 = QString::null,
00200            const QString& _obsolete2 = QString::null );
00201 
00217   static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile, bool runExecutables);
00218   // BIC merge with method above, using runExecutables=true
00219   static pid_t runURL( const KURL& _url, const QString& _mimetype, bool tempFile);
00220   // BIC merge with method above, using tempFiles=false
00221   static pid_t runURL( const KURL& _url, const QString& _mimetype );
00222 
00237   static pid_t runCommand( QString cmd );
00238 
00250   static pid_t runCommand( const QString& cmd, const QString & execName, const QString & icon );
00251 
00259   static bool displayOpenWithDialog( const KURL::List& lst, bool tempFiles );
00260   // BIC merge with method above, using tempFiles=false
00261   static bool displayOpenWithDialog( const KURL::List& lst );
00262 
00267   static void shellQuote( QString &_str );
00268 
00283   static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles);
00284   // BIC merge with method above, using tempFiles=false
00285   static QStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell);
00286 
00295   static QString binaryName( const QString & execLine, bool removePath );
00296 
00302   static bool isExecutable( const QString& serviceType );
00303 
00317    static bool isExecutableFile( const KURL& url, const QString &mimetype );
00318 
00319 signals:
00324   void finished();
00329   void error();
00330 
00331 protected slots:
00332   void slotTimeout();
00333   void slotScanFinished( KIO::Job * );
00334   void slotScanMimeType( KIO::Job *, const QString &type );
00335   virtual void slotStatResult( KIO::Job * );
00336 
00337 protected:
00338   virtual void init();
00339 
00340   virtual void scanFile();
00341 
00347   virtual void foundMimeType( const QString& _type );
00348 
00349   virtual void killJob();
00350 
00351   KURL m_strURL;
00352   bool m_bFault;
00353   bool m_bAutoDelete;
00354   bool m_bProgressInfo;
00355   bool m_bFinished;
00356   KIO::Job * m_job;
00357   QTimer m_timer;
00358 
00363   bool m_bScanFile;
00364   bool m_bIsDirectory;
00365 
00370   bool m_bInit;
00371 
00372   bool m_bIsLocalFile;
00373   mode_t m_mode;
00374 
00375 protected:
00376   virtual void virtual_hook( int id, void* data );
00377 
00378 private:
00379   void init (const KURL& url, QWidget* window, mode_t mode,
00380              bool isLocalFile, bool showProgressInfo);
00381 private:
00382   class KRunPrivate;
00383   KRunPrivate *d;
00384 };
00385 
00386 #ifndef KDE_NO_COMPAT
00387 
00393 class KIO_EXPORT_DEPRECATED KOpenWithHandler
00394 {
00395 public:
00396   KOpenWithHandler() {}
00397   static bool exists() { return true; }
00398 };
00399 #endif
00400 
00407 class KIO_EXPORT KProcessRunner : public QObject
00408 {
00409   Q_OBJECT
00410 
00411   public:
00412 
00413     static pid_t run(KProcess *, const QString & binName);
00414 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00415     static pid_t run(KProcess *, const QString & binName, const KStartupInfoId& id );
00416 #endif
00417 
00418     virtual ~KProcessRunner();
00419 
00420     pid_t pid() const;
00421 
00422   protected slots:
00423 
00424     void slotProcessExited(KProcess *);
00425 
00426   private:
00427 
00428     KProcessRunner(KProcess *, const QString & binName);
00429 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00430     KProcessRunner(KProcess *, const QString & binName, const KStartupInfoId& id );
00431 #endif
00432     KProcessRunner();
00433 
00434     KProcess * process_;
00435     QString binName;
00436 #ifdef Q_WS_X11 // We don't have KStartupInfo in Qt/Embedded
00437     KStartupInfoId id_;
00438 #endif
00439 };
00440 
00441 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:15:30 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003