1 /* 2 SPDX-FileCopyrightText: 2009, 2010, 2012, 2014 Rolf Eike Beer <kde@opensource.sf-tec.de> 3 SPDX-License-Identifier: GPL-2.0-or-later 4 */ 5 6 #ifndef KGPGTRANSACTIONJOB_H 7 #define KGPGTRANSACTIONJOB_H 8 9 #include <KJob> 10 11 class KGpgTransaction; 12 13 /** 14 * @brief Wrap a GnuPG transaction in a job 15 * 16 * This class allows to run any KGpgTransaction as KJob. 17 * 18 * @author Rolf Eike Beer 19 */ 20 class KGpgTransactionJob : public KJob { 21 Q_OBJECT 22 23 Q_DISABLE_COPY(KGpgTransactionJob) 24 KGpgTransactionJob() = delete; 25 26 public: 27 /** 28 * @brief create a new KJob for this transaction 29 * @param transaction operation to do 30 * 31 * The job will take ownership of the transaction, i.e. 32 * will delete the transaction object when the job is done. 33 */ 34 explicit KGpgTransactionJob(KGpgTransaction *transaction); 35 /** 36 * @brief KGpgTransactionJob destructor 37 */ 38 ~KGpgTransactionJob() override; 39 40 /** 41 * @brief starts the transaction 42 */ 43 void start() override; 44 45 /** 46 * @brief get the transaction this job is handling 47 */ 48 const KGpgTransaction *getTransaction() const; 49 50 /** 51 * @brief get the result of the transaction 52 */ 53 int getResultCode() const; 54 55 protected: 56 bool doKill() override; 57 58 private Q_SLOTS: 59 void slotTransactionDone(int result); 60 void slotStatusMessage(const QString &plain); 61 void slotInfoProgress(qulonglong processedAmount, qulonglong totalAmount); 62 63 private: 64 KGpgTransaction * const m_transaction; 65 int m_result; 66 bool m_wasKilled; 67 }; 68 69 #endif 70