• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

mailtransport

precommandjob.cpp

00001 /*
00002     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00003 
00004     Based on KMail code by:
00005     Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
00006     Copyright (c) 2000-2002 Michael Haeckel <haeckel@kde.org>
00007 
00008     This library is free software; you can redistribute it and/or modify it
00009     under the terms of the GNU Library General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or (at your
00011     option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful, but WITHOUT
00014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00016     License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to the
00020     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00021     02110-1301, USA.
00022 */
00023 
00024 #include "precommandjob.h"
00025 
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 #include <KProcess>
00029 
00030 using namespace MailTransport;
00031 
00036 class PreCommandJobPrivate
00037 {
00038   public:
00039     KProcess *process;
00040     QString precommand;
00041 };
00042 
00043 PrecommandJob::PrecommandJob( const QString &precommand, QObject *parent )
00044   : KJob( parent ), d( new PreCommandJobPrivate )
00045 {
00046   d->precommand = precommand;
00047   d->process = new KProcess( this );
00048   connect( d->process, SIGNAL(started()), SLOT(slotStarted()) );
00049   connect( d->process, SIGNAL(error(QProcess::ProcessError error)),
00050            SLOT(slotError(QProcess::ProcessError error)));
00051   connect( d->process, SIGNAL(finished(int, QProcess::ExitStatus)),
00052            SLOT(slotFinished(int, QProcess::ExitStatus)) );
00053 }
00054 
00055 PrecommandJob::~ PrecommandJob()
00056 {
00057   delete d;
00058 }
00059 
00060 void PrecommandJob::start()
00061 {
00062   d->process->setShellCommand( d->precommand );
00063   d->process->start();
00064 }
00065 
00066 void PrecommandJob::slotStarted()
00067 {
00068   emit infoMessage( this, i18n( "Executing precommand" ),
00069                     i18n( "Executing precommand '%1'.", d->precommand ) );
00070 }
00071 
00072 void PrecommandJob::slotError( QProcess::ProcessError error )
00073 {
00074   setError( UserDefinedError );
00075   setErrorText( i18n( "Could not execute precommand '%1'.", d->precommand ) );
00076   kDebug() << "Execution precommand has failed:" << error;
00077   emitResult();
00078 }
00079 
00080 bool PrecommandJob::doKill()
00081 {
00082   delete d->process;
00083   d->process = 0;
00084   return true;
00085 }
00086 
00087 void PrecommandJob::slotFinished( int exitCode, QProcess::ExitStatus exitStatus )
00088 {
00089   if ( exitStatus == QProcess::CrashExit ) {
00090     setError( UserDefinedError );
00091     setErrorText( i18n( "The precommand crashed." ) );
00092   } else if ( exitCode != 0 ) {
00093     setError( UserDefinedError );
00094     setErrorText( i18n( "The precommand exited with code %1.",
00095                         d->process->exitStatus() ) );
00096   }
00097   emitResult();
00098 }
00099 
00100 #include "precommandjob.moc"

mailtransport

Skip menu "mailtransport"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal