aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/em-stripsig-filter.c
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-06-06 21:27:19 +0800
committerDan Vrátil <dvratil@redhat.com>2012-06-06 21:27:19 +0800
commit5b8340563c271fb684a88c6e5bb6dd3bfb629058 (patch)
treec1c7d606fb4ce9fd2fe459a9226bfb9125423991 /em-format/em-stripsig-filter.c
parent26a4f24188fd89dbabaff192bec9c54af8fe5a80 (diff)
downloadgsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.tar
gsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.tar.gz
gsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.tar.bz2
gsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.tar.lz
gsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.tar.xz
gsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.tar.zst
gsoc2013-evolution-5b8340563c271fb684a88c6e5bb6dd3bfb629058.zip
Mail formatter rewrite
All mail-parsing and formatting code has been moved to em-format. Parsing is handeled by EMailParser class, formatting by EMailFormatter. Both classes have registry which hold extensions - simple classes that do actual parsing and formatting. Each supported mime-type has it's own parser and formatter extension class.
Diffstat (limited to 'em-format/em-stripsig-filter.c')
-rw-r--r--em-format/em-stripsig-filter.c165
1 files changed, 0 insertions, 165 deletions
diff --git a/em-format/em-stripsig-filter.c b/em-format/em-stripsig-filter.c
deleted file mode 100644
index fe08383d5c..0000000000
--- a/em-format/em-stripsig-filter.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Jeffrey Stedfast <fejj@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include "em-stripsig-filter.h"
-
-G_DEFINE_TYPE (EMStripSigFilter, em_stripsig_filter, CAMEL_TYPE_MIME_FILTER)
-
-static void
-strip_signature (CamelMimeFilter *filter,
- const gchar *in,
- gsize len,
- gsize prespace,
- gchar **out,
- gsize *outlen,
- gsize *outprespace,
- gint flush)
-{
- EMStripSigFilter *stripsig = (EMStripSigFilter *) filter;
- register const gchar *inptr = in;
- const gchar *inend = in + len;
- const gchar *start = NULL;
-
- if (stripsig->midline) {
- while (inptr < inend && *inptr != '\n')
- inptr++;
-
- if (inptr < inend) {
- stripsig->midline = FALSE;
- inptr++;
- }
- }
-
- while (inptr < inend) {
- if ((inend - inptr) >= 4 && !strncmp (inptr, "-- \n", 4)) {
- start = inptr;
- inptr += 4;
- } else if (!stripsig->text_plain_only &&
- (inend - inptr) >= 7 &&
- !g_ascii_strncasecmp (inptr, "-- <BR>", 7)) {
- start = inptr;
- inptr += 7;
- } else {
- while (inptr < inend && *inptr != '\n')
- inptr++;
-
- if (inptr == inend) {
- stripsig->midline = TRUE;
- break;
- }
-
- inptr++;
- }
- }
-
- if (start != NULL) {
- inptr = start;
- stripsig->midline = FALSE;
- }
-
- if (!flush && inend > inptr)
- camel_mime_filter_backup (filter, inptr, inend - inptr);
- else if (!start)
- inptr = inend;
-
- *out = (gchar *)in;
- *outlen = inptr - in;
- *outprespace = prespace;
-}
-
-static void
-filter_filter (CamelMimeFilter *filter,
- const gchar *in,
- gsize len,
- gsize prespace,
- gchar **out,
- gsize *outlen,
- gsize *outprespace)
-{
- strip_signature (
- filter, in, len, prespace, out, outlen, outprespace, FALSE);
-}
-
-static void
-filter_complete (CamelMimeFilter *filter,
- const gchar *in,
- gsize len,
- gsize prespace,
- gchar **out,
- gsize *outlen,
- gsize *outprespace)
-{
- strip_signature (
- filter, in, len, prespace, out, outlen, outprespace, TRUE);
-}
-
-/* should this 'flush' outstanding state/data bytes? */
-static void
-filter_reset (CamelMimeFilter *filter)
-{
- EMStripSigFilter *stripsig = (EMStripSigFilter *) filter;
-
- stripsig->midline = FALSE;
-}
-
-static void
-em_stripsig_filter_class_init (EMStripSigFilterClass *class)
-{
- CamelMimeFilterClass *mime_filter_class;
-
- mime_filter_class = CAMEL_MIME_FILTER_CLASS (class);
- mime_filter_class->filter = filter_filter;
- mime_filter_class->complete = filter_complete;
- mime_filter_class->reset = filter_reset;
-}
-
-static void
-em_stripsig_filter_init (EMStripSigFilter *filter)
-{
-}
-
-/**
- * em_stripsig_filter_new:
- * @text_plain_only: Whether should look for a text/plain signature
- * delimiter "-- \n" only or also an HTML signature delimiter "-- <BR>".
- *
- * Creates a new stripsig filter.
- *
- * Returns a new stripsig filter.
- **/
-CamelMimeFilter *
-em_stripsig_filter_new (gboolean text_plain_only)
-{
- EMStripSigFilter *filter = g_object_new (EM_TYPE_STRIPSIG_FILTER, NULL);
-
- filter->text_plain_only = text_plain_only;
-
- return CAMEL_MIME_FILTER (filter);
-}