diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-08-12 01:57:45 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-08-12 01:57:45 +0800 |
commit | b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb (patch) | |
tree | 2c0f3caac1a793197a951958fa7f07cdbf61ac07 /camel/camel-mime-filter-windows.c | |
parent | 7b1013be730b11384d0e0af340758bdef3f00330 (diff) | |
download | gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.tar gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.tar.gz gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.tar.bz2 gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.tar.lz gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.tar.xz gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.tar.zst gsoc2013-evolution-b328a21e7c026aaa9cdd5e332ed7e39e0003d8eb.zip |
New test suite for the mime parser (which is where the below 2 fixes were
* tests/message/test4.c: New test suite for the mime parser (which
is where the below 2 fixes were noticed).
* camel-mime-parser.c (folder_boundary_check): Calculate 'len' by
subtracting the boundary start from inend rather than 'atleast'.
(folder_scan_content): Calculate 'inend' differently depending on
the EOF state.
2003-08-08 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-filter-tohtml.c (html_convert): Rather than checking
*inptr == '\n', check inptr >= inend - this gets rid of an Invalid
Read report from valgrind.
* camel-mime-part.c (write_to_stream): Don't necessarily re-encode
just because the encodings differ. Need to look into making it so
that message/rfc822 and multipart parts ignore the
Content-Transfer-Encoding header and just keep their 'encoding'
bits set to DEFAULT.
2003-08-05 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap/camel-imap-folder.c (get_content): Updated.
* camel-mime-message.c (camel_mime_message_init): Don't override
the mime_type here.
(process_header): Updated to use CamelDataWrapper's mime_type
field.
(find_best_encoding): Same.
(best_encoding): Here too.
* camel-digest-folder.c (camel_digest_folder_new): Updated for
CamelMimePart::content_type change.
* camel-mime-part.c (camel_mime_part_init): Override our parent
class's default mime_type.
(camel_mime_part_finalize): Don't need to unref the content_type
anymore.
(process_header): Updated to use CamelDataWrapper's mime_type
field.
(camel_mime_part_set_filename): Same.
(camel_mime_part_get_filename): Same.
(camel_mime_part_get_content_type): Same.
(set_content_object): Here too.
(write_to_stream): Updated.
(construct_from_parser): Updated.
* camel-mime-part.h: Remove the content_type field.
2003-07-31 Jeffrey Stedfast <fejj@ximian.com>
* tests/lib/messages.c (test_message_compare_content): If the
chunks differ, perform a hexdump on the data being compared so
that we may analyse it easier.
* camel-multipart-signed.c (write_to_stream): Return ssize_t.
* camel-mime-utils.h: Added the CamelMimePartEncodingType enum
here.
* camel-mime-part.h: Removed the CamelMimePartEncodingType enum
from here.
* camel-mime-part.c (write_to_stream): Updated to return
ssize_t. Also minor changes to only re-encode the content stream
if the charset or encoding changed (this way we write it out in
the original raw form if nothing changed).
* camel-mime-part-utils.c
(simple_data_wrapper_construct_from_parser): Drastically
simplify. We no longer scan html content to try and find the
charset, nor do we care about converting the content to UTF-8 and
handling broken windows charsets.
* camel-mime-message.c (find_best_encoding): Use
decode_to_stream() here. Also updated to not assume the content
charset is UTF-8 since it is very likely not the case anymore
since data-wrappers no longer are converted to UTF-8 at parse
time.
* camel-folder-summary.c (summary_build_content_info_message): Use
decode_to_stream instead here too.
* camel-folder-search.c (match_words_1message): Use
decode_to_stream instead of write_to_stream so we can search the
contents.
* camel-data-wrapper.c (camel_data_wrapper_init): Set the default
encoding to DEFAULT.
(write_to_stream): Updated to return ssize_t
(camel_data_wrapper_decode_to_stream): New virtual function to
decode a data wrapper to a stream (results in nearly identical
behaviour to the old write_to_stream method).
(decode_to_stream): Default implementation of above virtual
method. Decodes base64/qp/etc streams.
* camel-data-wrapper.h: Removed the rawtext bit and added an
encoding member.
svn path=/trunk/; revision=22171
Diffstat (limited to 'camel/camel-mime-filter-windows.c')
-rw-r--r-- | camel/camel-mime-filter-windows.c | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/camel/camel-mime-filter-windows.c b/camel/camel-mime-filter-windows.c new file mode 100644 index 0000000000..0b6e00dea0 --- /dev/null +++ b/camel/camel-mime-filter-windows.c @@ -0,0 +1,180 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Jeffrey Stedfast <fejj@ximian.com> + * + * Copyright 2002 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include "camel-mime-filter-windows.h" + +#include "camel-charset-map.h" + +#define d(x) + +static void camel_mime_filter_windows_class_init (CamelMimeFilterWindowsClass *klass); +static void camel_mime_filter_windows_init (CamelObject *o); +static void camel_mime_filter_windows_finalize (CamelObject *o); + + +static CamelMimeFilterClass *parent_class = NULL; + + +CamelType +camel_mime_filter_windows_get_type (void) +{ + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register (camel_mime_filter_get_type (), + "CamelMimeFilterWindows", + sizeof (CamelMimeFilterWindows), + sizeof (CamelMimeFilterWindowsClass), + (CamelObjectClassInitFunc) camel_mime_filter_windows_class_init, + NULL, + (CamelObjectInitFunc) camel_mime_filter_windows_init, + (CamelObjectFinalizeFunc) camel_mime_filter_windows_finalize); + } + + return type; +} + +static void +camel_mime_filter_windows_finalize (CamelObject *o) +{ + CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) o; + + g_free (windows->claimed_charset); +} + +static void +camel_mime_filter_windows_init (CamelObject *o) +{ + CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) o; + + windows->is_windows = FALSE; + windows->claimed_charset = NULL; +} + +static void +filter_filter (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, + char **out, size_t *outlen, size_t *outprespace) +{ + CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) filter; + register unsigned char *inptr; + unsigned char *inend; + + if (!windows->is_windows) { + inptr = (unsigned char *) in; + inend = inptr + len; + + while (inptr < inend) { + register unsigned char c = *inptr++; + + if (c >= 128 && c <= 159) { + g_warning ("Encountered Windows charset parading as %s", + windows->claimed_charset); + windows->is_windows = TRUE; + break; + } + } + } + + *out = in; + *outlen = len; + *outprespace = prespace; +} + +static void +filter_complete (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, + char **out, size_t *outlen, size_t *outprespace) +{ + filter_filter (filter, in, len, prespace, out, outlen, outprespace); +} + +static void +filter_reset (CamelMimeFilter *filter) +{ + CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) filter; + + windows->is_windows = FALSE; +} + +static void +camel_mime_filter_windows_class_init (CamelMimeFilterWindowsClass *klass) +{ + CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass; + + parent_class = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ())); + + filter_class->reset = filter_reset; + filter_class->filter = filter_filter; + filter_class->complete = filter_complete; +} + + +/** + * camel_mime_filter_windows_new: + * @claimed_charset: + * + * Creates a new CamelMimeFilterWindows object. + * + * Returns a new CamelMimeFilter object. + **/ +CamelMimeFilter * +camel_mime_filter_windows_new (const char *claimed_charset) +{ + CamelMimeFilterWindows *new; + + g_return_val_if_fail (claimed_charset != NULL, NULL); + + new = CAMEL_MIME_FILTER_WINDOWS (camel_object_new (camel_mime_filter_windows_get_type ())); + + new->claimed_charset = g_strdup (claimed_charset); + + return CAMEL_MIME_FILTER (new); +} + + +gboolean +camel_mime_filter_windows_is_windows_charset (CamelMimeFilterWindows *filter) +{ + g_return_val_if_fail (CAMEL_IS_MIME_FILTER_WINDOWS (filter), FALSE); + + return filter->is_windows; +} + + +const char * +camel_mime_filter_windows_real_charset (CamelMimeFilterWindows *filter) +{ + g_return_val_if_fail (CAMEL_IS_MIME_FILTER_WINDOWS (filter), NULL); + + if (filter->is_windows) + return camel_charset_iso_to_windows (filter->claimed_charset); + else + return filter->claimed_charset; +} |