Lines 77-82
public:
Link Here
|
77 |
QString m_localPath; |
77 |
QString m_localPath; |
78 |
QString m_suggestedFileName; |
78 |
QString m_suggestedFileName; |
79 |
QGuardedPtr <QWidget> m_window; |
79 |
QGuardedPtr <QWidget> m_window; |
|
|
80 |
QCString m_asn; |
80 |
}; |
81 |
}; |
81 |
|
82 |
|
82 |
pid_t KRun::runURL( const KURL& u, const QString& _mimetype ) |
83 |
pid_t KRun::runURL( const KURL& u, const QString& _mimetype ) |
Lines 109-122
bool KRun::isExecutableFile( const KURL&
Link Here
|
109 |
return false; |
110 |
return false; |
110 |
} |
111 |
} |
111 |
|
112 |
|
112 |
// This is called by foundMimeType, since it knows the mimetype of the URL |
|
|
113 |
pid_t KRun::runURL( const KURL& u, const QString& _mimetype, bool tempFile, bool runExecutables, const QString& suggestedFileName ) |
113 |
pid_t KRun::runURL( const KURL& u, const QString& _mimetype, bool tempFile, bool runExecutables, const QString& suggestedFileName ) |
114 |
{ |
114 |
{ |
|
|
115 |
return runURL( u, _mimetype, NULL, "", tempFile, runExecutables, suggestedFileName ); |
116 |
} |
117 |
|
118 |
// This is called by foundMimeType, since it knows the mimetype of the URL |
119 |
pid_t KRun::runURL( const KURL& u, const QString& _mimetype, QWidget* window, const QCString& asn, |
120 |
bool tempFile, bool runExecutables, const QString& suggestedFileName ) |
121 |
{ |
115 |
bool noRun = false; |
122 |
bool noRun = false; |
116 |
bool noAuth = false; |
123 |
bool noAuth = false; |
117 |
if ( _mimetype == "inode/directory-locked" ) |
124 |
if ( _mimetype == "inode/directory-locked" ) |
118 |
{ |
125 |
{ |
119 |
KMessageBoxWrapper::error( 0L, |
126 |
KMessageBoxWrapper::error( window, |
120 |
i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>").arg(u.htmlURL()) ); |
127 |
i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>").arg(u.htmlURL()) ); |
121 |
return 0; |
128 |
return 0; |
122 |
} |
129 |
} |
Lines 133-139
pid_t KRun::runURL( const KURL& u, const
Link Here
|
133 |
{ |
140 |
{ |
134 |
QString path = u.path(); |
141 |
QString path = u.path(); |
135 |
shellQuote( path ); |
142 |
shellQuote( path ); |
136 |
return (KRun::runCommand(path)); // just execute the url as a command |
143 |
return (KRun::runCommand(path, QString::null, QString::null, window, asn)); // just execute the url as a command |
137 |
// ## TODO implement deleting the file if tempFile==true |
144 |
// ## TODO implement deleting the file if tempFile==true |
138 |
} |
145 |
} |
139 |
else |
146 |
else |
Lines 155-168
pid_t KRun::runURL( const KURL& u, const
Link Here
|
155 |
|
162 |
|
156 |
if ( noRun ) |
163 |
if ( noRun ) |
157 |
{ |
164 |
{ |
158 |
KMessageBox::sorry( 0L, |
165 |
KMessageBox::sorry( window, |
159 |
i18n("<qt>The file <b>%1</b> is an executable program. " |
166 |
i18n("<qt>The file <b>%1</b> is an executable program. " |
160 |
"For safety it will not be started.</qt>").arg(u.htmlURL())); |
167 |
"For safety it will not be started.</qt>").arg(u.htmlURL())); |
161 |
return 0; |
168 |
return 0; |
162 |
} |
169 |
} |
163 |
if ( noAuth ) |
170 |
if ( noAuth ) |
164 |
{ |
171 |
{ |
165 |
KMessageBoxWrapper::error( 0L, |
172 |
KMessageBoxWrapper::error( window, |
166 |
i18n("<qt>You do not have permission to run <b>%1</b>.</qt>").arg(u.htmlURL()) ); |
173 |
i18n("<qt>You do not have permission to run <b>%1</b>.</qt>").arg(u.htmlURL()) ); |
167 |
return 0; |
174 |
return 0; |
168 |
} |
175 |
} |
Lines 182-188
pid_t KRun::runURL( const KURL& u, const
Link Here
|
182 |
return displayOpenWithDialog( lst, tempFile, suggestedFileName ); |
189 |
return displayOpenWithDialog( lst, tempFile, suggestedFileName ); |
183 |
} |
190 |
} |
184 |
|
191 |
|
185 |
return KRun::run( *offer, lst, 0 /*window*/, tempFile, suggestedFileName ); |
192 |
return KRun::run( *offer, lst, window, asn, tempFile, suggestedFileName ); |
186 |
} |
193 |
} |
187 |
|
194 |
|
188 |
bool KRun::displayOpenWithDialog( const KURL::List& lst ) |
195 |
bool KRun::displayOpenWithDialog( const KURL::List& lst ) |
Lines 536-548
QString KRun::binaryName( const QString
Link Here
|
536 |
} |
543 |
} |
537 |
|
544 |
|
538 |
static pid_t runCommandInternal( KProcess* proc, const KService* service, const QString& binName, |
545 |
static pid_t runCommandInternal( KProcess* proc, const KService* service, const QString& binName, |
539 |
const QString &execName, const QString & iconName ) |
546 |
const QString &execName, const QString & iconName, QWidget* window, QCString asn ) |
540 |
{ |
547 |
{ |
541 |
if (service && !service->desktopEntryPath().isEmpty() |
548 |
if (service && !service->desktopEntryPath().isEmpty() |
542 |
&& !KDesktopFile::isAuthorizedDesktopFile( service->desktopEntryPath() )) |
549 |
&& !KDesktopFile::isAuthorizedDesktopFile( service->desktopEntryPath() )) |
543 |
{ |
550 |
{ |
544 |
kdWarning() << "No authorization to execute " << service->desktopEntryPath() << endl; |
551 |
kdWarning() << "No authorization to execute " << service->desktopEntryPath() << endl; |
545 |
KMessageBox::sorry(0, i18n("You are not authorized to execute this file.")); |
552 |
KMessageBox::sorry(window, i18n("You are not authorized to execute this file.")); |
546 |
return 0; |
553 |
return 0; |
547 |
} |
554 |
} |
548 |
QString bin = KRun::binaryName( binName, true ); |
555 |
QString bin = KRun::binaryName( binName, true ); |
Lines 550-559
static pid_t runCommandInternal( KProces
Link Here
|
550 |
bool silent; |
557 |
bool silent; |
551 |
QCString wmclass; |
558 |
QCString wmclass; |
552 |
KStartupInfoId id; |
559 |
KStartupInfoId id; |
553 |
bool startup_notify = KRun::checkStartupNotify( binName, service, &silent, &wmclass ); |
560 |
bool startup_notify = ( asn != "0" && KRun::checkStartupNotify( binName, service, &silent, &wmclass )); |
554 |
if( startup_notify ) |
561 |
if( startup_notify ) |
555 |
{ |
562 |
{ |
556 |
id.initId(); |
563 |
id.initId( asn ); |
557 |
id.setupStartupEnv(); |
564 |
id.setupStartupEnv(); |
558 |
KStartupInfoData data; |
565 |
KStartupInfoData data; |
559 |
data.setHostname(); |
566 |
data.setHostname(); |
Lines 572-577
static pid_t runCommandInternal( KProces
Link Here
|
572 |
if( silent ) |
579 |
if( silent ) |
573 |
data.setSilent( KStartupInfoData::Yes ); |
580 |
data.setSilent( KStartupInfoData::Yes ); |
574 |
data.setDesktop( KWin::currentDesktop()); |
581 |
data.setDesktop( KWin::currentDesktop()); |
|
|
582 |
if( window ) |
583 |
data.setLaunchedBy( window->winId()); |
575 |
KStartupInfo::sendStartup( id, data ); |
584 |
KStartupInfo::sendStartup( id, data ); |
576 |
} |
585 |
} |
577 |
pid_t pid = KProcessRunner::run( proc, binName, id ); |
586 |
pid_t pid = KProcessRunner::run( proc, binName, id ); |
Lines 629-635
bool KRun::checkStartupNotify( const QSt
Link Here
|
629 |
return true; |
638 |
return true; |
630 |
} |
639 |
} |
631 |
|
640 |
|
632 |
static pid_t runTempService( const KService& _service, const KURL::List& _urls, bool tempFiles, const QString& suggestedFileName ) |
641 |
static pid_t runTempService( const KService& _service, const KURL::List& _urls, QWidget* window, |
|
|
642 |
const QCString& asn, bool tempFiles, const QString& suggestedFileName ) |
633 |
{ |
643 |
{ |
634 |
if (!_urls.isEmpty()) { |
644 |
if (!_urls.isEmpty()) { |
635 |
kdDebug(7010) << "runTempService: first url " << _urls.first().url() << endl; |
645 |
kdDebug(7010) << "runTempService: first url " << _urls.first().url() << endl; |
Lines 648-654
static pid_t runTempService( const KServ
Link Here
|
648 |
{ |
658 |
{ |
649 |
KURL::List singleUrl; |
659 |
KURL::List singleUrl; |
650 |
singleUrl.append(*it); |
660 |
singleUrl.append(*it); |
651 |
runTempService( _service, singleUrl, tempFiles, suggestedFileName ); |
661 |
runTempService( _service, singleUrl, window, "", tempFiles, suggestedFileName ); |
652 |
} |
662 |
} |
653 |
KURL::List singleUrl; |
663 |
KURL::List singleUrl; |
654 |
singleUrl.append(_urls.first()); |
664 |
singleUrl.append(_urls.first()); |
Lines 667-673
static pid_t runTempService( const KServ
Link Here
|
667 |
proc->setWorkingDirectory(_service.path()); |
677 |
proc->setWorkingDirectory(_service.path()); |
668 |
|
678 |
|
669 |
return runCommandInternal( proc, &_service, KRun::binaryName( _service.exec(), false ), |
679 |
return runCommandInternal( proc, &_service, KRun::binaryName( _service.exec(), false ), |
670 |
_service.name(), _service.icon() ); |
680 |
_service.name(), _service.icon(), window, asn ); |
671 |
} |
681 |
} |
672 |
|
682 |
|
673 |
// WARNING: don't call this from processDesktopExec, since klauncher uses that too... |
683 |
// WARNING: don't call this from processDesktopExec, since klauncher uses that too... |
Lines 728-738
pid_t KRun::run( const KService& _servic
Link Here
|
728 |
|
738 |
|
729 |
pid_t KRun::run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles ) |
739 |
pid_t KRun::run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles ) |
730 |
{ |
740 |
{ |
731 |
return run( _service, _urls, window, tempFiles, QString::null ); |
741 |
return run( _service, _urls, window, "", tempFiles, QString::null ); |
|
|
742 |
} |
743 |
|
744 |
pid_t KRun::run( const KService& _service, const KURL::List& _urls, QWidget* window, const QCString& asn, bool tempFiles ) |
745 |
{ |
746 |
return run( _service, _urls, window, asn, tempFiles, QString::null ); |
732 |
} |
747 |
} |
733 |
|
748 |
|
734 |
pid_t KRun::run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles, const QString& suggestedFileName ) |
749 |
pid_t KRun::run( const KService& _service, const KURL::List& _urls, QWidget* window, bool tempFiles, const QString& suggestedFileName ) |
735 |
{ |
750 |
{ |
|
|
751 |
return run( _service, _urls, window, "", tempFiles, suggestedFileName ); |
752 |
} |
753 |
|
754 |
pid_t KRun::run( const KService& _service, const KURL::List& _urls, QWidget* window, const QCString& asn, |
755 |
bool tempFiles, const QString& suggestedFileName ) |
756 |
{ |
736 |
if (!_service.desktopEntryPath().isEmpty() && |
757 |
if (!_service.desktopEntryPath().isEmpty() && |
737 |
!KDesktopFile::isAuthorizedDesktopFile( _service.desktopEntryPath())) |
758 |
!KDesktopFile::isAuthorizedDesktopFile( _service.desktopEntryPath())) |
738 |
{ |
759 |
{ |
Lines 753-759
pid_t KRun::run( const KService& _servic
Link Here
|
753 |
|
774 |
|
754 |
if ( tempFiles || _service.desktopEntryPath().isEmpty() || !suggestedFileName.isEmpty() ) |
775 |
if ( tempFiles || _service.desktopEntryPath().isEmpty() || !suggestedFileName.isEmpty() ) |
755 |
{ |
776 |
{ |
756 |
return runTempService(_service, _urls, tempFiles, suggestedFileName); |
777 |
return runTempService(_service, _urls, window, asn, tempFiles, suggestedFileName); |
757 |
} |
778 |
} |
758 |
|
779 |
|
759 |
kdDebug(7010) << "KRun::run " << _service.desktopEntryPath() << endl; |
780 |
kdDebug(7010) << "KRun::run " << _service.desktopEntryPath() << endl; |
Lines 767-775
pid_t KRun::run( const KService& _servic
Link Here
|
767 |
|
788 |
|
768 |
QString error; |
789 |
QString error; |
769 |
int pid = 0; |
790 |
int pid = 0; |
770 |
|
791 |
|
|
|
792 |
QCString myasn = asn; |
793 |
// startServiceByDesktopPath() doesn't take QWidget*, add it to the startup info now |
794 |
if( window != NULL ) |
795 |
{ |
796 |
if( myasn.isEmpty()) |
797 |
myasn = KStartupInfo::createNewStartupId(); |
798 |
if( myasn != "0" ) |
799 |
{ |
800 |
KStartupInfoId id; |
801 |
id.initId( myasn ); |
802 |
KStartupInfoData data; |
803 |
data.setLaunchedBy( window->winId()); |
804 |
KStartupInfo::sendChange( id, data ); |
805 |
} |
806 |
} |
807 |
|
771 |
int i = KApplication::startServiceByDesktopPath( |
808 |
int i = KApplication::startServiceByDesktopPath( |
772 |
_service.desktopEntryPath(), urls.toStringList(), &error, 0L, &pid |
809 |
_service.desktopEntryPath(), urls.toStringList(), &error, 0L, &pid, myasn |
773 |
); |
810 |
); |
774 |
|
811 |
|
775 |
if (i != 0) |
812 |
if (i != 0) |
Lines 794-826
pid_t KRun::run( const QString& _exec, c
Link Here
|
794 |
|
831 |
|
795 |
pid_t KRun::runCommand( QString cmd ) |
832 |
pid_t KRun::runCommand( QString cmd ) |
796 |
{ |
833 |
{ |
797 |
return KRun::runCommand( cmd, QString::null, QString::null ); |
834 |
return KRun::runCommand( cmd, QString::null, QString::null, NULL, "" ); |
798 |
} |
835 |
} |
799 |
|
836 |
|
800 |
pid_t KRun::runCommand( const QString& cmd, const QString &execName, const QString & iconName ) |
837 |
pid_t KRun::runCommand( const QString& cmd, const QString &execName, const QString & iconName ) |
801 |
{ |
838 |
{ |
|
|
839 |
return KRun::runCommand( cmd, execName, iconName, NULL, "" ); |
840 |
} |
841 |
|
842 |
pid_t KRun::runCommand( const QString& cmd, const QString &execName, const QString & iconName, |
843 |
QWidget* window, const QCString& asn ) |
844 |
{ |
802 |
kdDebug(7010) << "runCommand " << cmd << "," << execName << endl; |
845 |
kdDebug(7010) << "runCommand " << cmd << "," << execName << endl; |
803 |
KProcess * proc = new KProcess; |
846 |
KProcess * proc = new KProcess; |
804 |
proc->setUseShell(true); |
847 |
proc->setUseShell(true); |
805 |
*proc << cmd; |
848 |
*proc << cmd; |
806 |
KService::Ptr service = KService::serviceByDesktopName( binaryName( execName, true ) ); |
849 |
KService::Ptr service = KService::serviceByDesktopName( binaryName( execName, true ) ); |
807 |
return runCommandInternal( proc, service.data(), binaryName( execName, false ), execName, iconName ); |
850 |
return runCommandInternal( proc, service.data(), binaryName( execName, false ), execName, iconName, |
|
|
851 |
window, asn ); |
808 |
} |
852 |
} |
809 |
|
853 |
|
810 |
KRun::KRun( const KURL& url, mode_t mode, bool isLocalFile, bool showProgressInfo ) |
854 |
KRun::KRun( const KURL& url, mode_t mode, bool isLocalFile, bool showProgressInfo ) |
811 |
:m_timer(0,"KRun::timer") |
855 |
:m_timer(0,"KRun::timer") |
812 |
{ |
856 |
{ |
813 |
init (url, 0, mode, isLocalFile, showProgressInfo); |
857 |
init (url, 0, "", mode, isLocalFile, showProgressInfo); |
814 |
} |
858 |
} |
815 |
|
859 |
|
816 |
KRun::KRun( const KURL& url, QWidget* window, mode_t mode, bool isLocalFile, |
860 |
KRun::KRun( const KURL& url, QWidget* window, mode_t mode, bool isLocalFile, |
817 |
bool showProgressInfo ) |
861 |
bool showProgressInfo ) |
818 |
:m_timer(0,"KRun::timer") |
862 |
:m_timer(0,"KRun::timer") |
819 |
{ |
863 |
{ |
820 |
init (url, window, mode, isLocalFile, showProgressInfo); |
864 |
init (url, window, "", mode, isLocalFile, showProgressInfo); |
|
|
865 |
} |
866 |
|
867 |
KRun::KRun( const KURL& url, QWidget* window, const QCString& asn, mode_t mode, bool isLocalFile, |
868 |
bool showProgressInfo ) |
869 |
:m_timer(0,"KRun::timer") |
870 |
{ |
871 |
init (url, window, asn, mode, isLocalFile, showProgressInfo); |
821 |
} |
872 |
} |
822 |
|
873 |
|
823 |
void KRun::init ( const KURL& url, QWidget* window, mode_t mode, bool isLocalFile, |
874 |
void KRun::init ( const KURL& url, QWidget* window, const QCString& asn, mode_t mode, bool isLocalFile, |
824 |
bool showProgressInfo ) |
875 |
bool showProgressInfo ) |
825 |
{ |
876 |
{ |
826 |
m_bFault = false; |
877 |
m_bFault = false; |
Lines 836-841
void KRun::init ( const KURL& url, QWidg
Link Here
|
836 |
d = new KRunPrivate; |
887 |
d = new KRunPrivate; |
837 |
d->m_runExecutables = true; |
888 |
d->m_runExecutables = true; |
838 |
d->m_window = window; |
889 |
d->m_window = window; |
|
|
890 |
d->m_asn = asn; |
839 |
setEnableExternalBrowser(true); |
891 |
setEnableExternalBrowser(true); |
840 |
|
892 |
|
841 |
// Start the timer. This means we will return to the event |
893 |
// Start the timer. This means we will return to the event |
Lines 936-942
void KRun::init()
Link Here
|
936 |
KService::Ptr service = KService::serviceByStorageId( exec ); |
988 |
KService::Ptr service = KService::serviceByStorageId( exec ); |
937 |
if (service) |
989 |
if (service) |
938 |
{ |
990 |
{ |
939 |
run( *service, urls ); |
991 |
run( *service, urls, d->m_window, d->m_asn ); |
940 |
ok = true; |
992 |
ok = true; |
941 |
} |
993 |
} |
942 |
} |
994 |
} |
Lines 1229-1235
void KRun::foundMimeType( const QString&
Link Here
|
1229 |
{ |
1281 |
{ |
1230 |
KURL::List lst; |
1282 |
KURL::List lst; |
1231 |
lst.append( m_strURL ); |
1283 |
lst.append( m_strURL ); |
1232 |
m_bFinished = KRun::run( *serv, lst ); |
1284 |
m_bFinished = KRun::run( *serv, lst, d->m_window, d->m_asn ); |
1233 |
/// Note: the line above means that if that service failed, we'll |
1285 |
/// Note: the line above means that if that service failed, we'll |
1234 |
/// go to runURL to maybe find another service, even though a dialog |
1286 |
/// go to runURL to maybe find another service, even though a dialog |
1235 |
/// box was displayed. That's good if runURL tries another service, |
1287 |
/// box was displayed. That's good if runURL tries another service, |
Lines 1244-1250
void KRun::foundMimeType( const QString&
Link Here
|
1244 |
m_strURL.setPath( d->m_localPath ); |
1296 |
m_strURL.setPath( d->m_localPath ); |
1245 |
} |
1297 |
} |
1246 |
|
1298 |
|
1247 |
if (!m_bFinished && KRun::runURL( m_strURL, type, false, d->m_runExecutables, d->m_suggestedFileName )){ |
1299 |
if (!m_bFinished && KRun::runURL( m_strURL, type, d->m_window, d->m_asn, false, d->m_runExecutables, d->m_suggestedFileName )){ |
1248 |
m_bFinished = true; |
1300 |
m_bFinished = true; |
1249 |
} |
1301 |
} |
1250 |
else{ |
1302 |
else{ |