After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 651964 - function needed to return rfc/822 messages as GMimeObjects
function needed to return rfc/822 messages as GMimeObjects
Status: RESOLVED NOTABUG
Product: gmime
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Jeffrey Stedfast
Jeffrey Stedfast
Depends on:
Blocks:
 
 
Reported: 2011-06-06 03:55 UTC by Jameson Rollins
Modified: 2011-06-07 19:04 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jameson Rollins 2011-06-06 03:55:03 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 */
  }
}
Comment 1 Jeffrey Stedfast 2011-06-07 17:44:25 UTC
I guess I'm a little confused. Both GMimeMessagePart and GMimeMessage subclass GMimeObject, so a get_object() shouldn't be necessary.
Comment 2 Jameson Rollins 2011-06-07 18:13:08 UTC
> 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.
Comment 3 Jeffrey Stedfast 2011-06-07 19:04:48 UTC
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)