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