36#ifndef __QGPGME_PROTOCOL_P_H__
37#define __QGPGME_PROTOCOL_P_H__
38#include "qgpgmenewcryptoconfig.h"
40#include "qgpgmeadqueryjob.h"
41#include "qgpgmekeygenerationjob.h"
42#include "qgpgmekeylistjob.h"
43#include "qgpgmelistallkeysjob.h"
44#include "qgpgmedecryptjob.h"
45#include "qgpgmedecryptverifyarchivejob.h"
46#include "qgpgmedecryptverifyjob.h"
47#include "qgpgmerefreshsmimekeysjob.h"
48#include "qgpgmedeletejob.h"
49#include "qgpgmedownloadjob.h"
50#include "qgpgmesignencryptjob.h"
51#include "qgpgmeencryptarchivejob.h"
52#include "qgpgmeencryptjob.h"
53#include "qgpgmesignarchivejob.h"
54#include "qgpgmesignencryptarchivejob.h"
55#include "qgpgmesignjob.h"
56#include "qgpgmesignkeyjob.h"
57#include "qgpgmeexportjob.h"
58#include "qgpgmeverifydetachedjob.h"
59#include "qgpgmeimportjob.h"
60#include "qgpgmeimportfromkeyserverjob.h"
61#include "qgpgmeverifyopaquejob.h"
62#include "qgpgmechangeexpiryjob.h"
63#include "qgpgmechangeownertrustjob.h"
64#include "qgpgmechangepasswdjob.h"
65#include "qgpgmeaddexistingsubkeyjob.h"
66#include "qgpgmeadduseridjob.h"
67#include "qgpgmekeyformailboxjob.h"
68#include "qgpgmewkdlookupjob.h"
69#include "qgpgmewkspublishjob.h"
70#include "qgpgmetofupolicyjob.h"
71#include "qgpgmequickjob.h"
72#include "qgpgmereceivekeysjob.h"
73#include "qgpgmerevokekeyjob.h"
74#include "qgpgmesetprimaryuseridjob.h"
75#include "qgpgmewkdrefreshjob.h"
82 GpgME::Protocol mProtocol;
84 explicit Protocol(GpgME::Protocol proto) : mProtocol(proto) {}
86 QString name()
const override
89 case GpgME::OpenPGP:
return QStringLiteral(
"OpenPGP");
90 case GpgME::CMS:
return QStringLiteral(
"SMIME");
91 default:
return QString();
95 QString displayName()
const override
100 case GpgME::OpenPGP:
return QStringLiteral(
"gpg");
101 case GpgME::CMS:
return QStringLiteral(
"gpgsm");
102 default:
return QStringLiteral(
"unknown");
106 QGpgME::SpecialJob *specialJob(
const char *,
const QMap<QString, QVariant> &)
const override
111 QGpgME::KeyListJob *keyListJob(
bool remote,
bool includeSigs,
bool validate)
const override
113 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
118 unsigned int mode = context->keyListMode();
120 mode |= GpgME::Extern;
121 mode &= ~GpgME::Local;
123 mode |= GpgME::Local;
124 mode &= ~GpgME::Extern;
127 mode |= GpgME::Signatures;
130 mode |= GpgME::Validate;
132 context->setKeyListMode(mode);
133 return new QGpgME::QGpgMEKeyListJob(context);
136 QGpgME::ListAllKeysJob *listAllKeysJob(
bool includeSigs,
bool validate)
const override
138 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
143 unsigned int mode = context->keyListMode();
144 mode |= GpgME::Local;
145 mode &= ~GpgME::Extern;
147 mode |= GpgME::Signatures;
150 mode |= GpgME::Validate;
157 context->setOffline(
true);
159 context->setKeyListMode(mode);
160 return new QGpgME::QGpgMEListAllKeysJob(context);
163 QGpgME::EncryptJob *encryptJob(
bool armor,
bool textmode)
const override
165 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
170 context->setArmor(armor);
171 context->setTextMode(textmode);
172 return new QGpgME::QGpgMEEncryptJob(context);
175 QGpgME::DecryptJob *decryptJob()
const override
177 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
181 return new QGpgME::QGpgMEDecryptJob(context);
184 QGpgME::SignJob *signJob(
bool armor,
bool textMode)
const override
186 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
191 context->setArmor(armor);
192 context->setTextMode(textMode);
193 return new QGpgME::QGpgMESignJob(context);
196 QGpgME::VerifyDetachedJob *verifyDetachedJob(
bool textMode)
const override
198 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
203 context->setTextMode(textMode);
204 return new QGpgME::QGpgMEVerifyDetachedJob(context);
207 QGpgME::VerifyOpaqueJob *verifyOpaqueJob(
bool textMode)
const override
209 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
214 context->setTextMode(textMode);
215 return new QGpgME::QGpgMEVerifyOpaqueJob(context);
218 QGpgME::KeyGenerationJob *keyGenerationJob()
const override
220 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
224 return new QGpgME::QGpgMEKeyGenerationJob(context);
227 QGpgME::ImportJob *importJob()
const override
229 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
233 return new QGpgME::QGpgMEImportJob(context);
236 QGpgME::ImportFromKeyserverJob *importFromKeyserverJob()
const override
238 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
242 return new QGpgME::QGpgMEImportFromKeyserverJob(context);
245 QGpgME::ReceiveKeysJob *receiveKeysJob()
const override
247 if (mProtocol != GpgME::OpenPGP) {
251 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
255 return new QGpgME::QGpgMEReceiveKeysJob{context};
258 QGpgME::ExportJob *publicKeyExportJob(
bool armor)
const override
260 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
265 context->setArmor(armor);
266 return new QGpgME::QGpgMEExportJob(context);
269 QGpgME::ExportJob *secretKeyExportJob(
bool armor,
const QString &)
const override
271 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
276 context->setArmor(armor);
277 return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecret);
280 QGpgME::ExportJob *secretSubkeyExportJob(
bool armor)
const override
282 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
287 context->setArmor(armor);
288 return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecretSubkey);
291 QGpgME::RefreshKeysJob *refreshKeysJob()
const override
293 if (mProtocol != GpgME::CMS) {
297 return new QGpgME::QGpgMERefreshSMIMEKeysJob;
300 QGpgME::DownloadJob *downloadJob(
bool armor)
const override
302 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
307 context->setArmor(armor);
309 context->setKeyListMode(GpgME::Extern);
310 return new QGpgME::QGpgMEDownloadJob(context);
313 QGpgME::DeleteJob *deleteJob()
const override
315 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
319 return new QGpgME::QGpgMEDeleteJob(context);
322 QGpgME::SignEncryptJob *signEncryptJob(
bool armor,
bool textMode)
const override
324 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
329 context->setArmor(armor);
330 context->setTextMode(textMode);
331 return new QGpgME::QGpgMESignEncryptJob(context);
334 QGpgME::DecryptVerifyJob *decryptVerifyJob(
bool textMode)
const override
336 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
341 context->setTextMode(textMode);
342 return new QGpgME::QGpgMEDecryptVerifyJob(context);
345 QGpgME::ChangeExpiryJob *changeExpiryJob()
const override
347 if (mProtocol != GpgME::OpenPGP) {
351 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
355 return new QGpgME::QGpgMEChangeExpiryJob(context);
358 QGpgME::ChangePasswdJob *changePasswdJob()
const override
360 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
364 return new QGpgME::QGpgMEChangePasswdJob(context);
367 QGpgME::SignKeyJob *signKeyJob()
const override
369 if (mProtocol != GpgME::OpenPGP) {
373 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
377 return new QGpgME::QGpgMESignKeyJob(context);
380 QGpgME::ChangeOwnerTrustJob *changeOwnerTrustJob()
const override
382 if (mProtocol != GpgME::OpenPGP) {
386 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
390 return new QGpgME::QGpgMEChangeOwnerTrustJob(context);
393 QGpgME:: AddExistingSubkeyJob *addExistingSubkeyJob()
const override
395 if (mProtocol != GpgME::OpenPGP) {
399 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
403 return new QGpgME::QGpgMEAddExistingSubkeyJob{context};
406 QGpgME::AddUserIDJob *addUserIDJob()
const override
408 if (mProtocol != GpgME::OpenPGP) {
412 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
416 return new QGpgME::QGpgMEAddUserIDJob(context);
419 QGpgME::KeyListJob *locateKeysJob()
const override
421 if (mProtocol != GpgME::OpenPGP) {
424 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
428 context->setKeyListMode(GpgME::Locate | GpgME::Signatures | GpgME::Validate);
429 return new QGpgME::QGpgMEKeyListJob(context);
432 QGpgME::KeyForMailboxJob *keyForMailboxJob()
const override
434 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
438 return new QGpgME::QGpgMEKeyForMailboxJob(context);
441 QGpgME::WKDLookupJob *wkdLookupJob()
const override
443 if (mProtocol != GpgME::OpenPGP) {
446 auto context = GpgME::Context::createForEngine(GpgME::AssuanEngine);
450 return new QGpgME::QGpgMEWKDLookupJob(context.release());
453 QGpgME::WKSPublishJob *wksPublishJob()
const override
455 if (mProtocol != GpgME::OpenPGP) {
458 auto context = GpgME::Context::createForEngine(GpgME::SpawnEngine);
462 return new QGpgME::QGpgMEWKSPublishJob(context.release());
465 QGpgME::TofuPolicyJob *tofuPolicyJob()
const override
467 if (mProtocol != GpgME::OpenPGP) {
470 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
474 return new QGpgME::QGpgMETofuPolicyJob(context);
477 QGpgME::QuickJob *quickJob()
const override
479 if (mProtocol != GpgME::OpenPGP) {
482 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
486 return new QGpgME::QGpgMEQuickJob(context);
489 QGpgME::RevokeKeyJob *revokeKeyJob()
const override
491 if (mProtocol != GpgME::OpenPGP) {
494 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
498 return new QGpgME::QGpgMERevokeKeyJob(context);
501 QGpgME::SetPrimaryUserIDJob *setPrimaryUserIDJob()
const override
503 if (mProtocol != GpgME::OpenPGP) {
506 GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
510 return new QGpgME::QGpgMESetPrimaryUserIDJob{context};
513 QGpgME::EncryptArchiveJob *encryptArchiveJob(
bool armor)
const override
515 if (mProtocol != GpgME::OpenPGP) {
518 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
519 context->setArmor(armor);
520 return new QGpgME::QGpgMEEncryptArchiveJob{context};
525 QGpgME::SignArchiveJob *signArchiveJob(
bool armor)
const override
527 if (mProtocol != GpgME::OpenPGP) {
530 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
531 context->setArmor(armor);
532 return new QGpgME::QGpgMESignArchiveJob{context};
537 QGpgME::SignEncryptArchiveJob *signEncryptArchiveJob(
bool armor)
const override
539 if (mProtocol != GpgME::OpenPGP) {
542 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
543 context->setArmor(armor);
544 return new QGpgME::QGpgMESignEncryptArchiveJob{context};
549 QGpgME::DecryptVerifyArchiveJob *decryptVerifyArchiveJob()
const override
551 if (mProtocol != GpgME::OpenPGP) {
554 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
555 return new QGpgME::QGpgMEDecryptVerifyArchiveJob{context};
560 QGpgME::WKDRefreshJob *wkdRefreshJob()
const override
562 if (mProtocol != GpgME::OpenPGP) {
565 if (
auto context = GpgME::Context::createForProtocol(mProtocol)) {
566 return new QGpgME::QGpgMEWKDRefreshJob{context};
571 QGpgME::ADQueryJob *adQueryJob()
const override
573 if (
auto context = GpgME::Context::createForEngine(GpgME::AssuanEngine)) {
574 return new QGpgME::QGpgMEADQueryJob{context.release()};
Definition protocol.h:120