- node->decrypt_attempted = true;
- node->decrypted_child = g_mime_multipart_encrypted_decrypt
-#if (GMIME_MAJOR_VERSION < 3)
- (encrypteddata, cryptoctx, &decrypt_result, &err);
-#else
- (encrypteddata, GMIME_DECRYPT_NONE, NULL, &decrypt_result, &err);
-#endif
+ if (! node->decrypted_child) {
+ mime_node_t *parent;
+ for (parent = node; parent; parent = parent->parent)
+ if (parent->envelope_file)
+ break;
+
+ node->decrypted_child = _notmuch_crypto_decrypt (&node->decrypt_attempted,
+ node->ctx->crypto->decrypt,
+ parent ? parent->envelope_file : NULL,
+ cryptoctx, encrypteddata, &decrypt_result, &err);
+ }