File indexing completed on 2024-05-05 05:53:24

0001 /*
0002     SPDX-FileCopyrightText: 2009 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGPGKEYSERVERTRANSACTION_H
0007 #define KGPGKEYSERVERTRANSACTION_H
0008 
0009 #include <QObject>
0010 #include <QString>
0011 
0012 #include "kgpgtransaction.h"
0013 
0014 class QProgressDialog;
0015 
0016 /**
0017  * @brief base class for transactions involving key servers
0018  */
0019 class KGpgKeyserverTransaction: public KGpgTransaction {
0020     Q_OBJECT
0021 
0022     Q_DISABLE_COPY(KGpgKeyserverTransaction)
0023     /**
0024      * @brief forbidden
0025      */
0026     KGpgKeyserverTransaction() = delete;
0027 protected:
0028     /**
0029      * @brief construct a new transaction for the given keyserver
0030      * @param parent object that owns the transaction
0031      * @param keyserver keyserver to work with
0032      * @param withProgress show a progress window with cancel button
0033      * @param proxy http proxy to use
0034      *
0035      * You should call this from the childrens constructor to set up
0036      * everything properly.
0037      *
0038      * If the progress window is enabled and parent is an QWidget it is
0039      * set as the parent of the progress window.
0040      */
0041     KGpgKeyserverTransaction(QObject *parent, const QString &keyserver, const bool withProgress = false, const QString &proxy = QString());
0042 public:
0043     ~KGpgKeyserverTransaction() override;
0044 
0045     /**
0046      * @brief set the keyserver
0047      * @param server keyserver to work with
0048      */
0049     void setKeyserver(const QString &server);
0050     /**
0051      * @brief set the http proxy
0052      * @param proxy http proxy to use
0053      *
0054      * If the server is set to an empty value no proxy is used.
0055      */
0056     void setProxy(const QString &proxy);
0057     /**
0058      * @brief activate the progress window
0059      * @param b new activation status
0060      */
0061     void setProgressEnable(const bool b);
0062 
0063 protected:
0064     void finish() override;
0065     bool preStart() override;
0066 
0067 private Q_SLOTS:
0068     /**
0069      * @brief abort the current operation
0070      */
0071     void slotAbort();
0072 
0073 private:
0074     QString m_keyserver;
0075     int m_keyserverpos;
0076     QString m_proxy;
0077     int m_proxypos;
0078     QProgressDialog *m_progress;
0079     bool m_showprogress;
0080 };
0081 
0082 #endif // KGPGUIDTRANSACTION_H