Re: About tny-mime-part-write-to-stream
- From: Felipe Erias Morandeira <femorandeira igalia com>
- To: tinymail-devel-list gnome org
- Subject: Re: About tny-mime-part-write-to-stream
- Date: Thu, 20 Dec 2007 10:30:56 +0100
Hi,
the attached patch adds a return value to the functions
tny_mime_part_write_to_stream and tny_mime_part_decode_to_stream, so
they return -1 if there was an error, or the number of bytes transferred
otherwise. The implementation use the output of the underlying functions
(i.e. camel_data_wrapper_decode_to_stream) to get that value.
Cheers,
Felipe
O Mar, 18-12-2007 ás 19:32 +0100, Felipe Erias Morandeira escribiu:
> Hi all,
>
> as you know, the sintaxis of tny_mime_part_write_to_stream is the
> following:
>
>
> void
> tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream)
>
>
> Since this function deals with data I/O, I think that it would be good
> to add a return value or a GError parameter, so we can get notified in
> case there is some error and inform the user.
>
> What are your thoughts about it?
>
>
> Cheers,
>
> Felipe
>
> _______________________________________________
> tinymail-devel-list mailing list
> tinymail-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/tinymail-devel-list
Index: tinymail/libtinymail-camel/tny-camel-mime-part.c
===================================================================
--- tinymail/libtinymail-camel/tny-camel-mime-part.c (revision 3164)
+++ tinymail/libtinymail-camel/tny-camel-mime-part.c (working copy)
@@ -537,14 +537,13 @@
return FALSE;
}
-static void
+static gssize
tny_camel_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream)
{
- TNY_CAMEL_MIME_PART_GET_CLASS (self)->write_to_stream_func (self, stream);
- return;
+ return TNY_CAMEL_MIME_PART_GET_CLASS (self)->write_to_stream_func (self, stream);;
}
-static void
+static gssize
tny_camel_mime_part_write_to_stream_default (TnyMimePart *self, TnyStream *stream)
{
TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self);
@@ -574,17 +573,17 @@
camel_data_wrapper_write_to_stream (wrapper, cstream); */
camel_stream_reset (wrapper->stream);
- camel_stream_write_to_stream (wrapper->stream, cstream);
+ gssize bytes = (gssize) camel_stream_write_to_stream (wrapper->stream, cstream);
camel_object_unref (cstream);
camel_object_unref (medium);
- return;
+ return bytes;
}
-static void
+static ssize_t
camel_stream_format_text (CamelDataWrapper *dw, CamelStream *stream)
{
/* Stolen from evolution, evil evil me!! moehahah */
@@ -623,14 +622,15 @@
camel_object_unref (filter);
}
- camel_data_wrapper_decode_to_stream (dw, (CamelStream *)filter_stream);
+ ssize_t bytes =
+ camel_data_wrapper_decode_to_stream (dw, (CamelStream *)filter_stream);
camel_stream_flush ((CamelStream *)filter_stream);
camel_object_unref (filter_stream);
if (windows)
camel_object_unref(windows);
- return;
+ return bytes;
}
static void
@@ -667,15 +667,17 @@
return;
}
+ gssize bytes = -1;
+
if (camel_content_type_is (wrapper->mime_type, "text", "*"))
- camel_stream_format_text (wrapper, cstream);
+ bytes = (gssize) camel_stream_format_text (wrapper, cstream);
else
- camel_data_wrapper_decode_to_stream (wrapper, cstream);
+ bytes = (gssize) camel_data_wrapper_decode_to_stream (wrapper, cstream);
camel_object_unref (cstream);
camel_object_unref (medium);
- return;
+ return bytes;
}
static gint
Index: tinymail/libtinymail/tny-mime-part.c
===================================================================
--- tinymail/libtinymail/tny-mime-part.c (revision 3164)
+++ tinymail/libtinymail/tny-mime-part.c (working copy)
@@ -618,10 +618,12 @@
* }
* </programlisting></informalexample>
*
+ * returns (null-ok): Returns %-1 on error, or the number of bytes succesfully
+ * copied across streams.
* since: 1.0
* audience: application-developer
**/
-void
+gssize
tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream)
{
#ifdef DBC /* require */
@@ -674,10 +676,12 @@
* }
* </programlisting></informalexample>
*
+ * returns (null-ok): Returns %-1 on error, or the number of bytes succesfully
+ * copied across streams.
* since: 1.0
* audience: application-developer
**/
-void
+gssize
tny_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream)
{
#ifdef DBC /* require */
Index: tinymail/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c
===================================================================
--- tinymail/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c (revision 3164)
+++ tinymail/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c (working copy)
@@ -487,8 +487,8 @@
if (dir == NULL) {
g_free(name);
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Could not scan folder `%s': %s"),
- root, g_strerror(errno));
+ _("Could not scan folder `%s', opendir(`%s') failed: %s"),
+ root, name, g_strerror(errno));
goto fail;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]