File indexing completed on 2022-09-27 16:32:28

0001 /*
0002     SPDX-FileCopyrightText: 2009, 2010, 2012, 2014 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGPGTRANSACTIONJOB_H
0007 #define KGPGTRANSACTIONJOB_H
0008 
0009 #include <KJob>
0010 
0011 class KGpgTransaction;
0012 
0013 /**
0014 * @brief Wrap a GnuPG transaction in a job
0015 *
0016 * This class allows to run any KGpgTransaction as KJob.
0017 *
0018 * @author Rolf Eike Beer
0019 */
0020 class KGpgTransactionJob : public KJob {
0021     Q_OBJECT
0022 
0023     Q_DISABLE_COPY(KGpgTransactionJob)
0024     KGpgTransactionJob() = delete;
0025 
0026 public:
0027     /**
0028      * @brief create a new KJob for this transaction
0029      * @param transaction operation to do
0030      *
0031      * The job will take ownership of the transaction, i.e.
0032      * will delete the transaction object when the job is done.
0033      */
0034     explicit KGpgTransactionJob(KGpgTransaction *transaction);
0035     /**
0036      * @brief KGpgTransactionJob destructor
0037      */
0038     ~KGpgTransactionJob() override;
0039 
0040     /**
0041      * @brief starts the transaction
0042      */
0043     void start() override;
0044 
0045     /**
0046      * @brief get the transaction this job is handling
0047      */
0048     const KGpgTransaction *getTransaction() const;
0049 
0050     /**
0051      * @brief get the result of the transaction
0052      */
0053     int getResultCode() const;
0054 
0055 protected:
0056     bool doKill() override;
0057 
0058 private Q_SLOTS:
0059     void slotTransactionDone(int result);
0060     void slotStatusMessage(const QString &plain);
0061     void slotInfoProgress(qulonglong processedAmount, qulonglong totalAmount);
0062 
0063 private:
0064     KGpgTransaction * const m_transaction;
0065     int m_result;
0066     bool m_wasKilled;
0067 };
0068 
0069 #endif