Re: [Evolution-hackers] Raw access to message



On Do, 2010-03-11 at 12:58 -0500, Jeffrey Stedfast wrote:
> Stefan Schulze Frielinghaus wrote:
> > On Do, 2010-03-11 at 10:45 -0500, Jeffrey Stedfast wrote:
> >   
> >> On 03/11/2010 09:16 AM, Stefan Schulze Frielinghaus wrote:
> >>     
> >>> Hi,
> >>>
> >>> Is it possible to get raw access to an email (including header and
> >>> body)? Or, if that is not possible, raw access to the body of the
> >>> message?
> >>>
> >>> Raw access is important for me because I want to write a plugin which
> >>> uses some kind of cryptography, e.g. character encoding is important to
> >>> me.
> >>>   
> >>>       
> >> You can get the raw message from a CamelMimeMessage object by writing it
> >> to a stream buffer.
> >>     
> >
> > This sounds great. I'm quite new to evolution could you give me a hint
> > how to do that? I'm starting with an EMEventTargetMessage object where I
> > can get an CamelMimeMessage object from. But how can I dump this one
> > into a stream? Writing to a stream requires a buffer of type gchar, but
> > I have a CamelMimeMessage object and I even do not know the length of
> > the message. What function calls could I look at?
> >   
> 
> CamelStream *stream = camel_stream_mem_new ();
> camel_data_wrapper_write_to_stream (message, stream);
> 
> It's been 4 or 5 years since I did any evo hacking, so the above code
> might not be quite right - but it should give you a general idea.

Ah perfect, thanks! I was not aware of a function like
camel_data_wrapper_write_to_stream().

Just for the records if someone else is looking for a similar solution:

CamelStreamMem *stream = (CamelStreamMem *)camel_stream_mem_new ();
camel_data_wrapper_write_to_stream ((CamelDataWrapper*)t->message,
                                    (CamelStream *)stream);

And then you can access the message via

stream->buffer->data;

and

stream->buffer->len;

cheers,
Stefan



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