File indexing completed on 2024-04-28 05:50:19

0001 /*
0002     SPDX-FileCopyrightText: 2008-2022 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGPGTRANSACTIONPRIVATE_H
0007 #define KGPGTRANSACTIONPRIVATE_H
0008 
0009 #include "gpgproc.h"
0010 
0011 #include <QUrl>
0012 
0013 #include <KPasswordDialog>
0014 #include <KNewPasswordDialog>
0015 
0016 class KGpgTransaction;
0017 
0018 class KGpgTransactionPrivate : public QObject {
0019 public:
0020     KGpgTransactionPrivate(KGpgTransaction *parent, bool allowChaining);
0021     ~KGpgTransactionPrivate() override;
0022 
0023     KGpgTransaction *m_parent;
0024     GPGProc *m_process;
0025     KGpgTransaction *m_inputTransaction;
0026     KNewPasswordDialog *m_newPasswordDialog;
0027     KPasswordDialog *m_passwordDialog;
0028     int m_success;
0029     int m_tries;
0030     QString m_description;
0031     bool m_chainingAllowed;
0032 
0033     QStringList m_idhints;
0034     QStringList m_expectedFingerprints;
0035 
0036     QUrl m_overwriteUrl;    ///< the file to overwrite or it's new name
0037 
0038     void slotReadReady();
0039     void slotProcessExited();
0040     void slotProcessStarted();
0041     void slotInputTransactionDone(int result);
0042     void slotPassphraseEntered(const QString &passphrase);
0043 
0044     /**
0045      * @brief a slot to handle the case that the passphrase entry was aborted by the user
0046      *
0047      * This will delete the sender as well as do the internal passphrase aborted handling.
0048      */
0049     void slotPassphraseAborted();
0050     /**
0051      * @brief do the internal passphrase aborted handling
0052      */
0053     void handlePassphraseAborted();
0054 
0055     QList<int *> m_argRefs;
0056     bool m_inputProcessDone;
0057     int m_inputProcessResult;
0058     bool m_ownProcessFinished;
0059 
0060     /**
0061      * terminate GnuPG session
0062      */
0063     void sendQuit(void);
0064 
0065     void write(const QByteArray &a);
0066 
0067     static const QStringList &hintNames(void);
0068 
0069     /**
0070      * @brief handle if this a KEY_CONSIDERED line
0071      * @param line the line from GnuPG output
0072      * @returns if this is a KEY_CONSIDERED line
0073      *
0074      * In case this is a KEY_CONSIDERED line (i.e. the return value is true),
0075      * but either it was malformed or the given fingerprint does not match any
0076      * key in m_expectedFingerprints, the success value will be set to TS_MSG_SEQUENCE.
0077      *
0078      * @see setExpectedIds
0079      */
0080     bool keyConsidered(const QString &line);
0081 
0082 private:
0083     void processDone();
0084 
0085     unsigned int m_quitTries;   ///< how many times we tried to quit
0086     QStringList m_quitLines;    ///< what we received after we tried to quit
0087 };
0088 
0089 #endif // KGPGTRANSACTIONPRIVATE_H