+ (params->include_html ||
+ ! g_mime_content_type_is_type (content_type, "text", "html"))) {
+ show_text_part_content (node->part, stream, 0);
+ } else {
+ char *content_string = g_mime_content_type_get_mime_type (content_type);
+ g_mime_stream_printf (stream, "Non-text part: %s\n", content_string);
+ g_free (content_string);
+ }
+ }
+
+ for (i = 0; i < node->nchildren; i++)
+ format_part_text (ctx, sp, mime_node_child (node, i), indent, params);
+
+ if (GMIME_IS_MESSAGE (node->part))
+ g_mime_stream_printf (stream, "\fbody}\n");
+
+ g_mime_stream_printf (stream, "\f%s}\n", part_type);
+
+ return NOTMUCH_STATUS_SUCCESS;
+}
+
+static void
+format_omitted_part_meta_sprinter (sprinter_t *sp, GMimeObject *meta, GMimePart *part)
+{
+ const char *content_charset = g_mime_object_get_content_type_parameter (meta, "charset");
+ const char *cte = g_mime_object_get_header (meta, "content-transfer-encoding");
+ GMimeDataWrapper *wrapper = g_mime_part_get_content (part);
+ GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper);
+ ssize_t content_length = g_mime_stream_length (stream);
+
+ if (content_charset != NULL) {
+ sp->map_key (sp, "content-charset");
+ sp->string (sp, content_charset);
+ }
+ if (cte != NULL) {
+ sp->map_key (sp, "content-transfer-encoding");
+ sp->string (sp, cte);
+ }
+ if (content_length >= 0) {
+ sp->map_key (sp, "content-length");
+ sp->integer (sp, content_length);
+ }
+}
+
+void
+format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
+ int duplicate,
+ bool output_body,
+ bool include_html)
+{
+ /* Any changes to the JSON or S-Expression format should be
+ * reflected in the file devel/schemata. */
+
+ if (node->envelope_file) {
+ const _notmuch_message_crypto_t *msg_crypto = NULL;
+ sp->begin_map (sp);
+ format_message_sprinter (sp, node->envelope_file);
+
+ sp->map_key (sp, "duplicate");
+ sp->integer (sp, duplicate > 0 ? duplicate : 1);
+
+ if (output_body) {
+ sp->map_key (sp, "body");
+ sp->begin_list (sp);
+ format_part_sprinter (ctx, sp, mime_node_child (node, 0), -1, true, include_html);
+ sp->end (sp);
+ }
+
+ 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);