File indexing completed on 2024-04-21 09:41:40

0001 /*
0002     SPDX-FileCopyrightText: 2010-2022 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGPGKEYSERVERSEARCHTRANSACTION_H
0007 #define KGPGKEYSERVERSEARCHTRANSACTION_H
0008 
0009 #include <QObject>
0010 #include <QString>
0011 #include <QStringList>
0012 
0013 #include "kgpgkeyservertransaction.h"
0014 
0015 /**
0016  * @brief base class for transactions downloading from key servers
0017  */
0018 class KGpgKeyserverSearchTransaction: public KGpgKeyserverTransaction {
0019     Q_OBJECT
0020 
0021     Q_DISABLE_COPY(KGpgKeyserverSearchTransaction)
0022     /**
0023      * @brief forbidden
0024      */
0025     KGpgKeyserverSearchTransaction() = delete;
0026 
0027 public:
0028     /**
0029      * @brief construct a new search on the given keyserver
0030      * @param parent object that owns the transaction
0031      * @param keyserver keyserver to work with
0032      * @param pattern the search pattern
0033      * @param withProgress show a progress window with cancel button
0034      * @param proxy http proxy to use
0035      *
0036      * You should call this from the childrens constructor to set up
0037      * everything properly
0038      */
0039     KGpgKeyserverSearchTransaction(QObject *parent, const QString &keyserver, const QString &pattern, const bool withProgress = false, const QString &proxy = QString());
0040     ~KGpgKeyserverSearchTransaction() override = default;
0041 
0042     void setPattern(const QString &pattern);
0043 
0044 Q_SIGNALS:
0045     /**
0046      * @brief emitted every time a new key is completed
0047      * @param lines the lines that belong to that key
0048      */
0049     void newKey(QStringList lines);
0050 
0051 protected:
0052     bool preStart() override;
0053     bool nextLine(const QString &line) override;
0054     /**
0055      * @brief needed to submit the last search result
0056      */
0057     void finish() override;
0058 
0059 private:
0060     QStringList m_keyLines;     ///< the lines belonging to one key
0061     int m_patternPos;
0062     bool m_pageEmpty;       ///< if the current page of output is empty
0063 };
0064 
0065 #endif // KGPGUIDTRANSACTION_H