diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-10-13 06:45:10 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-10-13 06:45:10 +0800 |
commit | dad441ba034c9c3b336a1af5b67c7e41f9bd9ad3 (patch) | |
tree | 26492bc4283ca0bef7dabb409ef79dec97d3b4a0 | |
parent | c90ced3180e92eaa690eef03b9b709f16030fa0c (diff) | |
download | gsoc2013-evolution-dad441ba034c9c3b336a1af5b67c7e41f9bd9ad3.tar.gz gsoc2013-evolution-dad441ba034c9c3b336a1af5b67c7e41f9bd9ad3.tar.zst gsoc2013-evolution-dad441ba034c9c3b336a1af5b67c7e41f9bd9ad3.zip |
Remove the stripheader filter from the build.
2001-10-12 Jeffrey Stedfast <fejj@ximian.com>
* Makefile.am: Remove the stripheader filter from the build.
* camel-mime-filter-stripheader.[c,h]: Removed.
* providers/smtp/camel-smtp-transport.c (smtp_data): Check the
return value of camel_stream_flush to make sure it flushed the
data successfully before continuing. Don't use the stripheader
filter, it was completely broken - instead remove the header and
set it again after we send.
svn path=/trunk/; revision=13641
-rw-r--r-- | camel/ChangeLog | 12 | ||||
-rw-r--r-- | camel/Makefile.am | 2 | ||||
-rw-r--r-- | camel/camel-mime-filter-stripheader.c | 181 | ||||
-rw-r--r-- | camel/camel-mime-filter-stripheader.h | 54 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 23 |
5 files changed, 27 insertions, 245 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 22326dda8f..30300365d2 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,15 @@ +2001-10-12 Jeffrey Stedfast <fejj@ximian.com> + + * Makefile.am: Remove the stripheader filter from the build. + + * camel-mime-filter-stripheader.[c,h]: Removed. + + * providers/smtp/camel-smtp-transport.c (smtp_data): Check the + return value of camel_stream_flush to make sure it flushed the + data successfully before continuing. Don't use the stripheader + filter, it was completely broken - instead remove the header and + set it again after we send. + 2001-10-12 <NotZed@Ximian.com> * camel-vee-folder.c (camel_vee_folder_remove_folder): Unhook from diff --git a/camel/Makefile.am b/camel/Makefile.am index 277c736235..a360eb53f3 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -54,7 +54,6 @@ libcamel_la_SOURCES = \ camel-mime-filter-index.c \ camel-mime-filter-linewrap.c \ camel-mime-filter-save.c \ - camel-mime-filter-stripheader.c \ camel-mime-filter.c \ camel-mime-message.c \ camel-mime-parser.c \ @@ -140,7 +139,6 @@ libcamelinclude_HEADERS = \ camel-mime-filter-index.h \ camel-mime-filter-linewrap.h \ camel-mime-filter-save.h \ - camel-mime-filter-stripheader.h \ camel-mime-filter.h \ camel-mime-message.h \ camel-mime-parser.h \ diff --git a/camel/camel-mime-filter-stripheader.c b/camel/camel-mime-filter-stripheader.c deleted file mode 100644 index 5c78bf459c..0000000000 --- a/camel/camel-mime-filter-stripheader.c +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Dan Winship <danw@ximian.com> - * Jeffrey Stedfast <fejj@ximian.com> - * Peter Williams <peterw@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <ctype.h> -#include <string.h> - -#include "camel-mime-filter-stripheader.h" - -static void filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace); -static void complete (CamelMimeFilter *f, char *in, size_t len, - size_t prespace, char **out, size_t *outlen, - size_t *outprespace); -static void reset (CamelMimeFilter *f); - - -static void -camel_mime_filter_stripheader_init (CamelMimeFilterStripHeader *cmf) -{ - cmf->seen_eoh = FALSE; - cmf->in_header = FALSE; - cmf->header = NULL; - cmf->header_len = 0; -} - -static void -camel_mime_filter_stripheader_finalize (CamelMimeFilterStripHeader *cmf) -{ - g_free (cmf->header); -} - -static void -camel_mime_filter_stripheader_class_init (CamelMimeFilterStripHeaderClass *klass) -{ - CamelMimeFilterClass *mime_filter_class = - (CamelMimeFilterClass *) klass; - - mime_filter_class->filter = filter; - mime_filter_class->complete = complete; - mime_filter_class->reset = reset; -} - -CamelType -camel_mime_filter_stripheader_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterStripHeader", - sizeof (CamelMimeFilterStripHeader), - sizeof (CamelMimeFilterStripHeaderClass), - (CamelObjectClassInitFunc) camel_mime_filter_stripheader_class_init, - NULL, - (CamelObjectInitFunc) camel_mime_filter_stripheader_init, - (CamelObjectFinalizeFunc) camel_mime_filter_stripheader_finalize); - } - - return type; -} - -static void -filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace) -{ - CamelMimeFilterStripHeader *sh = (CamelMimeFilterStripHeader *)f; - char *p, *q; - int left; - - /* all done? */ - if (sh->seen_eoh) { - *out = in; - *outlen = len; - *outprespace = prespace; - return; - } - - /* nope */ - - camel_mime_filter_set_size (f, len, FALSE); - - p = in; - q = f->outbuf; - - while (p < (in + len)) { - if (*p == '\n') { - left = in + len - p; - - /* Not enough left to do anything useful. */ - if (left < (sh->header_len + 3)) { - camel_mime_filter_backup (f, p, left); - break; - } - - /* MIME-ese for 'end of headers'. Our work here is done, */ - if (!strncmp (p, "\n\n", 2)) { - - if (sh->in_header) { - /* we've already got a \n */ - p++; - left--; - } - - sh->seen_eoh = TRUE; - memcpy (q, p, left); - q += left; - break; - } - - /* (Maybe) Grab this \n */ - if (!sh->in_header) - *q++ = *p; - p++; - - if (!strncmp (p, sh->header, sh->header_len) && p[sh->header_len] == ':') - /* ok it seems we /are/ in the header */ - sh->in_header = TRUE; - else if (!isspace ((int)(*p))) - /* if we were in a header and we are on a space - * in_header will remain true...*/ - sh->in_header = FALSE; - - } - - /* ok then */ - if (!sh->in_header) - *q++ = *p; - p++; - } - - *out = f->outbuf; - *outlen = q - f->outbuf; - *outprespace = f->outpre; -} - -static void -complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace) -{ - if (len) - filter (f, in, len, prespace, out, outlen, outprespace); -} - -static void -reset (CamelMimeFilter *f) -{ - CamelMimeFilterStripHeader *sh = (CamelMimeFilterStripHeader *)f; - - sh->seen_eoh = FALSE; - sh->in_header = FALSE; -} - -CamelMimeFilter * -camel_mime_filter_stripheader_new (const gchar *header) -{ - CamelMimeFilterStripHeader *sh = CAMEL_MIME_FILTER_STRIPHEADER(camel_object_new (CAMEL_MIME_FILTER_STRIPHEADER_TYPE)); - - sh->header = g_strdup (header); - sh->header_len = strlen (header); - - return (CamelMimeFilter *)sh; -} diff --git a/camel/camel-mime-filter-stripheader.h b/camel/camel-mime-filter-stripheader.h deleted file mode 100644 index 1a22dece2d..0000000000 --- a/camel/camel-mime-filter-stripheader.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2000 Ximian Inc. - * - * Authors: Dan Winship <danw@ximian.com> - * Jeffrey Stedfast <fejj@ximian.com> - * Peter Williams <peterw@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _CAMEL_MIME_FILTER_STRIPHEADER_H -#define _CAMEL_MIME_FILTER_STRIPHEADER_H - -#include <camel/camel-mime-filter.h> - -#define CAMEL_MIME_FILTER_STRIPHEADER_TYPE (camel_mime_filter_stripheader_get_type ()) -#define CAMEL_MIME_FILTER_STRIPHEADER(obj) CAMEL_CHECK_CAST (obj, CAMEL_MIME_FILTER_STRIPHEADER_TYPE, CamelMimeFilterStripHeader) -#define CAMEL_MIME_FILTER_STRIPHEADER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, CAMEL_MIME_FILTER_STRIPHEADER_TYPE, CamelMimeFilterStripHeaderClass) -#define CAMEL_IS_MIME_FILTER_STRIPHEADER(obj) CAMEL_CHECK_TYPE (obj, CAMEL_MIME_FILTER_STRIPHEADER_TYPE) - -typedef struct _CamelMimeFilterStripHeader CamelMimeFilterStripHeader; -typedef struct _CamelMimeFilterStripHeaderClass CamelMimeFilterStripHeaderClass; - -struct _CamelMimeFilterStripHeader { - CamelMimeFilter parent; - - gchar *header; - int header_len; - gboolean seen_eoh; /* end of headers */ - gboolean in_header; -}; - -struct _CamelMimeFilterStripHeaderClass { - CamelMimeFilterClass parent_class; -}; - -CamelType camel_mime_filter_stripheader_get_type (void); - -CamelMimeFilter *camel_mime_filter_stripheader_new (const gchar *header); - -#endif /* ! _CAMEL_MIME_FILTER_STRIPHEADER_H */ diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 000cdfe7f4..d88bd098db 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -40,7 +40,6 @@ #undef MIN #undef MAX #include "camel-mime-filter-crlf.h" -#include "camel-mime-filter-stripheader.h" #include "camel-mime-filter-linewrap.h" #include "camel-stream-filter.h" #include "camel-smtp-transport.h" @@ -950,9 +949,10 @@ static gboolean smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bit_parts, CamelException *ex) { /* now we can actually send what's important :p */ - gchar *cmdbuf, *respbuf = NULL; + char *cc, *cmdbuf, *respbuf = NULL; CamelStreamFilter *filtered_stream; - CamelMimeFilter *crlffilter, *bccfilter; + CamelMimeFilter *crlffilter; + int ret; /* if the message contains 8bit mime parts and the server doesn't support it, encode 8bit parts to the best @@ -996,14 +996,15 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi /* setup stream filtering */ crlffilter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS); - bccfilter = camel_mime_filter_stripheader_new ("Bcc"); filtered_stream = camel_stream_filter_new_with_stream (transport->ostream); - camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (bccfilter)); camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlffilter)); - camel_object_unref (CAMEL_OBJECT (bccfilter)); camel_object_unref (CAMEL_OBJECT (crlffilter)); - if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (filtered_stream)) == -1) { + cc = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "Cc")); + camel_medium_remove_header (CAMEL_MEDIUM (message), "Cc"); + + ret = camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (filtered_stream)); + if (ret == -1 || camel_stream_flush (CAMEL_STREAM (filtered_stream)) == -1) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("DATA send timed out: message termination: " "%s: mail not sent"), @@ -1011,11 +1012,17 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi camel_object_unref (CAMEL_OBJECT (filtered_stream)); + camel_medium_set_header (CAMEL_MEDIUM (message), "Cc", cc); + g_free (cc); + return FALSE; } - camel_stream_flush (CAMEL_STREAM (filtered_stream)); camel_object_unref (CAMEL_OBJECT (filtered_stream)); + if (cc) { + camel_medium_set_header (CAMEL_MEDIUM (message), "Cc", cc); + g_free (cc); + } /* terminate the message body */ |