|
|
|
@ -167,14 +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(settings->profile().toUtf8().toHex())); |
|
|
|
|
|
|
|
|
|
bool isInitial = !QFile::exists(cacheDirectory_); |
|
|
|
|
|
|
|
|
@ -578,12 +578,12 @@ 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(), |
|
|
|
|
QString(QCryptographicHash::hash(settings->profile().toUtf8(), |
|
|
|
|
QCryptographicHash::Sha256)) + |
|
|
|
|
"." + name.c_str()); |
|
|
|
|
job.setTextData(QString::fromStdString(secret)); |
|
|
|
@ -603,12 +603,12 @@ 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(), |
|
|
|
|
QString(QCryptographicHash::hash(settings->profile().toUtf8(), |
|
|
|
|
QCryptographicHash::Sha256)) + |
|
|
|
|
"." + name.c_str()); |
|
|
|
|
QEventLoop loop; |
|
|
|
@ -622,12 +622,12 @@ 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(), |
|
|
|
|
QString(QCryptographicHash::hash(settings->profile().toUtf8(), |
|
|
|
|
QCryptographicHash::Sha256)) + |
|
|
|
|
"." + name.c_str()); |
|
|
|
|
QEventLoop loop; |
|
|
|
|