File indexing completed on 2021-12-21 14:36:51

0001 /*
0002     SPDX-FileCopyrightText: 2002 Jean-Baptiste Mardelle <bj@altern.org>
0003     SPDX-FileCopyrightText: 2007, 2008, 2009, 2010, 2012, 2013 Rolf Eike Beer <kde@opensource.sf-tec.de>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KEYSERVERS_H
0008 #define KEYSERVERS_H
0009 
0010 #include <QSortFilterProxyModel>
0011 
0012 #include <QDialog>
0013 
0014 #include "core/kgpgkey.h"
0015 #include "model/kgpgsearchresultmodel.h"
0016 #include "ui_searchres.h"
0017 #include "ui_keyserver.h"
0018 
0019 class KGpgKeyserverSearchTransaction;
0020 class KeyListProxyModel;
0021 class KGpgItemModel;
0022 
0023 class keyServerWidget : public QWidget, public Ui::keyServerWidget
0024 {
0025 public:
0026     explicit keyServerWidget(QWidget *parent = nullptr)
0027       : QWidget(parent)
0028     {
0029         setupUi(this);
0030     }
0031 };
0032 
0033 class searchRes : public QWidget, public Ui::searchRes
0034 {
0035 public:
0036     explicit searchRes(QWidget *parent)
0037       : QWidget(parent)
0038     {
0039         setupUi(this);
0040     }
0041 };
0042 
0043 class KeyServer : public QDialog
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     explicit KeyServer(QWidget *parent = nullptr, KGpgItemModel *model = nullptr, const bool autoclose = false);
0049     ~KeyServer() override;
0050 
0051     /**
0052      * Returns the server list.
0053      * The first item is the server configured in gpg.
0054      */
0055     static QStringList getServerList();
0056 
0057     /**
0058      * @brief import the given keys
0059      * @param keys the key fingerprints or ids to import
0060      * @param server the key server to use, if empty the default server is used
0061      * @param proxy the proxy to use
0062      *
0063      * This will set up the underlying transaction to fetch the keys as well
0064      * as it will take care of setting up everything so the user will get the
0065      * results shown.
0066      */
0067     void startImport(const QStringList &keys, QString server = QString(), const QString &proxy = QString());
0068 
0069 Q_SIGNALS:
0070     /**
0071      * @brief emitted when importing keys succeeded
0072      *
0073      * This is only emitted when at least one key has been imported.
0074      */
0075     void importFinished(QStringList);
0076 
0077     /**
0078      * @brief importing failed
0079      *
0080      * This is emitted when key importing is finished and importFinished() is
0081      * _not_ emitted. The main usage is to properly clean up the object when
0082      * using startImport().
0083      */
0084     void importFailed();
0085 
0086 public Q_SLOTS:
0087     void slotImport();
0088 
0089     void slotExport(const QStringList &keyIds);
0090 
0091     void slotSetText(const QString &text);
0092     void slotTextChanged(const QString &text);
0093     void slotSetExportAttribute(const QString &attr);
0094     void slotEnableProxyI(const bool on);
0095     void slotEnableProxyE(const bool on);
0096     void slotSetKeyserver(const QString &server);
0097 
0098     void transferKeyID();
0099     void slotPreImport();
0100     void slotPreExport();
0101 
0102     void slotOk();
0103     void handleQuit();
0104 
0105 private Q_SLOTS:
0106     void slotDownloadKeysFinished(int resultcode);
0107     void slotUploadKeysFinished(int resultcode);
0108 
0109     void slotSearchResult(int result);
0110     void slotSearch();
0111     void slotSetFilterString(const QString &expression);
0112     void slotUpdateLabelOnFilterChange();
0113 
0114 private:
0115     QString m_readmessage;
0116 
0117     QDialog *m_dialogserver;
0118     KGpgKeyserverSearchTransaction *m_searchproc;
0119 
0120     keyServerWidget *page;
0121     searchRes *m_listpop;
0122 
0123     bool m_autoclose;
0124     QString expattr;
0125 
0126     KGpgSearchResultModel m_resultmodel;
0127 
0128     KeyListProxyModel *m_itemmodel;
0129 };
0130 
0131 #endif // KEYSERVERS_H