qt: Remove superfluous virtual overrides and member variables
* lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp (QGpgMEAddExistingSubkeyJob::exec): Remove call of resultHook. * lang/qt/src/qgpgmedecryptjob.cpp (QGpgMEDecryptJob::exec): Remove call of resultHook. (QGpgMEDecryptJob::resultHook): Remove. * lang/qt/src/qgpgmedecryptjob.h (QGpgMEDecryptJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmedecryptverifyjob.cpp (QGpgMEDecryptVerifyJob::exec): Remove call of resultHook. (QGpgMEDecryptVerifyJob::resultHook): Remove. * lang/qt/src/qgpgmedecryptverifyjob.h (QGpgMEDecryptVerifyJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJob::exec): Remove call of resultHook. (QGpgMEEncryptJob::resultHook): Remove. * lang/qt/src/qgpgmeencryptjob.h (QGpgMEEncryptJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmegpgcardjob.cpp (QGpgMEGpgCardJob::exec): Remove call of resultHook. * lang/qt/src/qgpgmeimportfromkeyserverjob.cpp (QGpgMEImportFromKeyserverJob::exec): Remove call of resultHook. (QGpgMEImportFromKeyserverJob::resultHook): Remove. * lang/qt/src/qgpgmeimportfromkeyserverjob.h (QGpgMEImportFromKeyserverJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJob::exec): Remove call of resultHook. (QGpgMEImportJob::resultHook): Remove. * lang/qt/src/qgpgmeimportjob.h (QGpgMEImportJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmekeyformailboxjob.cpp (QGpgMEKeyForMailboxJob::exec): Remove call of resultHook. * lang/qt/src/qgpgmekeylistjob.cpp (QGpgMEKeyListJob::QGpgMEKeyListJob): Remove initialization of mResult. (QGpgMEKeyListJob::resultHook): Do not set (removed) mResult. * lang/qt/src/qgpgmekeylistjob.h (QGpgMEKeyListJob): Remove member mResult. * lang/qt/src/qgpgmelistallkeysjob.cpp (QGpgMEListAllKeysJob::QGpgMEListAllKeysJob): Remove initialization of mResult. (QGpgMEListAllKeysJob::exec): Remove call of resultHook. (QGpgMEListAllKeysJob::resultHook): Remove. * lang/qt/src/qgpgmelistallkeysjob.h (QGpgMEListAllKeysJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmereceivekeysjob.cpp (QGpgMEReceiveKeysJob::exec): Remove call of resultHook. (QGpgMEReceiveKeysJob::resultHook): Remove. * lang/qt/src/qgpgmereceivekeysjob.h (QGpgMEReceiveKeysJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmerevokekeyjob.cpp (QGpgMERevokeKeyJob::exec): Remove call of resultHook. * lang/qt/src/qgpgmesignencryptjob.cpp (QGpgMESignEncryptJob::exec): Remove call of resultHook. (QGpgMESignEncryptJob::resultHook): Remove. * lang/qt/src/qgpgmesignencryptjob.h (QGpgMESignEncryptJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmesignjob.cpp (QGpgMESignJob::exec): Remove call of resultHook. (QGpgMESignJob::resultHook): Remove. * lang/qt/src/qgpgmesignjob.h (QGpgMESignJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmeverifydetachedjob.cpp (QGpgMEVerifyDetachedJob::exec): Remove call of resultHook. (QGpgMEVerifyDetachedJob::resultHook): Remove. * lang/qt/src/qgpgmeverifydetachedjob.h (QGpgMEVerifyDetachedJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmeverifyopaquejob.cpp (QGpgMEVerifyOpaqueJob::exec): Remove call of resultHook. (QGpgMEVerifyOpaqueJob::resultHook): Remove. * lang/qt/src/qgpgmeverifyopaquejob.h (QGpgMEVerifyOpaqueJob): Remove resultHook override. Remove member mResult. * lang/qt/src/qgpgmewkdlookupjob.cpp (QGpgMEWKDLookupJob::exec): Remove call of resultHook. -- All overrides of resultHook (except for the one of QGpgMEKeyListJob) are superfluous. All the resultHook overrides do is store the result in a member variable which is then returned in exec() (which just before returning calls resultHook). The member variable the result is stored in is only ever used by exec(). So exec() can simply return the result directly. Some Job subclasses call resultHook without overriding it. That's equally useless because the default implementation of resultHook is empty. The only resultHook override that does anything useful is the one of QGpgMEKeyListJob.
This commit is contained in:
parent
eae22d9a48
commit
0011412193
@ -90,7 +90,6 @@ Error QGpgMEAddExistingSubkeyJob::start(const GpgME::Key &key, const GpgME::Subk
|
||||
Error QGpgMEAddExistingSubkeyJob::exec(const GpgME::Key &key, const GpgME::Subkey &subkey)
|
||||
{
|
||||
const result_type r = add_subkey(context(), key, subkey);
|
||||
resultHook(r);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
|
@ -122,13 +122,7 @@ GpgME::DecryptionResult QGpgME::QGpgMEDecryptJob::exec(const QByteArray &cipherT
|
||||
{
|
||||
const result_type r = decrypt_qba(context(), cipherText);
|
||||
plainText = std::get<1>(r);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
}
|
||||
|
||||
void QGpgMEDecryptJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
#include "qgpgmedecryptjob.moc"
|
||||
|
@ -73,12 +73,6 @@ public:
|
||||
/* from DecryptJob */
|
||||
GpgME::DecryptionResult exec(const QByteArray &cipherText,
|
||||
QByteArray &plainText) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::DecryptionResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -195,13 +195,7 @@ QGpgME::QGpgMEDecryptVerifyJob::exec(const QByteArray &cipherText, QByteArray &p
|
||||
{
|
||||
const result_type r = decrypt_verify_qba(context(), cipherText);
|
||||
plainText = std::get<2>(r);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
}
|
||||
|
||||
void QGpgMEDecryptVerifyJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::make_pair(std::get<0>(tuple), std::get<1>(tuple));
|
||||
return std::make_pair(std::get<0>(r), std::get<1>(r));
|
||||
}
|
||||
|
||||
GpgME::Error QGpgMEDecryptVerifyJobPrivate::startIt()
|
||||
|
@ -78,12 +78,6 @@ public:
|
||||
/* from DecryptVerifyJob */
|
||||
std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
|
||||
exec(const QByteArray &cipherText, QByteArray &plainText) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
std::pair<GpgME::DecryptionResult, GpgME::VerificationResult> mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -228,8 +228,7 @@ EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, cons
|
||||
{
|
||||
const result_type r = encrypt_qba(context(), recipients, plainText, eflags, mOutputIsBase64Encoded, inputEncoding(), fileName());
|
||||
cipherText = std::get<1>(r);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const std::shared_ptr<QIODevice> &plainText, const std::shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
|
||||
@ -242,11 +241,6 @@ EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, cons
|
||||
return exec(recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText);
|
||||
}
|
||||
|
||||
void QGpgMEEncryptJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
}
|
||||
|
||||
GpgME::Error QGpgMEEncryptJobPrivate::startIt()
|
||||
{
|
||||
if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) {
|
||||
|
@ -97,12 +97,8 @@ public:
|
||||
/* from EncryptJob */
|
||||
void setOutputIsBase64Encoded(bool on) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
bool mOutputIsBase64Encoded;
|
||||
GpgME::EncryptionResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -122,7 +122,6 @@ Error QGpgMEGpgCardJob::exec(const QStringList &cmds, QString &std_out, QString
|
||||
return Error(make_error(GPG_ERR_NOT_SUPPORTED));
|
||||
}
|
||||
const result_type r = do_work(cmds, cardpath);
|
||||
resultHook(r);
|
||||
std_out = std::get<0>(r);
|
||||
std_err = std::get<1>(r);
|
||||
exitCode = std::get<2>(r);
|
||||
|
@ -74,12 +74,7 @@ Error QGpgMEImportFromKeyserverJob::start(const std::vector<Key> &keys)
|
||||
GpgME::ImportResult QGpgME::QGpgMEImportFromKeyserverJob::exec(const std::vector<Key> &keys)
|
||||
{
|
||||
const result_type r = importfromkeyserver(context(), keys);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
void QGpgME::QGpgMEImportFromKeyserverJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
}
|
||||
#include "qgpgmeimportfromkeyserverjob.moc"
|
||||
|
@ -69,12 +69,6 @@ public:
|
||||
|
||||
/* from ImportFromKeyserverJob */
|
||||
GpgME::ImportResult exec(const std::vector<GpgME::Key> &keys) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::ImportResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -156,8 +156,7 @@ Error QGpgMEImportJob::start(const QByteArray &certData)
|
||||
GpgME::ImportResult QGpgME::QGpgMEImportJob::exec(const QByteArray &keyData)
|
||||
{
|
||||
const result_type r = import_qba(context(), keyData, importFilter(), keyOrigin(), keyOriginUrl());
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
Error QGpgMEImportJob::startLater(const QByteArray &certData)
|
||||
@ -166,8 +165,4 @@ Error QGpgMEImportJob::startLater(const QByteArray &certData)
|
||||
return {};
|
||||
}
|
||||
|
||||
void QGpgME::QGpgMEImportJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
}
|
||||
#include "qgpgmeimportjob.moc"
|
||||
|
@ -73,12 +73,6 @@ public:
|
||||
GpgME::ImportResult exec(const QByteArray &keyData) override;
|
||||
|
||||
GpgME::Error startLater(const QByteArray &keyData) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::ImportResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -134,7 +134,6 @@ Error QGpgMEKeyForMailboxJob::start(const QString &mailbox, bool canEncrypt)
|
||||
KeyListResult QGpgMEKeyForMailboxJob::exec(const QString &mailbox, bool canEncrypt, Key &key, UserID &uid)
|
||||
{
|
||||
const result_type r = do_work(context(), mailbox, canEncrypt);
|
||||
resultHook(r);
|
||||
key = std::get<1>(r);
|
||||
uid = std::get<2>(r);
|
||||
return std::get<0>(r);
|
||||
|
@ -55,8 +55,8 @@ using namespace QGpgME;
|
||||
using namespace GpgME;
|
||||
|
||||
QGpgMEKeyListJob::QGpgMEKeyListJob(Context *context)
|
||||
: mixin_type(context),
|
||||
mResult(), mSecretOnly(false)
|
||||
: mixin_type(context)
|
||||
, mSecretOnly(false)
|
||||
{
|
||||
lateInitialization();
|
||||
}
|
||||
@ -151,7 +151,6 @@ KeyListResult QGpgMEKeyListJob::exec(const QStringList &patterns, bool secretOnl
|
||||
|
||||
void QGpgMEKeyListJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
for (const Key &key : std::get<1>(tuple)) {
|
||||
Q_EMIT nextKey(key);
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ public:
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &result) override;
|
||||
private:
|
||||
GpgME::KeyListResult mResult;
|
||||
bool mSecretOnly;
|
||||
};
|
||||
|
||||
|
@ -92,8 +92,7 @@ private:
|
||||
}
|
||||
|
||||
QGpgMEListAllKeysJob::QGpgMEListAllKeysJob(Context *context)
|
||||
: mixin_type(context),
|
||||
mResult()
|
||||
: mixin_type(context)
|
||||
{
|
||||
setJobPrivate(this, std::unique_ptr<QGpgMEListAllKeysJobPrivate>{new QGpgMEListAllKeysJobPrivate{this}});
|
||||
lateInitialization();
|
||||
@ -234,15 +233,9 @@ Error QGpgMEListAllKeysJob::start(bool mergeKeys)
|
||||
KeyListResult QGpgMEListAllKeysJob::exec(std::vector<Key> &pub, std::vector<Key> &sec, bool mergeKeys)
|
||||
{
|
||||
const result_type r = list_keys(context(), mergeKeys, options());
|
||||
resultHook(r);
|
||||
pub = std::get<1>(r);
|
||||
sec = std::get<2>(r);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
void QGpgMEListAllKeysJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
}
|
||||
|
||||
#include "qgpgmelistallkeysjob.moc"
|
||||
|
@ -74,12 +74,6 @@ public:
|
||||
|
||||
/* from ListAllKeysJob */
|
||||
GpgME::KeyListResult exec(std::vector<GpgME::Key> &pub, std::vector<GpgME::Key> &sec, bool mergeKeys) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &result) override;
|
||||
|
||||
private:
|
||||
GpgME::KeyListResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -67,13 +67,7 @@ Error QGpgMEReceiveKeysJob::start(const QStringList &keyIds)
|
||||
GpgME::ImportResult QGpgME::QGpgMEReceiveKeysJob::exec(const QStringList &keyIds)
|
||||
{
|
||||
const result_type r = importfromkeyserver(context(), keyIds);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
}
|
||||
|
||||
void QGpgME::QGpgMEReceiveKeysJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
#include "qgpgmereceivekeysjob.moc"
|
||||
|
@ -66,12 +66,6 @@ public:
|
||||
GpgME::Error start(const QStringList &keyIds) override;
|
||||
|
||||
GpgME::ImportResult exec(const QStringList &keyIds) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::ImportResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -119,7 +119,6 @@ Error QGpgMERevokeKeyJob::exec(const GpgME::Key &key,
|
||||
Error err = check_arguments(key, reason, description);
|
||||
if (!err) {
|
||||
const result_type r = revoke_key(context(), key, reason, description);
|
||||
resultHook(r);
|
||||
err = std::get<0>(r);
|
||||
}
|
||||
return err;
|
||||
|
@ -242,8 +242,7 @@ std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std:
|
||||
{
|
||||
const result_type r = sign_encrypt_qba(context(), signers, recipients, plainText, eflags, mOutputIsBase64Encoded, fileName());
|
||||
cipherText = std::get<2>(r);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
return std::make_pair(std::get<0>(r), std::get<1>(r));
|
||||
}
|
||||
|
||||
std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
|
||||
@ -251,11 +250,6 @@ std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std:
|
||||
return exec(signers, recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText);
|
||||
}
|
||||
|
||||
void QGpgMESignEncryptJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::make_pair(std::get<0>(tuple), std::get<1>(tuple));
|
||||
}
|
||||
|
||||
GpgME::Error QGpgMESignEncryptJobPrivate::startIt()
|
||||
{
|
||||
if (m_inputFilePath.isEmpty() || m_outputFilePath.isEmpty()) {
|
||||
|
@ -109,12 +109,8 @@ public:
|
||||
/* from SignEncryptJob */
|
||||
void setOutputIsBase64Encoded(bool on) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
bool mOutputIsBase64Encoded;
|
||||
std::pair<GpgME::SigningResult, GpgME::EncryptionResult> mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -231,13 +231,7 @@ SigningResult QGpgMESignJob::exec(const std::vector<Key> &signers, const QByteAr
|
||||
{
|
||||
const result_type r = sign_qba(context(), signers, plainText, mode, mOutputIsBase64Encoded);
|
||||
signature = std::get<1>(r);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
}
|
||||
|
||||
void QGpgMESignJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
GpgME::Error QGpgMESignJobPrivate::startIt()
|
||||
|
@ -89,11 +89,7 @@ public:
|
||||
/* from SignJob */
|
||||
void setOutputIsBase64Encoded(bool on) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::SigningResult mResult;
|
||||
bool mOutputIsBase64Encoded;
|
||||
};
|
||||
|
||||
|
@ -169,13 +169,7 @@ GpgME::VerificationResult QGpgME::QGpgMEVerifyDetachedJob::exec(const QByteArray
|
||||
const QByteArray &signedData)
|
||||
{
|
||||
const result_type r = verify_detached_qba(context(), signature, signedData);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
}
|
||||
|
||||
void QGpgME::QGpgMEVerifyDetachedJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
GpgME::Error QGpgMEVerifyDetachedJobPrivate::startIt()
|
||||
|
@ -73,12 +73,6 @@ public:
|
||||
/* from VerifyDetachedJob */
|
||||
GpgME::VerificationResult exec(const QByteArray &signature,
|
||||
const QByteArray &signedData) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::VerificationResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -184,13 +184,7 @@ GpgME::VerificationResult QGpgME::QGpgMEVerifyOpaqueJob::exec(const QByteArray &
|
||||
{
|
||||
const result_type r = verify_opaque_qba(context(), signedData);
|
||||
plainText = std::get<1>(r);
|
||||
resultHook(r);
|
||||
return mResult;
|
||||
}
|
||||
|
||||
void QGpgME::QGpgMEVerifyOpaqueJob::resultHook(const result_type &tuple)
|
||||
{
|
||||
mResult = std::get<0>(tuple);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
GpgME::Error QGpgMEVerifyOpaqueJobPrivate::startIt()
|
||||
|
@ -72,12 +72,6 @@ public:
|
||||
|
||||
/* form VerifyOpaqueJob */
|
||||
GpgME::VerificationResult exec(const QByteArray &signedData, QByteArray &plainData) override;
|
||||
|
||||
/* from ThreadedJobMixin */
|
||||
void resultHook(const result_type &r) override;
|
||||
|
||||
private:
|
||||
GpgME::VerificationResult mResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -178,7 +178,6 @@ Error QGpgMEWKDLookupJob::start(const QString &email)
|
||||
WKDLookupResult QGpgMEWKDLookupJob::exec(const QString &email)
|
||||
{
|
||||
const result_type r = lookup_keys(context(), email);
|
||||
resultHook(r);
|
||||
return std::get<0>(r);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user