1/*
2 Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3
4 Based on KMail code by:
5 Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
6 Copyright (c) 2000-2002 Michael Haeckel <haeckel@kde.org>
7
8 This library is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Library General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or (at your
11 option) any later version.
12
13 This library is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16 License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to the
20 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef MAILTRANSPORT_PRECOMMANDJOB_H
25#define MAILTRANSPORT_PRECOMMANDJOB_H
26
27#include "mailtransport/mailtransport_export.h"
28
29#include <KDE/KJob>
30
31class PreCommandJobPrivate;
32
33namespace MailTransport {
34
35/**
36 Job to execute a command.
37 This is used often for sending or receiving mails, for example to set up
38 a tunnel of VPN connection.
39 Basically this is just a KJob wrapper around a QProcess.
40
41 @since 4.4
42 */
43class MAILTRANSPORT_EXPORT PrecommandJob : public KJob
44{
45 Q_OBJECT
46
47 public:
48 /**
49 Creates a new precommand job.
50 @param precommand The command to run.
51 @param parent The parent object.
52 */
53 explicit PrecommandJob( const QString &precommand, QObject *parent = 0 );
54
55 /**
56 Destroys this job.
57 */
58 virtual ~PrecommandJob();
59
60 /**
61 Executes the precommand.
62 Reimplemented from KJob.
63 */
64 virtual void start();
65
66 protected:
67
68 /**
69 Reimplemented from KJob.
70 */
71 virtual bool doKill();
72
73 private:
74 friend class ::PreCommandJobPrivate;
75 PreCommandJobPrivate *const d;
76 Q_PRIVATE_SLOT( d, void slotFinished( int, QProcess::ExitStatus ) )
77 Q_PRIVATE_SLOT( d, void slotStarted() )
78 Q_PRIVATE_SLOT( d, void slotError( QProcess::ProcessError error ) )
79};
80
81} // namespace MailTransport
82
83#endif // MAILTRANSPORT_PRECOMMANDJOB_H
84