MCPcopy Create free account
hub / github.com/IJHack/QtPass / gpgErrorMessage

Function gpgErrorMessage

src/pass.cpp:510–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508} // namespace
509
510auto 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
553namespace {
554auto isGrepHeaderLine(const QString &rawLine, const QString &trimmedLine)

Calls 2

containsAnyFunction · 0.85

Tested by

no test coverage detected