KIO

krun.h
1 /* This file is part of the KDE project
2  Copyright (C) 1998, 1999 Torben Weis <[email protected]>
3  Copyright (C) 2006 David Faure <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KRUN_H
22 #define KRUN_H
23 
24 #include "kiowidgets_export.h"
25 
26 #include <QObject>
27 #include <QString>
28 #include <QUrl>
29 
30 class KService;
31 class KJob;
32 class QTimer;
33 class KRunPrivate;
34 
35 namespace KIO
36 {
37 class Job;
38 }
39 
40 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
41 
64 class KIOWIDGETS_EXPORT KRun : public QObject
65 {
66  Q_OBJECT
67 public:
96  KRun(const QUrl &url, QWidget *window,
97  bool showProgressInfo = true,
98  const QByteArray &asn = QByteArray());
99 
104  virtual ~KRun();
105 
112  void abort();
113 
119  bool hasError() const;
120 
126  bool hasFinished() const;
127 
135  bool autoDelete() const;
136 
145  void setAutoDelete(bool b);
146 
156  void setPreferredService(const QString &desktopEntryName);
157 
164  void setRunExecutables(bool b);
165 
172  void setFollowRedirections(bool b);
173 
180  void setEnableExternalBrowser(bool b);
181 
189  void setSuggestedFileName(const QString &fileName);
190 
197  void setShowScriptExecutionPrompt(bool showPrompt);
198 
202  QString suggestedFileName() const;
203 
208  QWidget *window() const;
209 
210 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 6)
211 
237  KIOWIDGETS_DEPRECATED_VERSION(5, 6, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
238  static bool run(const KService &service, const QList<QUrl> &urls, QWidget *window,
239  bool tempFiles = false, const QString &suggestedFileName = QString(),
240  const QByteArray &asn = QByteArray());
241 #endif
242 
243 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
244 
274  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
275  static qint64 runService(const KService &service, const QList<QUrl> &urls, QWidget *window,
276  bool tempFiles = false, const QString &suggestedFileName = QString(),
277  const QByteArray &asn = QByteArray());
278 #endif
279 
280 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
281 
284  enum RunFlag {
285  DeleteTemporaryFiles = 0x1,
286  RunExecutables = 0x2,
287  };
292  Q_DECLARE_FLAGS(RunFlags, RunFlag)
293 #endif
294 
295 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
296 
325  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob, see API docs for a code sample")
326  static qint64 runApplication(const KService &service, const QList<QUrl> &urls, QWidget *window,
327  RunFlags flags = RunFlags(), const QString &suggestedFileName = QString(),
328  const QByteArray &asn = QByteArray());
329 #endif
330 
331 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
332 
358  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::ApplicationLauncherJob with a temporary KService, see API docs for a code sample")
359  static bool run(const QString &exec, const QList<QUrl> &urls, QWidget *window,
360  const QString &name = QString(),
361  const QString &icon = QString(),
362  const QByteArray &asn = QByteArray());
363 #endif
364 
365 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 31)
366 
394  KIOWIDGETS_DEPRECATED_VERSION(5, 31, "Use KIO::OpenUrlJob, see API docs for a code sample")
395  static bool runUrl(const QUrl &url, const QString &mimetype, QWidget *window,
396  bool tempFile = false, bool runExecutables = true,
397  const QString &suggestedFileName = QString(), const QByteArray &asn = QByteArray());
398 #endif
399 
400 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
401 
426  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::OpenUrlJob, see API docs for a code sample")
427  static bool runUrl(const QUrl &url, const QString &mimetype, QWidget *window, RunFlags flags,
428  const QString &suggestedFileName = QString(), const QByteArray &asn = QByteArray());
429 #endif
430 
431 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
432 
455  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::CommandLauncherJob, see API docs for a code sample")
456  static bool runCommand(const QString &cmd, QWidget *window, const QString &workingDirectory = QString());
457 #endif
458 
459 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
460 
482  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::CommandLauncherJob, see API docs for a code sample")
483  static bool runCommand(const QString &cmd, const QString &execName,
484  const QString &icon, QWidget *window, const QByteArray &asn = QByteArray());
485 #endif
486 
487 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
488 
505  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::CommandLauncherJob, see API docs for a code sample")
506  static bool runCommand(const QString &cmd, const QString &execName,
507  const QString &icon, QWidget *window,
508  const QByteArray &asn, const QString &workingDirectory);
509 #endif
510 
511 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 71)
512 
534  KIOWIDGETS_DEPRECATED_VERSION(5, 71, "Use KIO::OpenUrlJob, see API docs for a code sample")
535  static bool displayOpenWithDialog(const QList<QUrl> &lst, QWidget *window,
536  bool tempFiles = false, const QString &suggestedFileName = QString(),
537  const QByteArray &asn = QByteArray());
538 #endif
539 
540 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 0)
541 
551  KIOWIDGETS_DEPRECATED_VERSION(4, 0, "Use KShell::quoteArg(...)")
552  static void shellQuote(QString &str);
553 #endif
554 
555 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0)
556 
567  KIOWIDGETS_DEPRECATED_VERSION(5, 0, "Use KIO::DesktopExecParser")
568  static QStringList processDesktopExec(const KService &_service, const QList<QUrl> &_urls,
569  bool tempFiles = false,
570  const QString &suggestedFileName = QString());
571 #endif
572 
573 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0)
574 
583  KIOWIDGETS_DEPRECATED_VERSION(5, 0, "See API docs")
584  static QString binaryName(const QString &execLine, bool removePath);
585 #endif
586 
591  static bool isExecutable(const QString &mimeType);
592 
605  static bool isExecutableFile(const QUrl &url, const QString &mimetype);
606 
610  static bool checkStartupNotify(const QString &binName, const KService *service, bool *silent_arg,
611  QByteArray *wmclass_arg);
612 
613 Q_SIGNALS:
619  void finished();
624  void error();
625 
626 protected Q_SLOTS:
635  void slotTimeout();
636 
640  void slotScanFinished(KJob *);
641 
646  void slotScanMimeType(KIO::Job *, const QString &type);
647 
653  void mimeTypeDetermined(const QString &mimeType);
654 
658  virtual void slotStatResult(KJob *);
659 
660 protected:
668  virtual void init();
669 
673  virtual void scanFile();
674 
686  virtual void foundMimeType(const QString &type);
687 
691  virtual void killJob();
692 
699  virtual void handleInitError(int kioErrorCode, const QString &errorMsg);
700 
706  virtual void handleError(KJob *job);
707 
711  void setUrl(const QUrl &url);
712 
716  QUrl url() const;
717 
721  void setError(bool error);
722 
726  void setProgressInfo(bool progressInfo);
727 
731  bool progressInfo() const;
732 
736  void setFinished(bool finished);
737 
741  void setJob(KIO::Job *job);
742 
746  KIO::Job *job();
747 
748 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 4)
749 
754  KIOWIDGETS_DEPRECATED_VERSION(4, 4, "See API docs")
755  QTimer &timer();
756 #endif
757 
758 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
759 
763  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
764  void setDoScanFile(bool scanFile);
765 #endif
766 
767 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
768 
772  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
773  bool doScanFile() const;
774 #endif
775 
776 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
777 
781  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
782  void setIsDirecory(bool isDirectory);
783 #endif
784 
788  bool isDirectory() const;
789 
790 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
791 
794  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
795  void setInitializeNextAction(bool initialize);
796 #endif
797 
798 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(4, 1)
799 
802  KIOWIDGETS_DEPRECATED_VERSION(4, 1, "Do not use")
803  bool initializeNextAction() const;
804 #endif
805 
809  bool isLocalFile() const;
810 
811 private:
812  friend class KRunPrivate;
813  KRunPrivate *const d;
814 };
815 #endif
816 
817 #endif
A namespace for KIO globals.
Definition: authinfo.h:34
To open files with their associated applications in KDE, use KRun.
Definition: krun.h:64
RunFlag
Definition: krun.h:284
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
Find mimetype for one file or directory.
Definition: mimetypejob.cpp:93
QCA_EXPORT void init()
The base class for all jobs.
Definition: job_base.h:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 5 2020 22:58:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.