File indexing completed on 2024-06-16 04:55:55
0001 /* -*- mode: c++; c-basic-offset:4 -*- 0002 crypto/controller.h 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <QObject> 0013 0014 #include <crypto/task.h> 0015 0016 #include <utils/pimpl_ptr.h> 0017 #include <utils/types.h> 0018 0019 #include <memory> 0020 0021 namespace Kleo 0022 { 0023 namespace Crypto 0024 { 0025 0026 class Controller : public QObject, protected ExecutionContextUser 0027 { 0028 Q_OBJECT 0029 public: 0030 explicit Controller(QObject *parent = nullptr); 0031 explicit Controller(const std::shared_ptr<const ExecutionContext> &cmd, QObject *parent = nullptr); 0032 ~Controller() override; 0033 0034 using ExecutionContextUser::setExecutionContext; 0035 0036 Q_SIGNALS: 0037 void progress(int current, int total, const QString &what); 0038 0039 protected: 0040 void emitDoneOrError(); 0041 void setLastError(int err, const QString &details); 0042 void connectTask(const std::shared_ptr<Task> &task); 0043 0044 virtual void doTaskDone(const Task *task, const std::shared_ptr<const Task::Result> &result); 0045 0046 protected Q_SLOTS: 0047 void taskDone(const std::shared_ptr<const Kleo::Crypto::Task::Result> &); 0048 0049 Q_SIGNALS: 0050 /** 0051 * Private signal, you can connect to it, but derived classes cannot emit it. 0052 */ 0053 void error(int err, 0054 const QString &details 0055 #ifndef DOXYGEN_SHOULD_SKIP_THIS 0056 , 0057 QPrivateSignal 0058 #endif 0059 ); 0060 0061 /** 0062 * Private signal, you can connect to it, but derived classes cannot emit it. 0063 */ 0064 void done( 0065 #ifndef DOXYGEN_SHOULD_SKIP_THIS 0066 QPrivateSignal 0067 #endif 0068 ); 0069 0070 private: 0071 class Private; 0072 kdtools::pimpl_ptr<Private> d; 0073 }; 0074 0075 } 0076 }