Simplify reply_part function to eliminate redundant code paths.

This is the same logic but with less code.
This commit is contained in:
Jameson Graef Rollins 2011-05-25 18:01:10 -07:00 committed by Carl Worth
parent a0ebd5c5e4
commit 03ac922c4b

View file

@ -88,15 +88,8 @@ static void
reply_part (GMimeObject *part, reply_part (GMimeObject *part,
unused (int *part_count)) unused (int *part_count))
{ {
GMimeContentDisposition *disposition; GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
GMimeContentType *content_type; GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (part);
disposition = g_mime_object_get_content_disposition (part);
if (disposition &&
strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
{
const char *filename = g_mime_part_get_filename (GMIME_PART (part));
content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
if (g_mime_content_type_is_type (content_type, "text", "*") && if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html")) !g_mime_content_type_is_type (content_type, "text", "html"))
@ -105,26 +98,20 @@ reply_part (GMimeObject *part,
} }
else else
{ {
if (disposition &&
strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
{
const char *filename = g_mime_part_get_filename (GMIME_PART (part));
printf ("Attachment: %s (%s)\n", filename, printf ("Attachment: %s (%s)\n", filename,
g_mime_content_type_to_string (content_type)); g_mime_content_type_to_string (content_type));
} }
return;
}
content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
{
reply_part_content (part);
}
else else
{ {
printf ("Non-text part: %s\n", printf ("Non-text part: %s\n",
g_mime_content_type_to_string (content_type)); g_mime_content_type_to_string (content_type));
} }
} }
}
/* Is the given address configured as one of the user's "personal" or /* Is the given address configured as one of the user's "personal" or
* "other" addresses. */ * "other" addresses. */