diff options
Diffstat (limited to 'framework/domain/mimetreeparser/interface.cpp')
-rw-r--r-- | framework/domain/mimetreeparser/interface.cpp | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index 77ffa4fd..2380e624 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp | |||
@@ -172,6 +172,7 @@ class KeyPrivate | |||
172 | public: | 172 | public: |
173 | Key *q; | 173 | Key *q; |
174 | GpgME::Key mKey; | 174 | GpgME::Key mKey; |
175 | QByteArray mKeyID; | ||
175 | }; | 176 | }; |
176 | 177 | ||
177 | Key::Key() | 178 | Key::Key() |
@@ -194,23 +195,37 @@ Key::~Key() | |||
194 | 195 | ||
195 | QString Key::keyid() const | 196 | QString Key::keyid() const |
196 | { | 197 | { |
197 | return d->mKey.keyID(); | 198 | if (!d->mKey.isNull()) { |
199 | return d->mKey.keyID(); | ||
200 | } | ||
201 | |||
202 | return d->mKeyID; | ||
198 | } | 203 | } |
199 | 204 | ||
200 | QString Key::name() const | 205 | QString Key::name() const |
201 | { | 206 | { |
202 | //FIXME: is this the correct way to get the primary UID? | 207 | //FIXME: is this the correct way to get the primary UID? |
203 | return d->mKey.userID(0).name(); | 208 | if (!d->mKey.isNull()) { |
209 | return d->mKey.userID(0).name(); | ||
210 | } | ||
211 | |||
212 | return QString(); | ||
204 | } | 213 | } |
205 | 214 | ||
206 | QString Key::email() const | 215 | QString Key::email() const |
207 | { | 216 | { |
208 | return d->mKey.userID(0).email(); | 217 | if (!d->mKey.isNull()) { |
218 | return d->mKey.userID(0).email(); | ||
219 | } | ||
220 | return QString(); | ||
209 | } | 221 | } |
210 | 222 | ||
211 | QString Key::comment() const | 223 | QString Key::comment() const |
212 | { | 224 | { |
213 | return d->mKey.userID(0).comment(); | 225 | if (!d->mKey.isNull()) { |
226 | return d->mKey.userID(0).comment(); | ||
227 | } | ||
228 | return QString(); | ||
214 | } | 229 | } |
215 | 230 | ||
216 | class SignaturePrivate | 231 | class SignaturePrivate |
@@ -269,6 +284,8 @@ class EncryptionPrivate | |||
269 | public: | 284 | public: |
270 | Encryption *q; | 285 | Encryption *q; |
271 | std::vector<Key::Ptr> mRecipients; | 286 | std::vector<Key::Ptr> mRecipients; |
287 | Encryption::ErrorType mErrorType; | ||
288 | QString mErrorString; | ||
272 | }; | 289 | }; |
273 | 290 | ||
274 | Encryption::Encryption(EncryptionPrivate *d_ptr) | 291 | Encryption::Encryption(EncryptionPrivate *d_ptr) |
@@ -281,6 +298,7 @@ Encryption::Encryption() | |||
281 | :d(std::unique_ptr<EncryptionPrivate>(new EncryptionPrivate)) | 298 | :d(std::unique_ptr<EncryptionPrivate>(new EncryptionPrivate)) |
282 | { | 299 | { |
283 | d->q = this; | 300 | d->q = this; |
301 | d->mErrorType = Encryption::NoError; | ||
284 | } | 302 | } |
285 | 303 | ||
286 | Encryption::~Encryption() | 304 | Encryption::~Encryption() |
@@ -293,6 +311,17 @@ std::vector<Key::Ptr> Encryption::recipients() const | |||
293 | return d->mRecipients; | 311 | return d->mRecipients; |
294 | } | 312 | } |
295 | 313 | ||
314 | QString Encryption::errorString() | ||
315 | { | ||
316 | return d->mErrorString; | ||
317 | } | ||
318 | |||
319 | Encryption::ErrorType Encryption::errorType() | ||
320 | { | ||
321 | return d->mErrorType; | ||
322 | } | ||
323 | |||
324 | |||
296 | class PartPrivate | 325 | class PartPrivate |
297 | { | 326 | { |
298 | public: | 327 | public: |
@@ -381,6 +410,19 @@ Encryption::Ptr PartPrivate::createEncryption(const MimeTreeParser::EncryptedMes | |||
381 | } | 410 | } |
382 | 411 | ||
383 | auto encpriv = new EncryptionPrivate(); | 412 | auto encpriv = new EncryptionPrivate(); |
413 | if (part->passphraseError()) { | ||
414 | encpriv->mErrorType = Encryption::PassphraseError; | ||
415 | encpriv->mErrorString = part->mMetaData.errorText; | ||
416 | } else if (part->isEncrypted() && !part->isDecryptable()) { | ||
417 | encpriv->mErrorType = Encryption::KeyMissing; | ||
418 | encpriv->mErrorString = part->mMetaData.errorText; | ||
419 | } else if (!part->isEncrypted() && !part->isDecryptable()) { | ||
420 | encpriv->mErrorType = Encryption::UnknownError; | ||
421 | encpriv->mErrorString = part->mMetaData.errorText; | ||
422 | } else { | ||
423 | encpriv->mErrorType = Encryption::NoError; | ||
424 | } | ||
425 | |||
384 | foreach(const auto &recipient, part->mDecryptRecipients) { | 426 | foreach(const auto &recipient, part->mDecryptRecipients) { |
385 | std::vector<GpgME::Key> found_keys; | 427 | std::vector<GpgME::Key> found_keys; |
386 | const auto &keyid = recipient.keyID(); | 428 | const auto &keyid = recipient.keyID(); |
@@ -396,6 +438,9 @@ Encryption::Ptr PartPrivate::createEncryption(const MimeTreeParser::EncryptedMes | |||
396 | if (found_keys.size() != 1) { | 438 | if (found_keys.size() != 1) { |
397 | // Should not Happen at this point | 439 | // Should not Happen at this point |
398 | qWarning() << "Oops: Found no Key for Fingerprint: " << keyid; | 440 | qWarning() << "Oops: Found no Key for Fingerprint: " << keyid; |
441 | auto keypriv = new KeyPrivate; | ||
442 | keypriv->mKeyID = keyid; | ||
443 | encpriv->mRecipients.push_back(Key::Ptr(new Key(keypriv))); | ||
399 | } else { | 444 | } else { |
400 | auto key = found_keys[0]; | 445 | auto key = found_keys[0]; |
401 | auto keypriv = new KeyPrivate; | 446 | auto keypriv = new KeyPrivate; |