83c50441168e3e2cbc175dbb57aeda676e1e0b46
[gpgme.git] / lang / qt / src / job.cpp
1 /*
2     job.cpp
3
4     This file is part of qgpgme, the Qt API binding for gpgme
5     Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB
6     Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
7     Software engineering by Intevation GmbH
8
9     QGpgME is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License as
11     published by the Free Software Foundation; either version 2 of the
12     License, or (at your option) any later version.
13
14     QGpgME is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17     General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
23     In addition, as a special exception, the copyright holders give
24     permission to link the code of this program with any edition of
25     the Qt library by Trolltech AS, Norway (or with modified versions
26     of Qt that use the same license as Qt), and distribute linked
27     combinations including the two.  You must obey the GNU General
28     Public License in all respects for all of the code used other than
29     Qt.  If you modify this file, you may extend this exception to
30     your version of the file, but you are not obligated to do so.  If
31     you do not wish to do so, delete this exception statement from
32     your version.
33 */
34
35 #ifdef HAVE_CONFIG_H
36  #include "config.h"
37 #endif
38
39 #include "job.h"
40
41 #include "keylistjob.h"
42 #include "listallkeysjob.h"
43 #include "encryptjob.h"
44 #include "decryptjob.h"
45 #include "decryptverifyjob.h"
46 #include "signjob.h"
47 #include "signkeyjob.h"
48 #include "signencryptjob.h"
49 #include "verifydetachedjob.h"
50 #include "verifyopaquejob.h"
51 #include "keygenerationjob.h"
52 #include "importjob.h"
53 #include "importfromkeyserverjob.h"
54 #include "exportjob.h"
55 #include "changeexpiryjob.h"
56 #include "changeownertrustjob.h"
57 #include "changepasswdjob.h"
58 #include "downloadjob.h"
59 #include "deletejob.h"
60 #include "refreshkeysjob.h"
61 #include "adduseridjob.h"
62 #include "specialjob.h"
63 #include "keyformailboxjob.h"
64 #include "wkspublishjob.h"
65 #include "tofupolicyjob.h"
66 #include "threadedjobmixin.h"
67
68 #include <QCoreApplication>
69 #include <QDebug>
70
71 #include <gpg-error.h>
72
73 QGpgME::Job::Job(QObject *parent)
74     : QObject(parent)
75 {
76     if (QCoreApplication *app = QCoreApplication::instance()) {
77         connect(app, &QCoreApplication::aboutToQuit, this, &Job::slotCancel);
78     }
79 }
80
81 QGpgME::Job::~Job()
82 {
83 }
84
85 QString QGpgME::Job::auditLogAsHtml() const
86 {
87     qDebug() << "QGpgME::Job::auditLogAsHtml() should be reimplemented in Kleo::Job subclasses!";
88     return QString();
89 }
90
91 GpgME::Error QGpgME::Job::auditLogError() const
92 {
93     qDebug() << "QGpgME::Job::auditLogError() should be reimplemented in Kleo::Job subclasses!";
94     return GpgME::Error::fromCode(GPG_ERR_NOT_IMPLEMENTED);
95 }
96
97 bool QGpgME::Job::isAuditLogSupported() const
98 {
99     return auditLogError().code() != GPG_ERR_NOT_IMPLEMENTED;
100 }
101
102 QMap <QGpgME::Job *, GpgME::Context *> QGpgME::g_context_map;
103
104 /* static */
105 GpgME::Context *QGpgME::Job::context(QGpgME::Job *job)
106 {
107     return QGpgME::g_context_map.value (job, nullptr);
108 }
109
110 #define make_job_subclass_ext(x,y)                \
111     QGpgME::x::x( QObject * parent ) : y( parent ) {} \
112     QGpgME::x::~x() {}
113
114 #define make_job_subclass(x) make_job_subclass_ext(x,Job)
115
116 make_job_subclass(KeyListJob)
117 make_job_subclass(ListAllKeysJob)
118 make_job_subclass(EncryptJob)
119 make_job_subclass(DecryptJob)
120 make_job_subclass(DecryptVerifyJob)
121 make_job_subclass(SignJob)
122 make_job_subclass(SignEncryptJob)
123 make_job_subclass(SignKeyJob)
124 make_job_subclass(VerifyDetachedJob)
125 make_job_subclass(VerifyOpaqueJob)
126 make_job_subclass(KeyGenerationJob)
127 make_job_subclass(AbstractImportJob)
128 make_job_subclass_ext(ImportJob, AbstractImportJob)
129 make_job_subclass_ext(ImportFromKeyserverJob, AbstractImportJob)
130 make_job_subclass(ExportJob)
131 make_job_subclass(ChangeExpiryJob)
132 make_job_subclass(ChangeOwnerTrustJob)
133 make_job_subclass(ChangePasswdJob)
134 make_job_subclass(DownloadJob)
135 make_job_subclass(DeleteJob)
136 make_job_subclass(RefreshKeysJob)
137 make_job_subclass(AddUserIDJob)
138 make_job_subclass(SpecialJob)
139 make_job_subclass(KeyForMailboxJob)
140 make_job_subclass(WKSPublishJob)
141 make_job_subclass(TofuPolicyJob)
142
143 #undef make_job_subclass
144
145 #include "job.moc"
146
147 #include "keylistjob.moc"
148 #include "listallkeysjob.moc"
149 #include "encryptjob.moc"
150 #include "decryptjob.moc"
151 #include "decryptverifyjob.moc"
152 #include "signjob.moc"
153 #include "signencryptjob.moc"
154 #include "signkeyjob.moc"
155 #include "verifydetachedjob.moc"
156 #include "verifyopaquejob.moc"
157 #include "keygenerationjob.moc"
158 #include "abstractimportjob.moc"
159 #include "importjob.moc"
160 #include "importfromkeyserverjob.moc"
161 #include "exportjob.moc"
162 #include "changeexpiryjob.moc"
163 #include "changeownertrustjob.moc"
164 #include "changepasswdjob.moc"
165 #include "downloadjob.moc"
166 #include "deletejob.moc"
167 #include "refreshkeysjob.moc"
168 #include "adduseridjob.moc"
169 #include "specialjob.moc"
170 #include "keyformailboxjob.moc"
171 #include "wkspublishjob.moc"
172 #include "tofupolicyjob.moc"