KIO
krun.h
Go to the documentation of this file.
00001 // -*- mode: c++; c-basic-offset: 2 -*- 00002 /* This file is part of the KDE project 00003 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00004 Copyright (C) 2006 David Faure <faure@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KRUN_H 00023 #define KRUN_H 00024 00025 #include <kio/kio_export.h> 00026 00027 #include <QtCore/QObject> 00028 #include <QtCore/QTimer> 00029 #include <QtCore/QString> 00030 #include <sys/types.h> 00031 #include <kurl.h> 00032 00033 class KService; 00034 class KStartupInfo; 00035 class KJob; 00036 namespace KIO 00037 { 00038 class Job; 00039 } 00040 00059 class KIO_EXPORT KRun : public QObject 00060 { 00061 Q_OBJECT 00062 public: 00089 KRun(const KUrl& url, QWidget* window, mode_t mode = 0, 00090 bool isLocalFile = false, bool showProgressInfo = true, 00091 const QByteArray& asn = QByteArray()); 00092 00097 virtual ~KRun(); 00098 00105 void abort(); 00106 00112 bool hasError() const; 00113 00119 bool hasFinished() const; 00120 00128 bool autoDelete() const; 00129 00138 void setAutoDelete(bool b); 00139 00149 void setPreferredService(const QString& desktopEntryName); 00150 00157 void setRunExecutables(bool b); 00158 00165 void setEnableExternalBrowser(bool b); 00166 00174 void setSuggestedFileName(const QString& fileName); 00175 00179 QString suggestedFileName() const; 00180 00185 QWidget* window() const; 00186 00187 00201 static bool run(const KService& service, const KUrl::List& urls, QWidget* window, 00202 bool tempFiles = false, const QString& suggestedFileName = QString(), 00203 const QByteArray& asn = QByteArray()); 00204 00221 static bool run(const QString& exec, const KUrl::List& urls, QWidget* window, 00222 const QString& name = QString(), 00223 const QString& icon = QString(), 00224 const QByteArray& asn = QByteArray()); 00225 00244 static bool runUrl(const KUrl& url, const QString& mimetype, QWidget* window, 00245 bool tempFile = false , bool runExecutables = true, 00246 const QString& suggestedFileName = QString(), const QByteArray& asn = QByteArray()); 00247 00262 static bool runCommand(const QString &cmd, QWidget* window); 00263 00269 static bool runCommand(const QString &cmd, QWidget* window, const QString& workingDirectory); 00270 // TODO KDE5: merge the above with 2-args runCommand, using QString() 00271 00284 static bool runCommand(const QString& cmd, const QString & execName, 00285 const QString & icon, QWidget* window, const QByteArray& asn = QByteArray()); 00286 00294 static bool runCommand(const QString& cmd, const QString & execName, 00295 const QString & icon, QWidget* window, 00296 const QByteArray& asn, const QString& workingDirectory); 00297 // TODO KDE5: merge the above with 5-args runCommand, using QString() 00298 00309 static bool displayOpenWithDialog(const KUrl::List& lst, QWidget* window, 00310 bool tempFiles = false, const QString& suggestedFileName = QString(), 00311 const QByteArray& asn = QByteArray()); 00312 00323 #ifndef KDE_NO_DEPRECATED 00324 static KDE_DEPRECATED void shellQuote(QString &str); 00325 #endif 00326 00337 static QStringList processDesktopExec(const KService &_service, const KUrl::List &_urls, 00338 bool tempFiles = false, 00339 const QString& suggestedFileName = QString()); 00340 00348 static QString binaryName(const QString & execLine, bool removePath); 00349 00354 static bool isExecutable(const QString& serviceType); 00355 00368 static bool isExecutableFile(const KUrl& url, const QString &mimetype); 00369 00373 static bool checkStartupNotify(const QString& binName, const KService* service, bool* silent_arg, 00374 QByteArray* wmclass_arg); 00375 00376 Q_SIGNALS: 00382 void finished(); 00387 void error(); 00388 00389 protected Q_SLOTS: 00398 void slotTimeout(); // KDE5: rename to slotNextStep() or something like that 00399 00403 void slotScanFinished(KJob *); 00404 00409 void slotScanMimeType(KIO::Job *, const QString &type); 00410 00416 void mimeTypeDetermined(const QString& mimeType); 00417 00421 virtual void slotStatResult(KJob *); 00422 00423 protected: 00431 virtual void init(); 00432 00436 virtual void scanFile(); 00437 00449 virtual void foundMimeType(const QString& type); 00450 00454 virtual void killJob(); 00455 00459 void setUrl(const KUrl &url); 00460 00464 KUrl url() const; 00465 00469 void setError(bool error); 00470 00474 void setProgressInfo(bool progressInfo); 00475 00479 bool progressInfo() const; 00480 00484 void setFinished(bool finished); 00485 00489 void setJob(KIO::Job *job); 00490 00494 KIO::Job* job(); 00495 00501 #ifndef KDE_NO_DEPRECATED 00502 KDE_DEPRECATED QTimer& timer(); 00503 #endif 00504 00509 #ifndef KDE_NO_DEPRECATED 00510 KDE_DEPRECATED void setDoScanFile(bool scanFile); 00511 #endif 00512 00517 #ifndef KDE_NO_DEPRECATED 00518 KDE_DEPRECATED bool doScanFile() const; 00519 #endif 00520 00525 #ifndef KDE_NO_DEPRECATED 00526 KDE_DEPRECATED void setIsDirecory(bool isDirectory); 00527 #endif 00528 00532 bool isDirectory() const; 00533 00537 #ifndef KDE_NO_DEPRECATED 00538 KDE_DEPRECATED void setInitializeNextAction(bool initialize); 00539 #endif 00540 00544 #ifndef KDE_NO_DEPRECATED 00545 KDE_DEPRECATED bool initializeNextAction() const; 00546 #endif 00547 00551 void setIsLocalFile(bool isLocalFile); 00552 00556 bool isLocalFile() const; 00557 00561 void setMode(mode_t mode); 00562 00566 mode_t mode() const; 00567 00568 private: 00569 class KRunPrivate; 00570 KRunPrivate* const d; 00571 }; 00572 00573 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Jan 21 2019 12:35:01 by doxygen 1.7.5.1 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Jan 21 2019 12:35:01 by doxygen 1.7.5.1 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.