36#ifndef __QGPGME_PROTOCOL_P_H__
37#define __QGPGME_PROTOCOL_P_H__
38#include "qgpgmenewcryptoconfig.h"
40#include "qgpgmekeygenerationjob.h"
41#include "qgpgmekeylistjob.h"
42#include "qgpgmelistallkeysjob.h"
43#include "qgpgmedecryptjob.h"
44#include "qgpgmedecryptverifyarchivejob.h"
45#include "qgpgmedecryptverifyjob.h"
46#include "qgpgmerefreshsmimekeysjob.h"
47#include "qgpgmedeletejob.h"
48#include "qgpgmedownloadjob.h"
49#include "qgpgmesignencryptjob.h"
50#include "qgpgmeencryptarchivejob.h"
51#include "qgpgmeencryptjob.h"
52#include "qgpgmesignarchivejob.h"
53#include "qgpgmesignencryptarchivejob.h"
54#include "qgpgmesignjob.h"
55#include "qgpgmesignkeyjob.h"
56#include "qgpgmeexportjob.h"
57#include "qgpgmeverifydetachedjob.h"
58#include "qgpgmeimportjob.h"
59#include "qgpgmeimportfromkeyserverjob.h"
60#include "qgpgmeverifyopaquejob.h"
61#include "qgpgmechangeexpiryjob.h"
62#include "qgpgmechangeownertrustjob.h"
63#include "qgpgmechangepasswdjob.h"
64#include "qgpgmeaddexistingsubkeyjob.h"
65#include "qgpgmeadduseridjob.h"
66#include "qgpgmekeyformailboxjob.h"
67#include "qgpgmewkdlookupjob.h"
68#include "qgpgmewkspublishjob.h"
69#include "qgpgmetofupolicyjob.h"
70#include "qgpgmequickjob.h"
71#include "qgpgmereceivekeysjob.h"
72#include "qgpgmerevokekeyjob.h"
73#include "qgpgmesetprimaryuseridjob.h"
74#include "qgpgmewkdrefreshjob.h"
81 GpgME::Protocol mProtocol;
83 explicit Protocol(GpgME::Protocol proto) : mProtocol(proto) {}
85 QString name()
const override
88 case GpgME::OpenPGP:
return QStringLiteral(
"OpenPGP");
89 case GpgME::CMS:
return QStringLiteral(
"SMIME");
90 default:
return QString();
94 QString displayName()
const override
99 case GpgME::OpenPGP:
return QStringLiteral(
"gpg");
100 case GpgME::CMS:
return QStringLiteral(
"gpgsm");
101 default:
return QStringLiteral(
"unknown");
105 QGpgME::SpecialJob *specialJob(
const char *,
const QMap<QString, QVariant> &)
const override
110 QGpgME::KeyListJob *keyListJob(
bool remote,
bool includeSigs,
bool validate)
const override
112 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
117 unsigned int mode = context->keyListMode();
119 mode |= GpgME::Extern;
120 mode &= ~GpgME::Local;
122 mode |= GpgME::Local;
123 mode &= ~GpgME::Extern;
126 mode |= GpgME::Signatures;
129 mode |= GpgME::Validate;
131 context->setKeyListMode(mode);
132 return new QGpgME::QGpgMEKeyListJob(context);
135 QGpgME::ListAllKeysJob *listAllKeysJob(
bool includeSigs,
bool validate)
const override
137 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
142 unsigned int mode = context->keyListMode();
143 mode |= GpgME::Local;
144 mode &= ~GpgME::Extern;
146 mode |= GpgME::Signatures;
149 mode |= GpgME::Validate;
156 context->setOffline(
true);
158 context->setKeyListMode(mode);
159 return new QGpgME::QGpgMEListAllKeysJob(context);
162 QGpgME::EncryptJob *encryptJob(
bool armor,
bool textmode)
const override
164 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
169 context->setArmor(armor);
170 context->setTextMode(textmode);
171 return new QGpgME::QGpgMEEncryptJob(context);
174 QGpgME::DecryptJob *decryptJob()
const override
176 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
180 return new QGpgME::QGpgMEDecryptJob(context);
183 QGpgME::SignJob *signJob(
bool armor,
bool textMode)
const override
185 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
190 context->setArmor(armor);
191 context->setTextMode(textMode);
192 return new QGpgME::QGpgMESignJob(context);
195 QGpgME::VerifyDetachedJob *verifyDetachedJob(
bool textMode)
const override
197 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
202 context->setTextMode(textMode);
203 return new QGpgME::QGpgMEVerifyDetachedJob(context);
206 QGpgME::VerifyOpaqueJob *verifyOpaqueJob(
bool textMode)
const override
208 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
213 context->setTextMode(textMode);
214 return new QGpgME::QGpgMEVerifyOpaqueJob(context);
217 QGpgME::KeyGenerationJob *keyGenerationJob()
const override
219 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
223 return new QGpgME::QGpgMEKeyGenerationJob(context);
226 QGpgME::ImportJob *importJob()
const override
228 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
232 return new QGpgME::QGpgMEImportJob(context);
235 QGpgME::ImportFromKeyserverJob *importFromKeyserverJob()
const override
237 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
241 return new QGpgME::QGpgMEImportFromKeyserverJob(context);
244 QGpgME::ReceiveKeysJob *receiveKeysJob()
const override
246 if (mProtocol != GpgME::OpenPGP) {
250 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
254 return new QGpgME::QGpgMEReceiveKeysJob{context};
257 QGpgME::ExportJob *publicKeyExportJob(
bool armor)
const override
259 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
264 context->setArmor(armor);
265 return new QGpgME::QGpgMEExportJob(context);
268 QGpgME::ExportJob *secretKeyExportJob(
bool armor,
const QString &)
const override
270 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
275 context->setArmor(armor);
276 return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecret);
279 QGpgME::ExportJob *secretSubkeyExportJob(
bool armor)
const override
281 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
286 context->setArmor(armor);
287 return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecretSubkey);
290 QGpgME::RefreshKeysJob *refreshKeysJob()
const override
292 if (mProtocol != GpgME::CMS) {
296 return new QGpgME::QGpgMERefreshSMIMEKeysJob;
299 QGpgME::DownloadJob *downloadJob(
bool armor)
const override
301 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
306 context->setArmor(armor);
308 context->setKeyListMode(GpgME::Extern);
309 return new QGpgME::QGpgMEDownloadJob(context);
312 QGpgME::DeleteJob *deleteJob()
const override
314 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
318 return new QGpgME::QGpgMEDeleteJob(context);
321 QGpgME::SignEncryptJob *signEncryptJob(
bool armor,
bool textMode)
const override
323 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
328 context->setArmor(armor);
329 context->setTextMode(textMode);
330 return new QGpgME::QGpgMESignEncryptJob(context);
333 QGpgME::DecryptVerifyJob *decryptVerifyJob(
bool textMode)
const override
335 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
340 context->setTextMode(textMode);
341 return new QGpgME::QGpgMEDecryptVerifyJob(context);
344 QGpgME::ChangeExpiryJob *changeExpiryJob()
const override
346 if (mProtocol != GpgME::OpenPGP) {
350 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
354 return new QGpgME::QGpgMEChangeExpiryJob(context);
357 QGpgME::ChangePasswdJob *changePasswdJob()
const override
359 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
363 return new QGpgME::QGpgMEChangePasswdJob(context);
366 QGpgME::SignKeyJob *signKeyJob()
const override
368 if (mProtocol != GpgME::OpenPGP) {
372 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
376 return new QGpgME::QGpgMESignKeyJob(context);
379 QGpgME::ChangeOwnerTrustJob *changeOwnerTrustJob()
const override
381 if (mProtocol != GpgME::OpenPGP) {
385 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
389 return new QGpgME::QGpgMEChangeOwnerTrustJob(context);
392 QGpgME:: AddExistingSubkeyJob *addExistingSubkeyJob()
const override
394 if (mProtocol != GpgME::OpenPGP) {
398 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
402 return new QGpgME::QGpgMEAddExistingSubkeyJob{context};
405 QGpgME::AddUserIDJob *addUserIDJob()
const override
407 if (mProtocol != GpgME::OpenPGP) {
411 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
415 return new QGpgME::QGpgMEAddUserIDJob(context);
418 QGpgME::KeyListJob *locateKeysJob()
const override
420 if (mProtocol != GpgME::OpenPGP) {
423 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
427 context->setKeyListMode(GpgME::Locate | GpgME::Signatures | GpgME::Validate);
428 return new QGpgME::QGpgMEKeyListJob(context);
431 QGpgME::KeyForMailboxJob *keyForMailboxJob()
const override
433 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
437 return new QGpgME::QGpgMEKeyForMailboxJob(context);
440 QGpgME::WKDLookupJob *wkdLookupJob()
const override
442 if (mProtocol != GpgME::OpenPGP) {
445 auto context = GpgME::Context::createForEngine(GpgME::AssuanEngine);
449 return new QGpgME::QGpgMEWKDLookupJob(context.release());
452 QGpgME::WKSPublishJob *wksPublishJob()
const override
454 if (mProtocol != GpgME::OpenPGP) {
457 auto context = GpgME::Context::createForEngine(GpgME::SpawnEngine);
461 return new QGpgME::QGpgMEWKSPublishJob(context.release());
464 QGpgME::TofuPolicyJob *tofuPolicyJob()
const override
466 if (mProtocol != GpgME::OpenPGP) {
469 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
473 return new QGpgME::QGpgMETofuPolicyJob(context);
476 QGpgME::QuickJob *quickJob()
const override
478 if (mProtocol != GpgME::OpenPGP) {
481 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
485 return new QGpgME::QGpgMEQuickJob(context);
488 QGpgME::RevokeKeyJob *revokeKeyJob()
const override
490 if (mProtocol != GpgME::OpenPGP) {
493 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
497 return new QGpgME::QGpgMERevokeKeyJob(context);
500 QGpgME::SetPrimaryUserIDJob *setPrimaryUserIDJob()
const override
502 if (mProtocol != GpgME::OpenPGP) {
505 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
509 return new QGpgME::QGpgMESetPrimaryUserIDJob{context};
512 QGpgME::EncryptArchiveJob *encryptArchiveJob(
bool armor)
const override
514 if (mProtocol != GpgME::OpenPGP) {
517 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
518 context->setArmor(armor);
519 return new QGpgME::QGpgMEEncryptArchiveJob{context};
524 QGpgME::SignArchiveJob *signArchiveJob(
bool armor)
const override
526 if (mProtocol != GpgME::OpenPGP) {
529 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
530 context->setArmor(armor);
531 return new QGpgME::QGpgMESignArchiveJob{context};
536 QGpgME::SignEncryptArchiveJob *signEncryptArchiveJob(
bool armor)
const override
538 if (mProtocol != GpgME::OpenPGP) {
541 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
542 context->setArmor(armor);
543 return new QGpgME::QGpgMESignEncryptArchiveJob{context};
548 QGpgME::DecryptVerifyArchiveJob *decryptVerifyArchiveJob()
const override
550 if (mProtocol != GpgME::OpenPGP) {
553 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
554 return new QGpgME::QGpgMEDecryptVerifyArchiveJob{context};
559 QGpgME::WKDRefreshJob *wkdRefreshJob()
const override
561 if (mProtocol != GpgME::OpenPGP) {
564 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
565 return new QGpgME::QGpgMEWKDRefreshJob{context};
Definition protocol.h:119