Okay - another newbie question for the group - I've made great progress in
creating a very simple application that tries to do the following (it is
mostly based on the "folder-lister" sample program in the "tests" directory):
1. Hook up to an account store that maps to one of my Gmail accounts - DONE!
2. Recurse my way through all the folders of that Gmail account - DONE!
3. When finding a folder called "Inbox", do an async folder refresh - DONE!
4. After the refresh of the Inbox folder, do an async get headers - DONE!
5. For each header in the header callback function, do an async get msg - DONE!
6. For each msg in the msg callback function, dump out its main text body - NOT DONE... :(
This is meant to be a very simple console app that does NOT use any of the
TinyMail UI framework!!!!!
All I want to do is grab the main "text/plain" mime parts of the messages in
the Inbox of a Gmail account - and I'm oh-so-close... !
But, there is obviously a little bit of a disconnect - from looking at the
zillions of APIs in the main TinyMail library (libtinymail main .h and .c
files) - and reading the very good documentation that I could find, and looking
at the class diagrams, and trying to do a little reverse engineering of the
sample implementations (although all the samples are GUI-based), I THOUGHT
I could just take a TnyMsg (which I get in the callback function I specify
in the "tny_folder_get_msg_async" function) and then get its mime parts
(using the "tny_mime_part_get_parts" function) - then once I saw any mime
part whose content type is "text/plain", I could then grab the raw text of
that mime part.
BUT (and here's the disconnect) - when I try to iterate through the mime
parts, I find the iterator is empty! The callback function looks something
like this (note that I'm not trying to actually get the body of any message,
at least not yet):
msg_received_callback (TnyFolder *folder, gboolean cancelled,
TnyMsg *msg, GError *err, gpointer user_data)
// announce that we got an Inbox message!
g_print ("msg_received_callback => Got an Inbox message:\n");
// just for yucks, show the url string associated with this message...
gchar * l_url_string = tny_msg_get_url_string (msg);
g_print (" => url_string : %s\n", l_url_string);
// time to get to the MEAT of this message - we start out by
// first getting all the mime parts of this message...
TnyList * l_mime_parts = tny_simple_list_new ();
tny_mime_part_get_parts (TNY_MIME_PART (msg), l_mime_parts);
TnyIterator * iter = tny_list_create_iterator (l_mime_parts);
while (!tny_iterator_is_done (iter))
// okay - we have some mime part of this message - show its content type...
TnyMimePart * l_mime_part = TNY_MIME_PART (tny_iterator_get_current (iter));
const gchar * l_mime_part_content_type = tny_mime_part_get_content_type (l_mime_part);
g_print (" => mime_part content type : %s\n", l_mime_part_content_type);
// well, we're done with this mime part - onto the next one...
// we're done with the iterator and the message mime parts, so cleanup...
In the above code, the url_string for the message gets dumped out and is exactly
correct - in fact, I can run over to the account store on disk and literally type
out each retrieved message - all looks good.
BUT - when I try to get the mime parts for the message, I don't see ANY mime parts
When stepping through with gdb, I see that the "tny_camel_mime_part_get_parts_default"
function eventually gets called - and this function doesn't seem to want to add any
mime parts to the list that I pass into it. But I'm not exactly sure why this is
So, my conclusion is that I'm (yet again) doing something wrong - so can anyone
help point me down the right path again?
I know all the GUI-based demos will implement some TnyMsgView - but this is part
of the TinyMailUI framework - and I want to try and avoid this, if at all possible -
so shouldn't I be able to just use the TinyMail base framework (no UI stuff) for
the simple case of just retrieving all the message bodies of a folder?
It seems like I should be able to use the default CAMEL-based implementations to
do what I want to do - at least I think I should be able to do this - and it looks
like I am oh-so-close right now...
Basically, if you just want to get the basic text body of a message, what are the
3 simple steps (or whatever) that you need to do? Again, I'm just trying to create
a really, really simple console app that does not have a fancy UI - or any UI, for
that matter - I'm going to be creating a C++ wrapper library that just allows our
applications to get messages from an inbox - and also notified when any change
happens to the inbox (new messages show up or an existing message is deleted, etc.).
Thank you in advance for any advice / help you can provide to me.