Re: [Evolution-hackers] Help request: Mime v1.0 from char* to CamelMimeMessage*



On Fri, 2006-06-09 at 11:24 +0200, Smartuser wrote:
> This is some extra information on my previous message.
> - Help request: Mime v1.0 from char* to CamelMimeMessage*
> 
> I've tried the following code to put the char* (containing the message) in a 
> stream. And then convert it to a message. But this dousnot work this way I 
> guess what am I doing wrong?
> 
> 
> CamelStream *stream = NULL;
>  CamelDataWrapper *dw = NULL;
>  CamelMimeParser *parser = NULL;
> // CamelContentType *ct = NULL;
>   int errwrap = 0;
>  debug(__FILE__,__FUNCTION__,__LINE__,1);
> //if(IMToINet(pMapiMessage, &szMessage) == hrSuccess){
>     if(IMToINet(pMapiMessage, &szMessage) != hrSuccess){
>  debug(__FILE__,__FUNCTION__,__LINE__,1);
>         printf("Message:\n  %s\n", szMessage);
> 
>         stream = camel_stream_mem_new();
>         camel_stream_reset(stream);

no need to reset the stream here (a new stream's cursor always points to
the first byte)

>         camel_stream_write(stream, szMessage, strlen(szMessage));

reset the stream *here*.

CamelStreams are just like normal POSIX file i/o... if you do:

fd = open (file, O_RDWR);
write (fd, data, len);

the cursor into the file is 'len' bytes into the file now and so if you
want to parse the resultant file from the beginning, you have to seek to
the beginning of the file, or any reads() will start at offset 'len'

>         msg = camel_mime_message_new ();
> 
>           if(-1 == 
> camel_data_wrapper_construct_from_stream((CamelDataWrapper*) msg,stream)){
>           printf("Hello World Data Wrapper");
>         }else{
> //          stream = camel_stream_mem_new_with_buffer((const char*)szMessage, 
> strlen(szMessage));
> //          errwrap = camel_data_wrapper_construct_from_stream(dw,stream);
> 
>           printf ("Error Wrap = \n");
> //          printf("mime_type = %s\n", camel_data_wrapper_get_mime_type(dw));
>         }
> _______________________________________________
> Evolution-hackers mailing list
> Evolution-hackers gnome org
> http://mail.gnome.org/mailman/listinfo/evolution-hackers
-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj novell com  - www.novell.com




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