This commit is contained in:
Nicolas Werner 2020-12-25 19:20:15 +01:00
parent b26a6bd9d2
commit 525b319a94
2 changed files with 20 additions and 17 deletions

View File

@ -173,7 +173,8 @@ Cache::setup()
cacheDirectory_ = QString("%1/%2%3")
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
.arg(QString::fromUtf8(localUserId_.toUtf8().toHex())).arg(QString::fromUtf8(settings.profile().toUtf8().toHex()));
.arg(QString::fromUtf8(localUserId_.toUtf8().toHex()))
.arg(QString::fromUtf8(settings.profile().toUtf8().toHex()));
bool isInitial = !QFile::exists(cacheDirectory_);
@ -186,7 +187,9 @@ Cache::setup()
if (!QDir().mkpath(cacheDirectory_)) {
throw std::runtime_error(
("Unable to create state directory:" + cacheDirectory_).toStdString().c_str());
("Unable to create state directory:" + cacheDirectory_)
.toStdString()
.c_str());
}
}
@ -579,9 +582,9 @@ Cache::storeSecret(const std::string &name, const std::string &secret)
QKeychain::WritePasswordJob job(QCoreApplication::applicationName());
job.setAutoDelete(false);
job.setInsecureFallback(true);
job.setKey(
"matrix." +
QString(QCryptographicHash::hash(settings.profile().toUtf8(), QCryptographicHash::Sha256)) +
job.setKey("matrix." +
QString(QCryptographicHash::hash(settings.profile().toUtf8(),
QCryptographicHash::Sha256)) +
"." + name.c_str());
job.setTextData(QString::fromStdString(secret));
QEventLoop loop;
@ -604,9 +607,9 @@ Cache::deleteSecret(const std::string &name)
QKeychain::DeletePasswordJob job(QCoreApplication::applicationName());
job.setAutoDelete(false);
job.setInsecureFallback(true);
job.setKey(
"matrix." +
QString(QCryptographicHash::hash(settings.profile().toUtf8(), QCryptographicHash::Sha256)) +
job.setKey("matrix." +
QString(QCryptographicHash::hash(settings.profile().toUtf8(),
QCryptographicHash::Sha256)) +
"." + name.c_str());
QEventLoop loop;
job.connect(&job, &QKeychain::Job::finished, &loop, &QEventLoop::quit);
@ -623,9 +626,9 @@ Cache::secret(const std::string &name)
QKeychain::ReadPasswordJob job(QCoreApplication::applicationName());
job.setAutoDelete(false);
job.setInsecureFallback(true);
job.setKey(
"matrix." +
QString(QCryptographicHash::hash(settings.profile().toUtf8(), QCryptographicHash::Sha256)) +
job.setKey("matrix." +
QString(QCryptographicHash::hash(settings.profile().toUtf8(),
QCryptographicHash::Sha256)) +
"." + name.c_str());
QEventLoop loop;
job.connect(&job, &QKeychain::Job::finished, &loop, &QEventLoop::quit);

View File

@ -56,8 +56,8 @@
MainWindow *MainWindow::instance_ = nullptr;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
userSettings_{QSharedPointer<UserSettings>{new UserSettings}}
: QMainWindow(parent)
, userSettings_{QSharedPointer<UserSettings>{new UserSettings}}
{
setWindowTitle(0);
setObjectName("MainWindow");