aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream-filter.c
Commit message (Collapse)AuthorAgeFilesLines
* Protect against either of the types being NULL.Jeffrey Stedfast2001-12-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2001-12-04 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.c (header_content_type_simple): Protect against either of the types being NULL. 2001-12-05 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-filter-basic.c (filter): If complete() allocates len+2 bytes for the out buffer, so should this. See bug #16371 for an example case. 2001-12-05 Jeffrey Stedfast <fejj@ximian.com> * camel-sasl-digest-md5.c: iconv() returns a size_t, not an int. * camel-pgp-context.c: The return value of iconv() is a size_t, not an int. * camel-mime-part-utils.c (convert_buffer): Always use size_t args for iconv(). * camel-mime-filter-charset.c (complete): Always use size_t args for iconv(). (filter): Same. * camel-mime-utils.c (header_address_fold): Make headerlen a size_t instead of an int. (header_fold): Same. (base64_encode_close): We should be returning a size_t and inlen should also be a size_t. (base64_encode_step): Same here. (base64_decode_step): Here too. (base64_encode_simple): And here... (base64_decode_simple): Same. (uuencode_close): We should also use size_t's here... (uuencode_step): And here too. (uudecode_step): And also here. (quoted_encode_close): Same idea here. (quoted_encode_step): Again here. (quoted_decode_step): Here too. (quoted_encode): Input length should be a size_t. (rfc2047_decode_word): Same. (g_string_append_len): Here too. (append_8bit): " (rfc2047_encode_word): " (quote_word): " (hex_decode): " (rfc2184_decode): Use size_t's with iconv(). (header_decode_param): Same. svn path=/trunk/; revision=14956
* More fixing of the license texts.Ettore Perazzoli2001-10-281-11/+11
| | | | svn path=/trunk/; revision=14217
* Update the copyrights, replacing Helix Code with Ximian andEttore Perazzoli2001-06-231-2/+2
| | | | | | helixcode.com with ximian.com all over the place. svn path=/trunk/; revision=10440
* Big header cleanups and nntp compile fixKjartan Maraas2001-03-301-0/+1
| | | | svn path=/trunk/; revision=9024
* Revert jeff's earlier change, the change below is the more-correct fix.Not Zed2001-02-051-8/+4
| | | | | | | | | | | | | | 2001-02-05 Not Zed <NotZed@Ximian.com> * camel-stream-filter.c (do_write): Revert jeff's earlier change, the change below is the more-correct fix. All his was doing was ignoring the return code & looping actually :) * camel-stream-fs.c (stream_write): Since we are non-blocking on the outgoing fd, keep looping if writing out large blocks, so we can keep checking for cancel, etc. svn path=/trunk/; revision=7966
* Make do_write loop until the entire buffer is written.Jeffrey Stedfast2001-02-051-4/+8
| | | | | | | | | 2001-02-04 Jeffrey Stedfast <fejj@ximian.com> * camel-stream-filter.c (do_write): Make do_write loop until the entire buffer is written. svn path=/trunk/; revision=7963
* Keep track of the caller bestenc flags that make sense.Not Zed2000-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-11-08 Not Zed <NotZed@HelixCode.com> * camel-mime-message.c (find_best_encoding): Keep track of the caller bestenc flags that make sense. * camel-mime-filter-bestenc.c (filter): Added code to detect when we have "^From " lines in the sequence of text. (camel_mime_filter_bestenc_get_best_encoding): Added a new flag CAMEL_BESTENC_NO_FROM: if set, it will not allow any lines matching "^From " to appear in the output - currently forcing base64 encoding to achieve this. * camel-mime-parser.c (folder_scan_step): Call camel_mime-filter_complete() once we're done, rather than filter_filter(). (folder_scan_content): Some fixes for state changing; so that when we do find another boundary it is properly flagged. Since we strip the last \n off all data, we must take that into account too. Sigh. Fixes a rather nasty set of bugs where multipart messages could start including following messages as parts, etc. (struct _header_scan_stack): Added new parameter, boundarylenfinal, which holds the length of the final boundary, if it is different (e.g. for From lines, whihc aren't) (folder_scan_step): Setup teh boundarylenfinal value when creating a new boundary. (folder_scan_content): Hmm, if we hit the end-of-buffer sentinal, reset the scanner back to leave 'atleast' chars in the buffer still, dump that content, and retry again. Stops us losing a check for a boundary on some data we haven't really looked at yet! (folder_scan_content): Use boundarylenfinal to calculate 'atleast'. (folder_scan_header): And here too. (folder_boundary_check): Use the atleast value directly, dont truncate it. Use the boundarylen/boundarylenfinal values directly too. (struct _header_scan_stack): Add an atleast parameter to cache the atleast info. (folder_push_part): Determine/set 'atleast', every time we add a new part. (folder_scan_header): Get the cached atleast info from the current part. (folder_scan_content): And here too. (folder_scan_header): Fix a problem where a part starting with " text" would be interpreted as a followon header wrongly. * camel-mime-filter-charset.c (complete): Add some assertions to find a bug. svn path=/trunk/; revision=6500
* Kill debugging, as it causes lots of evolution-mail spewage.Dan Winship2000-11-081-1/+1
| | | | | | | * camel-stream-filter.c (d): Kill debugging, as it causes lots of evolution-mail spewage. svn path=/trunk/; revision=6482
* Implement a complete() function, now we need one. (filter): Upgraded toNot Zed2000-11-071-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-11-07 Not Zed <NotZed@HelixCode.com> * camel-mime-filter-bestenc.c (complete): Implement a complete() function, now we need one. (filter): Upgraded to match rfrc2045 properly. Checks also for length of line and valid CRLF sequences. (camel_mime_filter_bestenc_get_best_encoding): Do the work of working out what is the best encoding given what we found about the stream. * camel-mime-part.c (camel_mime_part_encoding_to_string): Use a lookup table to get the encoding naem, and add the binary type. (camel_mime_part_encoding_from_string): Likewise for the reverse. * camel-mime-part.h: Added the binary encoding type, see rfc2045. * camel-mime-utils.c (header_param_list_format_append): Dont put a space before ;'s in parameter lists, makes them more readable/consistent. * camel-mime-message.c (multipart_has_8bit_parts): Cleaned up the old stuff, well removed it. (camel_mime_message_set_best_encoding): Added another argument that lets you select what you want to set the best of. i.e. for smtp transport we only need 7 bit, and dont need to optimise the charset (although of course, we should always). (find_best_encoding): Implement this feature, if we are not getting the best charset, use the one we have. (best_encoding): Set the charset on the part appropriately. Sigh, the interfaces for this are nonexistant. (find_best_encoding): Tell the bestenc filter that lf should be treated as crlf for the purposes of determining encodings. 2000-11-06 Not Zed <NotZed@HelixCode.com> * camel-charset-map.c (camel_charset_init): Init function for an iterative charset determinator. (camel_charset_step): Iterate another buffer. (camel_charset_mask): Removed, since it couldn't have worked. (camel_charset_best): Use the iterative interface to do the work. (camel_charset_best_name): Get the best name for a charset so far. * camel-mime-filter-bestenc.c: New class, a stream filter that can be used to memory-efficiently determine the best encoding and/or charset to use for a given stream of bytes. * Makefile.am (libcamelinclude_HEADERS): Added stream-null*. (libcamel_la_SOURCES): Added bestenc* * camel-stream-null.c: New class, a null-stream, that always succeeds, and never has any contents. * camel-stream.c: Minor pointless changes. Was going to do something else but changed my mind. Added trivial default implementations for all callbacks. * camel-mime-message.h: Cleaned up some old cruft. * camel-folder-summary.c (camel_folder_summary_format_address): address_list_format() no longer encodes, so we dont need to decode it. * camel-address.c (camel_address_unformat): New function, attempts to reverse the formatting process on display addresses. (camel_address_length): New function to get the number of addresses, without having to peek the structure. * camel-mime-message.c (camel_mime_message_set_from): Fix a typo. (camel_mime_message_finalize): Only unref from/reply_to if we have it. (camel_mime_message_set_recipients): New function - set the recipients as a CamelInternetAddress. This function effectively deprecates the older recipient setting functions. (camel_mime_message_add_recipient): What the hell, i'll bite the bullet. Terminate this function. The old api was ambiguious and inefficient and didn't work right anyway. (camel_mime_message_remove_recipient_address): And this one. (camel_mime_message_remove_recipient_name): And this one too. (camel_mime_message_set_recipients): If we set an empty header, then remove it from the header list. Allow a null receipient object to clear a header. (camel_mime_message_set_from): Likewise, if setting an empty from address. (camel_mime_message_encode_8bit_parts): Eeek!! camel_stream_mem_new_with_byte_array owns the byte_array we give it, so make sure we dont free any of it! (camel_mime_message_encode_8bit_parts): Infact, i'll just rewrite the whole lot, its a bit of a mess. Should really rename it and make it a little more useful too, lets see ... (best_encoding): This has a string interface? Oh boy. (camel_mime_message_foreach_part): New experimental function to iterate over all message parts. Might not remain. (camel_mime_message_has_8bit_parts): New implementation using foreach_part. Fixed a couple of problems. (find_best_encoding): New function, that finds the best encoding for a given part (will probably be moved to camel-mime-part), and also the best charset to use if it is a text part. Since one affects the other it is a two pass process, but uses streams and not memory to achieve this. (camel_mime_message_set_best_encoding): Uses the function above to configure an entire message for the best encoding possible given transport constraints. (camel_mime_message_encode_8bit_parts): Reimplemented to use the function above to perform the work. * camel-internet-address.c (camel_internet_address_format_address): Dont put <> around a lone address with no real name. (camel_internet_address_encode_address): Similarly. (internet_decode): Actually return the count of decoded addresses. (internet_unformat): Implement the unformatting routine. 2000-11-05 Not Zed <NotZed@HelixCode.com> * providers/smtp/camel-smtp-transport.c (_send_to): Changed to get the internetaddress directly, rather than having to parse it itself. * camel-address.c (camel_address_format): Added a new function which will format address, suitable for display. (camel_address_cat): Concatentate 1 camel address onto another. It is upto the caller to ensure the addresses are of compatible types. (camel_address_new_clone): New function to create a new address by copying an existing one of the same type. (camel_address_copy): New helper function to copy an address. * camel-mime-message.h (struct _CamelMimeMessage): Removed cached copy of date string. (struct _CamelMimeMessage): Added date_received info. * camel-mime-message.c (camel_mime_message_get_date_string): Removed. Nothing uses it anyway, and it is redundant. (camel_mime_message_finalize): No more date_str. (camel_mime_message_init): No more date_str, initialise date_received* (write_to_stream): Change the check for a date header. (process_header): No longer track the date_str. (camel_mime_message_get_received_date): Removed. totally invalid anyway. (camel_mime_message_get_sent_date): Removed. Redundant. The only 'date' is the sent date, the received date is just made up. (camel_mime_message_get_date): Args changed to be more consistent with utility functions. (camel_mime_message_get_date): Dont set the date when we're asked for it (if its not set by the time its written, it'll be set then). (camel_mime_message_get_date_received): Actually do 'the right thing' here, if we have a received header, use that to determine the received date. And return the data in the same format as get_date. (camel_mime_message_set_from): Changed the api to better match what we should be doing. Pass a camelinternetaddress, etc. (camel_mime_message_set_reply_to): Cahnged similarly to take an internetaddress. (camel_mime_message_get_reply_to): Likewise. (camel_mime_message_finalize): Unref the from/reply_to objects. (format_address): Removed, no longer needed. (process_header): Changed to store the from/reply_to as internetaddress's. (write_to_stream): Set the from header directly to empty, if we dont have one. Maybe we should just abort, and/or create one based on the current user. * camel-mime-utils.c (header_address_list_format): Renamed to header_address_list_encode, which is what it is actually doing. (header_address_list_format_append): Similarly. (encoding_map[]): Removed, no longer used. (header_address_list_encode_append): Take another arg, do we encode the address (for internet), or not (for display - utf8 only). (header_address_list_format): Re-added this function, but now it generates a display version only. Surprise surprise, that is all anythign needs to generate anyway. Sigh. * camel-internet-address.c (camel_internet_address_get): Return false if we get an invalid index only. (camel_internet_address_encode_address): Helper function to encode a single address for mailing. (internet_encode): Use the above function to format it. (camel_internet_address_format_address): Format a single address for display. (internet_format): Implement the display version. (camel_internet_address_class_init): Init the internet_format virtual function. (internet_cat): Implement virtual function to concatenate addresses. * camel-folder-summary.c (camel_folder_summary_info_new_from_header): new function, only build the summary info, dont add it. (camel_folder_summary_info_new_from_parser): Likewise, for new info from parser. (camel_folder_summary_add_from_parser): Cahnged to call function above to build info. (camel_folder_summary_add_from_header): Changed to call function above, to build info. (camel_folder_summary_info_free): New function to free the summary message info. (camel_folder_summary_clear): Changed to clal above to free info. (camel_folder_summary_remove): Likewise. (camel_folder_summary_add): Cleaned up the clashing uid re-assignment logic a little bit. (camel_folder_summary_decode_uint32): Fixed a typo, 01 != -1. (camel_folder_summary_decode_time_t): Return -1 on error. (camel_folder_summary_encode_off_t): New function to encode an off_t type. (camel_folder_summary_decode_off_t): And likewise for the reverse. (CAMEL_FOLDER_SUMMARY_VERSION): Bumped the summary version, since we're now encoding time/off_t's right. (summary_header_save): Use time_t encoder to save the timestamp. (summary_header_load): Likewise for decoding the timestamp. (content_info_load): Decode off_t types directly, now we can. (content_info_save): And likewise for encoding. (camel_folder_summary_add_from_message): New function, create a summary item from an existing message and add it. (camel_folder_summary_info_new_from_message): New function, create a summary item from an existing message. (summary_build_content_info_message): New function to do the dirty work of building the conent info/indexing, from a message source. (format_recipients): Format an internetaddress suitable for the summary. (message_info_new_from_message): Build a new summary item from a mime message. (content_info_new_from_message): Build a new conent info from a mime part. (camel_folder_summary_class_init): Init the new class functions. (message_info_new_from_message): Fixed for message api change. Added documentation to the functions. svn path=/trunk/; revision=6474
* Set the preface/postface from the parser into the multipart object.Not Zed2000-11-041-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-11-04 Not Zed <NotZed@HelixCode.com> * camel-mime-part-utils.c (camel_mime_part_construct_content_from_parser): Set the preface/postface from the parser into the multipart object. * camel-multipart.c (camel_multipart_set_postface): Function to set the postface text on a multipart. (camel_multipart_set_preface): Similarly for preface text. * camel-mime-parser.c (folder_scan_content): If we scan until a boundary, then we do not include the \n that starts the boundary line in the content. (struct _header_scan_stack): Added a ByteArray to store the multipart pre/post-text as we're scanning. (folder_pull_part): Free pre/posttext if they are allocated. (folder_scan_step): Build into the pre/posttext arrays as we encounter data. (camel_mime_parser_preface): REturn the multipart preface text, if there is any scanned. (camel_mime_parser_postface): Likewise for postface text. (byte_array_to_string): helper function for above. * providers/mbox/camel-mbox-folder.c (mbox_append_message): Change the from line to be "\nFrom ..." always, so no need to check/append a \n to messages. (mbox_append_message): Open the output stream with append mode [assuming this is more efficient than seeking to the end] And dont prepend \n on the From line if its the first in the mbox. (mbox_append_message): Pass the offset of the real start of the "From " line when we perform the update (which may != 'seek') * camel-mime-filter-charset.c (complete): Removed the terminating NUL 'fix'. * camel-stream-filter.c (do_read): Added some debug. (do_flush): And here. (do_write): And here too. (do_write): ARGH!!! ARGH! Ok, so the filter stream was writing a different number of bytes than the requester was asking it to write (because of filtering, of course!). So instead of returning the true number of written bytes, we'll return what they asked us to write - unless there is an error in which case we return -1. * camel-mime-utils.c (base64_encode_close): Sigh, forgot to make it unsigned. I think this is actually a gcc bug as (48 >> 2) somehow ended up negative, when it obviously should not, even if the data load was signed. svn path=/trunk/; revision=6388
* Merge with camel-async.Peter Williams2000-08-111-58/+43
| | | | svn path=/trunk/; revision=4687
* flush the filter stream before unreffing it, so it willDan Winship2000-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | * camel-mime-part.c (write_to_stream): flush the filter stream before unreffing it, so it will camel_mime_filter_complete. * camel-stream-filter.c (camel_stream_filter_class_init): Fix a braino so camel_stream_flush works here. * camel-stream-mem.c (stream_seek): Fix a bug that resulted in large attachments being silently dropped. * providers/pop3/camel-pop3-store.c (camel_pop3_command_get_additional_data): Don't use g_strjoinv here, since it is O(n^2) on the length of the output string, and we can do O(n). * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): add a CRLF decoder after the QP/B64 decoder if it's text. svn path=/trunk/; revision=3658
* Changed the read and write method prototypes to return an ssize_t typeJeffrey Stedfast2000-06-071-13/+15
| | | | | | | | | | | | | | | | | | | 2000-06-06 Jeffrey Stedfast <fejj@helixcode.com> * camel-stream.[c,h]: Changed the read and write method prototypes to return an ssize_t type rather than an int and also changed the 'number of bytes' to read or write to a size_t type * camel-stream-fs.c: same as above * camel-stream-mem.c: again, same as above * camel-stream-buffer.c: same * camel-imap-stream.[c,h]: Added this new stream, cache's previously read data so each successive call will instead read from the cache svn path=/trunk/; revision=3450
* > searchpart = strchr(namepart, '?');NotZed2000-05-201-20/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-05-19 NotZed <NotZed@HelixCode.com> * camel-simple-data-wrapper.c (construct_from_stream): If we already have been constructed, unref our content. (write_to_stream): Check we've been constructued, and change for stream api changes. * camel-mime-parser.c: Removed exception stuff. * md5-utils.c (md5_get_digest_from_stream): repaired. * camel-mime-message.c: Remove exception from write_to_stream, and fix, and fix formatting. * providers/sendmail/camel-sendmail-transport.c (_send_internal): Fix for stream changes. * providers/pop3/camel-pop3-store.c (camel_pop3_command): Fixes for stream changes. * providers/mbox/camel-mbox-folder.c, and elsewhere, fix all stream api changes. (mbox_append_message): Use stream_close() now its back. (mbox_append_message): unref the from filter. * camel-stream-mem.c: And here. * camel-stream-fs.[ch]: Here too. * camel-stream-filter.c: Likewise. This is getting tedious. * camel-stream-buffer.c (stream_write): Fix a few little problems. (stream_close): Reimplmeent. (camel_stream_buffer_read_line): Slightly more efficient version, that also only allocates the right amount of memory for strings. * camel-seekable-substream.c: Likewise. * camel-seekable-stream.[ch]: Remove exceptions, fix formatting, changes for stream (re)fixes. set_bounds returns an error. * camel-stream.[ch]: Remove exceptions. Make flush and reset return an error code, repair all the screwed up formatting, and put back close. * camel-mime-part-utils.c (camel_mime_part_construct_content_from_parser): And here. * camel-mime-part.c (camel_mime_part_set_content): And this too. (write_to_stream): Fixed for stream changes. * camel.h: Fixed. * providers/vee/camel-vee-folder.c (vee_search_by_expression): Implement. Performs an intersection of the two searches. (camel_vee_folder_finalise): Unref search folders. (vee_append_message): Implement append. svn path=/trunk/; revision=3142
* Use CamelException to signal failure. (camel_stream_write_strings):Dan Winship2000-05-091-30/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * camel-stream.c (camel_stream_read, camel_stream_write, camel_stream_flush, camel_stream_reset, camel_stream_printf, camel_stream_write_to_stream): Use CamelException to signal failure. (camel_stream_write_strings): Remove. camel_stream_printf is more useful in most of the places that used this. (camel_stream_write_string): Change from macro to function to prevent problems with double-evaluation. * camel-seekable-stream.c (camel_seekable_stream_seek, camel_seekable_stream_set_bounds): Use CamelException. (reset): Update. * camel-seekable-substream.c, camel-stream-buffer.c, camel-stream-filter.c, camel-stream-fs.c, camel-stream-mem.c: Update. * camel-stream-fs.c: Remove the virtual init functions and move the code into the creator functions. Add CamelExceptions to creation functions that could fail. * camel-data-wrapper.c (camel_data_wrapper_write_to_stream): Use CamelException. * camel-mime-message.c, camel-mime-part.c, camel-multipart.c (write_to_stream): Update. * camel-mime-parser.c: add an exception to the mime parser private data and pass that to stream functions as needed. * gmime-content-field.c, md5-utils.c: Update (badly) for stream changes. * camel-exception.h (camel_exception_is_set): convenience macro. * providers/Makefile.am: disable SMTP for now * providers/mbox/camel-mbox-folder.c (mbox_append_message): Pass CamelException to the functions that now need it. Check the exception after calling camel_stream_flush, and fail if it fails. (mbox_get_message_by_uid): More updates. * providers/pop/camel-pop3-folder.c, providers/pop/camel-pop3-store.c, providers/sendmail/camel-sendmail/transport.c: Update. svn path=/trunk/; revision=2924
* blahMichael Zucci2000-05-081-1/+1
| | | | svn path=/trunk/; revision=2907
* Merged NEW_SUMMARY branch back to trunk, and resolved conflicts.NotZed2000-05-081-5/+59
| | | | | | | | | | | | | 2000-05-08 NotZed <NotZed@HelixCode.com> * Merged NEW_SUMMARY branch back to trunk, and resolved conflicts. * providers/mbox/camel-mbox-summary.c (camel_mbox_summary_update): Return status. * camel-stream-filter.c (do_close): We NEED a stream close. svn path=/trunk/; revision=2906
* Make camel not leak like a sieve.Dan Winship2000-05-081-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * camel-object.c: New subclass of GtkObject which is now the base of the Camel object hierarchy. Currently the only difference between CamelObject and GtkObject is that CamelObjects don't start out floating. * *.h: Move a bunch of typedefs to camel-types.h. Standardize on using <camel/foo.h> in header files rather than <foo.h>, "foo.h", or "camel/foo.h". Remove some unneeded includes. * camel-address.c, camel-data-wrapper.c, camel-folder-search.c, camel-folder-summary.c, camel-folder.c, camel-mime-filter.c, camel-mime-parser.c, camel-service.c, camel-session.c, camel-stream.c: These are now subclasses of CamelObject. * camel-data-wrapper.c (set_output_stream): * camel-medium.c (set_content_object): * camel-seekable-substream.c (init_with_seekable_stream_and_bounds): * providers/mbox/camel-mbox-folder.c (mbox_get_message_by_uid): remove gtk_object_sink calls. * camel-stream-buffer.c (init_vbuf): * camel-stream-filter.c (camel_stream_filter_new_with_stream): ref the original stream. * camel-folder-summary.c (camel_folder_summary_finalise): unref the filters when finalizing. * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser, camel_mime_part_construct_content_from_parser): * camel-mime-part.c (camel_mime_part_set_content): Unref objects that are created only to be handed off to other objects. If they're going to be needed later, they will have been additionally ref'ed by the object that needs them. * providers/pop3/camel-pop3-folder.c (get_message_by_number): unref the message stream after creating the data from it. * camel-stream.c, camel-stream-buffer.c, camel-stream-filter.c, camel-stream-fs.c, camel-stream-mem.c: Remove camel_stream_close, since its semantics are dubious (what happens when you close a stream other people still have references on?). * providers/nntp/camel-nntp-store.c: * providers/smtp/camel-smtp-transport.c: * providers/pop3/camel-pop3-store.c: replace camel_stream_close calls with gtk_object_unref. * providers/mbox/camel-mbox-folder.c: * providers/nntp/camel-nntp-folder.c: * providers/sendmail/camel-sendmail-transport.c: replace camel_stream_close with camel_stream_flush + gtk_object_unref svn path=/trunk/; revision=2882
* Big cleanup of camel-stream-*, got rid of 3 classes, improved the interfaces,NotZed2000-04-261-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and fixed at least one problem (end of stream never happening in certain cases). Things that can fail now have a way of saying they failed too. So much for taking ANZAC day off to get drunk! 2000-04-26 NotZed <NotZed@HelixCode.com> * camel-seekable-substream.c (stream_seek): Changed to have absolute seek semantics, not relative to the bounds. * camel-seekable-stream.c (reset): When we reset, seek to the start of the bound, if there is one. (stream_tell): Make tell virtual. * camel-stream-filter.c (do_available): Removed. * camel-stream-buffer.c: Remove leading _'s from static functions. (stream_read): Renamed from read(). Fancy that conflicting! (my boo!) Others too. * providers/pop3/camel-pop3-folder.c (get_message_by_number): Changed to stream_mem interface. * providers/mbox/camel-mbox-folder.c (_get_message_by_uid): Fixed for streamfs interface changes, and implement a failure case. (_append_message): Changed for fs stream interface change. * camel-multipart.c (print_part): Iterate rahter than callback. I hate glists's interface (hence, move this to write_to_stream). (write_to_stream): Return an error (yuck, this is a royal PITA to do with the stream write interface). * camel-mime-message.c: Removed leading _ from static names. * camel-mime-part.h: construct_from_parser() now returns an error code. * camel-mime-part-utils.c (camel_mime_part_construct_content_from_parser): Changed to use a camel-data-wrapper instead of a camel-simple-data-wrapper (no change needed elsewhere?). (simple_data_wrapper_construct_from_parser): Fixes for stream-mem interface changes. * camel-simple-data-wrapper.[ch], camel-simple-data-wrapper-stream.[ch], camel-stream-data-wrapper.[ch], removed. Fixed including of these files. * camel-mime-part.c (camel_mime_part_set_text): Remove the use of the camel-simple-data-wrapper-stream, just use a mem stream. (write_to_stream): Renamed from my_* (construct_from_stream): Return an error on error. * camel-stream-mem.c (camel_stream_mem_new*): Remove mode parameter. * camel-stream-mem.h (enum CamelStreamMemMode): Removed. It wasn't used at all. * camel-data-wrapper.h: Add camel_data_wrapper_new() to create these. (write_to_stream, construct_from_stream): Return an error indicator for success. Fixed all methods to match (ICK). * Makefile.am (libcamel_la_SOURCES): Remove camel-simple-data-wrapper.c, camel-simple-data-wrapper-stream.c, camel-stream-data-wrapper.c. Obsoleted by code re-use! * camel-data-wrapper.c (construct_from_stream): Change the default implementation to just set the output stream == construction stream. Well, this lets me get rid of both simple-data-wrapper and stream-data-wrapper (unused anyway), and simple-data-wrapper-stream in one hit. CamelDataWrapper is now also a concrete class. (write_to_stream): Use camel_stream_write_to_stream() to calculate/return values (and save code). Include <errno.h> for obvious reasons. * camel-stream.c (eos): Provide a default implementation of .eos(). (camel_stream_write_to_stream): Make it return an error code on error. (camel_stream_printf): Changed to return the number of bytes written/error. (camel_stream_available): Removed. * camel-stream-fs.h (enum CamelStreamFsMode): Removed. Changed to use unix modes and so forth (wasn't used for anything but new file creation and didn't work well either). * camel-stream-fs.c: Removed leading _'s for names. And removed some virtual method 'documentation'. (destroy): Dont try and close a closed/error fd. Only report error if close returns -1. Moved all the code to finalise(), and killed this function. (init_with_fd): Properly setup the seek offset, if it is a valid and seekable file descriptor. (init_with_fd_and_bounds): Use off_t for bounds, set bounds on the seekable stream. (init_with_name): Return error codes. (init_with_name_and_bounds): Ditto. (camel_stream_fs_new_with_name): REturn NULL object if it failed. (camel_stream_fs_new_with_name_and_bounds): Return NULL object on failure. Changed with_name* api's to take unix open style args and flags. (read): The bounded stream bounds checking seemed off, simplified code a bit. (write): Implement bounds checking for writing, the comment was wrong, it could make sense to bound writing. Cleaned up a little. (available): Gone. (eos): Removed. Use CamelStream's implementation now. (close): Reset the fd to -1, provide a warning for bad usage. (seek): Cleaned up. Changed the behaviour a little, the returned offset is the absolute position in the file, even in bounded streams. (seek): Seek from end mirrors lseek() behaviour (reverse seeking). 2000-04-25 NotZed <NotZed@HelixCode.com> * camel-stream-fs.h (struct _CamelStreamFs): Moved bounds and eof indicator to other parent classes. * camel-stream.c (camel_stream_printf): New utility function. Obvious use. * camel-stream-mem.c: Removed leading _'s from static func's. (camel_stream_mem_new_with_byte_array): Fixed for api changes, set the owner for the byte array to us. : Removed A bunch of gtk doc stuff for static (implementation) functions. (available): Removed. (write): Fixed the write implementation so that seek() works on a seekable memory stream, as expected. Seeking past the end of the buffer has unix semantics (filling with 0). (available): Removed. (write): Implement seekable stream bounded stream. (read): Implement seekable stream bounded stream. (close): Dont free the stream_mem if we're not the owner. (seek): Allow to seek beyond the end of memory area, implement bounds checking. (seek): Set errno on bad policy. * camel-stream-mem.h (struct _CamelStreamMem): Changed position to off_t. (new_with_buffer): Changed len to be a size_t. (set_buffer, set_byte_array): New interface functions. (struct _CamelStreamMem): Removed position, it is stored in the superclass. * camel-stream.h: Removed some of the seemingly random whitespace. Removed the available method (its not impelemented/useful enough). * camel-seekable-substream.c (init_with_seekable_stream_and_bounds): Remove the data_available stuff, it hasn't been properly implemented/finished, and may never work (unfortunately *sigh). (reemit_parent_signal): Removed part of the above change. (set_bounds): Removed (moved to seekable-stream). : Fixed up some of the generally unreadable indenting (sorry, wrapping at 80 characters with camels_really_long_function_names() just_doesnt_work_very_well_does_it(). (available): Removed. (stream_seek): Fixup for object changes. Make sure we return -1 if the parent stream can't seek. * camel-seekable-stream.c (ccamel_seekable_stream_set_bounds): New function to bound any seekable stream. : Removed _'s. (camel_seekable_stream_class_init): Implement an init function, to setup the stream bounds to unbound. * camel-seekable-stream.h (CamelSeekableStreamClass): New virtual method set_bounds for seekable streams. (CAMEL_STREAM_UNBOUND): New define for no bound. * camel-seekable-substream.h (struct _CamelSeekableSubstream): Removed sup_bound and inf_bound, moved to CamelSeekableStream (and renamed, and changed to off_t's). (new_with_seekable_stream_and_bounds): Use off_t as the bounds. (CamelSeekableSubstreamClass): Uh, why was the intialiser virtual? Removed. * camel-seekable-stream.[ch] (CamelSeekableStreamClass): Changed seek to accept an off_t as the offset. (struct _CamelSeekableStream): Renamed cur_pos to position and changed it to an off_t type. (enum CamelStreamSeekPolicy): Set to match the SEEK_* constants from lseek(). (get_current_position): Renamed to tell(). * camel-stream-buffer.h: Commented out set_vbuf - never implemented. svn path=/trunk/; revision=2624
* Whole swag of changes. Still lots of cleanup remaining ...NotZed2000-04-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-04-23 NotZed <NotZed@HelixCode.com> * camel-data-wrapper.c (set_mime_type_field): Ref the content_field when we get it? * camel-mime-parser.c (camel_mime_parser_unstep): New function. Cause a subsequent call to mime_parser_step() to return the same state over again. * providers/mbox/camel-mbox-folder.c (_get_message_by_uid): Initial test code using the mime parser to construct the message. * camel-mime-part.c (construct_from_parser): part constructor. (camel_mime_part_construct_content): Basically a simpler replacement for the datawrapper repository. (camel_mime_part_init): Set the default type to text/plain. * camel-simple-data-wrapper.c (construct_from_parser): Initial implementation of a content constructor. * camel-multipart.c (construct_from_parser): Multipart construction routine. (camel_multipart_init): Set the default multipart type to multipart/mixed. Duh, no subtype is not allowed anyway. 2000-04-22 NotZed <NotZed@HelixCode.com> * camel-mime-message.h (struct _CamelMimeMessage): Removed send_date, and received_date, and replaced it with a time_t 'date' (this is what the header is called), and date_offset to store the GMT offset of the date. * camel-mime-message.c (camel_mime_message_set_from): Update raw header as we go. (_set_from): Removed. (_get_from): Removed. (camel_mime_message_get_from): Moved implementation here. (camel_mime_message_get_subject): Move implementation here. (_get_subject): Nuked. (camel_mime_message_set_subject): Handle utf-8 input, and also update raw header when changed. (_set_subject): Removed. (_set_received_date): Removed. (camel_mime_message_set_received_date): Removed. (_get_received_date): Removed. (camel_mime_message_get_received_date): Removed. (_get_sent_date): Removed. (camel_mime_message_get_sent_date): Removed. (camel_mime_message_get_date): New function to get the date as a time_t/offset. (camel_mime_message_set_date): Set the date as a time_t/offset. (camel_mime_message_get_date_string): Get the date as a string. (camel_mime_message_init): Initialise the current date as 'CMAEL_MESSAGE_DATE_CURRENT'. (_set_reply_to): Removed. (camel_mime_message_set_reply_to): Moved implementation here. This is still broken, reply-to can have multiple addresses. (_get_reply_to): Removed. (_set_field): Removed, no longer used anywhere. (_get_field): Also removed. (_init_header_name_table): Add the Date header. (process_header): Also handle snooping of Date header here. * camel-stream-filter.c (finalise): Unref the source stream on finalise, and also call the parent class (oops). * camel-mime-parser.c (camel_mime_parser_state): New function to get the current parser state. (camel_mime_parser_stream): Allow you to get the stream back from the mime_parser. (camel_mime_parser_fd): Alternative to allow you to get the fd back from the mime_parser. (folder_scan_init_with_stream): Properly ref/unref the stream. (folder_scan_close): Properly unref the stream/close the fd on exit. (folder_scan_init_with_fd): Close the old fd if there is one. * camel-data-wrapper.c (camel_data_wrapper_construct_from_parser): New method, construct a data wrapper from an initialised parser. (construct_from_parser): Empty implementation. * providers/mbox/camel-mbox-summary.c (message_struct_new): Convert subject line to unicode, before storing in the summary. (strdup_trim): Removed, no longer needed. * providers/mbox/camel-mbox-folder.c (_get_message_by_uid): Ref the folder after setting it in the new message. * camel-mime-part.c (my_set_content_object): Have the headers follow the content-type change here too. (my_write_to_stream): Dont write content-type here, automatically stored in the headers ... (my_write_to_stream): Use header_disposition_format() to format the content-disposition header. (my_write_to_stream): Removed old code, all headers are now stored in the camel-medium level, always. Need to do the same with camel-mime-message i suppose ... (my_write_to_stream): Write the content using the parent class, not some weird function. (camel_mime_part_class_init): Dont override get_output_stream. (camel_mime_part_encoding_from_string): Bleh, make it case-insensitive. * camel-mime-utils.c (header_content_type_is): Handle empty types. (header_encode_string): Start of an implementation of the rfc2047 encoder. It does iso-8859-1, and us-ascii, and utf-8 (others get tricky *sigh*) (rfc2047_encode_word): Convert a single word/string into rfc2047 encoding. (quoted_encode): Different quoted-printable encoding for rfc2047 encoding of headers. * gmime-content-field.c (gmime_content_field_write_to_stream): Use header_content_type_format() to format it. svn path=/trunk/; revision=2560
* MERGE NEW_PARSER branch into HEAD, fixed conflicts.NotZed2000-04-211-0/+314
2000-04-20 NotZed <NotZed@HelixCode.com> * MERGE NEW_PARSER branch into HEAD, fixed conflicts. * gmime-content-field.c (_print_parameter): Duh, removed again (@@#$@ cvs merge). * camel-mime-utils.c (header_content_type_is): Constify. (header_content_type_unref): Killed a couple warnings. * camel-folder.c (_init): Removed more log crap. * providers/Makefile.am (SUBDIRS): Removed nntp, pending fixes for summary changes. * providers/mbox/camel-mbox-folder.c (_get_message_by_number): Fixed for new summary interface. Added a warning for using this broken api. (_get_message_by_uid): Fixed for message new with session vanishing. svn path=/trunk/; revision=2531