[gmime-devel] g_mime_message_foreach_part does not recurse



Hi,

I am writing a maildir index & search program, and I use GMime for
parsing the messages. I try to determine the message body using
g_mime_message_foreach_part. However, it seems that function only gets
the parts on the current level, and does not recurse. Is that expected
behaviour. Maybe it should be documented?

To show this, I ran a patched test-parser with (patch attached). I get:

$ ./test-parser ./test1.eml

Testing MIME parser...

[...]

Content-Type: MULTIPART/MIXED
   Content-Type: MULTIPART/ALTERNATIVE
      Content-Type: text/plain
      Content-Type: text/html
   Content-Type: image/jpeg
**** g_mime_message_foreach_part
MULTIPART/ALTERNATIVE
image/jpeg


So, in the foreach case, the inner-parts are not seen.

Best wishes,
Dirk.

-- 
-----------------------------------------------
Dirk-Jan C. Binnema <djcb djcbsoftware nl>
blog: http://www.djcbsoftware.nl/ChangeLog (NL)
      http://djcbflux.blogspot.com (EN)
chat: djcb jabber org
-----------------------------------------------
--- test-parser.c.bak	2008-09-06 13:12:21.000000000 +0300
+++ test-parser.c	2008-09-06 13:14:47.000000000 +0300
@@ -86,6 +86,18 @@
 	}
 }
 
+
+static void 
+print_content_type (GMimeObject *part, void* data)
+{
+       g_return_if_fail (GMIME_IS_OBJECT(part));
+       
+       g_print ("%s\n",
+               g_mime_content_type_to_string(
+                       g_mime_object_get_content_type(part)));
+}
+
+
 static void
 test_parser (GMimeStream *stream)
 {
@@ -165,6 +177,8 @@
 #ifdef PRINT_MIME_STRUCT
 	/* print mime structure */
 	print_mime_struct (message->mime_part, 0);
+	g_print ("**** g_mime_message_foreach_part\n");
+        g_mime_message_foreach_part (message, print_content_type, NULL);
 #endif
 	
 	g_mime_object_unref (GMIME_OBJECT (message));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]