KIO
krun.cpp
Go to the documentation of this file.
122 bool KRun::runUrl(const KUrl& u, const QString& _mimetype, QWidget* window, bool tempFile, bool runExecutables, const QString& suggestedFileName, const QByteArray& asn)
128 i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>", Qt::escape(u.prettyUrl())));
139 return (KRun::runCommand(KShell::quoteArg(u.toLocalFile()), QString(), QString(), window, asn, u.directory())); // just execute the url as a command
179 // As KDE on windows doesnt know about the windows default applications offers will be empty in nearly all cases.
185 // Hmm, in fact KOpenWithDialog::setServiceType already guesses the mimetype from the first URL of the list...
407 QStringList KRun::processDesktopExec(const KService &_service, const KUrl::List& _urls, bool tempFiles, const QString& suggestedFileName)
422 kWarning() << "KRun: syntax error in command" << _service.exec() << ", service" << _service.name();
454 if (!isProtocolInSupportedList(*it, appSupportedProtocols) && !KProtocolInfo::isHelperProtocol(*it)) {
529 QStringList execlist = KShell::splitArgs(exec, KShell::AbortOnMeta | KShell::TildeExpand, &err);
580 static bool runCommandInternal(KProcess* proc, const KService* service, const QString& executable,
597 #ifdef Q_WS_X11 // Startup notification doesn't work with QT/E, service isn't needed without Startup notification
601 bool startup_notify = (asn != "0" && KRun::checkStartupNotify(QString() /*unused*/, service, &silent, &wmclass));
651 bool KRun::checkStartupNotify(const QString& /*binName*/, const KService* service, bool* silent_arg, QByteArray* wmclass_arg)
922 QPixmap warningIcon(KIconLoader::global()->loadIcon("dialog-warning", KIconLoader::NoGroup, KIconLoader::SizeHuge));
1049 bool KRun::run(const QString& _exec, const KUrl::List& _urls, QWidget* window, const QString& _name,
1079 bool KRun::runCommand(const QString& cmd, const QString &execName, const QString & iconName, QWidget* window, const QByteArray& asn)
1167 if (!d->m_externalBrowser.isEmpty() && d->m_strURL.protocol().startsWith(QLatin1String("http"))) {
1199 // Unknown mimetype because the file is unreadable, no point in showing an open-with dialog (#261002)
1247 KIO::StatJob *job = KIO::stat(d->m_strURL, KIO::StatJob::SourceSide, 0 /* no details */, flags);
1428 kWarning(7010) << "get() didn't emit a mimetype! Probably a kioslave bug, please check the implementation of" << url().protocol();
1516 if (!KRun::runUrl(d->m_strURL, type, d->m_window, false /*tempfile*/, d->m_runExecutables, d->m_suggestedFileName, d->m_asn)) {
1580 d->m_externalBrowser = KConfigGroup(KGlobal::config(), "General").readEntry("BrowserApplication");
1741 KProcessRunner::KProcessRunner(KProcess * p, const QString & executable, const KStartupInfoId& _id) :
virtual void setWindow(QWidget *window)
Associate this job with a window given by window.
Definition: jobuidelegate.cpp:58
static void resetStartupEnv()
void setShellCommand(const QString &cmd)
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
QString i18n(const char *text)
bool kill(KillVerbosity verbosity=Quietly)
QString readPathEntry(const QString &pKey, const QString &aDefault) const
static bool run(const KService &service, const KUrl::List &urls, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
Open a list of URLs with a certain service (application).
Definition: krun.cpp:984
void setEnableExternalBrowser(bool b)
Sets whether the external webbrowser setting should be honoured.
Definition: krun.cpp:1577
QString toNativeSeparators(const QString &pathName)
QString & append(QChar ch)
const char header[]
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
int width() const
void slotTimeout()
All following protected slots are used by subclasses of KRun!
Definition: krun.cpp:1330
virtual void foundMimeType(const QString &type)
Called if the mimetype has been detected.
Definition: krun.cpp:1472
static bool runTempService(const KService &_service, const KUrl::List &_urls, QWidget *window, bool tempFiles, const QString &suggestedFileName, const QByteArray &asn)
Definition: krun.cpp:694
void setDoScanFile(bool scanFile)
Indicate that the next action is to scan the file.
Definition: krun.cpp:1665
static QString realFilePath(const QString &filename)
static KIconLoader * global()
static Ptr serviceByDesktopName(const QString &_name)
void setWindowModality(Qt::WindowModality windowModality)
QString errorString() const
int timeout
KRun(const KUrl &url, QWidget *window, mode_t mode=0, bool isLocalFile=false, bool showProgressInfo=true, const QByteArray &asn=QByteArray())
Definition: krun.cpp:1101
QString & prepend(QChar ch)
MimetypeJob * mimetype(const KUrl &url, JobFlags flags=DefaultFlags)
Find mimetype for one file or directory.
Definition: job.cpp:1856
void setRunExecutables(bool b)
Sets whether executables, .desktop files or shell scripts should be run by KRun.
Definition: krun.cpp:1592
void setPixmap(const QPixmap &)
bool isNull() const
void slotProcessExited(int, QProcess::ExitStatus)
Definition: krun.cpp:1789
QVariant property(const QString &_name, QVariant::Type t) const
virtual bool open(OpenMode flags=QIODevice::ReadWrite)
File type, part of the mode returned by stat (for a link, this returns the file type of the pointed i...
Definition: udsentry.h:181
bool contains(const QString &str, Qt::CaseSensitivity cs) const
bool isEmpty() const
TransferJob * get(const KUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
Get (a.k.a.
Definition: job.cpp:1369
int stat(const QString &path, KDE_struct_stat *buf)
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
StatJob * stat(const KUrl &url, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
Definition: job.cpp:924
int exec()
static QStringList processDesktopExec(const KService &_service, const KUrl::List &_urls, bool tempFiles=false, const QString &suggestedFileName=QString())
Processes a Exec= line as found in .desktop files.
Definition: krun.cpp:407
QString genericName() const
A KIO job that retrieves information about a file or directory.
Definition: jobclasses.h:440
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
A local file path if the ioslave display files sitting on the local filesystem (but in another hierar...
Definition: udsentry.h:166
bool setPermissions(QFlags< QFile::Permission > permissions)
QString terminalOptions() const
bool exists() const
bool substituteUid() const
static void add(const KUrl &url)
Add a new item to the Recent Document menu.
Definition: krecentdocument.cpp:88
void abort()
void setBin(const QString &bin)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
static bool checkStartupNotify(const QString &binName, const KService *service, bool *silent_arg, QByteArray *wmclass_arg)
Definition: krun.cpp:651
void setName(const QString &name)
void ref()
bool run(const KUrl &_url, bool _is_local)
Invokes the default action for the desktop entry.
Definition: kdesktopfileactions.cpp:54
bool isApplication() const
QString i18nc(const char *ctxt, const char *text)
int size() const
KSharedConfigPtr config()
bool isNull() const
QString exec() const
void setPath(const QString &path)
void slotScanMimeType(KIO::Job *, const QString &type)
This slot is called when the scan job has found out the mime type.
Definition: krun.cpp:1425
QStringList splitArgs(const QString &cmd, Options flags=NoOptions, Errors *err=0)
static bool isAuthorizedDesktopFile(const QString &path)
QString path() const
void clear()
qint64 peek(char *data, qint64 maxSize)
Show the progress info GUI, no Resume and no Overwrite.
Definition: jobclasses.h:46
size
static bool displayNativeOpenWithDialog(const KUrl::List &lst, QWidget *window, bool tempFiles, const QString &suggestedFileName, const QByteArray &asn)
Definition: krun_win.cpp:82
static bool sendChange(const KStartupInfoId &id, const KStartupInfoData &data)
static bool isExecutableFile(const KUrl &url, const QString &mimetype)
Returns whether the url of mimetype is executable.
Definition: krun.cpp:100
static int currentDesktop()
static int startServiceByDesktopPath(const QString &_name, const QString &URL, QString *error=0, QString *serviceName=0, int *pid=0, const QByteArray &startup_id=QByteArray(), bool noWait=false)
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
int count(const T &value) const
QString errorString() const
void append(const T &value)
void setDescription(const QString &descr)
static bool sendStartup(const KStartupInfoId &id, const KStartupInfoData &data)
void deref()
static bool isExecutable(const QString &serviceType)
Returns whether serviceType refers to an executable program instead of a data file.
Definition: krun.cpp:1607
QWidget * topLevelWidget() const
void setIcon(const QString &icon)
bool authorizeUrlAction(const QString &action, const KUrl &baseUrl, const KUrl &destUrl)
KSharedPtr< KService > Ptr
QString protocol() const
bool isEmpty() const
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
void setObjectName(const QString &name)
const QString & name() const
QString buildErrorString(int errorCode, const QString &errorText)
Returns a translated error message for errorCode using the additional error information provided by e...
Definition: global.cpp:164
bool isEmpty() const
void setSilent(TriState state)
QString fragment() const
static bool runCommand(const QString &cmd, QWidget *window)
Run the given shell command and notifies KDE of the starting of the application.
Definition: krun.cpp:1057
virtual void slotStatResult(KJob *)
This slot is called when the 'stat' job has finished.
Definition: krun.cpp:1364
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QByteArray readAll()
Errors
static bool runCommandInternal(KProcess *proc, const KService *service, const QString &executable, const QString &userVisibleName, const QString &iconName, QWidget *window, const QByteArray &asn)
Definition: krun.cpp:580
static KMimeTypeTrader * self()
typedef Iterator
static QString defaultMimetype(const KUrl &url)
Returns default mimetype for this URL based on the protocol.
Definition: kprotocolmanager.cpp:1169
void setSuggestedFileName(const QString &fileName)
Sets the file name to use in the case of downloading the file to a tempfile in order to give to a non...
Definition: krun.cpp:1597
WId winId() const
void deleteLater()
void setHostname(const QByteArray &hostname=QByteArray())
T & first()
void slotScanFinished(KJob *)
This slot is called when the scan job is finished.
Definition: krun.cpp:1434
static int run(KProcess *, const QString &executable, const KStartupInfoId &id)
Definition: krun.cpp:1732
Definition: krun_p.h:37
static QString protocolClass(const QString &protocol)
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
void start()
static bool displayOpenWithDialog(const KUrl::List &lst, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
Display the Open-With dialog for those URLs, and run the chosen application.
Definition: krun.cpp:193
void setApplicationId(const QString &desktop)
bool allowMultipleFiles() const
QString username() const
iterator end()
QString toLower() const
void mimeTypeDetermined(const QString &mimeType)
Call this from subclasses when you have determined the mimetype.
Definition: krun.cpp:1457
QWidget * screen(int screen)
QString quoteArg(const QString &arg)
QString icon() const
static bool supportsReading(const KUrl &url)
Returns whether the protocol can retrieve data from URLs.
Definition: kprotocolmanager.cpp:1050
bool terminal() const
bool waitForStarted(int msecs)
bool finalize()
void setWorkingDirectory(const QString &dir)
static bool sendFinish(const KStartupInfoId &id)
void stop()
static QString exec(const QString &protocol)
virtual void close()
static KUrl mostLocalUrl(const KUrl &url, QWidget *window)
Tries to map a local URL for the given URL.
Definition: netaccess.cpp:234
static bool isHelperProtocol(const KUrl &url)
Definition: global.h:209
QString & replace(int position, int n, QChar after)
const QChar * unicode() const
int startTimer(int interval)
bool isValid() const
void setPreferredService(const QString &desktopEntryName)
Set the preferred service for opening this URL, after its mimetype will have been found by KRun...
Definition: krun.cpp:1587
static QStringList supportedProtocols(const KService &_service)
Definition: krun.cpp:370
static bool runUrl(const KUrl &url, const QString &mimetype, QWidget *window, bool tempFile=false, bool runExecutables=true, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
Open the given URL.
Definition: krun.cpp:122
void setWMClass(const QByteArray &wmclass)
QByteArray toLatin1() const
static bool makeServiceExecutable(const KService &service, QWidget *window)
Definition: krun.cpp:898
QString mid(int position, int n) const
QStringList toStringList() const
QString suggestedFileName() const
Suggested file name given by the server (e.g.
Definition: krun.cpp:1602
static QByteArray createNewStartupId()
QDesktopWidget * desktop()
QString desktopEntryName() const
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
void addStretch(int stretch)
QString escape(const QString &plain)
QByteArray encodedQuery() const
static QString findExe(const QString &appname, const QString &pathstr=QString(), SearchOptions options=NoSearchOptions)
typedef ConstIterator
int height() const
void setFileName(const QString &filename)
Definition: job.h:29
QStringList toStringList() const
Definition: global.h:255
virtual void init()
All following protected methods are used by subclasses of KRun!
Definition: krun.cpp:1139
QString query() const
bool toBool() const
virtual void showEvent(QShowEvent *event)
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
qint64 write(const char *data, qint64 maxSize)
bool authorize(const QString &genericAction)
QString joinArgs(const QStringList &args)
bool isValid() const
static bool isProtocolInSupportedList(const KUrl &url, const QStringList &supportedProtocols)
Definition: krun.cpp:400
KGuiItem cont()
int pid() const
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
A mime type; the slave should set it if it's known.
Definition: udsentry.h:192
Definition: jobclasses.h:446
static bool supportsListing(const KUrl &url)
Returns whether the protocol can list files/objects.
Definition: kprotocolmanager.cpp:1032
The transfer job pumps data into and/or out of a Slave.
Definition: jobclasses.h:555
void setProgressInfo(bool progressInfo)
Sets whether progress information shall be shown.
Definition: krun.cpp:1630
Permissions permissions() const
bool openUrl(const QUrl &url)
static void publishSlaveOnHold()
Send the slave that was put on hold back to KLauncher.
Definition: scheduler.cpp:830
bool isLocalFile() const
int size() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setDesktop(int desktop)
QObject * parent() const
void init(const KUrl &url, QWidget *window, mode_t mode, bool isLocalFile, bool showProgressInfo, const QByteArray &asn)
Definition: krun.cpp:1110
void initId(const QByteArray &id="")
QString toString() const
bool hasMimeType(const KServiceType *mimeTypePtr) const
T readEntry(const QString &key, const T &aDefault) const
void addPid(pid_t pid)
static QDebug kFatal(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
static QString binaryName(const QString &execLine, bool removePath)
Given a full command line (e.g.
Definition: krun.cpp:568
static void error(QWidget *parent, const QString &text, const QString &caption=QString())
Definition: kmessageboxwrapper.h:33
QProcess::ExitStatus exitStatus() const
iterator begin()
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
bool authorizeKAction(const QString &action)
KService::Ptr preferredService(const QString &mimeType, const QString &genericServiceType=QString::fromLatin1("Application"))
static KUrl::List resolveURLs(const KUrl::List &_urls, const KService &_service)
Definition: krun.cpp:745
QByteArray readAllStandardError()
Definition: krun_p.h:77
void addLayout(QLayout *layout, int stretch)
void setLaunchedBy(WId window)
static Ptr serviceByStorageId(const QString &_storageId)
void setSingleShot(bool singleShot)
void replace(int i, const T &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.