diff --git a/src/Cache.cpp b/src/Cache.cpp index bc364c34..a966fe57 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #if __has_include() @@ -754,6 +755,24 @@ Cache::backupVersion() } } +static void +fatalSecretError() +{ + QMessageBox::critical( + ChatPage::instance(), + QCoreApplication::translate("SecretStorage", "Failed to connect to secret storage"), + QCoreApplication::translate( + "SecretStorage", + "Nheko could not connect to the secure storage to save encryption secrets to. " + "This can have multiple reasons. Check if your D-Bus service is running and " + "you have configured a service like KWallet, Gnome Secrets or the equivalent " + "for your platform. If you are having trouble, feel free to open an issue " + "here: https://github.com/Nheko-Reborn/nheko/issues")); + + QCoreApplication::exit(1); + exit(1); +} + void Cache::storeSecret(const std::string name, const std::string secret) { @@ -780,6 +799,7 @@ Cache::storeSecret(const std::string name, const std::string secret) nhlog::db()->warn("Storing secret '{}' failed: {}", name, job->errorString().toStdString()); + fatalSecretError(); } else { // if we emit the signal directly, qtkeychain breaks and won't execute new // jobs. You can't start a job from the finish signal of a job. @@ -840,8 +860,14 @@ Cache::secret(const std::string name) const QString secret = job.textData(); if (job.error()) { - nhlog::db()->debug( - "Restoring secret '{}' failed: {}", name, job.errorString().toStdString()); + if (job.error() == QKeychain::Error::EntryNotFound) + return std::nullopt; + nhlog::db()->error("Restoring secret '{}' failed ({}): {}", + name, + job.error(), + job.errorString().toStdString()); + + fatalSecretError(); return std::nullopt; } if (secret.isEmpty()) {