GNOME Bugzilla – Bug 651964
function needed to return rfc/822 messages as GMimeObjects
Last modified: 2011-06-07 19:04:48 UTC
Even though rfc822 messages are exactly like any other GMimeObject, there appears to be no way to return the message as a GMimeObject. This limits what can be done with the message parts. Having the message available as a GMimeObject would: * allow for retrieving *all* headers from the rfc822 message in a message/rfc822 part (using eg g_mime_object_get_header), not just the few available with the GMimeMessage method. * allow for outputting the full raw message with g_mime_object_write_to_stream (). * allow for totally symmetric handling of all parts (see the example recursive function below). I suggest the function be defined as: GMimeObject * g_mime_message_part_get_object (GMimeMessagePart *part); Thanks, and please let me know if you have any questions. jamie. static void do_part (GMimeObject *part) { /* do stuff on part headers */ if (GMIME_IS_MULTIPART (part)) { GMimeMultipart *multipart = GMIME_MULTIPART (part); int i; for (i = 0; i < g_mime_multipart_get_count (multipart); i++) do_part (g_mime_multipart_get_part (multipart, i)); } else if (GMIME_IS_MESSAGE_PART (part)) { do_part (g_mime_message_part_get_object (GMIME_MESSAGE_PART (part))); } else { /* do stuff on part content */ } }
I guess I'm a little confused. Both GMimeMessagePart and GMimeMessage subclass GMimeObject, so a get_object() shouldn't be necessary.
> I guess I'm a little confused. Both GMimeMessagePart and GMimeMessage subclass > GMimeObject, so a get_object() shouldn't be necessary. Hi, Jeffrey. Thanks for the response. I actually figured out (or was pointed to) the solution to what I was looking for: GMIME_OBJECT. The following does exactly what I was looking for: GMIME_OBJECT(g_mime_message_part_get_message(GMIME_MESSAGE_PART(part))) The problem was that I didn't see any documentation about GMIME_OBJECT() (or any of the other macros, for that matter). That's a separate issue, though. Thanks again for the response.
fwiw, GMIME_OBJECT() is just a cast macro (well, if glib is built with debugging, it also performs a type-check and returns NULL and prints a warning to stderr if it's not a subclass of GMimeObject)