Skip to content

Commit

Permalink
Use some auto
Browse files Browse the repository at this point in the history
  • Loading branch information
frankosterfeld committed Feb 4, 2025
1 parent ad19e68 commit 3364c1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions qtkeychain/keychain_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void ReadPasswordJobPrivate::scheduledStart()
}

const QByteArray &encryptedData = plainTextStore.readData(q->key());
const KeyStore keyStore = KeyStore::getInstance(QStringLiteral("AndroidKeyStore"));
const auto keyStore = KeyStore::getInstance(QStringLiteral("AndroidKeyStore"));

if (!keyStore || !keyStore.load()) {
q->emitFinishedWithError(Error::AccessDenied, tr("Could not open keystore"));
Expand All @@ -70,7 +70,7 @@ void ReadPasswordJobPrivate::scheduledStart()
return;
}

const Cipher cipher = Cipher::getInstance(QStringLiteral("RSA/ECB/PKCS1Padding"));
const auto cipher = Cipher::getInstance(QStringLiteral("RSA/ECB/PKCS1Padding"));

if (!cipher || !cipher.init(Cipher::DECRYPT_MODE, entry.getPrivateKey())) {
q->emitFinishedWithError(Error::OtherError, tr("Could not create decryption cipher"));
Expand Down Expand Up @@ -99,8 +99,8 @@ void WritePasswordJobPrivate::scheduledStart()

const auto &alias = makeAlias(q->service(), q->key());
if (!keyStore.containsAlias(alias)) {
const Calendar start = Calendar::getInstance();
const Calendar end = Calendar::getInstance();
const auto start = Calendar::getInstance();
const auto end = Calendar::getInstance();
end.add(Calendar::YEAR, 99);

const KeyPairGeneratorSpec spec =
Expand Down Expand Up @@ -128,8 +128,8 @@ void WritePasswordJobPrivate::scheduledStart()
.setEndDate(end.getTime())
.build();

const KeyPairGenerator generator = KeyPairGenerator::getInstance(
QStringLiteral("RSA"), QStringLiteral("AndroidKeyStore"));
const auto generator = KeyPairGenerator::getInstance(QStringLiteral("RSA"),
QStringLiteral("AndroidKeyStore"));

if (!generator) {
q->emitFinishedWithError(Error::OtherError,
Expand All @@ -154,7 +154,7 @@ void WritePasswordJobPrivate::scheduledStart()
}

const RSAPublicKey publicKey = entry.getCertificate().getPublicKey();
const Cipher cipher = Cipher::getInstance(QStringLiteral("RSA/ECB/PKCS1Padding"));
const auto cipher = Cipher::getInstance(QStringLiteral("RSA/ECB/PKCS1Padding"));

if (!cipher || !cipher.init(Cipher::ENCRYPT_MODE, publicKey)) {
q->emitFinishedWithError(Error::OtherError, tr("Could not create encryption cipher"));
Expand All @@ -180,7 +180,7 @@ void WritePasswordJobPrivate::scheduledStart()

void DeletePasswordJobPrivate::scheduledStart()
{
const KeyStore keyStore = KeyStore::getInstance(QStringLiteral("AndroidKeyStore"));
const auto keyStore = KeyStore::getInstance(QStringLiteral("AndroidKeyStore"));

if (!keyStore || !keyStore.load()) {
q->emitFinishedWithError(Error::AccessDenied, tr("Could not open keystore"));
Expand Down
18 changes: 9 additions & 9 deletions qtkeychain/keychain_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void kwalletReadPasswordScheduledStartImpl(const char *service, const cha
priv->iface = new org::kde::KWallet(QLatin1String(service), QLatin1String(path),
QDBusConnection::sessionBus(), priv);
const QDBusPendingReply<QString> reply = priv->iface->networkWallet();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, priv);
auto watcher = new QDBusPendingCallWatcher(reply, priv);
priv->connect(watcher, &QDBusPendingCallWatcher::finished, priv,
&ReadPasswordJobPrivate::kwalletWalletFound);
} else {
Expand Down Expand Up @@ -246,7 +246,7 @@ void JobPrivate::kwalletWalletFound(QDBusPendingCallWatcher *watcher)
iface->setTimeout(0x7FFFFFFF);

const QDBusPendingReply<int> pendingReply = iface->open(reply.value(), 0, q->service());
QDBusPendingCallWatcher *pendingWatcher = new QDBusPendingCallWatcher(pendingReply, this);
auto pendingWatcher = new QDBusPendingCallWatcher(pendingReply, this);
connect(pendingWatcher, &QDBusPendingCallWatcher::finished, this,
&JobPrivate::kwalletOpenFinished);
}
Expand Down Expand Up @@ -350,7 +350,7 @@ void ReadPasswordJobPrivate::kwalletOpenFinished(QDBusPendingCallWatcher *watche

q->emitFinished();

WritePasswordJob *j = new WritePasswordJob(q->service(), nullptr);
auto j = new WritePasswordJob(q->service(), nullptr);
j->setSettings(q->settings());
j->setKey(key);
j->setAutoDelete(true);
Expand All @@ -375,7 +375,7 @@ void ReadPasswordJobPrivate::kwalletOpenFinished(QDBusPendingCallWatcher *watche

const QDBusPendingReply<int> nextReply =
iface->entryType(walletHandle, q->service(), key, q->service());
QDBusPendingCallWatcher *nextWatcher = new QDBusPendingCallWatcher(nextReply, this);
auto nextWatcher = new QDBusPendingCallWatcher(nextReply, this);
connect(nextWatcher, &QDBusPendingCallWatcher::finished, this,
&ReadPasswordJobPrivate::kwalletEntryTypeFinished);
}
Expand All @@ -387,7 +387,7 @@ void ReadPasswordJobPrivate::kwalletEntryTypeFinished(QDBusPendingCallWatcher *w
{
watcher->deleteLater();
if (watcher->isError()) {
const QDBusError err = watcher->error();
const auto err = watcher->error();
q->emitFinishedWithError(OtherError,
tr("Could not determine data type: %1; %2")
.arg(QDBusError::errorString(err.type()), err.message()));
Expand Down Expand Up @@ -415,10 +415,10 @@ void ReadPasswordJobPrivate::kwalletEntryTypeFinished(QDBusPendingCallWatcher *w
return;
}

const QDBusPendingCall nextReply = (mode == Text)
const auto nextReply = (mode == Text)
? QDBusPendingCall(iface->readPassword(walletHandle, q->service(), key, q->service()))
: QDBusPendingCall(iface->readEntry(walletHandle, q->service(), key, q->service()));
QDBusPendingCallWatcher *nextWatcher = new QDBusPendingCallWatcher(nextReply, this);
auto nextWatcher = new QDBusPendingCallWatcher(nextReply, this);
connect(nextWatcher, &QDBusPendingCallWatcher::finished, this,
&ReadPasswordJobPrivate::kwalletFinished);
}
Expand Down Expand Up @@ -449,7 +449,7 @@ static void kwalletWritePasswordScheduledStart(const char *service, const char *
priv->iface = new org::kde::KWallet(QLatin1String(service), QLatin1String(path),
QDBusConnection::sessionBus(), priv);
const QDBusPendingReply<QString> reply = priv->iface->networkWallet();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, priv);
auto watcher = new QDBusPendingCallWatcher(reply, priv);
priv->connect(watcher, &QDBusPendingCallWatcher::finished, priv,
&JobPrivate::kwalletWalletFound);
} else {
Expand Down Expand Up @@ -571,7 +571,7 @@ void JobPrivate::kwalletOpenFinished(QDBusPendingCallWatcher *watcher)
nextReply = iface->removeEntry(handle, q->service(), key, q->service());
}

QDBusPendingCallWatcher *nextWatcher = new QDBusPendingCallWatcher(nextReply, this);
auto nextWatcher = new QDBusPendingCallWatcher(nextReply, this);
connect(nextWatcher, &QDBusPendingCallWatcher::finished, this, &JobPrivate::kwalletFinished);
}

Expand Down

0 comments on commit 3364c1c

Please # to comment.