+ msg_crypto = mime_node_get_message_crypto_status (node);
+ if (notmuch_format_version >= 4) {
+ sp->map_key (sp, "crypto");
+ sp->begin_map (sp);
+ if (msg_crypto->sig_list ||
+ msg_crypto->decryption_status != NOTMUCH_MESSAGE_DECRYPTED_NONE) {
+ if (msg_crypto->sig_list) {
+ sp->map_key (sp, "signed");
+ sp->begin_map (sp);
+ sp->map_key (sp, "status");
+ format_part_sigstatus_sprinter (sp, msg_crypto->sig_list);
+ if (msg_crypto->signature_encrypted) {
+ sp->map_key (sp, "encrypted");
+ sp->boolean (sp, msg_crypto->signature_encrypted);
+ }
+ if (msg_crypto->payload_subject) {
+ sp->map_key (sp, "headers");
+ sp->begin_list (sp);
+ sp->string (sp, "Subject");
+ sp->end (sp);
+ }
+ sp->end (sp);
+ }
+ if (msg_crypto->decryption_status != NOTMUCH_MESSAGE_DECRYPTED_NONE) {
+ sp->map_key (sp, "decrypted");
+ sp->begin_map (sp);
+ sp->map_key (sp, "status");
+ sp->string (sp, msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL ?
+ "full" : "partial");
+
+ if (msg_crypto->payload_subject) {
+ const char *subject = g_mime_message_get_subject GMIME_MESSAGE (node->part);
+ if (subject == NULL || strcmp (subject, msg_crypto->payload_subject)) {
+ /* protected subject differs from the external header */
+ sp->map_key (sp, "header-mask");
+ sp->begin_map (sp);
+ sp->map_key (sp, "Subject");
+ if (subject == NULL)
+ sp->null (sp);
+ else
+ sp->string (sp, subject);
+ sp->end (sp);
+ }
+ }
+ sp->end (sp);
+ }
+ }
+ sp->end (sp);
+ }
+
+ sp->map_key (sp, "headers");
+ format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false, msg_crypto);
+
+ sp->end (sp);
+ return;
+ }
+
+ /* The disposition and content-type metadata are associated with
+ * the envelope for message parts */
+ GMimeObject *meta = node->envelope_part ? (
+ GMIME_OBJECT (node->envelope_part) ) : node->part;
+ GMimeContentType *content_type = g_mime_object_get_content_type (meta);
+ char *content_string;
+ const char *disposition = _get_disposition (meta);
+ const char *cid = g_mime_object_get_content_id (meta);
+ const char *filename = GMIME_IS_PART (node->part) ? (
+ g_mime_part_get_filename (GMIME_PART (node->part) ) ) : NULL;
+ int nclose = 0;
+ int i;
+
+ sp->begin_map (sp);
+
+ sp->map_key (sp, "id");
+ sp->integer (sp, node->part_num);
+
+ if (node->decrypt_attempted) {
+ sp->map_key (sp, "encstatus");
+ sp->begin_list (sp);
+ sp->begin_map (sp);
+ sp->map_key (sp, "status");
+ sp->string (sp, node->decrypt_success ? "good" : "bad");
+ sp->end (sp);
+ sp->end (sp);
+ }
+
+ if (node->verify_attempted) {
+ sp->map_key (sp, "sigstatus");
+ format_part_sigstatus_sprinter (sp, node->sig_list);