Changeset 3171
- Timestamp:
- 12/21/07 13:23:41
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-bs-mime-part.c (modified) (13 diffs)
- trunk/libtinymail-camel/tny-camel-bs-mime-part.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-mime-part.c (modified) (11 diffs)
- trunk/libtinymail-camel/tny-camel-mime-part.h (modified) (1 diff)
- trunk/libtinymail-test/tny-mime-part-test.c (modified) (1 diff)
- trunk/libtinymail/tny-mime-part.c (modified) (4 diffs)
- trunk/libtinymail/tny-mime-part.h (modified) (3 diffs)
- trunk/libtinymailui-webkit/tny-webkit-html-mime-part-view.c (modified) (1 diff)
- trunk/libtinymailui/tny-mime-part-save-strategy.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r3170 r3171 1 2007-12-21 Felipe Erias Morandeira <femorandeira@igalia.com> 2 3 * libtinymail/tny-mime-part.[hc] : changed the signature of 4 tny_mime_part_write_to_stream and tny_mime_part_decode_to_stream to 5 return the number of bytes written and use a GError to notify problems. 6 * libtinymail-camel/tny-camel-mime-part.[hc] : adapted the functions that 7 implemented the previous two functions to comply with their new 8 signatures. 9 * libtinymail-camel/tny-camel-bs-mime-part.[hc] : adapted the functions 10 that implemented the previous two functions to comply with their 11 new signatures. 12 * libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c: 13 * libtinymailui-webkit/tny-webkit-html-mime-part-view.c: 14 * libtinymailui/tny-mime-part-save-strategy.c: 15 * libtinymail-test/tny-mime-part-test.c: 16 Small changes to use the new signatures of the two functions. 17 1 18 2007-12-21 Philip Van Hoof <pvanhoof@gnome.org> 2 19 trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-store.c
r2950 r3171 488 488 g_free(name); 489 489 camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, 490 _("Could not scan folder `%s' : %s"),491 root, g_strerror(errno));490 _("Could not scan folder `%s', opendir(`%s') failed: %s"), 491 root, name, g_strerror(errno)); 492 492 goto fail; 493 493 } trunk/libtinymail-camel/tny-camel-bs-mime-part.c
r3151 r3171 125 125 } 126 126 127 static void127 static gssize 128 128 bs_camel_stream_format_text (CamelStream *from_stream, CamelStream *stream, const gchar *charset, const gchar *encoding) 129 129 { … … 131 131 CamelMimeFilterCharset *filter; 132 132 CamelMimeFilterWindows *windows = NULL; 133 133 gssize bytes_written = -1; 134 134 135 if (g_ascii_strncasecmp (charset, "iso-8859-", 9) == 0) { 135 136 CamelStream *null; … … 162 163 } 163 164 164 decode_to_stream (from_stream, (CamelStream *)filter_stream, encoding, TRUE);165 bytes_written = (gssize) decode_to_stream (from_stream, (CamelStream *)filter_stream, encoding, TRUE); 165 166 camel_stream_flush ((CamelStream *)filter_stream); 166 167 camel_object_unref (filter_stream); … … 169 170 camel_object_unref(windows); 170 171 171 return ;172 } 173 174 static void172 return bytes_written; 173 } 174 175 static gssize 175 176 decode_from_stream_to (TnyMimePart *self, TnyStream *from_stream, TnyStream *stream, gboolean binary, gboolean decode_text) 176 177 { 178 gssize bytes_written = -1; 177 179 TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (self); 178 180 … … 190 192 charset = "UTF-8"; 191 193 192 b s_camel_stream_format_text (cfrom_stream, cto_stream, charset, encoding);194 bytes_written = (gssize) bs_camel_stream_format_text (cfrom_stream, cto_stream, charset, encoding); 193 195 194 196 camel_object_unref (cfrom_stream); … … 196 198 } else { 197 199 if (binary) 198 tny_stream_write_to_stream (from_stream, stream);200 bytes_written = tny_stream_write_to_stream (from_stream, stream); 199 201 else { 200 202 CamelStream *cfrom_stream = tny_stream_camel_new (from_stream); … … 202 204 gchar *encoding = priv->bodystructure->encoding; 203 205 204 decode_to_stream (cfrom_stream, cto_stream, encoding, FALSE);206 bytes_written = (gssize) decode_to_stream (cfrom_stream, cto_stream, encoding, FALSE); 205 207 206 208 camel_object_unref (cfrom_stream); … … 208 210 } 209 211 } 210 } 211 212 static void 212 return bytes_written; 213 } 214 215 static gssize 213 216 fetch_part (TnyMimePart *self, TnyStream *stream, gboolean decode_text) 214 217 { … … 217 220 gboolean binary = TRUE; 218 221 TnyStream *from_stream; 222 gssize return_value = 0; 219 223 220 224 /* binary = !camel_strcase_equal (priv->bodystructure->content.type, "TEXT"); */ … … 225 229 g_warning ("Error while fetching part: %s", err->message); 226 230 g_error_free (err); 231 return_value = -1; 227 232 } else if (from_stream) 228 decode_from_stream_to (self, from_stream, stream, binary, decode_text);233 return_value = decode_from_stream_to (self, from_stream, stream, binary, decode_text); 229 234 230 235 if (from_stream) … … 232 237 233 238 234 return ;239 return return_value; 235 240 } 236 241 … … 403 408 } 404 409 405 static void 406 tny_camel_bs_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream) 407 { 408 TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->write_to_stream_func (self, stream); 409 return; 410 } 411 412 static void 413 tny_camel_bs_mime_part_write_to_stream_default (TnyMimePart *self, TnyStream *stream) 414 { 415 fetch_part (self, stream, FALSE); 416 return; 410 static gssize 411 tny_camel_bs_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream, GError **err) 412 { 413 return TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->write_to_stream_func (self, stream, err); 414 } 415 416 static gssize 417 tny_camel_bs_mime_part_write_to_stream_default (TnyMimePart *self, TnyStream *stream, GError **err) 418 { 419 return fetch_part (self, stream, FALSE); 417 420 } 418 421 … … 620 623 621 624 622 static void 623 tny_camel_bs_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream) 624 { 625 TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->decode_to_stream_func (self, stream); 626 return; 627 } 628 629 static void 630 tny_camel_bs_mime_part_decode_to_stream_default (TnyMimePart *self, TnyStream *stream) 631 { 632 fetch_part (self, stream, TRUE); 633 return; 625 static gssize 626 tny_camel_bs_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream, GError **err) 627 { 628 return TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->decode_to_stream_func (self, stream, err); 629 } 630 631 static gssize 632 tny_camel_bs_mime_part_decode_to_stream_default (TnyMimePart *self, TnyStream *stream, GError **err) 633 { 634 return fetch_part (self, stream, TRUE); 634 635 } 635 636 trunk/libtinymail-camel/tny-camel-bs-mime-part.h
r3070 r3171 51 51 gboolean (*content_type_is_func) (TnyMimePart *self, const gchar *content_type); 52 52 TnyStream* (*get_stream_func) (TnyMimePart *self); 53 void (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream);54 void (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream);53 gssize (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 54 gssize (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 55 55 gint (*construct_from_stream_func) (TnyMimePart *self, TnyStream *stream, const gchar *type); 56 56 const gchar* (*get_filename_func) (TnyMimePart *self); trunk/libtinymail-camel/tny-camel-mime-part.c
r3151 r3171 27 27 28 28 #include <string.h> 29 #include <errno.h> 29 30 30 31 #include <tny-mime-part.h> … … 38 39 #include <tny-simple-list.h> 39 40 #include <tny-camel-msg.h> 41 #include <tny-error.h> 40 42 41 43 static GObjectClass *parent_class = NULL; … … 245 247 DecodeAsyncInfo *info = g_slice_new0 (DecodeAsyncInfo); 246 248 247 tny_mime_part_decode_to_stream (self, stream );249 tny_mime_part_decode_to_stream (self, stream, NULL); 248 250 249 251 info->self = g_object_ref (self); … … 538 540 } 539 541 540 static void 541 tny_camel_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream) 542 { 543 TNY_CAMEL_MIME_PART_GET_CLASS (self)->write_to_stream_func (self, stream); 544 return; 545 } 546 547 static void 548 tny_camel_mime_part_write_to_stream_default (TnyMimePart *self, TnyStream *stream) 542 static gssize 543 tny_camel_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream, GError **err) 544 { 545 return TNY_CAMEL_MIME_PART_GET_CLASS (self)->write_to_stream_func (self, stream, err); 546 } 547 548 static gssize 549 tny_camel_mime_part_write_to_stream_default (TnyMimePart *self, TnyStream *stream, GError **err) 549 550 { 550 551 TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self); … … 552 553 CamelMedium *medium; 553 554 CamelStream *cstream; 555 gssize bytes = -1; 554 556 555 557 g_assert (TNY_IS_STREAM (stream)); … … 568 570 "tny_mime_part_construct_from_stream first")); 569 571 camel_object_unref (cstream); 570 return; 572 g_set_error (err, TNY_FOLDER_ERROR, 573 TNY_ERROR_UNSPEC, 574 _("Mime part does not yet have a source stream, use " 575 "tny_mime_part_construct_from_stream first")); 576 return bytes; 571 577 } 572 578 … … 575 581 576 582 camel_stream_reset (wrapper->stream); 577 camel_stream_write_to_stream (wrapper->stream, cstream);583 bytes = (gssize) camel_stream_write_to_stream (wrapper->stream, cstream); 578 584 579 585 camel_object_unref (cstream); 580 586 camel_object_unref (medium); 581 587 582 return; 583 } 584 585 586 587 static void 588 if (bytes < 0) { 589 g_set_error (err, TNY_FOLDER_ERROR, 590 TNY_ERROR_UNSPEC, 591 strerror (errno)); 592 } 593 594 return bytes; 595 } 596 597 598 599 static ssize_t 588 600 camel_stream_format_text (CamelDataWrapper *dw, CamelStream *stream) 589 601 { … … 594 606 const char *charset = "UTF-8"; /* I default to UTF-8, like it or not */ 595 607 CamelMimeFilterWindows *windows = NULL; 608 ssize_t bytes = -1; 596 609 597 610 if (dw->mime_type && (charset = camel_content_type_param … … 624 637 } 625 638 626 camel_data_wrapper_decode_to_stream (dw, (CamelStream *)filter_stream);639 bytes = camel_data_wrapper_decode_to_stream (dw, (CamelStream *)filter_stream); 627 640 camel_stream_flush ((CamelStream *)filter_stream); 628 641 camel_object_unref (filter_stream); … … 631 644 camel_object_unref(windows); 632 645 633 return; 634 } 635 636 static void 637 tny_camel_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream) 638 { 639 TNY_CAMEL_MIME_PART_GET_CLASS (self)->decode_to_stream_func (self, stream); 640 return; 641 } 642 643 static void 644 tny_camel_mime_part_decode_to_stream_default (TnyMimePart *self, TnyStream *stream) 646 return bytes; 647 } 648 649 static gssize 650 tny_camel_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream, GError **err) 651 { 652 return TNY_CAMEL_MIME_PART_GET_CLASS (self)->decode_to_stream_func (self, stream, err); 653 } 654 655 static gssize 656 tny_camel_mime_part_decode_to_stream_default (TnyMimePart *self, TnyStream *stream, GError **err) 645 657 { 646 658 … … 668 680 } 669 681 682 gssize bytes = -1; 683 670 684 if (camel_content_type_is (wrapper->mime_type, "text", "*")) 671 camel_stream_format_text (wrapper, cstream);685 bytes = (gssize) camel_stream_format_text (wrapper, cstream); 672 686 else 673 camel_data_wrapper_decode_to_stream (wrapper, cstream);687 bytes = (gssize) camel_data_wrapper_decode_to_stream (wrapper, cstream); 674 688 675 689 camel_object_unref (cstream); 676 690 camel_object_unref (medium); 677 678 return; 691 692 if (bytes < 0) { 693 g_set_error (err, TNY_FOLDER_ERROR, 694 TNY_ERROR_UNSPEC, 695 strerror (errno)); 696 } 697 698 return bytes; 679 699 } 680 700 trunk/libtinymail-camel/tny-camel-mime-part.h
r3070 r3171 53 53 gboolean (*content_type_is_func) (TnyMimePart *self, const gchar *content_type); 54 54 TnyStream* (*get_stream_func) (TnyMimePart *self); 55 void (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream);56 void (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream);55 gssize (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 56 gssize (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 57 57 gint (*construct_from_stream_func) (TnyMimePart *self, TnyStream *stream, const gchar *type); 58 58 const gchar* (*get_filename_func) (TnyMimePart *self); trunk/libtinymail-test/tny-mime-part-test.c
r1339 r3171 133 133 134 134 tny_mime_part_construct_from_stream (iface, from, "text/plain"); 135 tny_mime_part_write_to_stream (iface, to );135 tny_mime_part_write_to_stream (iface, to, NULL); 136 136 137 137 while (!tny_stream_is_eos (to) && n < 1) trunk/libtinymail/tny-mime-part.c
r3161 r3171 619 619 * </programlisting></informalexample> 620 620 * 621 * since: 1.0 622 * audience: application-developer 623 **/ 624 void 625 tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream) 621 * returns: Returns %-1 on error, or the number of bytes succesfully copied. 622 * since: 1.0 623 * audience: application-developer 624 **/ 625 gssize 626 tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream, GError **err) 626 627 { 627 628 #ifdef DBC /* require */ … … 632 633 #endif 633 634 634 TNY_MIME_PART_GET_IFACE (self)->write_to_stream_func (self, stream); 635 return; 635 return TNY_MIME_PART_GET_IFACE (self)->write_to_stream_func (self, stream, err); 636 636 } 637 637 … … 675 675 * </programlisting></informalexample> 676 676 * 677 * since: 1.0 678 * audience: application-developer 679 **/ 680 void 681 tny_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream) 677 * returns: Returns %-1 on error, or the number of bytes succesfully copied. 678 * since: 1.0 679 * audience: application-developer 680 **/ 681 gssize 682 tny_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream, GError **err) 682 683 { 683 684 #ifdef DBC /* require */ … … 688 689 #endif 689 690 690 TNY_MIME_PART_GET_IFACE (self)->decode_to_stream_func (self, stream); 691 return; 691 return TNY_MIME_PART_GET_IFACE (self)->decode_to_stream_func (self, stream, err); 692 692 } 693 693 trunk/libtinymail/tny-mime-part.h
r3070 r3171 47 47 gboolean (*content_type_is_func) (TnyMimePart *self, const gchar *content_type); 48 48 TnyStream* (*get_stream_func) (TnyMimePart *self); 49 void (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream);50 void (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream);49 gssize (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 50 gssize (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 51 51 gint (*construct_from_stream_func) (TnyMimePart *self, TnyStream *stream, const gchar *type); 52 52 const gchar* (*get_filename_func) (TnyMimePart *self); … … 76 76 gboolean tny_mime_part_content_type_is (TnyMimePart *self, const gchar *type); 77 77 TnyStream* tny_mime_part_get_stream (TnyMimePart *self); 78 void tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream);78 gssize tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream, GError **err); 79 79 gint tny_mime_part_construct_from_stream (TnyMimePart *self, TnyStream *stream, const gchar *type); 80 80 const gchar* tny_mime_part_get_filename (TnyMimePart *self); … … 90 90 void tny_mime_part_set_purged (TnyMimePart *self); 91 91 gboolean tny_mime_part_is_attachment (TnyMimePart *self); 92 void tny_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream);92 gssize tny_mime_part_decode_to_stream (TnyMimePart *self, TnyStream *stream, GError **err); 93 93 void tny_mime_part_get_parts (TnyMimePart *self, TnyList *list); 94 94 gint tny_mime_part_add_part (TnyMimePart *self, TnyMimePart *part); trunk/libtinymailui-webkit/tny-webkit-html-mime-part-view.c
r2825 r3171 89 89 dest = tny_webkit_stream_new (GTK_WEBKIT (self)); 90 90 tny_stream_reset (dest); 91 tny_mime_part_decode_to_stream (part, dest );91 tny_mime_part_decode_to_stream (part, dest, NULL); 92 92 g_object_unref (G_OBJECT (dest)); 93 93 trunk/libtinymailui/tny-mime-part-save-strategy.c
r3151 r3171 79 79 * if (fd != -1) { 80 80 * TnyStream *stream = tny_fs_stream_new (fd); 81 * tny_mime_part_decode_to_stream (part, stream );81 * tny_mime_part_decode_to_stream (part, stream, NULL); 82 82 * g_object_unref (stream); 83 83 * }
