File indexing completed on 2024-06-23 05:15:11

0001 /*
0002     SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
0003 
0004     Based on KMail code by:
0005     SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
0006     SPDX-FileCopyrightText: 2000-2002 Michael Haeckel <haeckel@kde.org>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include "mailtransport_export.h"
0014 
0015 #include <KJob>
0016 
0017 #include <memory>
0018 
0019 class PreCommandJobPrivate;
0020 
0021 namespace MailTransport
0022 {
0023 /**
0024   Job to execute a command.
0025   This is used often for sending or receiving mails, for example to set up
0026   a tunnel of VPN connection.
0027   Basically this is just a KJob wrapper around a QProcess.
0028 
0029   @since 4.4
0030  */
0031 class MAILTRANSPORT_EXPORT PrecommandJob : public KJob
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     /**
0037       Creates a new precommand job.
0038       @param precommand The command to run.
0039       @param parent The parent object.
0040     */
0041     explicit PrecommandJob(const QString &precommand, QObject *parent = nullptr);
0042 
0043     /**
0044       Destroys this job.
0045     */
0046     ~PrecommandJob() override;
0047 
0048     /**
0049       Executes the precommand.
0050       Reimplemented from KJob.
0051     */
0052     void start() override;
0053 
0054 protected:
0055     /**
0056       Reimplemented from KJob.
0057     */
0058     bool doKill() override;
0059 
0060 private:
0061     friend class ::PreCommandJobPrivate;
0062     std::unique_ptr<PreCommandJobPrivate> const d;
0063 };
0064 } // namespace MailTransport