summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-12-27 16:59:10 -0500
committerNicolas Werner <nicolas.werner@hotmail.de>2020-12-27 16:59:10 -0500
commit102ef05cfe55233154768e9ee6740cd9846ce90c (patch)
tree2dd2e32746c5a0efa053418c1ad80645290c7550 /src/Cache.cpp
parentRemove s3 upload for nightlies (diff)
parentFix #359 (diff)
downloadnheko-102ef05cfe55233154768e9ee6740cd9846ce90c.tar.xz
Merge branch 'ci-cleanups-and-experiments' into 'master'
Remove travis and build appimages on gitlab

See merge request nheko-reborn/nheko!2
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r--src/Cache.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 5d11a178..dac0b23a 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -167,13 +167,14 @@ Cache::Cache(const QString &userId, QObject *parent) void Cache::setup() { - UserSettings settings; + auto settings = UserSettings::instance(); nhlog::db()->debug("setting up cache"); 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()); } } @@ -575,14 +578,14 @@ Cache::restoreOlmAccount() void Cache::storeSecret(const std::string &name, const std::string &secret) { - UserSettings settings; + auto settings = UserSettings::instance(); QKeychain::WritePasswordJob job(QCoreApplication::applicationName()); job.setAutoDelete(false); job.setInsecureFallback(true); - job.setKey( - "matrix." + - QString(QCryptographicHash::hash(settings.profile().toUtf8(), QCryptographicHash::Sha256)) + - "." + name.c_str()); + job.setKey("matrix." + + QString(QCryptographicHash::hash(settings->profile().toUtf8(), + QCryptographicHash::Sha256)) + + "." + name.c_str()); job.setTextData(QString::fromStdString(secret)); QEventLoop loop; job.connect(&job, &QKeychain::Job::finished, &loop, &QEventLoop::quit); @@ -600,14 +603,14 @@ Cache::storeSecret(const std::string &name, const std::string &secret) void Cache::deleteSecret(const std::string &name) { - UserSettings settings; + auto settings = UserSettings::instance(); QKeychain::DeletePasswordJob job(QCoreApplication::applicationName()); job.setAutoDelete(false); job.setInsecureFallback(true); - job.setKey( - "matrix." + - QString(QCryptographicHash::hash(settings.profile().toUtf8(), QCryptographicHash::Sha256)) + - "." + name.c_str()); + 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); job.start(); @@ -619,14 +622,14 @@ Cache::deleteSecret(const std::string &name) std::optional<std::string> Cache::secret(const std::string &name) { - UserSettings settings; + auto settings = UserSettings::instance(); QKeychain::ReadPasswordJob job(QCoreApplication::applicationName()); job.setAutoDelete(false); job.setInsecureFallback(true); - job.setKey( - "matrix." + - QString(QCryptographicHash::hash(settings.profile().toUtf8(), QCryptographicHash::Sha256)) + - "." + name.c_str()); + 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); job.start();