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) :
static void error(QWidget *parent, const QString &text, const QString &caption=QString())
Definition: kmessageboxwrapper.h:33
static QString exec(const QString &protocol)
void init(const KUrl &url, QWidget *window, mode_t mode, bool isLocalFile, bool showProgressInfo, const QByteArray &asn)
Definition: krun.cpp:1110
QString desktopEntryName() const
virtual void slotStatResult(KJob *)
This slot is called when the 'stat' job has finished.
Definition: krun.cpp:1364
static bool isExecutable(const QString &serviceType)
Returns whether serviceType refers to an executable program instead of a data file.
Definition: krun.cpp:1607
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
static KIconLoader * global()
QString protocol() const
const char header[]
void slotScanFinished(KJob *)
This slot is called when the scan job is finished.
Definition: krun.cpp:1434
int timeout
Definition: krun_p.h:37
static int run(KProcess *, const QString &executable, const KStartupInfoId &id)
Definition: krun.cpp:1732
void setApplicationId(const QString &desktop)
static KUrl::List resolveURLs(const KUrl::List &_urls, const KService &_service)
Definition: krun.cpp:745
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
void setShellCommand(const QString &cmd)
Errors
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
int pid() const
void ref()
bool authorizeKAction(const QString &action)
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
bool authorize(const QString &genericAction)
QString suggestedFileName() const
Suggested file name given by the server (e.g.
Definition: krun.cpp:1602
QString entryPath() const
QString i18nc(const char *ctxt, const char *text)
static bool isAuthorizedDesktopFile(const QString &path)
static void add(const KUrl &url)
Add a new item to the Recent Document menu.
Definition: krecentdocument.cpp:88
KSharedPtr< KService > Ptr
static KUrl mostLocalUrl(const KUrl &url, QWidget *window)
Tries to map a local URL for the given URL.
Definition: netaccess.cpp:234
QString query() const
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
static bool supportsListing(const KUrl &url)
Returns whether the protocol can list files/objects.
Definition: kprotocolmanager.cpp:1033
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
QString genericName() const
static bool runTempService(const KService &_service, const KUrl::List &_urls, QWidget *window, bool tempFiles, const QString &suggestedFileName, const QByteArray &asn)
Definition: krun.cpp:694
QString errorString() const
Converts an error code and a non-i18n error message into an error message in the current language.
Definition: global.cpp:159
void mimeTypeDetermined(const QString &mimeType)
Call this from subclasses when you have determined the mimetype.
Definition: krun.cpp:1457
void slotProcessExited(int, QProcess::ExitStatus)
Definition: krun.cpp:1789
static Ptr findByUrl(const KUrl &url, mode_t mode=0, bool is_local_file=false, bool fast_mode=false, int *accuracy=0)
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)
@ UDS_FILE_TYPE
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
void deref()
virtual void showErrorMessage()
bool kill(KillVerbosity verbosity=Quietly)
void setFileName(const QString &filename)
static bool isHelperProtocol(const KUrl &url)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
const QString & name() const
QVariant property(const QString &_name, QVariant::Type t) const
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
KJobUiDelegate * uiDelegate() const
Definition: krun_p.h:77
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
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
void start()
void addPid(pid_t pid)
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
static QString findExe(const QString &appname, const QString &pathstr=QString(), SearchOptions options=NoSearchOptions)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
NoGroup
void setProgressInfo(bool progressInfo)
Sets whether progress information shall be shown.
Definition: krun.cpp:1630
void setLaunchedBy(WId window)
void setDoScanFile(bool scanFile)
Indicate that the next action is to scan the file.
Definition: krun.cpp:1665
static bool sendFinish(const KStartupInfoId &id)
void setDesktop(int desktop)
bool isLocalFile() const
virtual void init()
All following protected methods are used by subclasses of KRun!
Definition: krun.cpp:1139
QString terminalOptions() const
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)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
bool isApplication() const
bool run(const KUrl &_url, bool _is_local)
Invokes the default action for the desktop entry.
Definition: kdesktopfileactions.cpp:54
FoundMeta
QString icon() const
static QString binaryName(const QString &execLine, bool removePath)
Given a full command line (e.g.
Definition: krun.cpp:568
static QByteArray createNewStartupId()
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 path() const
static bool sendChange(const KStartupInfoId &id, const KStartupInfoData &data)
SizeHuge
static void publishSlaveOnHold()
Send the slave that was put on hold back to KLauncher.
Definition: scheduler.cpp:830
static bool makeServiceExecutable(const KService &service, QWidget *window)
Definition: krun.cpp:898
virtual void foundMimeType(const QString &type)
Called if the mimetype has been detected.
Definition: krun.cpp:1472
QStringList splitArgs(const QString &cmd, Options flags=NoOptions, Errors *err=0)
void setEnableExternalBrowser(bool b)
Sets whether the external webbrowser setting should be honoured.
Definition: krun.cpp:1577
KSharedConfigPtr config()
QString i18n(const char *text)
static bool sendStartup(const KStartupInfoId &id, const KStartupInfoData &data)
void setRunExecutables(bool b)
Sets whether executables, .desktop files or shell scripts should be run by KRun.
Definition: krun.cpp:1592
static bool supportsReading(const KUrl &url)
Returns whether the protocol can retrieve data from URLs.
Definition: kprotocolmanager.cpp:1051
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
TransferJob * get(const KUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
Get (a.k.a.
Definition: job.cpp:1369
KConfigGroup desktopGroup() const
MimetypeJob * mimetype(const KUrl &url, JobFlags flags=DefaultFlags)
Find mimetype for one file or directory.
Definition: job.cpp:1856
bool finalize()
long long numberValue(uint field, long long defaultValue=0) const
Definition: udsentry.cpp:78
QString name() const
static bool displayNativeOpenWithDialog(const KUrl::List &lst, QWidget *window, bool tempFiles, const QString &suggestedFileName, const QByteArray &asn)
Definition: krun_win.cpp:82
@ UDS_LOCAL_PATH
A local file path if the ioslave display files sitting on the local filesystem (but in another hierar...
Definition: udsentry.h:166
static QString realFilePath(const QString &filename)
bool allowMultipleFiles() const
static bool isExecutableFile(const KUrl &url, const QString &mimetype)
Returns whether the url of mimetype is executable.
Definition: krun.cpp:100
static bool checkStartupNotify(const QString &binName, const KService *service, bool *silent_arg, QByteArray *wmclass_arg)
Definition: krun.cpp:651
static Ptr serviceByStorageId(const QString &_storageId)
QString quoteArg(const QString &arg)
subst
void slotTimeout()
All following protected slots are used by subclasses of KRun!
Definition: krun.cpp:1330
void setBin(const QString &bin)
virtual void setWindow(QWidget *window)
Associate this job with a window given by window.
Definition: jobuidelegate.cpp:58
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
static QString defaultMimetype(const KUrl &url)
Returns default mimetype for this URL based on the protocol.
Definition: kprotocolmanager.cpp:1170
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
void abort()
bool substituteUid() const
KGuiItem cont()
A KIO job that retrieves information about a file or directory.
Definition: jobclasses.h:440
bool terminal() const
Cancel
static int currentDesktop()
bool authorizeUrlAction(const QString &action, const KUrl &baseUrl, const KUrl &destUrl)
QString readPathEntry(const char *key, const QString &aDefault) 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
void setDescription(const QString &descr)
static void resetStartupEnv()
void initId(const QByteArray &id="")
QString username() const
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
static QStringList supportedProtocols(const KService &_service)
Definition: krun.cpp:370
QString errorString() const
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
void setName(const QString &name)
int error() const
QStringList toStringList() const
KService::Ptr preferredService(const QString &mimeType, const QString &genericServiceType=QString::fromLatin1("Application"))
virtual bool open(OpenMode flags=QIODevice::ReadWrite)
AbortOnMeta
static Ptr serviceByDesktopName(const QString &_name)
static bool isProtocolInSupportedList(const KUrl &url, const QStringList &supportedProtocols)
Definition: krun.cpp:400
TildeExpand
static QDebug kFatal(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void setSilent(TriState state)
QString readEntry(const char *key, const char *aDefault=0) 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
QString joinArgs(const QStringList &args)
ResolveAliases
static KMimeTypeTrader * self()
void setPath(const QString &path)
QString exec() const
void setIcon(const QString &icon)
void setHostname(const QByteArray &hostname=QByteArray())
static QString protocolClass(const QString &protocol)
int stat(const QString &path, KDE_struct_stat *buf)
NoError
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jan 30 2020 00:00:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jan 30 2020 00:00:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.