mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
Merge branch 'dev' into qrcodegen
This commit is contained in:
+21
-16
@@ -6,6 +6,7 @@
|
|||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
@@ -222,35 +223,39 @@ QByteArray SecureQSettings::getEncIv() const
|
|||||||
|
|
||||||
QByteArray SecureQSettings::getSecTag(const QString &tag)
|
QByteArray SecureQSettings::getSecTag(const QString &tag)
|
||||||
{
|
{
|
||||||
ReadPasswordJob job(keyChainName);
|
auto job = QSharedPointer<ReadPasswordJob>(new ReadPasswordJob(keyChainName), &QObject::deleteLater);
|
||||||
job.setAutoDelete(false);
|
job->setAutoDelete(false);
|
||||||
job.setKey(tag);
|
job->setKey(tag);
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
job.connect(&job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
|
job->connect(job.data(), &ReadPasswordJob::finished, job.data(), [&loop](){
|
||||||
job.start();
|
loop.quit();
|
||||||
|
});
|
||||||
|
job->start();
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
if ( job.error() ) {
|
if ( job->error() ) {
|
||||||
qCritical() << "SecureQSettings::getSecTag Error:" << job.errorString();
|
qCritical() << "SecureQSettings::getSecTag Error:" << job->errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return job.binaryData();
|
return job->binaryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecureQSettings::setSecTag(const QString &tag, const QByteArray &data)
|
void SecureQSettings::setSecTag(const QString &tag, const QByteArray &data)
|
||||||
{
|
{
|
||||||
WritePasswordJob job(keyChainName);
|
auto job = QSharedPointer<WritePasswordJob>(new WritePasswordJob(keyChainName), &QObject::deleteLater);
|
||||||
job.setAutoDelete(false);
|
job->setAutoDelete(false);
|
||||||
job.setKey(tag);
|
job->setKey(tag);
|
||||||
job.setBinaryData(data);
|
job->setBinaryData(data);
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QTimer::singleShot(1000, &loop, SLOT(quit()));
|
QTimer::singleShot(1000, &loop, SLOT(quit()));
|
||||||
job.connect(&job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
|
job->connect(job.data(), &WritePasswordJob::finished, job.data(), [&loop](){
|
||||||
job.start();
|
loop.quit();
|
||||||
|
});
|
||||||
|
job->start();
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
if (job.error()) {
|
if (job->error()) {
|
||||||
qCritical() << "SecureQSettings::setSecTag Error:" << job.errorString();
|
qCritical() << "SecureQSettings::setSecTag Error:" << job->errorString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user