| 508 | } // namespace |
| 509 | |
| 510 | auto gpgErrorMessage(const QString &err) -> QString { |
| 511 | // Machine-readable status tokens added by --status-fd 2 |
| 512 | if (containsAny(err, {QStringLiteral("[GNUPG:] KEYEXPIRED"), |
| 513 | QStringLiteral("[GNUPG:] INV_RECP 5 ")})) |
| 514 | return QCoreApplication::translate( |
| 515 | "Pass", "Encryption failed: GPG key has expired. Please renew or " |
| 516 | "replace it."); |
| 517 | if (containsAny(err, {QStringLiteral("[GNUPG:] KEYREVOKED"), |
| 518 | QStringLiteral("[GNUPG:] INV_RECP 4 ")})) |
| 519 | return QCoreApplication::translate( |
| 520 | "Pass", "Encryption failed: GPG key has been revoked."); |
| 521 | if (containsAny(err, {QStringLiteral("[GNUPG:] NO_PUBKEY"), |
| 522 | QStringLiteral("[GNUPG:] INV_RECP")})) |
| 523 | return QCoreApplication::translate( |
| 524 | "Pass", "Encryption failed: recipient GPG key not found or invalid. " |
| 525 | "Check that the key ID in .gpg-id is correct and imported."); |
| 526 | if (err.contains(QStringLiteral("[GNUPG:] FAILURE"))) |
| 527 | return QCoreApplication::translate( |
| 528 | "Pass", "Encryption failed. Check that your GPG key is valid."); |
| 529 | |
| 530 | // Locale-dependent fallbacks |
| 531 | if (containsAnyCaseInsensitive(err, {QLatin1String("key has expired"), |
| 532 | QLatin1String("key expired")})) |
| 533 | return QCoreApplication::translate( |
| 534 | "Pass", "Encryption failed: GPG key has expired. Please renew or " |
| 535 | "replace it."); |
| 536 | if (containsAnyCaseInsensitive(err, {QLatin1String("key has been revoked"), |
| 537 | QLatin1String("revoked")})) |
| 538 | return QCoreApplication::translate( |
| 539 | "Pass", "Encryption failed: GPG key has been revoked."); |
| 540 | if (containsAnyCaseInsensitive(err, {QLatin1String("no public key"), |
| 541 | QLatin1String("unusable public key"), |
| 542 | QLatin1String("no secret key")})) |
| 543 | return QCoreApplication::translate( |
| 544 | "Pass", "Encryption failed: recipient GPG key not found or invalid. " |
| 545 | "Check that the key ID in .gpg-id is correct and imported."); |
| 546 | if (containsAnyCaseInsensitive(err, {QLatin1String("encryption failed")})) |
| 547 | return QCoreApplication::translate( |
| 548 | "Pass", "Encryption failed. Check that your GPG key is valid."); |
| 549 | |
| 550 | return {}; |
| 551 | } |
| 552 | |
| 553 | namespace { |
| 554 | auto isGrepHeaderLine(const QString &rawLine, const QString &trimmedLine) |
no test coverage detected