diff --git a/mailtransport/precommandjob.cpp b/mailtransport/precommandjob.cpp index d65a25f24..c44f28575 100644 --- a/mailtransport/precommandjob.cpp +++ b/mailtransport/precommandjob.cpp @@ -1,99 +1,100 @@ /* Copyright (c) 2007 Volker Krause Based on KMail code by: Copyright (c) 1996-1998 Stefan Taferner Copyright (c) 2000-2002 Michael Haeckel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "precommandjob.h" #include -#include +#include using namespace MailTransport; /** * Private class that helps to provide binary compatibility between releases. * @internal */ class PreCommandJobPrivate { public: - QProcess *process; + KProcess *process; QString precommand; }; PrecommandJob::PrecommandJob(const QString & precommand, QObject * parent) : KJob( parent ), d( new PreCommandJobPrivate ) { d->precommand = precommand; - d->process = new QProcess( this ); + d->process = new KProcess( this ); connect( d->process, SIGNAL(started()), SLOT(slotStarted()) ); connect( d->process, SIGNAL(error(QProcess::ProcessError error)), SLOT(slotError(QProcess::ProcessError error))); connect( d->process, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotFinished(int, QProcess::ExitStatus)) ); } PrecommandJob::~ PrecommandJob() { delete d; } void PrecommandJob::start() { - d->process->start( d->precommand ); + d->process->setShellCommand( d->precommand ); + d->process->start(); } void PrecommandJob::slotStarted() { emit infoMessage( this, i18n("Executing precommand"), i18n("Executing precommand '%1'.", d->precommand ) ); } -void PrecommandJob::slotEror( QProcess::ProcessError error) +void PrecommandJob::slotError( QProcess::ProcessError error) { setError( UserDefinedError ); setErrorText( i18n("Could not execute precommand '%1'.", d->precommand ) ); kDebug(5324) << "Execution precommand has failed: " << error << endl; emitResult(); } bool PrecommandJob::doKill() { delete d->process; d->process = 0; return true; } void PrecommandJob::slotFinished(int exitCode, QProcess::ExitStatus exitStatus ) { if ( exitStatus == QProcess::CrashExit ) { setError( UserDefinedError ); setErrorText( i18n("The precommand crashed." )); } else if ( exitCode != 0 ) { setError( UserDefinedError ); setErrorText( i18n("The precommand exited with code %1.", d->process->exitStatus()) ); } emitResult(); } #include "precommandjob.moc" diff --git a/mailtransport/precommandjob.h b/mailtransport/precommandjob.h index 62e0ae3b9..47a5177bd 100644 --- a/mailtransport/precommandjob.h +++ b/mailtransport/precommandjob.h @@ -1,74 +1,74 @@ /* Copyright (c) 2007 Volker Krause Based on KMail code by: Copyright (c) 1996-1998 Stefan Taferner Copyright (c) 2000-2002 Michael Haeckel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAILTRANSPORT_PRECOMMANDJOB_H #define MAILTRANSPORT_PRECOMMANDJOB_H #include #include class PreCommandJobPrivate; namespace MailTransport { /** Job to execute commands before connecting to an account. */ class PrecommandJob : public KJob { Q_OBJECT public: /** Creates a new precommand job. @param precommand The command to run. @param parent The parent object. */ explicit PrecommandJob( const QString &precommand, QObject *parent = 0 ); /** Destroys this job. */ virtual ~PrecommandJob(); /** Executes the precommand. */ virtual void start(); protected: virtual bool doKill(); private slots: void slotFinished(int, QProcess::ExitStatus); void slotStarted(); - void slotEror( QProcess::ProcessError error); + void slotError( QProcess::ProcessError error); private: PreCommandJobPrivate *const d; }; } #endif