krun.cpp
94 pid_t KRun::runURL( const KURL& u, const TQString& _mimetype, bool tempFile, bool runExecutables )
108 if ( mimeType->is("application/x-executable") || mimeType->is("application/x-executable-script") )
114 pid_t KRun::runURL( const KURL& u, const TQString& _mimetype, bool tempFile, bool runExecutables, const TQString& suggestedFileName )
120 pid_t KRun::runURL( const KURL& u, const TQString& _mimetype, TQWidget* window, const TQCString& asn,
128 i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>").arg(u.htmlURL()) );
150 return (KRun::runCommand(path, TQString::null, TQString::null, window, asn)); // just execute the url as a command
158 else if (_mimetype == "application/x-executable" || _mimetype == "application/x-pie-executable")
197 // Hmm, in fact KOpenWithDlg::setServiceType already guesses the mimetype from the first URL of the list...
214 bool KRun::displayOpenWithDialog( const KURL::List& lst, bool tempFiles, const TQString& suggestedFileName )
346 kdDebug() << "KRun::processDesktopExec: No URLs supplied to single-URL service " << str << endl;
348 kdWarning() << "KRun::processDesktopExec: " << urls.count() << " URLs supplied to single-URL service " << str << endl;
370 TQStringList KRun::processDesktopExec(const KService &_service, const KURL::List& _urls, bool has_shell) {
374 TQStringList KRun::processDesktopExec(const KService &_service, const KURL::List& _urls, bool has_shell /* KDE4: remove */, bool tempFiles)
379 TQStringList KRun::processDesktopExec(const KService &_service, const KURL::List& _urls, bool has_shell /* KDE4: remove */, bool tempFiles, const TQString& suggestedFileName)
399 memcpy( (void *)(exec.unicode() + pos), exec.unicode() + pos + 1, (pos2 - pos) * sizeof(TQChar));
488 kdWarning() << "KRun: syntax error in command `" << terminal << "', service `" << _service.name() << "'" << endl;
538 kdWarning() << "KRun: syntax error in command `" << _service.exec() << "', service `" << _service.name() << "'" << endl;
554 static pid_t runCommandInternal( TDEProcess* proc, const KService* service, const TQString& binName,
565 #ifdef Q_WS_X11 // Startup notification doesn't work with QT/E, service isn't needed without Startup notification
569 bool startup_notify = ( asn != "0" && KRun::checkStartupNotify( binName, service, &silent, &wmclass ));
612 bool KRun::checkStartupNotify( const TQString& /*binName*/, const KService* service, bool* silent_arg, TQCString* wmclass_arg )
656 static pid_t runTempService( const KService& _service, const KURL::List& _urls, TQWidget* window,
702 // This can be a list of actual protocol names, or just TDEIO for TDE apps, or KIO for KDE apps.
717 if ((categories.find("TDE") != categories.end()) || (categories.find("KDE") != categories.end()))
732 bool supported = url.isLocalFile() || supportedProtocols.find( url.protocol().lower() ) != supportedProtocols.end();
759 pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* window, bool tempFiles )
764 pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* window, const TQCString& asn, bool tempFiles )
769 pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* window, bool tempFiles, const TQString& suggestedFileName )
774 pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* window, const TQCString& asn,
857 pid_t KRun::runCommand( const TQString& cmd, const TQString &execName, const TQString & iconName )
862 pid_t KRun::runCommand( const TQString& cmd, const TQString &execName, const TQString & iconName,
875 return runCommandInternal( proc, service.data(), binaryName( execName, false ), execName, iconName, window, asn );
891 KRun::KRun( const KURL& url, TQWidget* window, const TQCString& asn, mode_t mode, bool isLocalFile,
898 void KRun::init ( const KURL& url, TQWidget* window, const TQCString& asn, mode_t mode, bool isLocalFile,
923 kdDebug(7010) << " new KRun " << this << " " << url.prettyURL() << " timer=" << &m_timer << endl;
1021 KMessageBoxWrapper::error( d->m_window, i18n( "<qt>Unable to run the command specified. The file or folder <b>%1</b> does not exist.</qt>" ).arg( m_strURL.htmlURL() ) );
1042 if (!((m_strURL.protocol().startsWith("http")) && (m_strURL.url() == "http://default.browser")))
1081 if ((m_strURL.protocol().startsWith("http")) && (m_strURL.url() == "http://default.browser")) {
1216 //kdDebug(7010) << this << " KRun returning from showErrorDialog, starting timer to delete us" << endl;
1271 kdWarning(7010) << "KRun::slotScanFinished : MimetypeJob didn't find a mimetype! Probably a tdeioslave bug." << endl;
1282 kdError(7010) << this << " ERROR (stat) : " << job->error() << " " << job->errorString() << endl;
1284 //kdDebug(7010) << this << " KRun returning from showErrorDialog, starting timer to delete us" << endl;
1363 kdDebug(7010) << "Attempting to open with preferred service: " << d->m_preferredService << endl;
1390 if (!m_bFinished && KRun::runURL( m_strURL, type, d->m_window, d->m_asn, false, d->m_runExecutables, d->m_suggestedFileName )){
1431 d->m_externalBrowser = TDEConfigGroup(TDEGlobal::config(), "General").readEntry("BrowserApplication");
static bool isExecutableFile(const KURL &url, const TQString &mimetype)
Returns wether the url of mimetype is executable.
Definition: krun.cpp:99
TQString terminalOptions() const
Returns any options associated with the terminal the service runs in, if it requires a terminal.
Definition: kservice.h:147
static TQString exec(const TQString &protocol)
Returns the library / executable to open for the protocol protocol Example : "tdeio_ftp",...
static bool supportsListing(const KURL &url)
Returns whether the protocol can list files/objects.
Definition: kprotocolinfo.cpp:121
TDEIO_EXPORT LocalURLJob * localURL(const KURL &remoteUrl)
Retrieve local URL if available.
Definition: job.cpp:841
KRun(const KURL &url, mode_t mode=0, bool isLocalFile=false, bool showProgressInfo=true)
Create a KRun object to run the preferred application for a file/URL.
Definition: krun.cpp:878
static TQString defaultMimetype(const KURL &url)
Returns default mimetype for this URL based on the protocol.
Definition: kprotocolinfo.cpp:249
static Ptr serviceByDesktopName(const TQString &_name)
Find a service by the name of its desktop file, not depending on its actual location (as long as it's...
Definition: kservice.cpp:680
TQString desktopEntryName() const
Returns the filename of the service desktop entry without any extension.
Definition: kservice.h:182
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
Definition: global.h:507
static bool displayOpenWithDialog(const KURL::List &lst, bool tempFiles)
Display the Open-With dialog for those URLs, and run the chosen application.
Definition: krun.cpp:209
static Ptr findByURL(const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false)
Finds a KMimeType with the given _url.
Definition: kmimetype.cpp:165
static bool supportsReading(const KURL &url)
Returns whether the protocol can retrieve data from URLs.
Definition: kprotocolinfo.cpp:139
static Ptr serviceByStorageId(const TQString &_storageId)
Find a service by its storage-id or desktop-file path.
Definition: kservice.cpp:694
TDEIO_EXPORT MimetypeJob * mimetype(const KURL &url, bool showProgressInfo=true)
Find mimetype for one file or directory.
Definition: job.cpp:1544
static KService::Ptr preferredService(const TQString &serviceType, const TQString &genericServiceType)
Returns the preferred service for _serviceType and _genericServiceType ("Application",...
Definition: kuserprofile.cpp:303
static bool isHelperProtocol(const KURL &url)
Returns whether the protocol can act as a helper protocol.
Definition: kprotocolinfo.cpp:94
TQString desktopEntryPath() const
Returns the path to the location where the service desktop entry is stored.
Definition: kservice.h:174
static void publishSlaveOnHold()
Send the slave that was put on hold back to TDELauncher.
Definition: scheduler.h:181
static pid_t runCommand(TQString cmd)
Run the given shell command and notifies kicker of the starting of the application.
Definition: krun.cpp:852
@ 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: global.h:366
The transfer job pumps data into and/or out of a Slave.
Definition: jobclasses.h:874
virtual void foundMimeType(const TQString &_type)
Called if the mimetype has been detected.
Definition: krun.cpp:1295
static pid_t run(const KURL &_url, bool _is_local)
Invokes the default action for the desktop entry.
Definition: kmimetype.cpp:790
void setSuggestedFileName(const TQString &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:1446
TDEIO_EXPORT TQString buildErrorString(int errorCode, const TQString &errorText)
Returns a translated error message for errorCode using the additional error information provided by e...
Definition: global.cpp:230
static KURL mostLocalURL(const KURL &url, TQWidget *window)
Tries to map a local URL for the given URL.
Definition: netaccess.cpp:213
void showErrorDialog(TQWidget *parent=0L)
Display a dialog box to inform the user of the error given by this job.
Definition: job.cpp:294
A TDEIO job that retrieves information about a file or directory.
Definition: jobclasses.h:687
static Ptr mimeType(const TQString &_name)
Retrieve a pointer to the mime type _name or a pointer to the default mime type "application/octet-st...
Definition: kmimetype.cpp:141
void setPreferredService(const TQString &desktopEntryName)
Set the preferred service for opening this URL, after its mimetype will have been found by KRun.
Definition: krun.cpp:1436
void setEnableExternalBrowser(bool b)
Sets whether the external webbrowser setting should be honoured.
Definition: krun.cpp:1428
static pid_t runURL(const KURL &_url, const TQString &_mimetype, bool tempFile, bool runExecutables)
Open the given URL.
Definition: krun.cpp:94
virtual TQVariant property(const TQString &_name) const
Returns the requested property.
Definition: kservice.cpp:528
void setRunExecutables(bool b)
Sets whether executables, .desktop files or shell scripts should be run by KRun.
Definition: krun.cpp:1441
@ UDS_LOCAL_PATH
A local file path if the ioslave display files sitting on the local filesystem (but in another hierar...
Definition: global.h:338
static pid_t run(const KService &_service, const KURL::List &_urls, TQWidget *window, bool tempFiles=false)
Open a list of URLs with a certain service (application).
Definition: krun.cpp:759
static TQString protocolClass(const TQString &protocol)
Returns the protocol class for the specified protocol.
TDEIO_EXPORT StatJob * stat(const KURL &url, bool showProgressInfo=true)
Find all details for one file or directory.
Definition: job.cpp:921
bool allowMultipleFiles() const
Checks whether this service can handle several files as startup arguments.
Definition: kservice.cpp:824
bool substituteUid() const
Checks whether the service runs with a different user id.
Definition: kservice.cpp:726
static TQString binaryName(const TQString &execLine, bool removePath)
Given a full command line (e.g.
Definition: krun.cpp:543
TQString username() const
Returns the user name, if the service runs with a different user id.
Definition: kservice.cpp:740
bool terminal() const
Checks whethe the service should be run in a terminal.
Definition: kservice.h:138
TDEIO_EXPORT TransferJob * get(const KURL &url, bool reload=false, bool showProgressInfo=true)
Get (a.k.a.
Definition: job.cpp:1255
static bool isExecutable(const TQString &serviceType)
Returns whether serviceType refers to an executable program instead of a data file.
Definition: krun.cpp:1451
static TQStringList processDesktopExec(const KService &_service, const KURL::List &_urls, bool has_shell, bool tempFiles)
Processes a Exec= line as found in .desktop files.
Definition: krun.cpp:374