Changeset View
Changeset View
Standalone View
Standalone View
messagecomposer/src/job/signjob.cpp
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | along with this library; see the file COPYING.LIB. If not, write to the | 16 | along with this library; see the file COPYING.LIB. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
18 | 02110-1301, USA. | 18 | 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "job/signjob.h" | 21 | #include "job/signjob.h" | ||
22 | 22 | | |||
23 | #include "contentjobbase_p.h" | 23 | #include "contentjobbase_p.h" | ||
24 | #include "job/protectedheaders.h" | ||||
24 | #include "utils/util_p.h" | 25 | #include "utils/util_p.h" | ||
25 | 26 | | |||
26 | #include <Libkleo/Enum> | 27 | #include <Libkleo/Enum> | ||
27 | #include <QGpgME/Protocol> | 28 | #include <QGpgME/Protocol> | ||
28 | #include <QGpgME/SignJob> | 29 | #include <QGpgME/SignJob> | ||
29 | #include <QVector> | 30 | #include <QVector> | ||
30 | 31 | | |||
31 | #include "messagecomposer_debug.h" | 32 | #include "messagecomposer_debug.h" | ||
Show All 12 Lines | |||||
44 | { | 45 | { | ||
45 | public: | 46 | public: | ||
46 | SignJobPrivate(SignJob *qq) | 47 | SignJobPrivate(SignJob *qq) | ||
47 | : ContentJobBasePrivate(qq) | 48 | : ContentJobBasePrivate(qq) | ||
48 | { | 49 | { | ||
49 | } | 50 | } | ||
50 | 51 | | |||
51 | KMime::Content *content = nullptr; | 52 | KMime::Content *content = nullptr; | ||
53 | KMime::Message *skeletonMessage = nullptr; | ||||
52 | std::vector<GpgME::Key> signers; | 54 | std::vector<GpgME::Key> signers; | ||
53 | Kleo::CryptoMessageFormat format; | 55 | Kleo::CryptoMessageFormat format; | ||
54 | 56 | | |||
57 | bool protectedHeaders = true; | ||||
58 | | ||||
55 | // copied from messagecomposer.cpp | 59 | // copied from messagecomposer.cpp | ||
56 | bool binaryHint(Kleo::CryptoMessageFormat f) | 60 | bool binaryHint(Kleo::CryptoMessageFormat f) | ||
57 | { | 61 | { | ||
58 | switch (f) { | 62 | switch (f) { | ||
59 | case Kleo::SMIMEFormat: | 63 | case Kleo::SMIMEFormat: | ||
60 | case Kleo::SMIMEOpaqueFormat: | 64 | case Kleo::SMIMEOpaqueFormat: | ||
61 | return true; | 65 | return true; | ||
62 | default: | 66 | default: | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
113 | 117 | | |||
114 | void SignJob::setSigningKeys(std::vector<GpgME::Key> &signers) | 118 | void SignJob::setSigningKeys(std::vector<GpgME::Key> &signers) | ||
115 | { | 119 | { | ||
116 | Q_D(SignJob); | 120 | Q_D(SignJob); | ||
117 | 121 | | |||
118 | d->signers = signers; | 122 | d->signers = signers; | ||
119 | } | 123 | } | ||
120 | 124 | | |||
125 | void SignJob::setSkeletonMessage(KMime::Message *skeletonMessage) | ||||
mlaurent: coding style remove <space> before "(" | |||||
126 | { | ||||
127 | Q_D(SignJob); | ||||
128 | | ||||
129 | d->skeletonMessage = skeletonMessage; | ||||
130 | } | ||||
131 | | ||||
132 | void SignJob::setProtectedHeaders(bool protectedHeaders) | ||||
133 | { | ||||
134 | Q_D(SignJob); | ||||
135 | | ||||
136 | d->protectedHeaders = protectedHeaders; | ||||
137 | } | ||||
138 | | ||||
121 | KMime::Content *SignJob::origContent() | 139 | KMime::Content *SignJob::origContent() | ||
122 | { | 140 | { | ||
123 | Q_D(SignJob); | 141 | Q_D(SignJob); | ||
124 | 142 | | |||
125 | return d->content; | 143 | return d->content; | ||
126 | } | 144 | } | ||
127 | 145 | | |||
146 | void SignJob::doStart() | ||||
147 | { | ||||
148 | Q_D(SignJob); | ||||
149 | Q_ASSERT(d->resultContent == nullptr); // Not processed before. | ||||
150 | | ||||
151 | if (d->protectedHeaders && d->skeletonMessage && d->format & Kleo::OpenPGPMIMEFormat) { | ||||
152 | ProtectedHeadersJob *pJob = new ProtectedHeadersJob; | ||||
153 | pJob->setContent(d->content); | ||||
154 | pJob->setSkeletonMessage(d->skeletonMessage); | ||||
155 | pJob->setObvoscate(false); | ||||
156 | QObject::connect(pJob, &ProtectedHeadersJob::finished, this, [d, pJob](KJob *job) { | ||||
157 | if (job->error()) { | ||||
158 | return; | ||||
159 | } | ||||
160 | d->content = pJob->content(); | ||||
161 | }); | ||||
162 | appendSubjob(pJob); | ||||
163 | } | ||||
164 | | ||||
165 | ContentJobBase::doStart(); | ||||
166 | } | ||||
167 | | ||||
168 | void SignJob::slotResult(KJob *job) | ||||
169 | { | ||||
170 | Q_D(SignJob); | ||||
171 | if (error()) { | ||||
172 | ContentJobBase::slotResult(job); | ||||
173 | return; | ||||
174 | } | ||||
175 | if (subjobs().size() == 2) { | ||||
176 | auto pjob = static_cast<ProtectedHeadersJob *>(subjobs().last()); | ||||
177 | if (pjob) { | ||||
178 | auto cjob = dynamic_cast<ContentJobBase *>(job); | ||||
auto cjob = dynamic_cast<ContentJobBase *>(job); > we use directly cjob.mlaurent: auto cjob = dynamic_cast<ContentJobBase *>(job);
Q_ASSERT(cjob);
pjob->setcontent(cjob->content… | |||||
179 | Q_ASSERT(cjob); | ||||
180 | pjob->setContent(cjob->content()); | ||||
181 | } | ||||
182 | } | ||||
183 | | ||||
184 | ContentJobBase::slotResult(job); | ||||
185 | } | ||||
186 | | ||||
128 | void SignJob::process() | 187 | void SignJob::process() | ||
129 | { | 188 | { | ||
130 | Q_D(SignJob); | 189 | Q_D(SignJob); | ||
131 | Q_ASSERT(d->resultContent == nullptr); // Not processed before. | 190 | Q_ASSERT(d->resultContent == nullptr); // Not processed before. | ||
132 | 191 | | |||
133 | // if setContent hasn't been called, we assume that a subjob was added | 192 | // if setContent hasn't been called, we assume that a subjob was added | ||
134 | // and we want to use that | 193 | // and we want to use that | ||
135 | if (!d->content) { | 194 | if (!d->content) { | ||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
coding style remove <space> before "("