diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/MainWindow.h | 4 | ||||
-rw-r--r-- | include/gpg/GpgContext.h | 21 | ||||
-rw-r--r-- | include/gpg/result_analyse/DecryptResultAnalyse.h | 23 | ||||
-rw-r--r-- | include/gpg/result_analyse/EncryptResultAnalyse.h | 17 | ||||
-rw-r--r-- | include/gpg/result_analyse/ResultAnalyse.h | 28 | ||||
-rw-r--r-- | include/gpg/result_analyse/SignResultAnalyse.h | 18 | ||||
-rw-r--r-- | include/gpg/result_analyse/VerifyResultAnalyse.h | 16 | ||||
-rw-r--r-- | include/ui/VerifyDetailsDialog.h | 5 |
8 files changed, 96 insertions, 36 deletions
diff --git a/include/MainWindow.h b/include/MainWindow.h index b4dc9b44..66a11169 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -36,6 +36,10 @@ #include "ui/FindWidget.h" #include "ui/Wizard.h" +#include "gpg/result_analyse/SignResultAnalyse.h" +#include "gpg/result_analyse/EncryptResultAnalyse.h" +#include "gpg/result_analyse/DecryptResultAnalyse.h" + /** * @brief diff --git a/include/gpg/GpgContext.h b/include/gpg/GpgContext.h index 600d7c57..2ffbeac2 100644 --- a/include/gpg/GpgContext.h +++ b/include/gpg/GpgContext.h @@ -83,13 +83,13 @@ namespace GpgME { void deleteKeys(QStringList *uidList); - bool encrypt(QStringList *uidList, const QByteArray &inBuffer, - QByteArray *outBuffer); + gpg_error_t encrypt(QVector<GpgKey> &keys, const QByteArray &inBuffer, QByteArray *outBuffer, + gpgme_encrypt_result_t *result); - bool encryptSign(QVector<GpgKey> &keys, const QByteArray &inBuffer, - QByteArray *outBuffer); + gpgme_error_t encryptSign(QVector<GpgKey> &keys, const QByteArray &inBuffer, QByteArray *outBuffer, + gpgme_encrypt_result_t *encr_result, gpgme_sign_result_t *sign_result); - bool decrypt(const QByteArray &inBuffer, QByteArray *outBuffer); + gpgme_error_t decrypt(const QByteArray &inBuffer, QByteArray *outBuffer, gpgme_decrypt_result_t *result); void clearPasswordCache(); @@ -99,13 +99,15 @@ namespace GpgME { void setSigners(const QVector<GpgKey> &keys); - bool signKey(const GpgKey &target, const QString& uid, const QDateTime *expires); + bool signKey(const GpgKey &target, const QString &uid, const QDateTime *expires); bool revSign(const GpgKey &key, const GpgKeySignature &signature); - gpgme_signature_t verify(QByteArray *inBuffer, QByteArray *sigBuffer = nullptr); + gpgme_error_t verify(QByteArray *inBuffer, QByteArray *sigBuffer, gpgme_verify_result_t *result); - bool sign(QVector<GpgKey> keys, const QByteArray &inBuffer, QByteArray *outBuffer, bool detached = false); + gpg_error_t + sign(const QVector<GpgKey> &keys, const QByteArray &inBuffer, QByteArray *outBuffer, bool detached = false, + gpgme_sign_result_t* result = nullptr); bool addUID(const GpgKey &key, const GpgUID &uid); @@ -116,8 +118,11 @@ namespace GpgME { bool setExpire(const GpgKey &key, const GpgSubKey *subkey, QDateTime *expires); static bool checkIfKeyCanSign(const GpgKey &key); + static bool checkIfKeyCanCert(const GpgKey &key); + static bool checkIfKeyCanAuth(const GpgKey &key); + static bool checkIfKeyCanEncr(const GpgKey &key); /** diff --git a/include/gpg/result_analyse/DecryptResultAnalyse.h b/include/gpg/result_analyse/DecryptResultAnalyse.h new file mode 100644 index 00000000..6ec7d3be --- /dev/null +++ b/include/gpg/result_analyse/DecryptResultAnalyse.h @@ -0,0 +1,23 @@ +// +// Created by eric on 2021/6/9. +// + +#ifndef GPGFRONTEND_DECRYPTRESULTANALYSE_H +#define GPGFRONTEND_DECRYPTRESULTANALYSE_H + +#include "gpg/GpgContext.h" +#include "ResultAnalyse.h" + +class DecryptResultAnalyse: public ResultAnalyse{ +public: + explicit DecryptResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_decrypt_result_t result); + +private: + + GpgME::GpgContext *mCtx; + + bool printReci(QTextStream &stream, gpgme_recipient_t reci); +}; + + +#endif //GPGFRONTEND_DECRYPTRESULTANALYSE_H diff --git a/include/gpg/result_analyse/EncryptResultAnalyse.h b/include/gpg/result_analyse/EncryptResultAnalyse.h new file mode 100644 index 00000000..4717728b --- /dev/null +++ b/include/gpg/result_analyse/EncryptResultAnalyse.h @@ -0,0 +1,17 @@ +// +// Created by eric on 2021/6/9. +// + +#ifndef GPGFRONTEND_ENCRYPTRESULTANALYSE_H +#define GPGFRONTEND_ENCRYPTRESULTANALYSE_H + +#include "ResultAnalyse.h" + +class EncryptResultAnalyse : public ResultAnalyse{ +public: + explicit EncryptResultAnalyse(gpgme_error_t error, gpgme_encrypt_result_t result); + +}; + + +#endif //GPGFRONTEND_ENCRYPTRESULTANALYSE_H diff --git a/include/gpg/result_analyse/ResultAnalyse.h b/include/gpg/result_analyse/ResultAnalyse.h new file mode 100644 index 00000000..debfb71a --- /dev/null +++ b/include/gpg/result_analyse/ResultAnalyse.h @@ -0,0 +1,28 @@ +// +// Created by eric on 2021/6/8. +// + +#ifndef GPGFRONTEND_RESULTANALYSE_H +#define GPGFRONTEND_RESULTANALYSE_H + +#include "GpgFrontend.h" + +class ResultAnalyse { +public: + ResultAnalyse() = default; + + [[nodiscard]] const QString &getResultReport() const; + + [[nodiscard]] int getStatus() const; + +protected: + QString resultText; + QTextStream stream{&resultText}; + + int status = 1; + + void setStatus(int mStatus); +}; + + +#endif //GPGFRONTEND_RESULTANALYSE_H diff --git a/include/gpg/result_analyse/SignResultAnalyse.h b/include/gpg/result_analyse/SignResultAnalyse.h index 933089bf..e837140d 100644 --- a/include/gpg/result_analyse/SignResultAnalyse.h +++ b/include/gpg/result_analyse/SignResultAnalyse.h @@ -7,24 +7,14 @@ #include "GpgFrontend.h" -class SignResultAnalyse { -public: - SignResultAnalyse(gpgme_sign_result_t result); +#include "ResultAnalyse.h" - [[nodiscard]] const QString &getResultReport() const; +class SignResultAnalyse : public ResultAnalyse{ +public: + explicit SignResultAnalyse(gpgme_error_t error, gpgme_sign_result_t result); - [[nodiscard]] int getStatus() const; private: - QString resultText; - QTextStream stream{&resultText}; - - int status = 1; - - void setStatus(int mStatus) { - if(mStatus < status) status = mStatus; - } - }; diff --git a/include/gpg/result_analyse/VerifyResultAnalyse.h b/include/gpg/result_analyse/VerifyResultAnalyse.h index 7c4faf3c..2041940b 100644 --- a/include/gpg/result_analyse/VerifyResultAnalyse.h +++ b/include/gpg/result_analyse/VerifyResultAnalyse.h @@ -8,27 +8,19 @@ #include "gpg/GpgContext.h" #include "gpg/GpgKeySignature.h" -class VerifyResultAnalyse { -public: - - explicit VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_signature_t signature); +#include "ResultAnalyse.h" - [[nodiscard]] const QString &getResultReport() const; +class VerifyResultAnalyse : public ResultAnalyse{ +public: - [[nodiscard]] int getStatus() const; + explicit VerifyResultAnalyse(GpgME::GpgContext *ctx, gpgme_error_t error, gpgme_verify_result_t result); private: GpgME::GpgContext *mCtx; - QString verifyLabelText; - QTextStream textSteam{&verifyLabelText}; - - int status = 1; bool printSigner(QTextStream &stream, gpgme_signature_t sign); - void setStatus(int mStatus); - }; diff --git a/include/ui/VerifyDetailsDialog.h b/include/ui/VerifyDetailsDialog.h index 571f7ba1..a1f28e5d 100644 --- a/include/ui/VerifyDetailsDialog.h +++ b/include/ui/VerifyDetailsDialog.h @@ -31,8 +31,8 @@ class VerifyDetailsDialog : public QDialog { Q_OBJECT public: - explicit VerifyDetailsDialog(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList, - gpgme_signature_t signature); + explicit VerifyDetailsDialog(QWidget *parent, GpgME::GpgContext *ctx, KeyList *keyList, gpg_error_t error, + gpgme_verify_result_t result); private slots: @@ -47,6 +47,7 @@ private: QByteArray *mInputSignature{}; /** Data to be verified */ QDialogButtonBox *buttonBox{}; gpgme_signature_t sign; + gpgme_error_t error; }; #endif // __VERIFYDETAILSDIALOG_H__ |