- /* status */
- printf ("\"status\": %s",
- json_quote_str (ctx_quote,
- signer_status_to_string (signer->status)));
-
- if (signer->status == GMIME_SIGNER_STATUS_GOOD)
- {
- if (signer->fingerprint)
- printf (", \"fingerprint\": %s", json_quote_str (ctx_quote, signer->fingerprint));
- /* these dates are seconds since the epoch; should we
- * provide a more human-readable format string? */
- if (signer->created)
- printf (", \"created\": %d", (int) signer->created);
- if (signer->expires)
- printf (", \"expires\": %d", (int) signer->expires);
- /* output user id only if validity is FULL or ULTIMATE. */
- /* note that gmime is using the term "trust" here, which
- * is WRONG. It's actually user id "validity". */
- if ((signer->name) && (signer->trust)) {
- if ((signer->trust == GMIME_SIGNER_TRUST_FULLY) || (signer->trust == GMIME_SIGNER_TRUST_ULTIMATE))
- printf (", \"userid\": %s", json_quote_str (ctx_quote, signer->name));
- }
- } else {
- if (signer->keyid)
- printf (", \"keyid\": %s", json_quote_str (ctx_quote, signer->keyid));
- }
- if (signer->errors != GMIME_SIGNER_ERROR_NONE) {
- printf (", \"errors\": %d", signer->errors);
- }
-
- printf ("}");
- signer = signer->next;
+ content_string = g_mime_content_type_get_mime_type (content_type);
+ g_mime_stream_printf (stream, ", Content-type: %s\n", content_string);
+ g_free (content_string);
+ }
+
+ if (GMIME_IS_MESSAGE (node->part)) {
+ GMimeMessage *message = GMIME_MESSAGE (node->part);
+ char *recipients_string;
+ char *date_string;
+
+ g_mime_stream_printf (stream, "\fheader{\n");
+ if (node->envelope_file)
+ g_mime_stream_printf (stream, "%s\n", _get_one_line_summary (ctx, node->envelope_file));
+ g_mime_stream_printf (stream, "Subject: %s\n", g_mime_message_get_subject (message));
+ g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_from_string (message));
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
+ if (recipients_string)
+ g_mime_stream_printf (stream, "To: %s\n", recipients_string);
+ g_free (recipients_string);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
+ if (recipients_string)
+ g_mime_stream_printf (stream, "Cc: %s\n", recipients_string);
+ g_free (recipients_string);
+ date_string = g_mime_message_get_date_string (node, message);
+ g_mime_stream_printf (stream, "Date: %s\n", date_string);
+ g_mime_stream_printf (stream, "\fheader}\n");
+
+ if (! params->output_body) {
+ g_mime_stream_printf (stream, "\f%s}\n", part_type);
+ return NOTMUCH_STATUS_SUCCESS;
+ }
+ g_mime_stream_printf (stream, "\fbody{\n");
+ }
+
+ if (leaf) {
+ if (g_mime_content_type_is_type (content_type, "text", "*") &&
+ (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);
+ }