qt: Add factory function for secret subkey export job
* lang/qt/src/protocol.h (class Protocol): Add member function secretSubkeyExportJob. * lang/qt/src/protocol_p.h (Protocol::secretSubkeyExportJob): Implement. * lang/qt/tests/run-exportjob.cpp (showUsageAndExitWithCode): Print new option. (createExportJob): Create secret subkey export job if requested. (main): New option --secret-subkey. -- GnuPG-bug-id: 5757
This commit is contained in:
parent
e5c7fc3e02
commit
04723a6e96
@ -128,6 +128,7 @@ public:
|
|||||||
virtual ExportJob *publicKeyExportJob(bool armor = false) const = 0;
|
virtual ExportJob *publicKeyExportJob(bool armor = false) const = 0;
|
||||||
// the second parameter is ignored; the passphrase in the exported file is always utf-8 encoded
|
// the second parameter is ignored; the passphrase in the exported file is always utf-8 encoded
|
||||||
virtual ExportJob *secretKeyExportJob(bool armor = false, const QString & = QString()) const = 0;
|
virtual ExportJob *secretKeyExportJob(bool armor = false, const QString & = QString()) const = 0;
|
||||||
|
virtual ExportJob *secretSubkeyExportJob(bool armor = false) const = 0;
|
||||||
virtual DownloadJob *downloadJob(bool armor = false) const = 0;
|
virtual DownloadJob *downloadJob(bool armor = false) const = 0;
|
||||||
virtual DeleteJob *deleteJob() const = 0;
|
virtual DeleteJob *deleteJob() const = 0;
|
||||||
virtual SignEncryptJob *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
|
virtual SignEncryptJob *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
|
||||||
|
@ -254,6 +254,17 @@ public:
|
|||||||
return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecret);
|
return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGpgME::ExportJob *secretSubkeyExportJob(bool armor) const Q_DECL_OVERRIDE
|
||||||
|
{
|
||||||
|
GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
|
||||||
|
if (!context) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
context->setArmor(armor);
|
||||||
|
return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecretSubkey);
|
||||||
|
}
|
||||||
|
|
||||||
QGpgME::RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE
|
QGpgME::RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE
|
||||||
{
|
{
|
||||||
if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
|
if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
|
||||||
|
@ -52,13 +52,16 @@ static void showUsageAndExitWithCode(int exitCode)
|
|||||||
cerr << "Usage: run-exportjob [OPTION]... [PATTERN]...\n"
|
cerr << "Usage: run-exportjob [OPTION]... [PATTERN]...\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" --secret export secret keys instead of public keys\n"
|
" --secret export secret keys instead of public keys\n"
|
||||||
|
" --secret-subkey export secret subkeys instead of public keys\n";
|
||||||
|
|
||||||
exit(exitCode);
|
exit(exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto createExportJob(unsigned int mode)
|
static auto createExportJob(unsigned int mode)
|
||||||
{
|
{
|
||||||
if (mode & Context::ExportSecret) {
|
if (mode & Context::ExportSecretSubkey) {
|
||||||
|
return QGpgME::openpgp()->secretSubkeyExportJob(/*armor=*/true);
|
||||||
|
} else if (mode & Context::ExportSecret) {
|
||||||
return QGpgME::openpgp()->secretKeyExportJob(/*armor=*/true);
|
return QGpgME::openpgp()->secretKeyExportJob(/*armor=*/true);
|
||||||
}
|
}
|
||||||
return QGpgME::openpgp()->publicKeyExportJob(/*armor=*/true);
|
return QGpgME::openpgp()->publicKeyExportJob(/*armor=*/true);
|
||||||
@ -90,6 +93,9 @@ int main(int argc, char *argv[])
|
|||||||
} else if (arg == QLatin1String{"--secret"}) {
|
} else if (arg == QLatin1String{"--secret"}) {
|
||||||
exportMode = Context::ExportSecret;
|
exportMode = Context::ExportSecret;
|
||||||
arguments.pop_front();
|
arguments.pop_front();
|
||||||
|
} else if (arg == QLatin1String{"--secret-subkey"}) {
|
||||||
|
exportMode = Context::ExportSecretSubkey;
|
||||||
|
arguments.pop_front();
|
||||||
} else {
|
} else {
|
||||||
cerr << "Error: Invalid option " << arg.toStdString() << std::endl;
|
cerr << "Error: Invalid option " << arg.toStdString() << std::endl;
|
||||||
showUsageAndExitWithCode(1);
|
showUsageAndExitWithCode(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user