Re: Having trouble trying to get the functional tests of TinyMail to work



El mié, 19-05-2010 a las 13:20 -0700, Steve Rosen escribió:

> Then, my "decode_to_stream_callback" functions looks like this:
> 
> static void
> decode_to_stream_callback (TnyMimePart *self, gboolean cancelled,
> TnyStream *stream, GError *err, gpointer user_data)
> {
>     // announce that we got called back to decode a stream for some
> message mime part..
>     g_print ("decode_to_stream_callback => Time to decode a stream for
> some text/plain mime part, cancelled = %d\n", cancelled);
> 
>     char tmp_buf[4096];
>     gssize nb_total = 0;
>     gssize nb_read;
> 
>     // for now, just see if we can read all the bytes in the decoded
> stream - we'll
>     // display the contents later...
>     while ( !tny_stream_is_eos (stream) )
>     {
>         nb_read = tny_stream_read (stream, tmp_buf, sizeof (tmp_buf));
>         nb_total += nb_read;
>     }
>     g_print ("decode_to_stream_callback => number of bytes read from
> the TnyStream = %d\n", nb_total);
> 
>     return;
> }
> 
> Unfortunately, this does not seem to be quite right, as I always show
> that I
> have read 0 bytes - so, any hints on this issue?  Thanks again in
> advance for
> any help / assistance ...

	There are some options:
	* In the case of what you're trying: I think you need to reset the
stream position before beginning to output. If not, you'll get it in the
very last position written, and then, empty data.
	* You could read directly from the buffer of the stream you created
(i.e. creating the camel mem stream with a GByteArray).
	* Or you could create a new stream of the buffer of the camel mem
stream, and read from it.

-- 
José Dapena Paz <jdapena igalia com>
Igalia



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