From dcdb8430945e6323d78997ce47639eebc683c6d3 Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins Date: Fri, 20 May 2011 11:45:33 -0700 Subject: pass entire format structure to various show_message functions Various show_message* functions require formatting functions, which were previously being passed individually as arguments. Since we will need to be needing to passing in more formatting function in the future (ie. for crypto support), we here modify things so that we just pass in the entire format structure. This will make things much simpler down the line as we need to pass in new format functions. We move the show_format structure into notmuch-client.c as notmuch_show_format. This also affects notmuch-reply.c, so we create a mostly-empty format_reply to pass the reply_part function to show_message_body. --- show-message.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'show-message.c') diff --git a/show-message.c b/show-message.c index c206bddc..44ab8194 100644 --- a/show-message.c +++ b/show-message.c @@ -25,8 +25,7 @@ static void show_message_part (GMimeObject *part, int *part_count, - void (*show_part) (GMimeObject *part, int *part_count, int first), - void (*show_part_end) (GMimeObject *part), + const notmuch_show_format_t *format, int first) { if (GMIME_IS_MULTIPART (part)) { @@ -34,15 +33,15 @@ show_message_part (GMimeObject *part, int i; *part_count = *part_count + 1; - (*show_part) (part, part_count, first); + format->part (part, part_count, first); for (i = 0; i < g_mime_multipart_get_count (multipart); i++) { show_message_part (g_mime_multipart_get_part (multipart, i), - part_count, show_part, show_part_end, i == 0); + part_count, format, i == 0); } - if (show_part_end) - (*show_part_end) (part); + if (format->part_end) + format->part_end (part); return; } @@ -53,7 +52,7 @@ show_message_part (GMimeObject *part, mime_message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part)); show_message_part (g_mime_message_get_mime_part (mime_message), - part_count, show_part, show_part_end, first); + part_count, format, first); return; } @@ -66,15 +65,14 @@ show_message_part (GMimeObject *part, *part_count = *part_count + 1; - (*show_part) (part, part_count, first); - if (show_part_end) - (*show_part_end) (part); + format->part (part, part_count, first); + if (format->part_end) + format->part_end (part); } notmuch_status_t show_message_body (const char *filename, - void (*show_part) (GMimeObject *part, int *part_count, int first), - void (*show_part_end) (GMimeObject *part)) + const notmuch_show_format_t *format) { GMimeStream *stream = NULL; GMimeParser *parser = NULL; @@ -98,7 +96,9 @@ show_message_body (const char *filename, mime_message = g_mime_parser_construct_message (parser); show_message_part (g_mime_message_get_mime_part (mime_message), - &part_count, show_part, show_part_end, TRUE); + &part_count, + format, + TRUE); DONE: if (mime_message) -- cgit v1.2.3