aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/GpgFileOpera.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-07-06 03:01:22 +0000
committerSaturneric <[email protected]>2021-07-06 03:01:22 +0000
commitad507f2373e6fada6b92e4f4a6d1374bca011c3d (patch)
treea58a794b410fb4ccdd52908ed0f62a5253ad9ba1 /src/gpg/GpgFileOpera.cpp
parentMerge branch 'main' of https://github.com/saturneric/GpgFrontend (diff)
parentFix issues. (diff)
downloadGpgFrontend-ad507f2373e6fada6b92e4f4a6d1374bca011c3d.tar.gz
GpgFrontend-ad507f2373e6fada6b92e4f4a6d1374bca011c3d.zip
Merge branch 'develop' into main
Diffstat (limited to 'src/gpg/GpgFileOpera.cpp')
-rw-r--r--src/gpg/GpgFileOpera.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/gpg/GpgFileOpera.cpp b/src/gpg/GpgFileOpera.cpp
index f7db9d44..9395bd17 100644
--- a/src/gpg/GpgFileOpera.cpp
+++ b/src/gpg/GpgFileOpera.cpp
@@ -132,6 +132,8 @@ gpgme_error_t GpgFileOpera::signFile(GpgME::GpgContext *ctx, QVector<GpgKey> &ke
gpgme_error_t GpgFileOpera::verifyFile(GpgME::GpgContext *ctx, const QString &mPath, gpgme_verify_result_t *result) {
+ qDebug() << "Verify File Path" << mPath;
+
QFileInfo fileInfo(mPath);
if (!fileInfo.isFile() || !fileInfo.isReadable())
@@ -142,29 +144,33 @@ gpgme_error_t GpgFileOpera::verifyFile(GpgME::GpgContext *ctx, const QString &mP
if (!infile.open(QIODevice::ReadOnly))
throw std::runtime_error("cannot open file");
-
QByteArray inBuffer = infile.readAll();
- QFile signFile;
- signFile.setFileName(mPath + ".sig");
- if (!signFile.open(QIODevice::ReadOnly)) {
- throw std::runtime_error("cannot open file");
+ if(fileInfo.suffix() == "gpg") {
+ auto error = ctx->verify(&inBuffer, nullptr, result);
+ return error;
}
+ else {
+ QFile signFile;
+ signFile.setFileName(mPath + ".sig");
+ if (!signFile.open(QIODevice::ReadOnly)) {
+ throw std::runtime_error("cannot open file");
+ }
+ auto signBuffer = signFile.readAll();
+ infile.close();
-
- auto signBuffer = signFile.readAll();
- infile.close();
-
-
- auto error = ctx->verify(&inBuffer, &signBuffer, result);
-
- return error;
+ auto error = ctx->verify(&inBuffer, &signBuffer, result);
+ return error;
+ }
}
gpg_error_t GpgFileOpera::encryptSignFile(GpgME::GpgContext *ctx, QVector<GpgKey> &keys, const QString &mPath,
gpgme_encrypt_result_t *encr_res,
gpgme_sign_result_t *sign_res) {
+
+ qDebug() << "Encrypt Sign File Path" << mPath;
+
QFileInfo fileInfo(mPath);
if (!fileInfo.isFile() || !fileInfo.isReadable())
@@ -198,6 +204,9 @@ gpg_error_t GpgFileOpera::encryptSignFile(GpgME::GpgContext *ctx, QVector<GpgKey
gpg_error_t GpgFileOpera::decryptVerifyFile(GpgME::GpgContext *ctx, const QString &mPath, gpgme_decrypt_result_t *decr_res,
gpgme_verify_result_t *verify_res) {
+
+ qDebug() << "Decrypt Verify File Path" << mPath;
+
QFileInfo fileInfo(mPath);
if (!fileInfo.isFile() || !fileInfo.isReadable())